From ff5a819ad3a8e78ffd39122557158f40bb39cd3b Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 16 May 2019 05:05:53 +0300 Subject: [PATCH] (62a89ce6a) Refactor and fix priority calculations. WIP, but should already improve things. --- .../Source/GUI/GUIComponent.cs | 2 ++ .../Source/GUI/GUIMessageBox.cs | 6 +++++ .../BarotraumaClient/Source/GUI/GUIStyle.cs | 6 +++++ .../BarotraumaClient/Source/GameMain.cs | 4 +++ .../Source/GameSession/CrewManager.cs | 5 ++++ .../BarotraumaClient/Source/Map/Hull.cs | 27 +++++++++++++++++++ .../Source/Screens/NetLobbyScreen.cs | 19 ------------- .../Source/Characters/AI/EnemyAIController.cs | 2 ++ .../Characters/AI/IndoorsSteeringManager.cs | 10 +++++-- .../Characters/AI/Objectives/AIObjective.cs | 5 ++-- .../AI/Objectives/AIObjectiveCombat.cs | 2 +- .../Objectives/AIObjectiveExtinguishFire.cs | 2 +- .../Objectives/AIObjectiveExtinguishFires.cs | 5 ++-- .../AI/Objectives/AIObjectiveFixLeak.cs | 8 ++++-- .../AI/Objectives/AIObjectiveFixLeaks.cs | 13 +-------- .../AI/Objectives/AIObjectiveLoop.cs | 14 +++++++++- .../AI/Objectives/AIObjectivePumpWater.cs | 13 ++------- .../AI/Objectives/AIObjectiveRescue.cs | 1 + .../AI/Objectives/AIObjectiveRescueAll.cs | 1 + .../Source/Characters/Character.cs | 4 +++ .../Items/Components/Machines/Steering.cs | 13 +++++++++ .../BarotraumaShared/Source/Map/FireSource.cs | 2 -- .../BarotraumaShared/Source/Map/Hull.cs | 19 +++++++++++++ .../BarotraumaShared/Source/Map/Structure.cs | 9 ------- .../BarotraumaShared/Source/PlayerInput.cs | 15 +++++++++++ 25 files changed, 142 insertions(+), 65 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs index 78dbc6468..02beb3df8 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs @@ -138,6 +138,8 @@ namespace Barotrauma public bool IgnoreLayoutGroups; + public bool IgnoreLayoutGroups; + public virtual ScalableFont Font { get; diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs index f9d40494a..de8bc615c 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs @@ -65,6 +65,12 @@ namespace Barotrauma Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 }; Tag = tag; + InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null); + GUI.Style.Apply(InnerFrame, "", this); + + Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 }; + Tag = tag; + if (height == 0) { string wrappedText = ToolBox.WrapText(text, Content.Rect.Width, GUI.Font); diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs index 1e4b1cc88..5db702d57 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs @@ -111,6 +111,12 @@ namespace Barotrauma return style; } + public GUIComponentStyle GetComponentStyle(string name) + { + componentStyles.TryGetValue(name.ToLowerInvariant(), out GUIComponentStyle style); + return style; + } + public void Apply(GUIComponent targetComponent, string styleName = "", GUIComponent parent = null) { GUIComponentStyle componentStyle = null; diff --git a/Barotrauma/BarotraumaClient/Source/GameMain.cs b/Barotrauma/BarotraumaClient/Source/GameMain.cs index 96409dd29..12f296bf5 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -180,6 +180,10 @@ namespace Barotrauma GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window); + GUI.KeyboardDispatcher = new EventInput.KeyboardDispatcher(Window); + + + PerformanceCounter = new PerformanceCounter(); PerformanceCounter = new PerformanceCounter(); diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index 4e8d7da28..5e85a406d 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -69,6 +69,11 @@ namespace Barotrauma public CrewManager(XElement element, bool isSinglePlayer) : this(isSinglePlayer) + { + return characterListBox.Rect; + } + + partial void InitProjectSpecific() { guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent) { diff --git a/Barotrauma/BarotraumaClient/Source/Map/Hull.cs b/Barotrauma/BarotraumaClient/Source/Map/Hull.cs index 6f9edce00..0f5c15c60 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Hull.cs @@ -434,6 +434,33 @@ namespace Barotrauma Color.Green, width: 2); } } + + foreach (MapEntity e in linkedTo) + { + if (e is Hull) + { + Hull linkedHull = (Hull)e; + Rectangle connectedHullRect = e.Submarine == null ? + linkedHull.rect : + new Rectangle( + (int)(Submarine.DrawPosition.X + linkedHull.WorldPosition.X), + (int)(Submarine.DrawPosition.Y + linkedHull.WorldPosition.Y), + linkedHull.WorldRect.Width, linkedHull.WorldRect.Height); + + //center of the hull + Rectangle currentHullRect = Submarine == null ? + WorldRect : + new Rectangle( + (int)(Submarine.DrawPosition.X + WorldPosition.X), + (int)(Submarine.DrawPosition.Y + WorldPosition.Y), + WorldRect.Width, WorldRect.Height); + + GUI.DrawLine(spriteBatch, + new Vector2(currentHullRect.X, -currentHullRect.Y), + new Vector2(connectedHullRect.X, -connectedHullRect.Y), + Color.Green, width: 2); + } + } } public static void UpdateVertices(GraphicsDevice graphicsDevice, Camera cam, WaterRenderer renderer) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs index e9adfa167..3716a8561 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs @@ -312,25 +312,6 @@ namespace Barotrauma return true; }; - playYourself = new GUITickBox(new RectTransform(new Vector2(0.06f, 0.06f), myCharacterFrame.RectTransform) { RelativeOffset = new Vector2(0.05f,0.05f) }, - TextManager.Get("PlayYourself")) - { - Selected = true, - OnSelected = TogglePlayYourself, - UserData = "playyourself" - }; - - var toggleMyPlayerFrame = new GUIButton(new RectTransform(new Point(25, 70), myCharacterFrame.RectTransform, Anchor.TopLeft, Pivot.TopRight), "", style: "GUIButtonHorizontalArrow"); - toggleMyPlayerFrame.OnClicked += (GUIButton btn, object userdata) => - { - MyCharacterFrameOpen = !MyCharacterFrameOpen; - foreach (GUIComponent child in btn.Children) - { - child.SpriteEffects = MyCharacterFrameOpen ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - } - return true; - }; - playYourself = new GUITickBox(new RectTransform(new Vector2(0.06f, 0.06f), myCharacterFrame.RectTransform) { RelativeOffset = new Vector2(0.05f,0.05f) }, TextManager.Get("PlayYourself")) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index c4f189672..fd920d136 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -1054,6 +1054,8 @@ namespace Barotrauma private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure; + private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure; + //goes through all the AItargets, evaluates how preferable it is to attack the target, //whether the Character can see/hear the target and chooses the most preferable target within //sight/hearing range diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs index 2d3de2875..e264c0f05 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs @@ -224,7 +224,7 @@ namespace Barotrauma } //only humanoids can climb ladders - if (character.AnimController is HumanoidAnimController && IsNextLadderSameAsCurrent) + if (!character.AnimController.InWater && character.AnimController is HumanoidAnimController && IsNextLadderSameAsCurrent) { if (character.SelectedConstruction != currentPath.CurrentNode.Ladders.Item && currentPath.CurrentNode.Ladders.Item.IsInsideTrigger(character.WorldPosition)) @@ -234,7 +234,7 @@ namespace Barotrauma } var collider = character.AnimController.Collider; - if (character.IsClimbing) + if (character.IsClimbing && !character.AnimController.InWater) { Vector2 diff = currentPath.CurrentNode.SimPosition - pos; bool nextLadderSameAsCurrent = IsNextLadderSameAsCurrent; @@ -278,6 +278,12 @@ namespace Barotrauma } else if (character.AnimController.InWater) { + // If the character is underwater, we don't need the ladders anymore + if (character.IsClimbing) + { + character.AnimController.Anim = AnimController.Animation.None; + character.SelectedConstruction = null; + } if (Vector2.DistanceSquared(pos, currentPath.CurrentNode.SimPosition) < MathUtils.Pow(collider.radius * 3, 2)) { currentPath.SkipToNextNode(); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs index 95ca26e2d..99a7aee71 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs @@ -105,7 +105,7 @@ namespace Barotrauma CurrentSubObjective.SortSubObjectives(objectiveManager); } - public virtual float GetPriority(AIObjectiveManager objectiveManager) => Priority; + public virtual float GetPriority(AIObjectiveManager objectiveManager) => Priority * PriorityModifier; public virtual void Update(AIObjectiveManager objectiveManager, float deltaTime) { @@ -116,9 +116,8 @@ namespace Barotrauma } else if (objectiveManager.CurrentObjective == this || subObjective == this) { - Priority += Devotion * deltaTime; + Priority += Devotion * PriorityModifier * deltaTime; } - Priority *= PriorityModifier; Priority = MathHelper.Clamp(Priority, 0, 100); subObjectives.ForEach(so => so.Update(objectiveManager, deltaTime)); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs index 318b386f5..344d5d40f 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs @@ -296,7 +296,7 @@ namespace Barotrauma } public override bool CanBeCompleted => !abandon && (reloadWeaponObjective == null || reloadWeaponObjective.CanBeCompleted) && (retreatObjective == null || retreatObjective.CanBeCompleted); - public override float GetPriority(AIObjectiveManager objectiveManager) => (Enemy != null && (Enemy.Removed || Enemy.IsDead)) ? 0 : 100; + public override float GetPriority(AIObjectiveManager objectiveManager) => (Enemy != null && (Enemy.Removed || Enemy.IsDead)) ? 0 : 100 * PriorityModifier; public override bool IsDuplicate(AIObjective otherObjective) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs index 16c589231..4788aa829 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs @@ -32,7 +32,7 @@ namespace Barotrauma float dist = Math.Abs(character.WorldPosition.X - targetHull.WorldPosition.X) + Math.Abs(character.WorldPosition.Y - targetHull.WorldPosition.Y) * 2.0f; float distanceFactor = MathHelper.Lerp(1, 0.1f, MathUtils.InverseLerp(0, 10000, dist)); float severityFactor = MathHelper.Lerp(0, 1, MathHelper.Clamp(targetHull.FireSources.Sum(fs => fs.Size.X) / targetHull.Size.X, 0, 1)); - return MathHelper.Clamp(Priority * severityFactor * distanceFactor, 0, 100); + return MathHelper.Lerp(0, 100, severityFactor * distanceFactor); } public override bool IsCompleted() diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs index 527425dda..e20596174 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; namespace Barotrauma { + // TODO: use objective loop and sort the targets by severity class AIObjectiveExtinguishFires : AIObjective { public override string DebugTag => "extinguish fires"; @@ -23,8 +24,8 @@ namespace Barotrauma { return AIObjectiveManager.OrderPriority; } - - return MathHelper.Clamp(fireCount * 20, 0, 100); + float basePriority = MathHelper.Clamp(Priority, 0, 10); + return MathHelper.Clamp(basePriority + fireCount * 20, 0, 100); } public override bool IsCompleted() => false; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs index 633d4f17b..7b7bc317e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs @@ -40,11 +40,15 @@ namespace Barotrauma { if (leak.Open == 0.0f) { return 0.0f; } - float leakSize = (leak.IsHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f); + //float leakSize = (leak.IsHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f); + //float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition); + //dist = Math.Max(dist / 100.0f, 1.0f); + //return Math.Min(leakSize / dist, 40.0f); + float leakSize = (leak.IsHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f); float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition); dist = Math.Max(dist / 100.0f, 1.0f); - return Math.Min(leakSize / dist, 40.0f); + return MathHelper.Clamp(Priority + leakSize / dist, 0, 100); } public override bool IsDuplicate(AIObjective otherObjective) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs index 83fe8c556..c3a1aa6ff 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs @@ -14,17 +14,6 @@ namespace Barotrauma public AIObjectiveFixLeaks(Character character, float priorityModifier = 1) : base(character, "", priorityModifier) { } - public override float GetPriority(AIObjectiveManager objectiveManager) - { - if (character.Submarine == null) { return 0; } - if (targets.None()) { return 0; } - if (objectiveManager.CurrentOrder == this) - { - return AIObjectiveManager.OrderPriority; - } - return MathHelper.Lerp(0, AIObjectiveManager.OrderPriority, targets.Average(t => Average(t))); - } - protected override void FindTargets() { base.FindTargets(); @@ -61,7 +50,7 @@ namespace Barotrauma } public override bool IsDuplicate(AIObjective otherObjective) => otherObjective is AIObjectiveFixLeaks; - protected override float Average(Gap gap) => gap.Open; + protected override float Average(Gap gap) => gap.Open * 100; protected override IEnumerable GetList() => Gap.GapList; protected override AIObjective ObjectiveConstructor(Gap gap) => new AIObjectiveFixLeak(gap, character); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs index 586b38e59..3b788c3af 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs @@ -86,8 +86,16 @@ namespace Barotrauma { if (character.Submarine == null) { return 0; } if (targets.None()) { return 0; } + //if (objectiveManager.CurrentOrder == this) + //{ + // return AIObjectiveManager.OrderPriority; + //} float avg = targets.Average(t => Average(t)); - return MathHelper.Lerp(0, AIObjectiveManager.OrderPriority + 20, avg / 100); + // If the avg is less than 1% of the max value, let's just treat it as zero. + if (avg < 1) { return 0; } + float max = MathHelper.Min(AIObjectiveManager.OrderPriority + 20, 100); + float value = MathHelper.Min((Priority + avg) / 100 * PriorityModifier, 1); + return MathHelper.Lerp(0, max, value); } protected void UpdateTargets() @@ -126,6 +134,10 @@ namespace Barotrauma /// List of all possible items of the specified type. Used for filtering the removed objectives. /// protected abstract IEnumerable GetList(); + + /// + /// 0 to 100. + /// protected abstract float Average(T target); protected abstract AIObjective ObjectiveConstructor(T target); protected abstract bool Filter(T target); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs index d69e9338c..6f17b7a85 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs @@ -1,6 +1,7 @@ using Barotrauma.Items.Components; using System.Collections.Generic; using System.Linq; +using Microsoft.Xna.Framework; namespace Barotrauma { @@ -15,16 +16,6 @@ namespace Barotrauma pumpList = character.Submarine.GetItems(true).Select(i => i.GetComponent()).Where(p => p != null); } - public override float GetPriority(AIObjectiveManager objectiveManager) - { - if (character.Submarine == null) { return 0; } - if (objectiveManager.CurrentOrder == this && targets.Count > 0) - { - return AIObjectiveManager.OrderPriority; - } - return 0.0f; - } - public override bool IsDuplicate(AIObjective otherObjective) => otherObjective is AIObjectivePumpWater && otherObjective.Option == Option; //availablePumps = allPumps.Where(p => !p.Item.HasTag("ballast") && p.Item.Connections.None(c => c.IsPower && p.Item.GetConnectedComponentsRecursive(c).None())).ToList(); @@ -63,6 +54,6 @@ namespace Barotrauma protected override bool Filter(Pump pump) => true; protected override IEnumerable GetList() => pumpList; protected override AIObjective ObjectiveConstructor(Pump pump) => new AIObjectiveOperateItem(pump, character, Option, false); - protected override float Average(Pump target) => 0; + protected override float Average(Pump target) => MathHelper.Lerp(0, 100, target.CurrFlow / target.MaxFlow); } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs index 06423963f..7d7553cca 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs @@ -230,6 +230,7 @@ namespace Barotrauma public override float GetPriority(AIObjectiveManager objectiveManager) { + // TODO: review if (targetCharacter.AnimController.CurrentHull == null || targetCharacter.IsDead) { return 0.0f; } Vector2 diff = targetCharacter.WorldPosition - character.WorldPosition; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs index d8f8f4b6e..9d025a3ee 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs @@ -27,6 +27,7 @@ namespace Barotrauma public override float GetPriority(AIObjectiveManager objectiveManager) { + // TODO: review if (character.Submarine == null) { return 0; } GetRescueTargets(); if (!rescueTargets.Any()) { return 0.0f; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index c32e374be..4998238ac 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -2610,6 +2610,10 @@ namespace Barotrauma GameMain.GameSession?.CrewManager?.RemoveCharacter(this); #endif +#if CLIENT + GameMain.GameSession?.CrewManager?.RemoveCharacter(this); +#endif + #if CLIENT GameMain.GameSession?.CrewManager?.RemoveCharacter(this); #endif diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs index b542be300..b02f9d911 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs @@ -224,6 +224,19 @@ namespace Barotrauma.Items.Components return true; } + public override void OnItemLoaded() + { + sonar = item.GetComponent(); + } + + public override bool Select(Character character) + { + if (!CanBeSelected) return false; + + user = character; + return true; + } + public override void Update(float deltaTime, Camera cam) { networkUpdateTimer -= deltaTime; diff --git a/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs b/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs index 686cd222f..11bf41f6c 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs @@ -24,8 +24,6 @@ namespace Barotrauma private bool removed; - private bool removed; - #if CLIENT private List burnDecals = new List(); #endif diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 25ebe915b..b4490cfe6 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -147,6 +147,25 @@ namespace Barotrauma } } + public string DisplayName + { + get; + private set; + } + + private string roomName; + [Editable, Serialize("", true, translationTextTag: "RoomName.")] + public string RoomName + { + get { return roomName; } + set + { + if (roomName == value) { return; } + roomName = value; + DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName; + } + } + public override Rectangle Rect { get diff --git a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs index 1dc9e5844..dbc86e55a 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -1203,15 +1203,6 @@ namespace Barotrauma if (FlippedX) element.Add(new XAttribute("flippedx", true)); if (FlippedY) element.Add(new XAttribute("flippedy", true)); - if (FlippedX) element.Add(new XAttribute("flippedx", true)); - if (FlippedY) element.Add(new XAttribute("flippedy", true)); - - if (FlippedX) element.Add(new XAttribute("flippedx", true)); - if (FlippedY) element.Add(new XAttribute("flippedy", true)); - - if (FlippedX) element.Add(new XAttribute("flippedx", true)); - if (FlippedY) element.Add(new XAttribute("flippedy", true)); - for (int i = 0; i < Sections.Length; i++) { if (Sections[i].damage == 0.0f) continue; diff --git a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs index e13028523..8ad826eea 100644 --- a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs +++ b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs @@ -162,6 +162,21 @@ namespace Barotrauma get { return binding; } } + public void SetState() + { + hit = binding.IsHit(); + if (hit) hitQueue = true; + + held = binding.IsDown(); + if (held) heldQueue = true; + } +#endif + + public KeyOrMouse State + { + get { return binding; } + } + public void SetState() { hit = binding.IsHit();