Build 0.18.9.0

This commit is contained in:
Markus Isberg
2022-06-14 04:14:47 +09:00
parent 4f5a3bf8b9
commit 856f894203
39 changed files with 459 additions and 377 deletions
@@ -460,13 +460,14 @@ namespace Barotrauma.MapCreatures.Behavior
{
if (parentBranchId > -1)
{
if (parentBranchId < Branches.Count)
var parentBranch = Branches.Find(b => b.ID == parentBranchId);
if (parentBranch == null)
{
branch.ParentBranch = Branches[parentBranchId];
DebugConsole.AddWarning($"Error while loading ballast flora: couldn't find a parent branch with the ID {parentBranchId}");
}
else
{
DebugConsole.AddWarning($"Error while loading ballast flora: parent branch ID {parentBranchId} out of range (total {Branches.Count} branches)");
branch.ParentBranch = parentBranch;
}
}
}
@@ -790,7 +791,8 @@ namespace Barotrauma.MapCreatures.Behavior
MaxHealth = RootHealth,
Health = RootHealth,
IsRoot = true,
CurrentHull = Parent
CurrentHull = Parent,
ID = CreateID()
};
Branches.Add(root);
@@ -1015,14 +1017,6 @@ namespace Barotrauma.MapCreatures.Behavior
public void DamageBranch(BallastFloraBranch branch, float amount, AttackType type, Character? attacker = null)
{
float damage = amount;
if (damage > 0)
{
damage = Math.Min(damage, branch.Health);
}
else
{
damage = Math.Max(damage, branch.Health - branch.MaxHealth);
}
if (type != AttackType.Other && type != AttackType.CutFromRoot)
{
@@ -1081,6 +1075,14 @@ namespace Barotrauma.MapCreatures.Behavior
}
}
if (damage > 0)
{
damage = Math.Min(damage, branch.Health);
}
else
{
damage = Math.Max(damage, branch.Health - branch.MaxHealth);
}
branch.Health -= damage;
#if SERVER
@@ -1,12 +1,11 @@
using Barotrauma.Items.Components;
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Xml.Linq;
using Barotrauma.IO;
using Barotrauma.Extensions;
using System.Collections.Immutable;
namespace Barotrauma
{
@@ -82,6 +81,8 @@ namespace Barotrauma
private XElement saveElement;
private Vector2? positionRelativeToMainSub;
public override bool Linkable
{
get
@@ -256,6 +257,15 @@ namespace Barotrauma
}
}
public void SetPositionRelativeToMainSub()
{
if (positionRelativeToMainSub.HasValue)
{
Sub.SetPosition(Submarine.WorldPosition + positionRelativeToMainSub.Value);
}
positionRelativeToMainSub = null;
}
public override void OnMapLoaded()
{
if (!loadSub) { return; }
@@ -317,7 +327,19 @@ namespace Barotrauma
{
if (worldPos == Vector2.Zero)
{
DebugConsole.ThrowError("Something went wrong when loading a linked submarine - the save didn't include either a world position or a linked port for the submarine.");
Vector2 relativePos = saveElement.GetAttributeVector2("posrelativetomainsub", Vector2.Zero);
if (relativePos != Vector2.Zero)
{
positionRelativeToMainSub = relativePos;
}
else
{
DebugConsole.ThrowError("Something went wrong when loading a linked submarine - the save didn't include a world position, a linked port or position relative to the main sub.");
}
}
else
{
sub.Submarine = Submarine;
}
return;
}
@@ -469,8 +491,9 @@ namespace Barotrauma
}
else
{
if (saveElement.Attribute("location") != null) saveElement.Attribute("location").Remove();
if (saveElement.Attribute("worldpos") != null) saveElement.Attribute("worldpos").Remove();
if (saveElement.Attribute("location") != null) { saveElement.Attribute("location").Remove(); }
if (saveElement.Attribute("worldpos") != null) { saveElement.Attribute("worldpos").Remove(); }
saveElement.SetAttributeValue("posrelativetomainsub", XMLExtensions.Vector2ToString(sub.WorldPosition - Submarine.WorldPosition));
}
saveElement.SetAttributeValue("pos", XMLExtensions.Vector2ToString(Position - Submarine.HiddenSubPosition));
}