From e63ffe652e5ac722a5a71e33f4892fe026c71718 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sat, 18 May 2019 17:26:34 +0300 Subject: [PATCH] (5e16139ed) Added "OrderGiver" field to AI orders, always show reports from the currently controlled character (even if the report is not targeted for the character's class) --- .../Source/Characters/CharacterHUD.cs | 8 +++- .../Source/GameSession/CrewManager.cs | 2 +- .../GameModes/Tutorials/DoctorTutorial.cs | 6 +-- .../Source/Networking/ChatMessage.cs | 4 +- .../Source/Characters/AI/HumanAIController.cs | 10 ++-- .../AI/Objectives/AIObjectiveManager.cs | 6 ++- .../Source/Characters/AI/Order.cs | 7 ++- .../BarotraumaShared/Source/GameSettings.cs | 48 +++++++++++++++++++ 8 files changed, 76 insertions(+), 15 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs index acdfb33ab..0ee4b4bdf 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/CharacterHUD.cs @@ -370,7 +370,13 @@ namespace Barotrauma private static void DrawOrderIndicator(SpriteBatch spriteBatch, Camera cam, Character character, Order order, float iconAlpha = 1.0f) { - if (order.TargetAllCharacters && !order.HasAppropriateJob(character)) { return; } + if (order.TargetAllCharacters) + { + if (order.OrderGiver != character && !order.HasAppropriateJob(character)) + { + return; + } + } Entity target = order.ConnectedController != null ? order.ConnectedController.Item : order.TargetEntity; if (target == null) { return; } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index c3871b3d1..ba3ef5ba5 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -747,7 +747,7 @@ namespace Barotrauma { if (orderGiver == null || orderGiver.CurrentHull == null) { return; } var hull = orderGiver.CurrentHull; - AddOrder(new Order(order.Prefab, hull, null), order.Prefab.FadeOutTime); + AddOrder(new Order(order.Prefab, hull, null, orderGiver), order.Prefab.FadeOutTime); if (IsSinglePlayer) { orderGiver.Speak( diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs index 011867366..3045bdc5c 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs @@ -233,7 +233,7 @@ namespace Barotrauma.Tutorials //patient 1 requests first aid patient1.CanSpeak = true; - var newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient1.CurrentHull, null); + var newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient1.CurrentHull, null, orderGiver: patient1); GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime); patient1.Speak(newOrder.GetChatMessage("", patient1.CurrentHull?.RoomName, givingOrderToSelf: false), ChatMessageType.Order); patient1.AIController.Enabled = true; @@ -317,7 +317,7 @@ namespace Barotrauma.Tutorials //patient calls for help patient2.CanSpeak = true; - newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient2.CurrentHull, null); + newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), patient2.CurrentHull, null, orderGiver: patient2); GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime); patient2.Speak(newOrder.GetChatMessage("", patient1.CurrentHull?.RoomName, givingOrderToSelf: false), ChatMessageType.Order); patient2.AIController.Enabled = true; @@ -378,7 +378,7 @@ namespace Barotrauma.Tutorials //(within 1 minute intervals of entering the sub) if (!patientCalledHelp[i] && Timing.TotalTime > subEnterTime + 60 * (i + 1)) { - newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), subPatients[i].CurrentHull, null); + newOrder = new Order(Order.PrefabList.Find(o => o.AITag == "requestfirstaid"), subPatients[i].CurrentHull, null, orderGiver: subPatients[i]); GameMain.GameSession.CrewManager.AddOrder(newOrder, newOrder.FadeOutTime); string message = newOrder.GetChatMessage("", subPatients[i].CurrentHull?.RoomName, givingOrderToSelf: false); diff --git a/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs b/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs index 4a560e126..32c8d5a98 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/ChatMessage.cs @@ -66,13 +66,13 @@ namespace Barotrauma.Networking if (order.TargetAllCharacters) { GameMain.GameSession?.CrewManager?.AddOrder( - new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType)), + new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType), orderGiver: senderCharacter), order.Prefab.FadeOutTime); } else if (targetCharacter != null) { targetCharacter.SetOrder( - new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType)), + new Order(order.Prefab, targetEntity, (targetEntity as Item)?.Components.FirstOrDefault(ic => ic.GetType() == order.ItemComponentType), orderGiver: senderCharacter), orderOption, senderCharacter); } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 593e5a714..83962b19c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -295,7 +295,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportintruders"); - newOrder = new Order(orderPrefab, c.CurrentHull, null); + newOrder = new Order(orderPrefab, c.CurrentHull, null, orderGiver: Character); } } } @@ -305,7 +305,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportfire"); - newOrder = new Order(orderPrefab, hull, null); + newOrder = new Order(orderPrefab, hull, null, orderGiver: Character); } } foreach (Character c in Character.CharacterList) @@ -317,7 +317,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "requestfirstaid"); - newOrder = new Order(orderPrefab, c.CurrentHull, null); + newOrder = new Order(orderPrefab, c.CurrentHull, null, orderGiver: Character); } } } @@ -329,7 +329,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbreach"); - newOrder = new Order(orderPrefab, hull, null); + newOrder = new Order(orderPrefab, hull, null, orderGiver: Character); } } } @@ -343,7 +343,7 @@ namespace Barotrauma if (newOrder == null) { var orderPrefab = Order.PrefabList.Find(o => o.AITag == "reportbrokendevices"); - newOrder = new Order(orderPrefab, item.CurrentHull, item.Repairables?.FirstOrDefault()); + newOrder = new Order(orderPrefab, item.CurrentHull, item.Repairables?.FirstOrDefault(), orderGiver: Character); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index aa296d02c..94ba80959 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -81,7 +81,11 @@ namespace Barotrauma Item.ItemList.FindAll(it => it.Components.Any(ic => ic.GetType() == orderPrefab.ItemComponentType)); matchingItems.RemoveAll(it => it.Submarine != character.Submarine); var item = matchingItems.GetRandom(); - var order = new Order(orderPrefab, item ?? character.CurrentHull as Entity, item?.Components.FirstOrDefault(ic => ic.GetType() == orderPrefab.ItemComponentType)); + var order = new Order( + orderPrefab, + item ?? character.CurrentHull as Entity, + item?.Components.FirstOrDefault(ic => ic.GetType() == orderPrefab.ItemComponentType), + orderGiver: character); if (order == null) { continue; } var objective = CreateObjective(order, automaticOrder.option, character, automaticOrder.priorityModifier); if (objective != null) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs index b7986dcff..6391147f5 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Order.cs @@ -39,7 +39,9 @@ namespace Barotrauma public Entity TargetEntity; public ItemComponent TargetItemComponent; public readonly bool UseController; - public Controller ConnectedController; + public Controller ConnectedController; + + public Character OrderGiver; public readonly string[] AppropriateJobs; public readonly string[] Options; @@ -120,7 +122,7 @@ namespace Barotrauma } } - public Order(Order prefab, Entity targetEntity, ItemComponent targetItem) + public Order(Order prefab, Entity targetEntity, ItemComponent targetItem, Character orderGiver = null) { Prefab = prefab; @@ -134,6 +136,7 @@ namespace Barotrauma TargetAllCharacters = prefab.TargetAllCharacters; AppropriateJobs = prefab.AppropriateJobs; FadeOutTime = prefab.FadeOutTime; + OrderGiver = orderGiver; TargetEntity = targetEntity; if (targetItem != null) diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index d6722b111..64b8a8358 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -821,6 +821,54 @@ namespace Barotrauma VoiceSetting = voiceSetting; } } + if (!SelectedContentPackages.Any()) + { + var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage); + if (availablePackage != null) + { + SelectedContentPackages.Add(availablePackage); + } + } + + //save to get rid of the invalid selected packages in the config file + if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); } + } + #endregion + + #region Save DefaultConfig + private void SaveNewDefaultConfig() + { + XDocument doc = new XDocument(); + + if (doc.Root == null) + { + doc.Add(new XElement("config")); + } + + doc.Root.Add( + new XAttribute("language", TextManager.Language), + new XAttribute("masterserverurl", MasterServerUrl), + new XAttribute("autocheckupdates", AutoCheckUpdates), + new XAttribute("musicvolume", musicVolume), + new XAttribute("soundvolume", soundVolume), + new XAttribute("voicechatvolume", voiceChatVolume), + new XAttribute("verboselogging", VerboseLogging), + new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs), + new XAttribute("enablesplashscreen", EnableSplashScreen), + new XAttribute("usesteammatchmaking", useSteamMatchmaking), + new XAttribute("quickstartsub", QuickStartSubmarineName), + new XAttribute("requiresteamauthentication", requireSteamAuthentication), + new XAttribute("aimassistamount", aimAssistAmount)); + + if (!ShowUserStatisticsPrompt) + { + doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics)); + } + + if (WasGameUpdated) + { + doc.Root.Add(new XAttribute("wasgameupdated", true)); + } useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking); requireSteamAuthentication = doc.Root.GetAttributeBool("requiresteamauthentication", requireSteamAuthentication);