diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs index 1f146ab06..0344ba7c1 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ServerListScreen.cs @@ -218,22 +218,6 @@ namespace Barotrauma return true; } - private bool RefreshJoinButtonState(GUIComponent component, object obj) - { - if (obj == null || waitingForRefresh) { return false; } - - if (!string.IsNullOrWhiteSpace(clientNameBox.Text) && !string.IsNullOrWhiteSpace(ipBox.Text)) - { - joinButton.Enabled = true; - } - else - { - joinButton.Enabled = false; - } - - return true; - } - private bool SelectServer(GUIComponent component, object obj) { if (obj == null || waitingForRefresh) { return false; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index c68f451cb..b91b277b9 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -553,8 +553,6 @@ namespace Barotrauma public static bool HasItem(Character character, string tag, string containedTag, float conditionPercentage = 0) { - if (character == null) { return false; } - if (character.Inventory == null) { return false; } var item = character.Inventory.FindItemByTag(tag); return item != null && item.ConditionPercentage > conditionPercentage && diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs index c8cb23e10..9d23de7d3 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs @@ -16,9 +16,6 @@ namespace Barotrauma public Func customCondition; - public bool followControlledCharacter; - public bool mimic; - /// /// Display units /// @@ -27,11 +24,9 @@ namespace Barotrauma public bool AllowGoingOutside { get; set; } public bool CheckVisibility { get; set; } - public ISpatialEntity Target { get; private set; } - public override float GetPriority() { - if (followControlledCharacter && Character.Controlled == null) { return 0.0f; } + if (FollowControlledCharacter && Character.Controlled == null) { return 0.0f; } if (Target is Entity e && e.Removed) { return 0.0f; } if (IgnoreIfTargetDead && Target is Character character && character.IsDead) { return 0.0f; } if (objectiveManager.CurrentOrder == this) @@ -41,6 +36,10 @@ namespace Barotrauma return 1.0f; } + public ISpatialEntity Target { get; private set; } + + public bool FollowControlledCharacter; + public AIObjectiveGoTo(ISpatialEntity target, Character character, AIObjectiveManager objectiveManager, bool repeat = false, bool getDivingGearIfNeeded = true, float priorityModifier = 1) : base (character, objectiveManager, priorityModifier) { @@ -53,7 +52,7 @@ namespace Barotrauma protected override void Act(float deltaTime) { - if (followControlledCharacter) + if (FollowControlledCharacter) { if (Character.Controlled == null) { @@ -138,9 +137,8 @@ namespace Barotrauma } if (getDivingGearIfNeeded) { - Character followTarget = Target as Character; - bool needsDivingGear = HumanAIController.NeedsDivingGear(targetHull) || mimic && HumanAIController.HasDivingMask(followTarget); - bool needsDivingSuit = needsDivingGear && (targetHull == null || targetIsOutside || targetHull.WaterPercentage > 90) || mimic && HumanAIController.HasDivingSuit(followTarget); + bool needsDivingGear = HumanAIController.NeedsDivingGear(targetHull); + bool needsDivingSuit = needsDivingGear && (targetHull == null || targetIsOutside || targetHull.WaterPercentage > 90); bool needsEquipment = false; if (needsDivingSuit) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index 8451af1fc..8aae67958 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -239,8 +239,7 @@ namespace Barotrauma CloseEnough = 150, AllowGoingOutside = true, IgnoreIfTargetDead = true, - followControlledCharacter = orderGiver == character, - mimic = true + FollowControlledCharacter = orderGiver == character }; break; case "wait": diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs index c996f1e2d..7f357dffc 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Connection.cs @@ -79,8 +79,59 @@ namespace Barotrauma.Items.Components wires = new Wire[MaxLinked]; - IsOutput = (element.Name.ToString() == "output"); - Name = element.GetAttributeString("name", (IsOutput) ? "output" : "input"); + IsOutput = element.Name.ToString() == "output"; + Name = element.GetAttributeString("name", IsOutput ? "output" : "input"); + + string displayNameTag = "", fallbackTag = ""; + //if displayname is not present, attempt to find it from the prefab + if (element.Attribute("displayname") == null) + { + foreach (XElement subElement in item.Prefab.ConfigElement.Elements()) + { + if (subElement.Name.ToString().ToLowerInvariant() != "connectionpanel") { continue; } + + foreach (XElement connectionElement in subElement.Elements()) + { + if (connectionElement.Name.ToString() != element.Name.ToString()) { continue; } + + string prefabConnectionName = element.GetAttributeString("name", IsOutput ? "output" : "input"); + if (prefabConnectionName == Name) + { + displayNameTag = connectionElement.GetAttributeString("displayname", ""); + fallbackTag = connectionElement.GetAttributeString("fallbackdisplayname", ""); + } + } + } + } + else + { + displayNameTag = element.GetAttributeString("displayname", ""); + fallbackTag = element.GetAttributeString("fallbackdisplayname", null); + } + + if (!string.IsNullOrEmpty(displayNameTag)) + { + //extract the tag parts in case the tags contains variables + string tagWithoutVariables = displayNameTag?.Split('~')?.FirstOrDefault(); + string fallbackTagWithoutVariables = fallbackTag?.Split('~')?.FirstOrDefault(); + //use displayNameTag if found, otherwise fallBack + if (TextManager.ContainsTag(tagWithoutVariables)) + { + DisplayName = TextManager.GetServerMessage(displayNameTag); + } + else if (TextManager.ContainsTag(fallbackTagWithoutVariables)) + { + DisplayName = TextManager.GetServerMessage(fallbackTag); + } + } + + if (string.IsNullOrEmpty(DisplayName)) + { +#if DEBUG + DebugConsole.ThrowError("Missing display name in connection " + item.Name + ": " + Name); +#endif + DisplayName = Name; + } //if displayname is not present, attempt to find it from the prefab if (element.Attribute("displayname") == null) diff --git a/Barotrauma/BarotraumaShared/Source/TextManager.cs b/Barotrauma/BarotraumaShared/Source/TextManager.cs index 6e40253f3..00b59b288 100644 --- a/Barotrauma/BarotraumaShared/Source/TextManager.cs +++ b/Barotrauma/BarotraumaShared/Source/TextManager.cs @@ -80,6 +80,26 @@ namespace Barotrauma } } + public static bool ContainsTag(string textTag) + { + if (string.IsNullOrEmpty(textTag)) { return false; } + + if (!textPacks.ContainsKey(Language)) + { + DebugConsole.ThrowError("No text packs available for the selected language (" + Language + ")! Switching to English..."); + Language = "English"; + if (!textPacks.ContainsKey(Language)) + { + throw new Exception("No text packs available in English!"); + } + } + foreach (TextPack textPack in textPacks[Language]) + { + if (textPack.Get(textTag) != null) { return true; } + } + return false; + } + public static string Get(string textTag, bool returnNull = false, string fallBackTag = null) { if (!textPacks.ContainsKey(Language)) @@ -114,7 +134,13 @@ namespace Barotrauma foreach (TextPack textPack in textPacks["English"]) { string text = textPack.Get(textTag); - if (text != null) return text; + if (text != null) + { +#if DEBUG + DebugConsole.NewMessage("Text \"" + textTag + "\" not found for the language \"" + Language + "\". Using the English text \"" + text + "\" instead."); +#endif + return text; + } } } diff --git a/Barotrauma/BarotraumaShared/Submarines/Bunyip.sub b/Barotrauma/BarotraumaShared/Submarines/Bunyip.sub index 0981c2849..3d6deb368 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Bunyip.sub and b/Barotrauma/BarotraumaShared/Submarines/Bunyip.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Dugong.sub b/Barotrauma/BarotraumaShared/Submarines/Dugong.sub index 4286ee8ec..ce81dd5a0 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Dugong.sub and b/Barotrauma/BarotraumaShared/Submarines/Dugong.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Humpback.sub b/Barotrauma/BarotraumaShared/Submarines/Humpback.sub index f221d0f6b..c986d80a9 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Humpback.sub and b/Barotrauma/BarotraumaShared/Submarines/Humpback.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Orca.sub b/Barotrauma/BarotraumaShared/Submarines/Orca.sub index d0c3b54c7..39ebfe8e7 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Orca.sub and b/Barotrauma/BarotraumaShared/Submarines/Orca.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Remora.sub b/Barotrauma/BarotraumaShared/Submarines/Remora.sub index 6e3afa65c..20671aa41 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Remora.sub and b/Barotrauma/BarotraumaShared/Submarines/Remora.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub b/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub index ec48ad330..a69e7251c 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub and b/Barotrauma/BarotraumaShared/Submarines/RemoraDrone.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Selkie.sub b/Barotrauma/BarotraumaShared/Submarines/Selkie.sub index e5a2fc4f9..1c30b9a86 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Selkie.sub and b/Barotrauma/BarotraumaShared/Submarines/Selkie.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Typhon.sub b/Barotrauma/BarotraumaShared/Submarines/Typhon.sub index 10d56258f..8605eff50 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Typhon.sub and b/Barotrauma/BarotraumaShared/Submarines/Typhon.sub differ