mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Jam fixes (#825)
## Improvements - NH will save data less often, only when base game does. ## Bug fixes - Fixes ship not being added to volumes when warping - Fixed generated map mode icons being ugly, especially when they have no logs attached - Fixed signal related crashes, "change frequency" prompt being shown at the wrong times
This commit is contained in:
commit
6e39d07e86
Binary file not shown.
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 128 KiB |
@ -1,9 +1,11 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using NewHorizons.External;
|
||||||
using NewHorizons.External.Modules.Props.Audio;
|
using NewHorizons.External.Modules.Props.Audio;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -36,27 +38,16 @@ namespace NewHorizons.Builder.Props.Audio
|
|||||||
};
|
};
|
||||||
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
||||||
|
|
||||||
_qmSignals = new (){ SearchUtilities.Find("QuantumMoon_Body/Signal_Quantum").GetComponent<AudioSignal>() };
|
_qmSignals = new () { SearchUtilities.Find("QuantumMoon_Body/Signal_Quantum").GetComponent<AudioSignal>() };
|
||||||
_cloakedSignals = new();
|
_cloakedSignals = new();
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
|
|
||||||
SceneManager.sceneUnloaded -= OnSceneUnloaded;
|
SceneManager.sceneUnloaded -= OnSceneUnloaded;
|
||||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||||
Main.Instance.OnStarSystemLoaded.RemoveListener(OnStarSystemLoaded);
|
|
||||||
Main.Instance.OnStarSystemLoaded.AddListener(OnStarSystemLoaded);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static HashSet<SignalFrequency> _frequenciesInUse = new();
|
|
||||||
|
|
||||||
private static void OnSceneUnloaded(Scene _)
|
|
||||||
{
|
|
||||||
_frequenciesInUse.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnStarSystemLoaded(string starSystem)
|
|
||||||
{
|
|
||||||
// If its the base game solar system or eye we get all the main frequencies
|
// If its the base game solar system or eye we get all the main frequencies
|
||||||
|
var starSystem = Main.Instance.CurrentStarSystem;
|
||||||
if (starSystem == "SolarSystem" || starSystem == "EyeOfTheUniverse")
|
if (starSystem == "SolarSystem" || starSystem == "EyeOfTheUniverse")
|
||||||
{
|
{
|
||||||
_frequenciesInUse.Add(SignalFrequency.Quantum);
|
_frequenciesInUse.Add(SignalFrequency.Quantum);
|
||||||
@ -69,19 +60,43 @@ namespace NewHorizons.Builder.Props.Audio
|
|||||||
// We don't want a scenario where the player knows no frequencies
|
// We don't want a scenario where the player knows no frequencies
|
||||||
_frequenciesInUse.Add(SignalFrequency.Traveler);
|
_frequenciesInUse.Add(SignalFrequency.Traveler);
|
||||||
|
|
||||||
|
// Make sure the NH save file has all the right frequencies
|
||||||
|
// Skip "default"
|
||||||
|
for (int i = 1; i < PlayerData._currentGameSave.knownFrequencies.Length; i++)
|
||||||
|
{
|
||||||
|
if (PlayerData._currentGameSave.knownFrequencies[i])
|
||||||
|
{
|
||||||
|
NewHorizonsData.LearnFrequency(AudioSignal.IndexToFrequency(i).ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NHLogger.LogVerbose($"Frequencies in use in {starSystem}: {_frequenciesInUse.Join(x => x.ToString())}");
|
NHLogger.LogVerbose($"Frequencies in use in {starSystem}: {_frequenciesInUse.Join(x => x.ToString())}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static HashSet<SignalFrequency> _frequenciesInUse = new();
|
||||||
|
|
||||||
|
private static void OnSceneUnloaded(Scene _)
|
||||||
|
{
|
||||||
|
_frequenciesInUse.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsFrequencyInUse(SignalFrequency freq) => _frequenciesInUse.Contains(freq);
|
public static bool IsFrequencyInUse(SignalFrequency freq) => _frequenciesInUse.Contains(freq);
|
||||||
|
|
||||||
|
public static bool IsFrequencyInUse(string freqString)
|
||||||
|
{
|
||||||
|
if (Enum.TryParse<SignalFrequency>(freqString, out var freq))
|
||||||
|
{
|
||||||
|
return IsFrequencyInUse(freq);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsCloaked(this AudioSignal signal) => _cloakedSignals.Contains(signal);
|
public static bool IsCloaked(this AudioSignal signal) => _cloakedSignals.Contains(signal);
|
||||||
|
|
||||||
public static bool IsOnQuantumMoon(this AudioSignal signal) => _qmSignals.Contains(signal);
|
public static bool IsOnQuantumMoon(this AudioSignal signal) => _qmSignals.Contains(signal);
|
||||||
|
|
||||||
public static SignalFrequency AddFrequency(string str)
|
public static SignalFrequency AddFrequency(string str)
|
||||||
{
|
{
|
||||||
if (_customFrequencyNames == null) Init();
|
|
||||||
|
|
||||||
var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
|
var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
|
||||||
if (freq != default) return freq;
|
if (freq != default) return freq;
|
||||||
|
|
||||||
@ -99,23 +114,19 @@ namespace NewHorizons.Builder.Props.Audio
|
|||||||
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
||||||
|
|
||||||
// This stuff happens after the signalscope is Awake so we have to change the number of frequencies now
|
// This stuff happens after the signalscope is Awake so we have to change the number of frequencies now
|
||||||
Object.FindObjectOfType<Signalscope>()._strongestSignals = new AudioSignal[NumberOfFrequencies + 1];
|
GameObject.FindObjectOfType<Signalscope>()._strongestSignals = new AudioSignal[NumberOfFrequencies + 1];
|
||||||
|
|
||||||
return freq;
|
return freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCustomFrequencyName(SignalFrequency frequencyName)
|
public static string GetCustomFrequencyName(SignalFrequency frequencyName)
|
||||||
{
|
{
|
||||||
if (_customFrequencyNames == null) Init();
|
|
||||||
|
|
||||||
_customFrequencyNames.TryGetValue(frequencyName, out string name);
|
_customFrequencyNames.TryGetValue(frequencyName, out string name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SignalName AddSignalName(string str)
|
public static SignalName AddSignalName(string str)
|
||||||
{
|
{
|
||||||
if (_customSignalNames == null) Init();
|
|
||||||
|
|
||||||
var name = CollectionUtilities.KeyByValue(_customSignalNames, str);
|
var name = CollectionUtilities.KeyByValue(_customSignalNames, str);
|
||||||
if (name != default) return name;
|
if (name != default) return name;
|
||||||
|
|
||||||
@ -129,8 +140,6 @@ namespace NewHorizons.Builder.Props.Audio
|
|||||||
|
|
||||||
public static string GetCustomSignalName(SignalName signalName)
|
public static string GetCustomSignalName(SignalName signalName)
|
||||||
{
|
{
|
||||||
if (_customSignalNames == null) Init();
|
|
||||||
|
|
||||||
_customSignalNames.TryGetValue(signalName, out string name);
|
_customSignalNames.TryGetValue(signalName, out string name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -148,6 +148,7 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
|
|
||||||
astroObject._imageObj = CreateImage(gameObject, image, body.Config.name + " Revealed", layer);
|
astroObject._imageObj = CreateImage(gameObject, image, body.Config.name + " Revealed", layer);
|
||||||
astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.name + " Outline", layer);
|
astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.name + " Outline", layer);
|
||||||
|
|
||||||
if (ShipLogHandler.BodyHasEntries(body))
|
if (ShipLogHandler.BodyHasEntries(body))
|
||||||
{
|
{
|
||||||
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
|
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
|
||||||
@ -162,6 +163,12 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
|
|
||||||
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
|
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
|
||||||
astroObject._unviewedObj.transform.localPosition = new Vector3(imageRect.width / 2 + unviewedIconOffset, imageRect.height / 2 + unviewedIconOffset, 0);
|
astroObject._unviewedObj.transform.localPosition = new Vector3(imageRect.width / 2 + unviewedIconOffset, imageRect.height / 2 + unviewedIconOffset, 0);
|
||||||
|
|
||||||
|
// Set all icons inactive, they will be conditionally activated when the map mode is opened for the first time
|
||||||
|
astroObject._unviewedObj.SetActive(false);
|
||||||
|
astroObject._imageObj.SetActive(false);
|
||||||
|
astroObject._outlineObj.SetActive(false);
|
||||||
|
|
||||||
return astroObject;
|
return astroObject;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
11
NewHorizons/External/NewHorizonsData.cs
vendored
11
NewHorizons/External/NewHorizonsData.cs
vendored
@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NewHorizons.Builder.Props.Audio;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
|
|
||||||
namespace NewHorizons.External
|
namespace NewHorizons.External
|
||||||
@ -124,7 +126,6 @@ namespace NewHorizons.External
|
|||||||
if (!KnowsFrequency(frequency))
|
if (!KnowsFrequency(frequency))
|
||||||
{
|
{
|
||||||
_activeProfile.KnownFrequencies.Add(frequency);
|
_activeProfile.KnownFrequencies.Add(frequency);
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,13 +135,12 @@ namespace NewHorizons.External
|
|||||||
if (KnowsFrequency(frequency))
|
if (KnowsFrequency(frequency))
|
||||||
{
|
{
|
||||||
_activeProfile.KnownFrequencies.Remove(frequency);
|
_activeProfile.KnownFrequencies.Remove(frequency);
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool KnowsMultipleFrequencies()
|
public static bool KnowsMultipleFrequencies()
|
||||||
{
|
{
|
||||||
return _activeProfile != null && _activeProfile.KnownFrequencies.Count > 0;
|
return _activeProfile?.KnownFrequencies != null && _activeProfile.KnownFrequencies.Count(SignalBuilder.IsFrequencyInUse) > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -159,7 +159,6 @@ namespace NewHorizons.External
|
|||||||
if (!KnowsSignal(signal))
|
if (!KnowsSignal(signal))
|
||||||
{
|
{
|
||||||
_activeProfile.KnownSignals.Add(signal);
|
_activeProfile.KnownSignals.Add(signal);
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +169,6 @@ namespace NewHorizons.External
|
|||||||
public static void AddNewlyRevealedFactID(string id)
|
public static void AddNewlyRevealedFactID(string id)
|
||||||
{
|
{
|
||||||
_activeProfile?.NewlyRevealedFactIDs.Add(id);
|
_activeProfile?.NewlyRevealedFactIDs.Add(id);
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> GetNewlyRevealedFactIDs()
|
public static List<string> GetNewlyRevealedFactIDs()
|
||||||
@ -181,7 +179,6 @@ namespace NewHorizons.External
|
|||||||
public static void ClearNewlyRevealedFactIDs()
|
public static void ClearNewlyRevealedFactIDs()
|
||||||
{
|
{
|
||||||
_activeProfile?.NewlyRevealedFactIDs.Clear();
|
_activeProfile?.NewlyRevealedFactIDs.Clear();
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -191,7 +188,6 @@ namespace NewHorizons.External
|
|||||||
public static void ReadOneTimePopup(string id)
|
public static void ReadOneTimePopup(string id)
|
||||||
{
|
{
|
||||||
_activeProfile?.PopupsRead.Add(id);
|
_activeProfile?.PopupsRead.Add(id);
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HasReadOneTimePopup(string id)
|
public static bool HasReadOneTimePopup(string id)
|
||||||
@ -208,7 +204,6 @@ namespace NewHorizons.External
|
|||||||
{
|
{
|
||||||
if (name == CharacterDialogueTree.RECORDING_NAME || name == CharacterDialogueTree.SIGN_NAME) return;
|
if (name == CharacterDialogueTree.RECORDING_NAME || name == CharacterDialogueTree.SIGN_NAME) return;
|
||||||
_activeProfile?.CharactersTalkedTo.SafeAdd(name);
|
_activeProfile?.CharactersTalkedTo.SafeAdd(name);
|
||||||
Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HasTalkedToFiveCharacters()
|
public static bool HasTalkedToFiveCharacters()
|
||||||
|
|||||||
@ -115,6 +115,17 @@ namespace NewHorizons.Handlers
|
|||||||
}
|
}
|
||||||
// For some reason none of this seems to apply to the Player.
|
// For some reason none of this seems to apply to the Player.
|
||||||
// If somebody ever makes a sound volume thats somehow always applying to the player tho then itd probably be this
|
// If somebody ever makes a sound volume thats somehow always applying to the player tho then itd probably be this
|
||||||
|
|
||||||
|
// Sometimes the ship isn't added to the volumes it's meant to now be in
|
||||||
|
foreach (var volume in SpawnPointBuilder.ShipSpawn.GetAttachedOWRigidbody().GetComponentsInChildren<EffectVolume>())
|
||||||
|
{
|
||||||
|
if (volume.GetOWTriggerVolume().GetPenetrationDistance(ship.transform.position) > 0)
|
||||||
|
{
|
||||||
|
// Add ship to volume
|
||||||
|
// If it's already tracking it it will complain here but thats fine
|
||||||
|
volume.GetOWTriggerVolume().AddObjectToVolume(Locator.GetShipDetector());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Main.Instance.CurrentStarSystem != "SolarSystem" && !Main.Instance.IsWarpingFromShip)
|
else if (Main.Instance.CurrentStarSystem != "SolarSystem" && !Main.Instance.IsWarpingFromShip)
|
||||||
|
|||||||
@ -85,12 +85,8 @@ namespace NewHorizons.Patches.PlayerPatches
|
|||||||
[HarmonyPatch(nameof(PlayerData.KnowsMultipleFrequencies))]
|
[HarmonyPatch(nameof(PlayerData.KnowsMultipleFrequencies))]
|
||||||
public static bool PlayerData_KnowsMultipleFrequencies(ref bool __result)
|
public static bool PlayerData_KnowsMultipleFrequencies(ref bool __result)
|
||||||
{
|
{
|
||||||
if (NewHorizonsData.KnowsMultipleFrequencies())
|
__result = NewHorizonsData.KnowsMultipleFrequencies();
|
||||||
{
|
return false;
|
||||||
__result = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
@ -140,5 +136,12 @@ namespace NewHorizons.Patches.PlayerPatches
|
|||||||
{
|
{
|
||||||
NewHorizonsData.Reset();
|
NewHorizonsData.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(nameof(PlayerData.SaveCurrentGame))]
|
||||||
|
public static void PlayerData_SaveCurrentGame()
|
||||||
|
{
|
||||||
|
NewHorizonsData.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,32 @@ namespace NewHorizons.Patches.ShipLogPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))]
|
||||||
|
public static bool ShipLogAstroObject_UpdateState_Pre(ShipLogAstroObject __instance)
|
||||||
|
{
|
||||||
|
// Custom astro objects might have no entries, in this case they will be permanently hidden
|
||||||
|
// Just treat it as if it were revealed
|
||||||
|
if (__instance._entries.Count == 0)
|
||||||
|
{
|
||||||
|
__instance._state = ShipLogEntry.State.Explored;
|
||||||
|
__instance._imageObj.SetActive(true);
|
||||||
|
__instance._outlineObj?.SetActive(false);
|
||||||
|
if (__instance._image != null)
|
||||||
|
{
|
||||||
|
__instance.SetMaterialGreyscale(false);
|
||||||
|
__instance._image.color = Color.white;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))]
|
[HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))]
|
||||||
public static void ShipLogAstroObject_UpdateState(ShipLogAstroObject __instance)
|
public static void ShipLogAstroObject_UpdateState_Post(ShipLogAstroObject __instance)
|
||||||
{
|
{
|
||||||
Transform detailsParent = __instance.transform.Find("Details");
|
Transform detailsParent = __instance.transform.Find("Details");
|
||||||
if (detailsParent != null)
|
if (detailsParent != null)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using NewHorizons.Builder.Props.Audio;
|
using NewHorizons.Builder.Props.Audio;
|
||||||
|
using NewHorizons.Utility.OWML;
|
||||||
|
|
||||||
namespace NewHorizons.Patches.SignalPatches
|
namespace NewHorizons.Patches.SignalPatches
|
||||||
{
|
{
|
||||||
@ -19,13 +20,17 @@ namespace NewHorizons.Patches.SignalPatches
|
|||||||
{
|
{
|
||||||
var count = SignalBuilder.NumberOfFrequencies;
|
var count = SignalBuilder.NumberOfFrequencies;
|
||||||
__instance._frequencyFilterIndex += increment;
|
__instance._frequencyFilterIndex += increment;
|
||||||
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 0 : __instance._frequencyFilterIndex;
|
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 1 : __instance._frequencyFilterIndex;
|
||||||
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex < 0 ? count - 1 : __instance._frequencyFilterIndex;
|
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex < 1 ? count - 1 : __instance._frequencyFilterIndex;
|
||||||
var signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex);
|
var signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex);
|
||||||
|
|
||||||
|
NHLogger.Log($"Changed freq to {signalFrequency} at {__instance._frequencyFilterIndex}");
|
||||||
|
|
||||||
// Skip over this frequency
|
// Skip over this frequency
|
||||||
var isUnknown = !PlayerData.KnowsFrequency(signalFrequency) && !(__instance._isUnknownFreqNearby && __instance._unknownFrequency == signalFrequency);
|
// Never skip traveler (always known)
|
||||||
if (isUnknown || !SignalBuilder.IsFrequencyInUse(signalFrequency))
|
var isTraveler = __instance._frequencyFilterIndex == 1;
|
||||||
|
var isUnknown = !PlayerData.KnowsFrequency(signalFrequency) && (!__instance._isUnknownFreqNearby || __instance._unknownFrequency != signalFrequency);
|
||||||
|
if (!isTraveler && (isUnknown || !SignalBuilder.IsFrequencyInUse(signalFrequency)))
|
||||||
{
|
{
|
||||||
__instance.SwitchFrequencyFilter(increment);
|
__instance.SwitchFrequencyFilter(increment);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user