Merge branch 'dev' into eye-of-the-universe

This commit is contained in:
Noah 2022-10-02 11:57:42 -04:00 committed by GitHub
commit f8f0ae92cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 85 additions and 30 deletions

View File

@ -1,4 +1,5 @@
{ {
"$schema": "https://raw.githubusercontent.com/Outer-Wilds-New-Horizons/new-horizons/main/NewHorizons/Schemas/addon_manifest_schema.json",
"credits": [ "credits": [
"xen#Mod Director\n#Programmer", "xen#Mod Director\n#Programmer",
"Bwc9876#Mod Manager\n#Programmer\n#Dev Ops", "Bwc9876#Mod Manager\n#Programmer\n#Dev Ops",

View File

@ -101,11 +101,6 @@ namespace NewHorizons.Builder.Props
prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale); 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) if (detail.removeChildren != null)
{ {
var detailPath = prop.transform.GetPath(); 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; return prop;
} }

View File

@ -53,10 +53,14 @@ namespace NewHorizons.Builder.Props
_isInit = true; _isInit = true;
// Just take every scroll and get the first arc
if (_arcPrefabs == null || _childArcPrefabs == null) if (_arcPrefabs == null || _childArcPrefabs == null)
{ {
var existingArcs = GameObject.FindObjectsOfType<ScrollItem>().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<ScrollItem>()
.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<GameObject>(); _arcPrefabs = new List<GameObject>();
_childArcPrefabs = new List<GameObject>(); _childArcPrefabs = new List<GameObject>();
foreach (var existingArc in existingArcs) foreach (var existingArc in existingArcs)
@ -74,7 +78,11 @@ namespace NewHorizons.Builder.Props
if (_ghostArcPrefabs == null) if (_ghostArcPrefabs == null)
{ {
var existingGhostArcs = GameObject.FindObjectsOfType<GhostWallText>().Select(x => x?._textLine?.gameObject).Where(x => x != null).ToArray(); var existingGhostArcs = GameObject.FindObjectsOfType<GhostWallText>()
.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<GameObject>(); _ghostArcPrefabs = new List<GameObject>();
foreach (var existingArc in existingGhostArcs) foreach (var existingArc in existingGhostArcs)
{ {

View File

@ -206,7 +206,7 @@ namespace NewHorizons.Builder.ShipLog
private static Sprite GetEntrySprite(string entryId, NewHorizonsBody body, bool logError) 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 try
{ {
Texture2D newTexture = ImageUtilities.GetTexture(body.Mod, relativePath); Texture2D newTexture = ImageUtilities.GetTexture(body.Mod, relativePath);

View File

@ -655,11 +655,11 @@ namespace NewHorizons
} }
} }
// Has to go before translations for achievements // 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); LoadAddonManifest("addon-manifest.json", mod);
} }
if (Directory.Exists(folder + @"translations\")) if (Directory.Exists(Path.Combine(folder, "translations")))
{ {
LoadTranslations(folder, mod); LoadTranslations(folder, mod);
} }
@ -677,9 +677,19 @@ namespace NewHorizons
var addonConfig = mod.ModHelper.Storage.Load<AddonConfig>(file); var addonConfig = mod.ModHelper.Storage.Load<AddonConfig>(file);
if (addonConfig.achievements != null) AchievementHandler.RegisterAddon(addonConfig, mod as ModBehaviour); if (addonConfig.achievements != null)
if (addonConfig.credits != null) CreditsHandler.RegisterCredits(mod.ModHelper.Manifest.Name, addonConfig.credits); {
if (!string.IsNullOrEmpty(addonConfig.popupMessage)) MenuHandler.RegisterOneTimePopup(mod, addonConfig.popupMessage); 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) private void LoadTranslations(string folder, IModBehaviour mod)
@ -687,15 +697,15 @@ namespace NewHorizons
var foundFile = false; var foundFile = false;
foreach (TextTranslation.Language language in Enum.GetValues(typeof(TextTranslation.Language))) 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}"); 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; foundFile = true;

View File

@ -15,8 +15,7 @@
<DebugType>none</DebugType> <DebugType>none</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HarmonyX" Version="2.10.0" /> <PackageReference Include="OWML" Version="2.7.2" />
<PackageReference Include="OWML" Version="2.6.0" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.393" /> <PackageReference Include="OuterWildsGameLibs" Version="1.1.13.393" />
<Reference Include="../Lib/System.ComponentModel.Annotations.dll" /> <Reference Include="../Lib/System.ComponentModel.Annotations.dll" />
</ItemGroup> </ItemGroup>

View File

@ -19,24 +19,31 @@ namespace NewHorizons.Utility.DebugUtilities
private ScreenPrompt _raycastPrompt; private ScreenPrompt _raycastPrompt;
private void Awake() private void Start()
{ {
_rb = this.GetRequiredComponent<OWRigidbody>(); _rb = this.GetRequiredComponent<OWRigidbody>();
_raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P)); if (_raycastPrompt == null)
{
Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false); _raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P));
Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false);
}
} }
private void OnDestroy() private void OnDestroy()
{ {
Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight); if (_raycastPrompt != null)
{
Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight);
}
} }
private void Update() private void Update()
{ {
UpdatePromptVisibility(); UpdatePromptVisibility();
if (!Main.Debug) return; if (!Main.Debug) return;
if (Keyboard.current == null) return; if (Keyboard.current == null) return;
if (Keyboard.current[Key.P].wasReleasedThisFrame) if (Keyboard.current[Key.P].wasReleasedThisFrame)
@ -48,7 +55,10 @@ namespace NewHorizons.Utility.DebugUtilities
public void UpdatePromptVisibility() public void UpdatePromptVisibility()
{ {
_raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug); if (_raycastPrompt != null)
{
_raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug);
}
} }

View File

@ -1,5 +1,6 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using OWML.Common; using OWML.Common;
using System.Linq;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Utility namespace NewHorizons.Utility
{ {
@ -10,6 +11,8 @@ namespace NewHorizons.Utility
Config = config; Config = config;
Mod = mod; Mod = mod;
RelativePath = relativePath; RelativePath = relativePath;
Migrate();
} }
public PlanetConfig Config; public PlanetConfig Config;
@ -17,5 +20,31 @@ namespace NewHorizons.Utility
public string RelativePath; public string RelativePath;
public GameObject Object; 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
} }
} }

View File

@ -119,7 +119,7 @@ namespace NewHorizons.Utility
var name = names.Last(); var name = names.Last();
if (warn) Logger.LogWarning($"Couldn't find object in path {path}, will look for potential matches for name {name}"); 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<GameObject>() go = Resources.FindObjectsOfTypeAll<GameObject>()
.FirstOrDefault(x => x.name == name && x.scene.name != null); .FirstOrDefault(x => x.name == name && x.scene.name != null);
if (go) if (go)

View File

@ -4,8 +4,8 @@
"author": "xen, Bwc9876, clay, MegaPiggy, John, Hawkbar, Trifid, Book", "author": "xen, Bwc9876, clay, MegaPiggy, John, Hawkbar, Trifid, Book",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.6.1", "version": "1.6.2",
"owmlVersion": "2.6.0", "owmlVersion": "2.7.2",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility" ], "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ],
"pathsToPreserve": [ "planets", "systems", "translations" ] "pathsToPreserve": [ "planets", "systems", "translations" ]