Skip to content

Commit

Permalink
v0.11.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Regalis11 committed Dec 16, 2020
1 parent f433a7b commit e47f085
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,19 @@ partial void OnSkillChanged(string skillIdentifier, float prevLevel, float newLe

private void GetDisguisedSprites(IdCard idCard)
{
if (idCard.Item.Tags == string.Empty) return;

if (idCard.StoredJobPrefab == null || idCard.StoredPortrait == null)
{
string[] readTags = idCard.Item.Tags.Split(',');

if (readTags.Length == 0) return;

if (idCard.StoredJobPrefab == null)
{
string jobIdTag = readTags.First(s => s.StartsWith("jobid:"));
string jobIdTag = readTags.FirstOrDefault(s => s.StartsWith("jobid:"));

if (jobIdTag != string.Empty && jobIdTag.Length > 6)
if (jobIdTag != null && jobIdTag.Length > 6)
{
string jobId = jobIdTag.Substring(6);
if (jobId != string.Empty)
Expand Down
51 changes: 40 additions & 11 deletions Barotrauma/BarotraumaClient/ClientSource/GUI/GUINumberInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ public float? MaxValueFloat
private float floatValue;
public float FloatValue
{
get { return floatValue; }
get
{
return floatValue;
}
set
{
if (MathUtils.NearlyEqual(value, floatValue)) return;
if (MathUtils.NearlyEqual(value, floatValue)) { return; }
floatValue = value;
ClampFloatValue();
float newValue = floatValue;
Expand Down Expand Up @@ -129,10 +132,13 @@ public int? MaxValueInt
private int intValue;
public int IntValue
{
get { return intValue; }
get
{
return intValue;
}
set
{
if (value == intValue) return;
if (value == intValue) { return; }
intValue = value;
UpdateText();
}
Expand Down Expand Up @@ -192,6 +198,29 @@ public GUINumberInput(RectTransform rectT, NumberType inputType, string style =
};
TextBox.CaretColor = TextBox.TextColor;
TextBox.OnTextChanged += TextChanged;
TextBox.OnDeselected += (sender, key) =>
{
if (inputType == NumberType.Int)
{
ClampIntValue();
}
else
{
ClampFloatValue();
}
};
TextBox.OnEnterPressed += (textBox, text) =>
{
if (inputType == NumberType.Int)
{
ClampIntValue();
}
else
{
ClampFloatValue();
}
return true;
};

var buttonArea = new GUIFrame(new RectTransform(new Vector2(_relativeButtonAreaWidth, 1.0f), LayoutGroup.RectTransform, Anchor.CenterRight), style: null);
PlusButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.5f), buttonArea.RectTransform), style: null);
Expand Down Expand Up @@ -299,10 +328,12 @@ private void ReduceValue()
if (inputType == NumberType.Int)
{
IntValue -= valueStep > 0 ? (int)valueStep : 1;
ClampIntValue();
}
else if (maxValueFloat.HasValue && minValueFloat.HasValue)
{
FloatValue -= valueStep > 0 ? valueStep : Round();
ClampFloatValue();
}
}

Expand All @@ -311,10 +342,12 @@ private void IncreaseValue()
if (inputType == NumberType.Int)
{
IntValue += valueStep > 0 ? (int)valueStep : 1;
ClampIntValue();
}
else if (inputType == NumberType.Float)
{
FloatValue += valueStep > 0 ? valueStep : Round();
ClampFloatValue();
}
}

Expand All @@ -325,7 +358,7 @@ private void IncreaseValue()
/// </summary>
private float Round()
{
if (!maxValueFloat.HasValue || !minValueFloat.HasValue) return 0;
if (!maxValueFloat.HasValue || !minValueFloat.HasValue) { return 0; }
float onePercent = MathHelper.Lerp(minValueFloat.Value, maxValueFloat.Value, 0.01f);
float diff = maxValueFloat.Value - minValueFloat.Value;
int decimals = (int)MathHelper.Lerp(3, 0, MathUtils.InverseLerp(10, 1000, diff));
Expand All @@ -337,28 +370,24 @@ private bool TextChanged(GUITextBox textBox, string text)
switch (InputType)
{
case NumberType.Int:
int newIntValue = IntValue;
if (string.IsNullOrWhiteSpace(text) || text == "-")
{
intValue = 0;
}
else if (int.TryParse(text, out newIntValue))
else if (int.TryParse(text, out int newIntValue))
{
intValue = newIntValue;
}
ClampIntValue();
break;
case NumberType.Float:
float newFloatValue = FloatValue;
if (string.IsNullOrWhiteSpace(text) || text == "-")
{
floatValue = 0;
}
else if (float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out newFloatValue))
else if (float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out float newFloatValue))
{
floatValue = newFloatValue;
}
ClampFloatValue();
break;
}
OnValueChanged?.Invoke(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ partial void UseProjSpecific(float deltaTime, Vector2 raystart)
{
foreach (ParticleEmitter particleEmitter in particleEmitters)
{
float particleAngle = item.body.Rotation + MathHelper.ToRadians(BarrelRotation) + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi);
float particleAngle = MathHelper.ToRadians(BarrelRotation);
if (item.body != null)
{
particleAngle += item.body.Rotation + ((item.body.Dir > 0.0f) ? 0.0f : MathHelper.Pi);
}
particleEmitter.Emit(
deltaTime, ConvertUnits.ToDisplayUnits(raystart),
item.CurrentHull, particleAngle, particleEmitter.Prefab.CopyEntityAngle ? -particleAngle : 0);
Expand Down Expand Up @@ -118,7 +122,7 @@ partial void FixItemProjSpecific(Character user, float deltaTime, Item targetIte
if (door == null || door.Stuck <= 0)
{
Vector2 progressBarPos = targetItem.DrawPosition;
var progressBar = user.UpdateHUDProgressBar(
var progressBar = user?.UpdateHUDProgressBar(
targetItem,
progressBarPos,
progressBarState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void DrawConnections(SpriteBatch spriteBatch, ConnectionPanel pane

Wire equippedWire = null;

bool allowRewiring = GameMain.NetworkMember?.ServerSettings == null || GameMain.NetworkMember.ServerSettings.AllowRewiring;
bool allowRewiring = GameMain.NetworkMember?.ServerSettings == null || GameMain.NetworkMember.ServerSettings.AllowRewiring || panel.AlwaysAllowRewiring;
if (allowRewiring && (!panel.Locked || Screen.Selected == GameMain.SubEditorScreen))
{
//if the Character using the panel has a wire item equipped
Expand Down Expand Up @@ -380,7 +380,7 @@ private static void DrawWire(SpriteBatch spriteBatch, Wire wire, Vector2 end, Ve
{
ConnectionPanel.HighlightedWire = wire;

bool allowRewiring = GameMain.NetworkMember?.ServerSettings == null || GameMain.NetworkMember.ServerSettings.AllowRewiring;
bool allowRewiring = GameMain.NetworkMember?.ServerSettings == null || GameMain.NetworkMember.ServerSettings.AllowRewiring || panel.AlwaysAllowRewiring;
if (allowRewiring && (!wire.Locked && !panel.Locked || Screen.Selected == GameMain.SubEditorScreen))
{
//start dragging the wire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,10 +1677,6 @@ private void CreateSaveScreen(bool quickSave = false)
};
outpostModuleGroup.RectTransform.MinSize = new Point(0, outpostModuleGroup.RectTransform.Children.Max(c => c.MinSize.Y));





// module flags ---------------------

var allowAttachGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.1f), outpostSettingsContainer.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
Expand Down Expand Up @@ -1717,17 +1713,6 @@ private void CreateSaveScreen(bool quickSave = false)
};
allowAttachGroup.RectTransform.MinSize = new Point(0, allowAttachGroup.RectTransform.Children.Max(c => c.MinSize.Y));












// location types ---------------------

var locationTypeGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.1f), outpostSettingsContainer.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/LinuxClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.11.0.9</Version>
<Version>0.11.0.10</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/MacClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.11.0.9</Version>
<Version>0.11.0.10</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion Barotrauma/BarotraumaClient/WindowsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product>
<Version>0.11.0.9</Version>
<Version>0.11.0.10</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName>
Expand Down
13 changes: 11 additions & 2 deletions Barotrauma/BarotraumaServer/ServerSource/Networking/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2293,9 +2293,18 @@ private IEnumerable<object> StartGame(SubmarineInfo selectedSub, SubmarineInfo s
}
}

if (crewManager != null && crewManager.HasBots && hadBots)
if (crewManager != null && crewManager.HasBots)
{
crewManager?.InitRound();
if (hadBots)
{
//loaded existing bots -> init them
crewManager?.InitRound();
}
else
{
//created new bots -> save them
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
}
}

campaign?.LoadPets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,16 +1315,23 @@ void UpdateDying(float deltaTime)
var thigh = i == 0 ? GetLimb(LimbType.LeftThigh) : GetLimb(LimbType.RightThigh);
if (thigh == null) { continue; }
if (thigh.IsSevered) { continue; }

float thighDiff = Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, thigh.Rotation));
float thighTorque = thighDiff * thigh.Mass * Math.Sign(torso.Rotation - thigh.Rotation) * 5.0f;
thigh.body.ApplyTorque(thighTorque * strength);
float diff = torso.Rotation - thigh.Rotation;
if (MathUtils.IsValid(diff))
{
float thighTorque = thighDiff * thigh.Mass * Math.Sign(diff) * 5.0f;
thigh.body.ApplyTorque(thighTorque * strength);
}

var leg = i == 0 ? GetLimb(LimbType.LeftLeg) : GetLimb(LimbType.RightLeg);
if (leg == null || leg.IsSevered) { continue; }
float legDiff = Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, leg.Rotation));
float legTorque = legDiff * leg.Mass * Math.Sign(torso.Rotation - leg.Rotation) * 5.0f;
leg.body.ApplyTorque(legTorque * strength);
diff = torso.Rotation - leg.Rotation;
if (MathUtils.IsValid(diff))
{
float legTorque = legDiff * leg.Mass * Math.Sign(diff) * 5.0f;
leg.body.ApplyTorque(legTorque * strength);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public bool CanBeDeattached()

//if the item has a connection panel and rewiring is disabled, don't allow deattaching
var connectionPanel = item.GetComponent<ConnectionPanel>();
if (connectionPanel != null && (connectionPanel.Locked || !(GameMain.NetworkMember?.ServerSettings?.AllowRewiring ?? true)))
if (connectionPanel != null && !connectionPanel.AlwaysAllowRewiring && (connectionPanel.Locked || !(GameMain.NetworkMember?.ServerSettings?.AllowRewiring ?? true)))
{
return false;
}
Expand Down Expand Up @@ -578,7 +578,7 @@ private Vector2 GetAttachPosition(Character user, bool useWorldCoordinates = fal

Vector2 attachPos = userPos + mouseDiff;

if (user.Submarine == null)
if (user.Submarine == null && Level.Loaded != null)
{
bool edgeFound = false;
foreach (var cell in Level.Loaded.GetCells(attachPos))
Expand Down Expand Up @@ -606,6 +606,7 @@ private Vector2 GetAttachPosition(Character user, bool useWorldCoordinates = fal

private Voronoi2.VoronoiCell GetAttachTargetCell(float maxDist)
{
if (Level.Loaded == null) { return null; }
foreach (var cell in Level.Loaded.GetCells(item.WorldPosition, searchDepth: 1))
{
if (cell.CellType != Voronoi2.CellType.Solid) { continue; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ public Vector2 TransformedBarrelPos
{
get
{
if (item.body == null) { return BarrelPos; }
Matrix bodyTransform = Matrix.CreateRotationZ(item.body.Rotation + MathHelper.ToRadians(BarrelRotation));
Vector2 flippedPos = BarrelPos;
if (item.body.Dir < 0.0f) { flippedPos.X = -flippedPos.X; }
return (Vector2.Transform(flippedPos, bodyTransform));
return Vector2.Transform(flippedPos, bodyTransform);
}
}

Expand Down Expand Up @@ -228,11 +229,15 @@ public override bool Use(float deltaTime, Character character = null)
}

float spread = MathHelper.ToRadians(MathHelper.Lerp(UnskilledSpread, Spread, degreeOfSuccess));
float angle = item.body.Rotation + MathHelper.ToRadians(BarrelRotation) + spread * Rand.Range(-0.5f, 0.5f);
Vector2 rayEnd = rayStartWorld +
ConvertUnits.ToSimUnits(new Vector2(
(float)Math.Cos(angle),
(float)Math.Sin(angle)) * Range * item.body.Dir);

float angle = MathHelper.ToRadians(BarrelRotation) + spread * Rand.Range(-0.5f, 0.5f);
float dir = 1;
if (item.body != null)
{
angle += item.body.Rotation;
dir = item.body.Dir;
}
Vector2 rayEnd = rayStartWorld + ConvertUnits.ToSimUnits(new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Range * dir);

ignoredBodies.Clear();
if (character != null)
Expand Down Expand Up @@ -438,7 +443,7 @@ private void Repair(Vector2 rayStart, Vector2 rayEnd, float deltaTime, Character
}
}

if (WaterAmount > 0.0f && item.CurrentHull?.Submarine != null)
if (WaterAmount > 0.0f && item.Submarine != null)
{
Vector2 pos = ConvertUnits.ToDisplayUnits(rayStart + item.Submarine.SimPosition);

Expand Down Expand Up @@ -466,7 +471,7 @@ private void Repair(Vector2 rayStart, Vector2 rayEnd, float deltaTime, Character
#if CLIENT
float barOffset = 10f * GUI.Scale;
Vector2 offset = planter.PlantSlots.ContainsKey(i) ? planter.PlantSlots[i].Offset : Vector2.Zero;
user.UpdateHUDProgressBar(planter, planter.Item.DrawPosition + new Vector2(barOffset, 0) + offset, seed.Health / seed.MaxHealth, GUI.Style.Blue, GUI.Style.Blue, "progressbar.watering");
user?.UpdateHUDProgressBar(planter, planter.Item.DrawPosition + new Vector2(barOffset, 0) + offset, seed.Health / seed.MaxHealth, GUI.Style.Blue, GUI.Style.Blue, "progressbar.watering");
#endif
}
}
Expand Down
Loading

0 comments on commit e47f085

Please sign in to comment.