diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs index 1be79d6b6..78dbc6468 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIComponent.cs @@ -136,6 +136,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 fa8ac527b..f9d40494a 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIMessageBox.cs @@ -59,6 +59,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 14b219a4a..1e4b1cc88 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUIStyle.cs @@ -105,6 +105,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 4708c53b4..96409dd29 100644 --- a/Barotrauma/BarotraumaClient/Source/GameMain.cs +++ b/Barotrauma/BarotraumaClient/Source/GameMain.cs @@ -178,6 +178,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 d6bec4488..4e8d7da28 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -69,11 +69,6 @@ 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) { @@ -181,16 +176,6 @@ namespace Barotrauma ToolTip = order.Name }; - new GUIFrame(new RectTransform(new Vector2(1.5f), btn.RectTransform, Anchor.Center), "OuterGlow") - { - Color = Color.Red * 0.8f, - HoverColor = Color.Red * 1.0f, - PressedColor = Color.Red * 0.6f, - UserData = "highlighted", - CanBeFocused = false, - Visible = false - }; - var characterInfo = new CharacterInfo(subElement); characterInfos.Add(characterInfo); foreach (XElement invElement in subElement.Elements()) @@ -208,6 +193,16 @@ namespace Barotrauma ToggleCrewAreaOpen = GameMain.Config.CrewMenuOpen; } + + #endregion + + #region Character list management + + public Rectangle GetCharacterListArea() + { + return characterListBox.Rect; + } + partial void InitProjectSpecific() { guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent) @@ -729,7 +724,7 @@ namespace Barotrauma characterListBox.BarScroll = roundedPos; } - ChatBox.AddMessage(ChatMessage.Create(senderName, text, messageType, sender)); + return radioItem.GetComponent(); } private IEnumerable KillCharacterAnim(GUIComponent component) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Hull.cs b/Barotrauma/BarotraumaClient/Source/Map/Hull.cs index 9ed321c15..6f9edce00 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Hull.cs @@ -407,6 +407,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/CampaignUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs index 5a122773b..655c6fb9d 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs @@ -18,11 +18,6 @@ namespace Barotrauma private GUIListBox myItemList; private GUIListBox storeItemList; - private GUITextBox searchBox; - - private GUIComponent missionPanel; - private GUIComponent selectedLocationInfo; - private GUIListBox selectedMissionInfo; private GUIComponent missionPanel; private GUIComponent selectedLocationInfo; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs index 3716a8561..e9adfa167 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs @@ -312,6 +312,25 @@ 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 0d91bfffd..c4f189672 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -1052,6 +1052,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/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 2237d4a0b..6ac802352 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -55,7 +55,6 @@ namespace Barotrauma objectiveManager = new AIObjectiveManager(c); objectiveManager.AddObjective(new AIObjectiveFindSafety(c)); objectiveManager.AddObjective(new AIObjectiveIdle(c)); - // TODO: do this only when the player hasn't issued an order for a while foreach (var automaticOrder in c.Info.Job.Prefab.AutomaticOrders) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == automaticOrder.aiTag); @@ -66,16 +65,8 @@ namespace Barotrauma matchingItems.RemoveAll(it => it.Submarine != c.Submarine); var item = matchingItems.GetRandom(); var order = new Order(orderPrefab, item ?? c.CurrentHull as Entity, item?.Components.FirstOrDefault(ic => ic.GetType() == orderPrefab.ItemComponentType)); - SetOrder(order, automaticOrder.option, c, true); - -//#if CLIENT -// GameMain.GameSession?.CrewManager?.SetCharacterOrder(c, order, automaticOrder.option, c); -//#endif - -// if (GameMain.GameSession?.CrewManager != null && GameMain.GameSession.CrewManager.AddOrder(order, order.FadeOutTime)) -// { -// Character.Speak(order.GetChatMessage("", Character.CurrentHull?.RoomName, givingOrderToSelf: true), ChatMessageType.Order); -// } + //SetOrder(order, automaticOrder.option, c, true); + objectiveManager.AddObjective(objectiveManager.CreateObjective(order, automaticOrder.option, c, automaticOrder.priorityModifier)); } updateObjectiveTimer = Rand.Range(0.0f, UpdateObjectiveInterval); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs index 7824857ad..95ca26e2d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjective.cs @@ -16,6 +16,7 @@ namespace Barotrauma protected readonly List subObjectives = new List(); public float Priority { get; set; } + public float PriorityModifier { get; private set; } protected readonly Character character; protected string option; protected bool abandon; @@ -33,11 +34,11 @@ namespace Barotrauma get { return option; } } - public AIObjective(Character character, string option) + public AIObjective(Character character, string option, float priorityModifier) { this.character = character; this.option = option; - + PriorityModifier = priorityModifier; #if DEBUG IsDuplicate(null); #endif @@ -117,6 +118,7 @@ namespace Barotrauma { Priority += Devotion * 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 9acf4bc99..318b386f5 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs @@ -57,7 +57,7 @@ namespace Barotrauma public CombatMode Mode { get; private set; } - public AIObjectiveCombat(Character character, Character enemy, CombatMode mode) : base(character, "") + public AIObjectiveCombat(Character character, Character enemy, CombatMode mode, float priorityModifier = 1) : base(character, "", priorityModifier) { Enemy = enemy; coolDownTimer = CoolDown; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveContainItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveContainItem.cs index a3af1fea9..34631b16d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveContainItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveContainItem.cs @@ -25,13 +25,9 @@ namespace Barotrauma private AIObjectiveGetItem getItemObjective; private AIObjectiveGoTo goToObjective; - public AIObjectiveContainItem(Character character, string itemIdentifier, ItemContainer container) - : this(character, new string[] { itemIdentifier }, container) - { - } + public AIObjectiveContainItem(Character character, string itemIdentifier, ItemContainer container, float priorityModifier = 1) : this(character, new string[] { itemIdentifier }, container, priorityModifier) { } - public AIObjectiveContainItem(Character character, string[] itemIdentifiers, ItemContainer container) - : base (character, "") + public AIObjectiveContainItem(Character character, string[] itemIdentifiers, ItemContainer container, float priorityModifier = 1) : base (character, "", priorityModifier) { this.itemIdentifiers = itemIdentifiers; for (int i = 0; i < itemIdentifiers.Length; i++) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveDecontainItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveDecontainItem.cs index a73d7ec57..f6baf7a01 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveDecontainItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveDecontainItem.cs @@ -21,21 +21,16 @@ namespace Barotrauma private AIObjectiveGoTo goToObjective; private Item targetItem; - public AIObjectiveDecontainItem(Character character, Item targetItem, ItemContainer container) - : base(character, "") + public AIObjectiveDecontainItem(Character character, Item targetItem, ItemContainer container, float priorityModifier = 1) : base(character, "", priorityModifier) { this.targetItem = targetItem; this.container = container; } - public AIObjectiveDecontainItem(Character character, string itemIdentifier, ItemContainer container) - : this(character, new string[] { itemIdentifier }, container) - { - } + public AIObjectiveDecontainItem(Character character, string itemIdentifier, ItemContainer container, float priorityModifier = 1) : this(character, new string[] { itemIdentifier }, container, priorityModifier) { } - public AIObjectiveDecontainItem(Character character, string[] itemIdentifiers, ItemContainer container) - : base(character, "") + public AIObjectiveDecontainItem(Character character, string[] itemIdentifiers, ItemContainer container, float priorityModifier = 1) : base(character, "", priorityModifier) { this.itemIdentifiers = itemIdentifiers; for (int i = 0; i < itemIdentifiers.Length; i++) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs index f5965df98..16c589231 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs @@ -20,7 +20,7 @@ namespace Barotrauma private float useExtinquisherTimer; - public AIObjectiveExtinguishFire(Character character, Hull targetHull) : base(character, "") + public AIObjectiveExtinguishFire(Character character, Hull targetHull, float priorityModifier = 1) : base(character, "", priorityModifier) { this.targetHull = targetHull; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs index 4da5093e8..527425dda 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFires.cs @@ -13,7 +13,7 @@ namespace Barotrauma private Dictionary extinguishObjectives = new Dictionary(); - public AIObjectiveExtinguishFires(Character character) : base(character, "") { } + public AIObjectiveExtinguishFires(Character character, float priorityModifier = 1) : base(character, "", priorityModifier) { } public override float GetPriority(AIObjectiveManager objectiveManager) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs index 647275d2e..08d15c49d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs @@ -29,7 +29,7 @@ namespace Barotrauma return false; } - public AIObjectiveFindDivingGear(Character character, bool needDivingSuit) : base(character, "") + public AIObjectiveFindDivingGear(Character character, bool needDivingSuit, float priorityModifier = 1) : base(character, "", priorityModifier) { gearTag = needDivingSuit ? "divingsuit" : "diving"; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs index 6b735f0f5..2faf90070 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs @@ -27,7 +27,7 @@ namespace Barotrauma private AIObjectiveGoTo goToObjective; private AIObjectiveFindDivingGear divingGearObjective; - public AIObjectiveFindSafety(Character character) : base(character, "") { } + public AIObjectiveFindSafety(Character character, float priorityModifier = 1) : base(character, "", priorityModifier) { } public override bool IsCompleted() => false; public override bool CanBeCompleted => true; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs index a6edccb86..633d4f17b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs @@ -24,7 +24,7 @@ namespace Barotrauma get { return leak; } } - public AIObjectiveFixLeak(Gap leak, Character character) : base (character, "") + public AIObjectiveFixLeak(Gap leak, Character character, float priorityModifier = 1) : base (character, "", priorityModifier) { this.leak = leak; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs index 0e814171e..83fe8c556 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs @@ -12,7 +12,7 @@ namespace Barotrauma public override bool KeepDivingGearOn => true; public override bool ForceRun => true; - public AIObjectiveFixLeaks(Character character) : base (character, "") { } + public AIObjectiveFixLeaks(Character character, float priorityModifier = 1) : base(character, "", priorityModifier) { } public override float GetPriority(AIObjectiveManager objectiveManager) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs index d0c519da9..1a85a0576 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs @@ -36,16 +36,16 @@ namespace Barotrauma return 1.0f; } - public AIObjectiveGetItem(Character character, Item targetItem, bool equip = false) : base(character, "") + public AIObjectiveGetItem(Character character, Item targetItem, bool equip = false, float priorityModifier = 1) : base(character, "", priorityModifier) { currSearchIndex = -1; this.equip = equip; this.targetItem = targetItem; } - public AIObjectiveGetItem(Character character, string itemIdentifier, bool equip = false) : this(character, new string[] { itemIdentifier }, equip) { } + public AIObjectiveGetItem(Character character, string itemIdentifier, bool equip = false, float priorityModifier = 1) : this(character, new string[] { itemIdentifier }, equip, priorityModifier) { } - public AIObjectiveGetItem(Character character, string[] itemIdentifiers, bool equip = false) : base(character, "") + public AIObjectiveGetItem(Character character, string[] itemIdentifiers, bool equip = false, float priorityModifier = 1) : base(character, "", priorityModifier) { currSearchIndex = -1; this.equip = equip; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs index 6cadf0d2e..3a429bf29 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs @@ -84,8 +84,7 @@ namespace Barotrauma public bool FollowControlledCharacter; - public AIObjectiveGoTo(Entity target, Character character, bool repeat = false, bool getDivingGearIfNeeded = true) - : base (character, "") + public AIObjectiveGoTo(Entity target, Character character, bool repeat = false, bool getDivingGearIfNeeded = true, float priorityModifier = 1) : base (character, "", priorityModifier) { this.Target = target; this.repeat = repeat; @@ -96,8 +95,7 @@ namespace Barotrauma } - public AIObjectiveGoTo(Vector2 simPos, Character character, bool repeat = false, bool getDivingGearIfNeeded = true) - : base(character, "") + public AIObjectiveGoTo(Vector2 simPos, Character character, bool repeat = false, bool getDivingGearIfNeeded = true, float priorityModifier = 1) : base(character, "", priorityModifier) { this.targetPos = simPos; this.repeat = repeat; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs index c03fbef43..596f86321 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs @@ -29,7 +29,7 @@ namespace Barotrauma private readonly List targetHulls = new List(20); private readonly List hullWeights = new List(20); - public AIObjectiveIdle(Character character) : base(character, "") + public AIObjectiveIdle(Character character, float priorityModifier = 1) : base(character, "", priorityModifier) { standStillTimer = Rand.Range(-10.0f, 10.0f); walkDuration = Rand.Range(0.0f, 10.0f); diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs index 00c02f3bd..586b38e59 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs @@ -17,7 +17,7 @@ namespace Barotrauma protected virtual float IgnoreListClearInterval => 0; protected virtual float TargetUpdateInterval => 2; - public AIObjectiveLoop(Character character, string option) : base(character, option) + public AIObjectiveLoop(Character character, string option, float priorityModifier = 1) : base(character, option, priorityModifier) { Reset(); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index 0d22a0905..5846fd23c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -144,13 +144,17 @@ namespace Barotrauma public void SetOrder(Order order, string option, Character orderGiver) { - CurrentOrder = null; - if (order == null) return; + CurrentOrder = CreateObjective(order, option, orderGiver); + } + public AIObjective CreateObjective(Order order, string option, Character orderGiver, float priorityModifier = 1) + { + if (order == null) { return null; } + AIObjective newObjective; switch (order.AITag.ToLowerInvariant()) { case "follow": - CurrentOrder = new AIObjectiveGoTo(orderGiver, character, true) + newObjective = new AIObjectiveGoTo(orderGiver, character, true, priorityModifier: priorityModifier) { CloseEnough = 1.5f, AllowGoingOutside = true, @@ -159,40 +163,41 @@ namespace Barotrauma }; break; case "wait": - CurrentOrder = new AIObjectiveGoTo(character, character, true) + newObjective = new AIObjectiveGoTo(character, character, true, priorityModifier: priorityModifier) { AllowGoingOutside = true }; break; case "fixleaks": - CurrentOrder = new AIObjectiveFixLeaks(character); + newObjective = new AIObjectiveFixLeaks(character, priorityModifier: priorityModifier); break; case "chargebatteries": - CurrentOrder = new AIObjectiveChargeBatteries(character, option); + newObjective = new AIObjectiveChargeBatteries(character, option); break; case "rescue": - CurrentOrder = new AIObjectiveRescueAll(character); + newObjective = new AIObjectiveRescueAll(character, priorityModifier: priorityModifier); break; case "repairsystems": - CurrentOrder = new AIObjectiveRepairItems(character) { RequireAdequateSkills = option != "all" }; + newObjective = new AIObjectiveRepairItems(character, priorityModifier: priorityModifier) { RequireAdequateSkills = option != "all" }; break; case "pumpwater": - CurrentOrder = new AIObjectivePumpWater(character, option); + newObjective = new AIObjectivePumpWater(character, option, priorityModifier: priorityModifier); break; case "extinguishfires": - CurrentOrder = new AIObjectiveExtinguishFires(character); + newObjective = new AIObjectiveExtinguishFires(character, priorityModifier: priorityModifier); break; case "steer": var steering = (order?.TargetEntity as Item)?.GetComponent(); if (steering != null) steering.PosToMaintain = steering.Item.Submarine?.WorldPosition; - if (order.TargetItemComponent == null) return; - CurrentOrder = new AIObjectiveOperateItem(order.TargetItemComponent, character, option, false, null, order.UseController); + if (order.TargetItemComponent == null) { return null; } + newObjective = new AIObjectiveOperateItem(order.TargetItemComponent, character, option, false, null, order.UseController, priorityModifier: priorityModifier); break; default: - if (order.TargetItemComponent == null) return; - CurrentOrder = new AIObjectiveOperateItem(order.TargetItemComponent, character, option, false, null, order.UseController); + if (order.TargetItemComponent == null) { return null; } + newObjective = new AIObjectiveOperateItem(order.TargetItemComponent, character, option, false, null, order.UseController, priorityModifier: priorityModifier); break; } + return newObjective; } } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs index 9a443557d..9bb8894c6 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs @@ -52,8 +52,7 @@ namespace Barotrauma return base.GetPriority(objectiveManager); } - public AIObjectiveOperateItem(ItemComponent item, Character character, string option, bool requireEquip, Entity operateTarget = null, bool useController = false) - : base (character, option) + public AIObjectiveOperateItem(ItemComponent item, Character character, string option, bool requireEquip, Entity operateTarget = null, bool useController = false, float priorityModifier = 1) : base (character, option, priorityModifier) { this.component = item ?? throw new System.ArgumentNullException("item", "Attempted to create an AIObjectiveOperateItem with a null target."); this.requireEquip = requireEquip; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs index 5409a82d5..d69e9338c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectivePumpWater.cs @@ -10,7 +10,7 @@ namespace Barotrauma public override bool KeepDivingGearOn => true; private readonly IEnumerable pumpList; - public AIObjectivePumpWater(Character character, string option) : base(character, option) + public AIObjectivePumpWater(Character character, string option, float priorityModifier = 1) : base(character, option, priorityModifier) { pumpList = character.Submarine.GetItems(true).Select(i => i.GetComponent()).Where(p => p != null); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs index fd2d1c962..5cd35b506 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs @@ -19,7 +19,7 @@ namespace Barotrauma private float previousCondition = -1; - public AIObjectiveRepairItem(Character character, Item item) : base(character, "") + public AIObjectiveRepairItem(Character character, Item item, float priorityModifier = 1) : base(character, "", priorityModifier) { Item = item; } @@ -114,7 +114,7 @@ namespace Barotrauma { // If the current condition is less than the previous condition, we can't complete the task, so let's abandon it. The item is probably deteriorating at a greater speed than we can repair it. abandon = true; - character?.Speak(TextManager.Get("DialogRepairFailed").Replace("[itemname]", Item.Name), null, 0.0f, "repairfailed", 10.0f); + character?.Speak(TextManager.Get("DialogCannotRepair").Replace("[itemname]", Item.Name), null, 0.0f, "cannotrepair", 10.0f); } } repairable.CurrentFixer = abandon && repairable.CurrentFixer == character ? null : character; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItems.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItems.cs index 2b2afd3f5..ab1b303bf 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItems.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItems.cs @@ -14,9 +14,8 @@ namespace Barotrauma /// public bool RequireAdequateSkills; - public AIObjectiveRepairItems(Character character) : base(character, "") { } + public AIObjectiveRepairItems(Character character, float priorityModifier = 1) : base(character, "", priorityModifier) { } - // TODO: This can allow two active repair items objectives, if RequireAdequateSkills is not at the same value. We don't want that. public override bool IsDuplicate(AIObjective otherObjective) => otherObjective is AIObjectiveRepairItems repairItems && repairItems.RequireAdequateSkills == RequireAdequateSkills; protected override void CreateObjectives() diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs index 72004ee14..06423963f 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescue.cs @@ -37,8 +37,7 @@ namespace Barotrauma } } - public AIObjectiveRescue(Character character, Character targetCharacter) - : base(character, "") + public AIObjectiveRescue(Character character, Character targetCharacter, float priorityModifier = 1) : base(character, "", priorityModifier) { Debug.Assert(character != targetCharacter); this.targetCharacter = targetCharacter; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs index 2dc93f0f4..d8f8f4b6e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs @@ -15,7 +15,7 @@ namespace Barotrauma private List rescueTargets; - public AIObjectiveRescueAll(Character character) : base (character, "") + public AIObjectiveRescueAll(Character character, float priorityModifier = 1) : base (character, "", priorityModifier) { rescueTargets = new List(); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index a1ac30d52..c32e374be 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -2606,6 +2606,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/Characters/Jobs/JobPrefab.cs b/Barotrauma/BarotraumaShared/Source/Characters/Jobs/JobPrefab.cs index e96a3cc66..e37ccb59a 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Jobs/JobPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Jobs/JobPrefab.cs @@ -9,13 +9,14 @@ namespace Barotrauma { public string aiTag; public string option; - public float priority; + public float priorityModifier; public AutomaticOrder(XElement element) { aiTag = element.GetAttributeString("aitag", null); option = element.GetAttributeString("option", null); - priority = element.GetAttributeFloat("priority", 0); + priorityModifier = element.GetAttributeFloat("prioritymodifier", 1); + priorityModifier = MathHelper.Max(priorityModifier, 0); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs index cf60f4585..b542be300 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs @@ -211,6 +211,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 11bf41f6c..686cd222f 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/FireSource.cs @@ -24,6 +24,8 @@ 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 03220257b..25ebe915b 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -128,6 +128,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 250c1e652..1dc9e5844 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -1209,6 +1209,9 @@ 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)); + 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 8ad826eea..e13028523 100644 --- a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs +++ b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs @@ -162,21 +162,6 @@ 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();