Build 1.1.4.0
This commit is contained in:
@@ -11,7 +11,7 @@ using Barotrauma.Extensions;
|
||||
namespace Barotrauma
|
||||
{
|
||||
[Flags]
|
||||
public enum SpawnType { Path = 0, Human = 1, Enemy = 2, Cargo = 4, Corpse = 8 };
|
||||
public enum SpawnType { Path = 0, Human = 1, Enemy = 2, Cargo = 4, Corpse = 8, Submarine = 16, ExitPoint = 32 };
|
||||
|
||||
partial class WayPoint : MapEntity
|
||||
{
|
||||
@@ -29,7 +29,32 @@ namespace Barotrauma
|
||||
|
||||
private HashSet<Identifier> tags;
|
||||
|
||||
public bool isObstructed;
|
||||
public bool IsObstructed;
|
||||
|
||||
public bool IsInWater => CurrentHull == null || CurrentHull.Surface > Position.Y;
|
||||
|
||||
// Waypoints linked to doors are traversable, unless they are obstructed, because we filter them out in the setter of Gap.Open.
|
||||
// The only way to add the open gaps should be by calling OnGapStateSchanged.
|
||||
public bool IsTraversable => !IsObstructed && (openGaps == null || openGaps.Count == 0 || IsInWater);
|
||||
|
||||
private HashSet<Gap> openGaps;
|
||||
/// <summary>
|
||||
/// Only called by a Gap when the state changes.
|
||||
/// So in practice used like an event callback, although technically just a method
|
||||
/// (It would be cleaner to use an actual event in Gap.cs, but event registering and unregistering might cause an extra hassle)
|
||||
/// </summary>
|
||||
public void OnGapStateChanged(bool open, Gap gap)
|
||||
{
|
||||
openGaps ??= new HashSet<Gap>();
|
||||
if (open)
|
||||
{
|
||||
openGaps.Add(gap);
|
||||
}
|
||||
else
|
||||
{
|
||||
openGaps.Remove(gap);
|
||||
}
|
||||
}
|
||||
|
||||
private ushort gapId;
|
||||
public Gap ConnectedGap
|
||||
@@ -54,6 +79,12 @@ namespace Barotrauma
|
||||
set { spawnType = value; }
|
||||
}
|
||||
|
||||
public Point ExitPointSize { get; private set; }
|
||||
|
||||
public Rectangle ExitPointWorldRect => new Rectangle(
|
||||
(int)WorldPosition.X - ExitPointSize.X / 2, (int)WorldPosition.Y + ExitPointSize.Y / 2,
|
||||
ExitPointSize.X, ExitPointSize.Y);
|
||||
|
||||
public Action<WayPoint> OnLinksChanged { get; set; }
|
||||
|
||||
public override string Name
|
||||
@@ -140,7 +171,9 @@ namespace Barotrauma
|
||||
{ "Cargo", new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(384,0,128,128)) },
|
||||
{ "Corpse", new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(512,0,128,128)) },
|
||||
{ "Ladder", new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(0,128,128,128)) },
|
||||
{ "Door", new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(128,128,128,128)) }
|
||||
{ "Door", new Sprite("Content/UI/MainIconsAtlas.png", new Rectangle(128,128,128,128)) },
|
||||
{ "Submarine", new Sprite("Content/UI/CommandUIBackground.png", new Rectangle(0,896,128,128)) },
|
||||
{ "ExitPoint", new Sprite("Content/UI/CommandUIBackground.png", new Rectangle(0,896,128,128)) }
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -981,6 +1014,12 @@ namespace Barotrauma
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
if (Submarine == null)
|
||||
{
|
||||
// Don't try to connect waypoints that are not linked to any submarines to hulls, stairs, gaps etc.
|
||||
// Used to cause weird pathfinding errors on some outpost modules, because the waypoints of the main path or side path got linked to a hull in the outpost.
|
||||
return;
|
||||
}
|
||||
InitializeLinks();
|
||||
FindHull();
|
||||
FindStairs();
|
||||
@@ -1018,7 +1057,6 @@ namespace Barotrauma
|
||||
int.Parse(element.GetAttribute("y").Value),
|
||||
(int)Submarine.GridSize.X, (int)Submarine.GridSize.Y);
|
||||
|
||||
|
||||
Enum.TryParse(element.GetAttributeString("spawn", "Path"), out SpawnType spawnType);
|
||||
WayPoint w = new WayPoint(spawnType == SpawnType.Path ? Type.WayPoint : Type.SpawnPoint, rect, submarine, idRemap.GetOffsetId(element))
|
||||
{
|
||||
@@ -1036,6 +1074,8 @@ namespace Barotrauma
|
||||
w.IdCardTags = idCardTagString.Split(',');
|
||||
}
|
||||
|
||||
w.ExitPointSize = element.GetAttributePoint("exitpointsize", Point.Zero);
|
||||
|
||||
w.tags = element.GetAttributeIdentifierArray("tags", Array.Empty<Identifier>()).ToHashSet();
|
||||
|
||||
Identifier jobIdentifier = element.GetAttributeIdentifier("job", Identifier.Empty);
|
||||
@@ -1076,6 +1116,10 @@ namespace Barotrauma
|
||||
new XAttribute("x", (int)(rect.X - Submarine.HiddenSubPosition.X)),
|
||||
new XAttribute("y", (int)(rect.Y - Submarine.HiddenSubPosition.Y)),
|
||||
new XAttribute("spawn", spawnType));
|
||||
if (SpawnType == SpawnType.ExitPoint)
|
||||
{
|
||||
element.Add(new XAttribute("exitpointsize", XMLExtensions.PointToString(ExitPointSize)));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(IdCardDesc)) element.Add(new XAttribute("idcarddesc", IdCardDesc));
|
||||
if (idCardTags.Length > 0)
|
||||
|
||||
Reference in New Issue
Block a user