diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs index b7b1e13c4..438597ec1 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFindSafety.cs @@ -68,6 +68,8 @@ namespace Barotrauma } } + private Hull currentSafeHull; + private Hull previousSafeHull; protected override void Act(float deltaTime) { var currentHull = character.AnimController.CurrentHull; @@ -107,15 +109,20 @@ namespace Barotrauma else { searchHullTimer = SearchHullInterval; - var bestHull = FindBestHull(); - if (bestHull != null && bestHull != currentHull) + previousSafeHull = currentSafeHull; + currentSafeHull = FindBestHull(); + if (currentSafeHull == null) { - if (goToObjective?.Target != bestHull) + currentSafeHull = previousSafeHull; + } + if (currentSafeHull != null && currentSafeHull != currentHull) + { + if (goToObjective?.Target != currentSafeHull) { goToObjective = null; } TryAddSubObjective(ref goToObjective, - constructor: () => new AIObjectiveGoTo(bestHull, character, objectiveManager, getDivingGearIfNeeded: false) + constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: false) { // If we need diving gear, we should already have it, if possible. AllowGoingOutside = HumanAIController.HasDivingSuit(character) @@ -179,11 +186,11 @@ namespace Barotrauma { if (hull.Submarine == null) { continue; } if (ignoredHulls != null && ignoredHulls.Contains(hull)) { continue; } + if (unreachable.Contains(hull)) { continue; } float hullSafety = 0; - if (character.Submarine != null && SteeringManager == PathSteering) + if (character.CurrentHull != null) { - // Inside or outside near the sub - if (unreachable.Contains(hull)) { continue; } + // Inside if (!character.Submarine.IsConnectedTo(hull.Submarine)) { continue; } hullSafety = HumanAIController.GetHullSafety(hull, character); // Vertical distance matters more than horizontal (climbing up/down is harder than moving horizontally) @@ -212,7 +219,7 @@ namespace Barotrauma else { // Outside - if (hull.RoomName?.ToLowerInvariant() == "airlock") + if (hull.RoomName != null && hull.RoomName.ToLowerInvariant().Contains("airlock")) { hullSafety = 100; } @@ -221,7 +228,7 @@ namespace Barotrauma // TODO: could also target gaps that get us inside? foreach (Item item in Item.ItemList) { - if (item.CurrentHull == hull && item.HasTag("airlock")) + if (item.CurrentHull != hull && item.HasTag("airlock")) { hullSafety = 100; break; 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);