diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj
index 60e6af5cd..21105dc66 100644
--- a/Subsurface/Barotrauma.csproj
+++ b/Subsurface/Barotrauma.csproj
@@ -63,6 +63,7 @@
+
diff --git a/Subsurface/Content/UI/style.xml b/Subsurface/Content/UI/style.xml
index de7bb89eb..31ba04d98 100644
--- a/Subsurface/Content/UI/style.xml
+++ b/Subsurface/Content/UI/style.xml
@@ -39,7 +39,7 @@
diff --git a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs
index 30900b39f..25c199891 100644
--- a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs
+++ b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs
@@ -36,6 +36,12 @@ namespace Barotrauma
get { return currentTarget; }
}
+ public bool HasOutdoorsNodes
+ {
+ get;
+ private set;
+ }
+
public IndoorsSteeringManager(ISteerable host, bool canOpenDoors)
: base(host)
{
@@ -79,6 +85,8 @@ namespace Barotrauma
}
currentPath = pathFinder.FindPath(pos, target);
+
+ HasOutdoorsNodes = currentPath.Nodes.Find(n => n.CurrentHull == null) != null;
findPathTimer = Rand.Range(1.0f,1.2f);
@@ -151,6 +159,22 @@ namespace Barotrauma
bool open = currentPath.CurrentNode != null &&
Math.Sign(door.Item.SimPosition.X - host.SimPosition.X) == Math.Sign(currentPath.CurrentNode.SimPosition.X - host.SimPosition.X);
+ if (currentPath.CurrentNode==null)
+ {
+ open = false;
+ }
+ else
+ {
+ if (door.LinkedGap.isHorizontal)
+ {
+ open = Math.Sign(door.Item.SimPosition.X - character.SimPosition.X) == Math.Sign(currentPath.CurrentNode.SimPosition.X - character.SimPosition.X);
+ }
+ else
+ {
+ open = Math.Sign(door.Item.SimPosition.Y - character.SimPosition.Y) == Math.Sign(currentPath.CurrentNode.SimPosition.Y - character.SimPosition.Y);
+ }
+ }
+
//toggle the door if it's the previous node and open, or if it's current node and closed
if (door.IsOpen != open)
{
diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs
new file mode 100644
index 000000000..6aee02fb7
--- /dev/null
+++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs
@@ -0,0 +1,76 @@
+using Barotrauma.Items.Components;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Barotrauma
+{
+ class AIObjectiveFindDivingGear : AIObjective
+ {
+ private AIObjective subObjective;
+
+ private string gearName;
+
+ public override bool IsCompleted()
+ {
+ var item = character.Inventory.FindItem(gearName);
+ if (item == null) return false;
+
+ var containedItems = item.ContainedItems;
+ var oxygenTank = Array.Find(containedItems, i => i.Name == "Oxygen Tank" && i.Condition > 0.0f);
+ return oxygenTank != null;
+ }
+
+ public AIObjectiveFindDivingGear(Character character, bool needDivingSuit)
+ : base(character, "")
+ {
+ gearName = needDivingSuit ? "Diving Suit" : "diving";
+ }
+
+ protected override void Act(float deltaTime)
+ {
+ var item = character.Inventory.FindItem(gearName);
+ if (item == null)
+ {
+ //get a diving mask/suit first
+ if (!(subObjective is AIObjectiveGetItem))
+ {
+ subObjective = new AIObjectiveGetItem(character, gearName, true);
+ }
+ }
+ else
+ {
+ var containedItems = item.ContainedItems;
+ if (containedItems == null) return;
+
+ //check if there's an oxygen tank in the mask
+ var oxygenTank = Array.Find(containedItems, i => i.Name == "Oxygen Tank" && i.Condition > 0.0f);
+
+ if (oxygenTank != null)
+ {
+ //isCompleted = true;
+ return;
+ }
+
+
+ if (!(subObjective is AIObjectiveContainItem))
+ {
+ subObjective = new AIObjectiveContainItem(character, "Oxygen Tank", item.GetComponent());
+ }
+ }
+
+ if (subObjective != null)
+ {
+ subObjective.TryComplete(deltaTime);
+
+ //isCompleted = subObjective.IsCompleted();
+ }
+ }
+
+ public override bool IsDuplicate(AIObjective otherObjective)
+ {
+ return otherObjective is AIObjectiveFindDivingGear;
+ }
+ }
+}
diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs
index 2c5064c88..a0a7684af 100644
--- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs
+++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs
@@ -117,45 +117,50 @@ namespace Barotrauma
private bool FindDivingGear(float deltaTime)
{
-
-
- var item = character.Inventory.FindItem("diving");
- if (item == null)
+ if (divingGearObjective==null)
{
- //get a diving mask/suit first
- if (!(divingGearObjective is AIObjectiveGetItem))
- {
- divingGearObjective = new AIObjectiveGetItem(character, "diving", true);
- }
- }
- else
- {
- var containedItems = item.ContainedItems;
- if (containedItems == null) return true;
-
- //check if there's an oxygen tank in the mask
- var oxygenTank = Array.Find(containedItems, i => i.Name == "Oxygen Tank" && i.Condition > 0.0f);
-
- if (oxygenTank != null) return true;
-
-
- if (!(divingGearObjective is AIObjectiveContainItem))
- {
- divingGearObjective = new AIObjectiveContainItem(character, "Oxygen Tank", item.GetComponent());
-
- }
+ divingGearObjective = new AIObjectiveFindDivingGear(character, false);
}
- if (divingGearObjective != null)
- {
- divingGearObjective.TryComplete(deltaTime);
+ divingGearObjective.TryComplete(deltaTime);
+ return divingGearObjective.IsCompleted();
- bool isCompleted = divingGearObjective.IsCompleted();
- if (isCompleted) divingGearObjective = null;
- return isCompleted;
- }
+ //var item = character.Inventory.FindItem("diving");
+ //if (item == null)
+ //{
+ // //get a diving mask/suit first
+ // if (!(divingGearObjective is AIObjectiveGetItem))
+ // {
+ // divingGearObjective = new AIObjectiveGetItem(character, "diving", true);
+ // }
+ //}
+ //else
+ //{
+ // var containedItems = item.ContainedItems;
+ // if (containedItems == null) return true;
- return false;
+ // //check if there's an oxygen tank in the mask
+ // var oxygenTank = Array.Find(containedItems, i => i.Name == "Oxygen Tank" && i.Condition > 0.0f);
+
+ // if (oxygenTank != null) return true;
+
+
+ // if (!(divingGearObjective is AIObjectiveContainItem))
+ // {
+ // divingGearObjective = new AIObjectiveContainItem(character, "Oxygen Tank", item.GetComponent());
+ // }
+ //}
+
+ //if (divingGearObjective != null)
+ //{
+ // divingGearObjective.TryComplete(deltaTime);
+
+ // bool isCompleted = divingGearObjective.IsCompleted();
+ // if (isCompleted) divingGearObjective = null;
+ // return isCompleted;
+ //}
+
+ //return false;
}
public override bool IsDuplicate(AIObjective otherObjective)
diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs
index d5794beeb..379135caf 100644
--- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs
+++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs
@@ -10,11 +10,11 @@ namespace Barotrauma
{
class AIObjectiveGoTo : AIObjective
{
- Entity target;
+ private Entity target;
- Vector2 targetPos;
+ private Vector2 targetPos;
- bool repeat;
+ private bool repeat;
//how long until the path to the target is declared unreachable
private float waitUntilPathUnreachable;
@@ -90,7 +90,7 @@ namespace Barotrauma
{
//currTargetPos += target.Submarine.SimPosition;
}
- else if (target.Submarine==null)
+ else if (target.Submarine == null)
{
currTargetPos -= Submarine.Loaded.SimPosition;
}
@@ -103,9 +103,15 @@ namespace Barotrauma
}
else
{
+ character.AIController.SteeringManager.SteeringSeek(currTargetPos);
- character.AIController.SteeringManager.SteeringSeek(currTargetPos);
+ var indoorsSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
+ if (indoorsSteering.CurrentPath != null && indoorsSteering.HasOutdoorsNodes)
+ {
+
+ AddSubObjective(new AIObjectiveGetItem(character, "Diving Suit", true));
+ }
}
}
diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs
index c3717b7e5..baf8b9de8 100644
--- a/Subsurface/Source/GUI/GUIListBox.cs
+++ b/Subsurface/Source/GUI/GUIListBox.cs
@@ -135,14 +135,14 @@ namespace Barotrauma
if (isHorizontal)
{
scrollBar = new GUIScrollBar(
- new Rectangle(this.rect.X, this.rect.Bottom - 20, this.rect.Width, 20), color, 1.0f, GUI.Style);
+ new Rectangle(this.rect.X, this.rect.Bottom - 20, this.rect.Width, 20), null, 1.0f, GUI.Style);
}
else
{
scrollBar = new GUIScrollBar(
- new Rectangle(this.rect.Right - 20, this.rect.Y, 20, this.rect.Height), color, 1.0f, GUI.Style);
+ new Rectangle(this.rect.Right - 20, this.rect.Y, 20, this.rect.Height), null, 1.0f, GUI.Style);
}
-
+
frame = new GUIFrame(Rectangle.Empty, style, this);
if (style != null) style.Apply(frame, this);
diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs
index a4a725082..a4c86e6de 100644
--- a/Subsurface/Source/Map/FireSource.cs
+++ b/Subsurface/Source/Map/FireSource.cs
@@ -85,6 +85,8 @@ namespace Barotrauma
private void LimitSize()
{
+ if (hull == null) return;
+
position.X = Math.Max(hull.Rect.X, position.X);
position.Y = Math.Min(hull.Rect.Y, position.Y);
diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs
index e3476c1b3..33202404c 100644
--- a/Subsurface/Source/Networking/GameClient.cs
+++ b/Subsurface/Source/Networking/GameClient.cs
@@ -595,12 +595,12 @@ namespace Barotrauma.Networking
public IEnumerable