diff --git a/Subsurface/Content/Orders.xml b/Subsurface/Content/Orders.xml
index c28b1b516..4ae1b0331 100644
--- a/Subsurface/Content/Orders.xml
+++ b/Subsurface/Content/Orders.xml
@@ -19,5 +19,9 @@
-
+
+
+
+
+
\ No newline at end of file
diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs
new file mode 100644
index 000000000..83140a770
--- /dev/null
+++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs
@@ -0,0 +1,68 @@
+using Microsoft.Xna.Framework;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Barotrauma
+{
+ class AIObjectiveFixLeaks : AIObjective
+ {
+ const float UpdateGapListInterval = 5.0f;
+
+ private float updateGapListTimer;
+
+ private List objectiveList;
+
+ public AIObjectiveFixLeaks(Character character)
+ : base (character, "")
+ {
+ objectiveList = new List();
+ }
+
+ public override bool IsCompleted()
+ {
+ return false;
+ }
+
+ protected override void Act(float deltaTime)
+ {
+ updateGapListTimer -= deltaTime;
+
+ if (updateGapListTimer<=0.0f)
+ {
+ UpdateGapList();
+
+ updateGapListTimer = UpdateGapListInterval;
+ }
+
+ if (objectiveList.Any()) objectiveList[0].TryComplete(deltaTime);
+ }
+
+ private void UpdateGapList()
+ {
+ objectiveList.Clear();
+
+ foreach (Gap gap in Gap.GapList)
+ {
+ if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open < 0.1f) continue;
+
+ float dist = Vector2.DistanceSquared(character.WorldPosition, gap.WorldPosition);
+
+ int index = 0;
+ while (index y.GetPriority(character).CompareTo(x.GetPriority(character)));
-
- foreach (Gap gap in Gap.GapList)
- {
- if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.1f) continue;
-
- AddObjective(new AIObjectiveFixLeak(gap, character));
- }
}
public void DoCurrentObjective(float deltaTime)
@@ -87,6 +80,10 @@ namespace Barotrauma
case "wait":
currentObjective = new AIObjectiveGoTo(character.SimPosition, character, true);
break;
+ case "fixleaks":
+ case "fix leaks":
+ currentObjective = new AIObjectiveFixLeaks(character);
+ break;
default:
if (order.TargetItem == null) return;