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 NewHorizons.External;
|
||||
using NewHorizons.External.Modules.Props.Audio;
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.Utility.OWML;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
@ -43,20 +45,9 @@ namespace NewHorizons.Builder.Props.Audio
|
||||
|
||||
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
|
||||
var starSystem = Main.Instance.CurrentStarSystem;
|
||||
if (starSystem == "SolarSystem" || starSystem == "EyeOfTheUniverse")
|
||||
{
|
||||
_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
|
||||
_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())}");
|
||||
}
|
||||
|
||||
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(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 IsOnQuantumMoon(this AudioSignal signal) => _qmSignals.Contains(signal);
|
||||
|
||||
public static SignalFrequency AddFrequency(string str)
|
||||
{
|
||||
if (_customFrequencyNames == null) Init();
|
||||
|
||||
var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
|
||||
if (freq != default) return freq;
|
||||
|
||||
@ -99,23 +114,19 @@ namespace NewHorizons.Builder.Props.Audio
|
||||
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
public static string GetCustomFrequencyName(SignalFrequency frequencyName)
|
||||
{
|
||||
if (_customFrequencyNames == null) Init();
|
||||
|
||||
_customFrequencyNames.TryGetValue(frequencyName, out string name);
|
||||
return name;
|
||||
}
|
||||
|
||||
public static SignalName AddSignalName(string str)
|
||||
{
|
||||
if (_customSignalNames == null) Init();
|
||||
|
||||
var name = CollectionUtilities.KeyByValue(_customSignalNames, str);
|
||||
if (name != default) return name;
|
||||
|
||||
@ -129,8 +140,6 @@ namespace NewHorizons.Builder.Props.Audio
|
||||
|
||||
public static string GetCustomSignalName(SignalName signalName)
|
||||
{
|
||||
if (_customSignalNames == null) Init();
|
||||
|
||||
_customSignalNames.TryGetValue(signalName, out string name);
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -148,6 +148,7 @@ namespace NewHorizons.Builder.ShipLog
|
||||
|
||||
astroObject._imageObj = CreateImage(gameObject, image, body.Config.name + " Revealed", layer);
|
||||
astroObject._outlineObj = CreateImage(gameObject, outline, body.Config.name + " Outline", layer);
|
||||
|
||||
if (ShipLogHandler.BodyHasEntries(body))
|
||||
{
|
||||
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
|
||||
@ -162,6 +163,12 @@ namespace NewHorizons.Builder.ShipLog
|
||||
|
||||
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
|
||||
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;
|
||||
}
|
||||
#endregion
|
||||
|
||||
11
NewHorizons/External/NewHorizonsData.cs
vendored
11
NewHorizons/External/NewHorizonsData.cs
vendored
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NewHorizons.Builder.Props.Audio;
|
||||
using NewHorizons.Utility.OWML;
|
||||
|
||||
namespace NewHorizons.External
|
||||
@ -124,7 +126,6 @@ namespace NewHorizons.External
|
||||
if (!KnowsFrequency(frequency))
|
||||
{
|
||||
_activeProfile.KnownFrequencies.Add(frequency);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,13 +135,12 @@ namespace NewHorizons.External
|
||||
if (KnowsFrequency(frequency))
|
||||
{
|
||||
_activeProfile.KnownFrequencies.Remove(frequency);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool KnowsMultipleFrequencies()
|
||||
{
|
||||
return _activeProfile != null && _activeProfile.KnownFrequencies.Count > 0;
|
||||
return _activeProfile?.KnownFrequencies != null && _activeProfile.KnownFrequencies.Count(SignalBuilder.IsFrequencyInUse) > 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -159,7 +159,6 @@ namespace NewHorizons.External
|
||||
if (!KnowsSignal(signal))
|
||||
{
|
||||
_activeProfile.KnownSignals.Add(signal);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +169,6 @@ namespace NewHorizons.External
|
||||
public static void AddNewlyRevealedFactID(string id)
|
||||
{
|
||||
_activeProfile?.NewlyRevealedFactIDs.Add(id);
|
||||
Save();
|
||||
}
|
||||
|
||||
public static List<string> GetNewlyRevealedFactIDs()
|
||||
@ -181,7 +179,6 @@ namespace NewHorizons.External
|
||||
public static void ClearNewlyRevealedFactIDs()
|
||||
{
|
||||
_activeProfile?.NewlyRevealedFactIDs.Clear();
|
||||
Save();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -191,7 +188,6 @@ namespace NewHorizons.External
|
||||
public static void ReadOneTimePopup(string id)
|
||||
{
|
||||
_activeProfile?.PopupsRead.Add(id);
|
||||
Save();
|
||||
}
|
||||
|
||||
public static bool HasReadOneTimePopup(string id)
|
||||
@ -208,7 +204,6 @@ namespace NewHorizons.External
|
||||
{
|
||||
if (name == CharacterDialogueTree.RECORDING_NAME || name == CharacterDialogueTree.SIGN_NAME) return;
|
||||
_activeProfile?.CharactersTalkedTo.SafeAdd(name);
|
||||
Save();
|
||||
}
|
||||
|
||||
public static bool HasTalkedToFiveCharacters()
|
||||
|
||||
@ -115,6 +115,17 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
// 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
|
||||
|
||||
// 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)
|
||||
|
||||
@ -85,13 +85,9 @@ namespace NewHorizons.Patches.PlayerPatches
|
||||
[HarmonyPatch(nameof(PlayerData.KnowsMultipleFrequencies))]
|
||||
public static bool PlayerData_KnowsMultipleFrequencies(ref bool __result)
|
||||
{
|
||||
if (NewHorizonsData.KnowsMultipleFrequencies())
|
||||
{
|
||||
__result = true;
|
||||
__result = NewHorizonsData.KnowsMultipleFrequencies();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(PlayerData.AddNewlyRevealedFactID))]
|
||||
@ -140,5 +136,12 @@ namespace NewHorizons.Patches.PlayerPatches
|
||||
{
|
||||
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]
|
||||
[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");
|
||||
if (detailsParent != null)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Builder.Props.Audio;
|
||||
using NewHorizons.Utility.OWML;
|
||||
|
||||
namespace NewHorizons.Patches.SignalPatches
|
||||
{
|
||||
@ -19,13 +20,17 @@ namespace NewHorizons.Patches.SignalPatches
|
||||
{
|
||||
var count = SignalBuilder.NumberOfFrequencies;
|
||||
__instance._frequencyFilterIndex += increment;
|
||||
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 0 : __instance._frequencyFilterIndex;
|
||||
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex < 0 ? count - 1 : __instance._frequencyFilterIndex;
|
||||
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 1 : __instance._frequencyFilterIndex;
|
||||
__instance._frequencyFilterIndex = __instance._frequencyFilterIndex < 1 ? count - 1 : __instance._frequencyFilterIndex;
|
||||
var signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex);
|
||||
|
||||
NHLogger.Log($"Changed freq to {signalFrequency} at {__instance._frequencyFilterIndex}");
|
||||
|
||||
// Skip over this frequency
|
||||
var isUnknown = !PlayerData.KnowsFrequency(signalFrequency) && !(__instance._isUnknownFreqNearby && __instance._unknownFrequency == signalFrequency);
|
||||
if (isUnknown || !SignalBuilder.IsFrequencyInUse(signalFrequency))
|
||||
// Never skip traveler (always known)
|
||||
var isTraveler = __instance._frequencyFilterIndex == 1;
|
||||
var isUnknown = !PlayerData.KnowsFrequency(signalFrequency) && (!__instance._isUnknownFreqNearby || __instance._unknownFrequency != signalFrequency);
|
||||
if (!isTraveler && (isUnknown || !SignalBuilder.IsFrequencyInUse(signalFrequency)))
|
||||
{
|
||||
__instance.SwitchFrequencyFilter(increment);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user