Merge branch 'dev' into enum

This commit is contained in:
Noah Pilarski 2022-10-03 18:02:58 -04:00
commit 13025f2e48
13 changed files with 106 additions and 43 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

@ -50,7 +50,11 @@ namespace NewHorizons.Builder.Props
private static void InitPrefabs() private static void InitPrefabs()
{ {
// Just take every scroll and get the first arc // 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).ToArray(); 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)
@ -69,7 +73,11 @@ namespace NewHorizons.Builder.Props
} }
} }
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

@ -21,8 +21,8 @@ namespace NewHorizons.Builder.Props
public static int NumberOfFrequencies; public static int NumberOfFrequencies;
public static List<SignalName> QMSignals { get; private set; } private static List<SignalName> _qmSignals;
public static List<SignalName> CloakedSignals { get; private set; } private static List<SignalName> _cloakedSignals;
public static bool Initialized; public static bool Initialized;
@ -37,12 +37,22 @@ namespace NewHorizons.Builder.Props
}; };
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length; NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
QMSignals = new List<SignalName>() { SignalName.Quantum_QM }; _qmSignals = new List<SignalName>() { SignalName.Quantum_QM };
CloakedSignals = new List<SignalName>(); _cloakedSignals = new List<SignalName>();
Initialized = true; 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) public static SignalFrequency AddFrequency(string str)
{ {
var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str); var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
@ -177,8 +187,8 @@ namespace NewHorizons.Builder.Props
signalGO.SetActive(true); signalGO.SetActive(true);
// Track certain special signal things // Track certain special signal things
if (planetGO.GetComponent<AstroObject>()?.GetAstroObjectName() == AstroObject.Name.QuantumMoon) QMSignals.Add(name); if (planetGO.GetComponent<AstroObject>()?.GetAstroObjectName() == AstroObject.Name.QuantumMoon) _qmSignals.Add(name);
if (info.insideCloak) CloakedSignals.Add(name); if (info.insideCloak) _cloakedSignals.Add(name);
return signalGO; return signalGO;
} }

View File

@ -204,7 +204,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

@ -47,11 +47,6 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public BrambleModule Bramble; public BrambleModule Bramble;
/// <summary>
/// Set to a higher number if you wish for this body to be built sooner
/// </summary>
[DefaultValue(-1)] public int buildPriority = -1;
/// <summary> /// <summary>
/// Should this planet ever be shown on the title screen? /// Should this planet ever be shown on the title screen?
/// </summary> /// </summary>

View File

@ -573,11 +573,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);
} }
@ -595,9 +595,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)
@ -605,15 +615,15 @@ namespace NewHorizons
var foundFile = false; var foundFile = false;
foreach (TextTranslation.Language language in EnumUtils.GetValues<TextTranslation.Language>()) foreach (TextTranslation.Language language in EnumUtils.GetValues<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.7.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

@ -119,7 +119,10 @@ namespace NewHorizons.Patches
{ {
if (!SignalBuilder.Initialized) return true; 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; __instance._canBePickedUpByScope = false;
if (__instance._sunController != null && __instance._sunController.IsPointInsideSupernova(__instance.transform.position)) 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 // 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._signalStrength = 0f;
__instance._degreesFromScope = 180f; __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 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()) if (!PlayerState.InCloakingField())
{ {

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