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 4c916571..e1a07c76 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -53,10 +53,14 @@ namespace NewHorizons.Builder.Props _isInit = true; - // Just take every scroll and get the first arc if (_arcPrefabs == null || _childArcPrefabs == null) { - var existingArcs = GameObject.FindObjectsOfType().Select(x => x?._nomaiWallText?.gameObject?.transform?.Find("Arc 1")?.gameObject).Where(x => x != null).ToArray(); + // 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) + .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) @@ -74,7 +78,11 @@ namespace NewHorizons.Builder.Props if (_ghostArcPrefabs == null) { - 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/ShipLog/RumorModeBuilder.cs b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs index 9e82ae8b..740731ec 100644 --- a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs @@ -206,7 +206,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/Main.cs b/NewHorizons/Main.cs index e93e91c4..61cda5e8 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -655,11 +655,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); } @@ -677,9 +677,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) @@ -687,15 +697,15 @@ namespace NewHorizons var foundFile = false; foreach (TextTranslation.Language language in Enum.GetValues(typeof(TextTranslation.Language))) { - 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 a4e7f6e4..d231d709 100644 --- a/NewHorizons/NewHorizons.csproj +++ b/NewHorizons/NewHorizons.csproj @@ -15,8 +15,7 @@ none - - + 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" ]