diff --git a/NewHorizons/Assets/addon-manifest.json b/NewHorizons/Assets/addon-manifest.json index 9d8fd2a8..da53675c 100644 --- a/NewHorizons/Assets/addon-manifest.json +++ b/NewHorizons/Assets/addon-manifest.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/Outer-Wilds-New-Horizons/new-horizons/main/NewHorizons/Schemas/addon_manifest_schema.json", "credits": [ "xen#Mod Director\n#Programmer", "Bwc9876#Mod Manager\n#Programmer\n#Dev Ops", diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 6cb415a2..4aa2fc42 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -101,11 +101,6 @@ namespace NewHorizons.Builder.Props prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale); - if (!detail.keepLoaded) GroupsBuilder.Make(prop, sector); - prop.SetActive(true); - - if (prop == null) return null; - if (detail.removeChildren != null) { var detailPath = prop.transform.GetPath(); @@ -161,6 +156,9 @@ namespace NewHorizons.Builder.Props } } + if (!detail.keepLoaded) GroupsBuilder.Make(prop, sector); + prop.SetActive(true); + return prop; } diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 790e66cf..6851e2b3 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -50,7 +50,11 @@ namespace NewHorizons.Builder.Props private static void InitPrefabs() { // Just take every scroll and get the first arc - var existingArcs = GameObject.FindObjectsOfType().Select(x => x?._nomaiWallText?.gameObject?.transform?.Find("Arc 1")?.gameObject).Where(x => x != null).ToArray(); + var existingArcs = GameObject.FindObjectsOfType() + .Select(x => x?._nomaiWallText?.gameObject?.transform?.Find("Arc 1")?.gameObject) + .Where(x => x != null) + .OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things + .ToArray(); _arcPrefabs = new List(); _childArcPrefabs = new List(); foreach (var existingArc in existingArcs) @@ -69,7 +73,11 @@ namespace NewHorizons.Builder.Props } } - var existingGhostArcs = GameObject.FindObjectsOfType().Select(x => x?._textLine?.gameObject).Where(x => x != null).ToArray(); + var existingGhostArcs = GameObject.FindObjectsOfType() + .Select(x => x?._textLine?.gameObject) + .Where(x => x != null) + .OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things + .ToArray(); _ghostArcPrefabs = new List(); foreach (var existingArc in existingGhostArcs) { diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index be694a65..03f0774e 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -21,8 +21,8 @@ namespace NewHorizons.Builder.Props public static int NumberOfFrequencies; - public static List QMSignals { get; private set; } - public static List CloakedSignals { get; private set; } + private static List _qmSignals; + private static List _cloakedSignals; public static bool Initialized; @@ -37,12 +37,22 @@ namespace NewHorizons.Builder.Props }; NumberOfFrequencies = EnumUtils.GetValues().Length; - QMSignals = new List() { SignalName.Quantum_QM }; - CloakedSignals = new List(); + _qmSignals = new List() { SignalName.Quantum_QM }; + _cloakedSignals = new List(); Initialized = true; } + public static bool IsCloaked(this SignalName signalName) + { + return _cloakedSignals.Contains(signalName); + } + + public static bool IsOnQuantumMoon(this SignalName signalName) + { + return _qmSignals.Contains(signalName); + } + public static SignalFrequency AddFrequency(string str) { var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str); @@ -177,8 +187,8 @@ namespace NewHorizons.Builder.Props signalGO.SetActive(true); // Track certain special signal things - if (planetGO.GetComponent()?.GetAstroObjectName() == AstroObject.Name.QuantumMoon) QMSignals.Add(name); - if (info.insideCloak) CloakedSignals.Add(name); + if (planetGO.GetComponent()?.GetAstroObjectName() == AstroObject.Name.QuantumMoon) _qmSignals.Add(name); + if (info.insideCloak) _cloakedSignals.Add(name); return signalGO; } diff --git a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs index ed717557..0543b0ae 100644 --- a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs @@ -204,7 +204,7 @@ namespace NewHorizons.Builder.ShipLog private static Sprite GetEntrySprite(string entryId, NewHorizonsBody body, bool logError) { - string relativePath = body.Config.ShipLog.spriteFolder + "/" + entryId + ".png"; + string relativePath = Path.Combine(body.Config.ShipLog.spriteFolder, entryId + ".png"); try { Texture2D newTexture = ImageUtilities.GetTexture(body.Mod, relativePath); diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 55c59231..af007f48 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -47,11 +47,6 @@ namespace NewHorizons.External.Configs /// public BrambleModule Bramble; - /// - /// Set to a higher number if you wish for this body to be built sooner - /// - [DefaultValue(-1)] public int buildPriority = -1; - /// /// Should this planet ever be shown on the title screen? /// diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index e99e6dc0..6d1c9562 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -573,11 +573,11 @@ namespace NewHorizons } } // Has to go before translations for achievements - if (File.Exists(folder + "addon-manifest.json")) + if (File.Exists(Path.Combine(folder, "addon-manifest.json"))) { LoadAddonManifest("addon-manifest.json", mod); } - if (Directory.Exists(folder + @"translations\")) + if (Directory.Exists(Path.Combine(folder, "translations"))) { LoadTranslations(folder, mod); } @@ -595,9 +595,19 @@ namespace NewHorizons var addonConfig = mod.ModHelper.Storage.Load(file); - if (addonConfig.achievements != null) AchievementHandler.RegisterAddon(addonConfig, mod as ModBehaviour); - if (addonConfig.credits != null) CreditsHandler.RegisterCredits(mod.ModHelper.Manifest.Name, addonConfig.credits); - if (!string.IsNullOrEmpty(addonConfig.popupMessage)) MenuHandler.RegisterOneTimePopup(mod, addonConfig.popupMessage); + if (addonConfig.achievements != null) + { + AchievementHandler.RegisterAddon(addonConfig, mod as ModBehaviour); + } + if (addonConfig.credits != null) + { + var translatedCredits = addonConfig.credits.Select(x => TranslationHandler.GetTranslation(x, TranslationHandler.TextType.UI)).ToArray(); + CreditsHandler.RegisterCredits(mod.ModHelper.Manifest.Name, translatedCredits); + } + if (!string.IsNullOrEmpty(addonConfig.popupMessage)) + { + MenuHandler.RegisterOneTimePopup(mod, TranslationHandler.GetTranslation(addonConfig.popupMessage, TranslationHandler.TextType.UI)); + } } private void LoadTranslations(string folder, IModBehaviour mod) @@ -605,15 +615,15 @@ namespace NewHorizons var foundFile = false; foreach (TextTranslation.Language language in EnumUtils.GetValues()) { - if (language == TextTranslation.Language.UNKNOWN || language == TextTranslation.Language.TOTAL) continue; + if (language is TextTranslation.Language.UNKNOWN or TextTranslation.Language.TOTAL) continue; - var relativeFile = $"translations/{language.ToString().ToLower()}.json"; + var relativeFile = Path.Combine("translations", language.ToString().ToLower() + ".json"); - if (File.Exists($"{folder}{relativeFile}")) + if (File.Exists(Path.Combine(folder, relativeFile))) { Logger.LogVerbose($"Registering {language} translation from {mod.ModHelper.Manifest.Name} from {relativeFile}"); - var config = new TranslationConfig($"{folder}{relativeFile}"); + var config = new TranslationConfig(Path.Combine(folder, relativeFile)); foundFile = true; diff --git a/NewHorizons/NewHorizons.csproj b/NewHorizons/NewHorizons.csproj index f232a410..95916ac6 100644 --- a/NewHorizons/NewHorizons.csproj +++ b/NewHorizons/NewHorizons.csproj @@ -15,8 +15,7 @@ none - - + diff --git a/NewHorizons/Patches/AudioSignalPatches.cs b/NewHorizons/Patches/AudioSignalPatches.cs index 18544af3..a5087919 100644 --- a/NewHorizons/Patches/AudioSignalPatches.cs +++ b/NewHorizons/Patches/AudioSignalPatches.cs @@ -119,7 +119,10 @@ namespace NewHorizons.Patches { if (!SignalBuilder.Initialized) return true; - if (!SignalBuilder.CloakedSignals.Contains(__instance._name) && !SignalBuilder.QMSignals.Contains(__instance._name)) return true; + var isCloaked = SignalBuilder.IsCloaked(__instance._name); + var isOnQuantumMoon = SignalBuilder.IsOnQuantumMoon(__instance._name); + + if (!isCloaked && !isOnQuantumMoon) return true; __instance._canBePickedUpByScope = false; if (__instance._sunController != null && __instance._sunController.IsPointInsideSupernova(__instance.transform.position)) @@ -130,7 +133,7 @@ namespace NewHorizons.Patches } // This part is modified from the original to include all QM signals - if (Locator.GetQuantumMoon() != null && Locator.GetQuantumMoon().IsPlayerInside() && !SignalBuilder.QMSignals.Contains(__instance._name)) + if (Locator.GetQuantumMoon() != null && Locator.GetQuantumMoon().IsPlayerInside() && !isOnQuantumMoon) { __instance._signalStrength = 0f; __instance._degreesFromScope = 180f; @@ -167,7 +170,7 @@ namespace NewHorizons.Patches } // If it's a cloaked signal we don't want to hear it outside the cloak field - if (SignalBuilder.CloakedSignals.Contains(__instance._name)) + if (isCloaked) { if (!PlayerState.InCloakingField()) { diff --git a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs index 16f502e8..6f4e23fa 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs @@ -19,24 +19,31 @@ namespace NewHorizons.Utility.DebugUtilities private ScreenPrompt _raycastPrompt; - private void Awake() + private void Start() { _rb = this.GetRequiredComponent(); - _raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " ", ImageUtilities.GetButtonSprite(KeyCode.P)); - - Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false); + if (_raycastPrompt == null) + { + _raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " ", ImageUtilities.GetButtonSprite(KeyCode.P)); + Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false); + } } private void OnDestroy() { - Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight); + if (_raycastPrompt != null) + { + Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight); + } } private void Update() { UpdatePromptVisibility(); + if (!Main.Debug) return; + if (Keyboard.current == null) return; if (Keyboard.current[Key.P].wasReleasedThisFrame) @@ -48,7 +55,10 @@ namespace NewHorizons.Utility.DebugUtilities public void UpdatePromptVisibility() { - _raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug); + if (_raycastPrompt != null) + { + _raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug); + } } diff --git a/NewHorizons/Utility/NewHorizonBody.cs b/NewHorizons/Utility/NewHorizonBody.cs index fbbc7de6..fc9f53bd 100644 --- a/NewHorizons/Utility/NewHorizonBody.cs +++ b/NewHorizons/Utility/NewHorizonBody.cs @@ -1,5 +1,6 @@ -using NewHorizons.External.Configs; +using NewHorizons.External.Configs; using OWML.Common; +using System.Linq; using UnityEngine; namespace NewHorizons.Utility { @@ -10,6 +11,8 @@ namespace NewHorizons.Utility Config = config; Mod = mod; RelativePath = relativePath; + + Migrate(); } public PlanetConfig Config; @@ -17,5 +20,31 @@ namespace NewHorizons.Utility public string RelativePath; public GameObject Object; + + #region Migration + private static readonly string[] _keepLoadedModsList = new string[] + { + "CreativeNameTxt.theirhomeworld", + "Roggsy.enterthewarioverse", + "Jammer.jammerlore", + "ErroneousCreationist.solarneighbourhood", + "ErroneousCreationist.incursionfinaldawn" + }; + + private void Migrate() + { + // Some old mods get really broken by this change in 1.6.1 + if (_keepLoadedModsList.Contains(Mod.ModHelper.Manifest.UniqueName)) + { + if (Config?.Props?.details != null) + { + foreach (var detail in Config.Props.details) + { + detail.keepLoaded = true; + } + } + } + } + #endregion } } diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 97cb4a5e..99cd2cdb 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -119,7 +119,7 @@ namespace NewHorizons.Utility var name = names.Last(); if (warn) Logger.LogWarning($"Couldn't find object in path {path}, will look for potential matches for name {name}"); - // 3: find resource to include inactive objects (but skip prefabs + // 3: find resource to include inactive objects (but skip prefabs) go = Resources.FindObjectsOfTypeAll() .FirstOrDefault(x => x.name == name && x.scene.name != null); if (go) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 6fb4c0d4..ae3d41c3 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,8 +4,8 @@ "author": "xen, Bwc9876, clay, MegaPiggy, John, Hawkbar, Trifid, Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.6.1", - "owmlVersion": "2.6.0", + "version": "1.6.2", + "owmlVersion": "2.7.2", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ], "pathsToPreserve": [ "planets", "systems", "translations" ]