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