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": [
"xen#Mod Director\n#Programmer",
"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);
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;
}

View File

@ -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<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>();
_childArcPrefabs = new List<GameObject>();
foreach (var existingArc in existingArcs)
@ -74,7 +78,11 @@ namespace NewHorizons.Builder.Props
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>();
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)
{
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);

View File

@ -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<AddonConfig>(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;

View File

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

View File

@ -19,24 +19,31 @@ namespace NewHorizons.Utility.DebugUtilities
private ScreenPrompt _raycastPrompt;
private void Awake()
private void Start()
{
_rb = this.GetRequiredComponent<OWRigidbody>();
_raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P));
Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false);
if (_raycastPrompt == null)
{
_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()
{
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);
}
}

View File

@ -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
}
}

View File

@ -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<GameObject>()
.FirstOrDefault(x => x.name == name && x.scene.name != null);
if (go)

View File

@ -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" ]