mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Finished custom signals + custom save data
This commit is contained in:
parent
4a912056c5
commit
11652e8939
@ -1,6 +1,7 @@
|
|||||||
using NewHorizons.External;
|
using NewHorizons.External;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
@ -35,7 +36,13 @@ namespace NewHorizons.Builder.General
|
|||||||
|
|
||||||
GravityVolume GV = gravityGO.AddComponent<GravityVolume>();
|
GravityVolume GV = gravityGO.AddComponent<GravityVolume>();
|
||||||
GV.SetValue("_cutoffAcceleration", 0.1f);
|
GV.SetValue("_cutoffAcceleration", 0.1f);
|
||||||
GV.SetValue("_falloffType", GV.GetType().GetNestedType("FalloffType", BindingFlags.NonPublic).GetField(config.Base.GravityFallOff).GetValue(GV));
|
|
||||||
|
GravityVolume.FalloffType falloff = GravityVolume.FalloffType.linear;
|
||||||
|
if (config.Base.GravityFallOff.ToUpper().Equals("LINEAR")) falloff = GravityVolume.FalloffType.linear;
|
||||||
|
else if (config.Base.GravityFallOff.ToUpper().Equals("INVERSESQUARED")) falloff = GravityVolume.FalloffType.inverseSquared;
|
||||||
|
else Logger.LogError($"Couldn't set gravity type {config.Base.GravityFallOff}. Must be either \"linear\" or \"inverseSquared\". Defaulting to linear.");
|
||||||
|
GV._falloffType = falloff;
|
||||||
|
|
||||||
GV.SetValue("_alignmentRadius", config.Base.SurfaceGravity != 0 ? 1.5f * config.Base.SurfaceSize : 0f);
|
GV.SetValue("_alignmentRadius", config.Base.SurfaceGravity != 0 ? 1.5f * config.Base.SurfaceSize : 0f);
|
||||||
GV.SetValue("_upperSurfaceRadius", config.Base.SurfaceSize);
|
GV.SetValue("_upperSurfaceRadius", config.Base.SurfaceSize);
|
||||||
GV.SetValue("_lowerSurfaceRadius", 0);
|
GV.SetValue("_lowerSurfaceRadius", 0);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.External;
|
using NewHorizons.Components;
|
||||||
|
using NewHorizons.External;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -15,41 +16,55 @@ namespace NewHorizons.Builder.Props
|
|||||||
private static AnimationCurve _customCurve = null;
|
private static AnimationCurve _customCurve = null;
|
||||||
|
|
||||||
private static Dictionary<SignalName, string> _customSignalNames;
|
private static Dictionary<SignalName, string> _customSignalNames;
|
||||||
private static Stack<int> _availableSignalNames;
|
private static Stack<SignalName> _availableSignalNames;
|
||||||
|
|
||||||
// TODO : Save and load this from/to a file
|
public static Dictionary<SignalFrequency, string> SignalFrequencyOverrides;
|
||||||
public static List<string> KnownSignals { get; private set; } = new List<string>();
|
|
||||||
|
|
||||||
public static void Reset()
|
public static void Reset()
|
||||||
{
|
{
|
||||||
_customSignalNames = new Dictionary<SignalName, string>();
|
_customSignalNames = new Dictionary<SignalName, string>();
|
||||||
_availableSignalNames = new Stack<int> (new int[]
|
_availableSignalNames = new Stack<SignalName> (new SignalName[]
|
||||||
{
|
{
|
||||||
17,
|
(SignalName)17,
|
||||||
18,
|
(SignalName)18,
|
||||||
19,
|
(SignalName)19,
|
||||||
26,
|
(SignalName)26,
|
||||||
27,
|
(SignalName)27,
|
||||||
28,
|
(SignalName)28,
|
||||||
29,
|
(SignalName)29,
|
||||||
33,
|
(SignalName)33,
|
||||||
34,
|
(SignalName)34,
|
||||||
35,
|
(SignalName)35,
|
||||||
36,
|
(SignalName)36,
|
||||||
37,
|
(SignalName)37,
|
||||||
38,
|
(SignalName)38,
|
||||||
39,
|
(SignalName)39,
|
||||||
50,
|
(SignalName)50,
|
||||||
51,
|
(SignalName)51,
|
||||||
52,
|
(SignalName)52,
|
||||||
53,
|
(SignalName)53,
|
||||||
54,
|
(SignalName)54,
|
||||||
55,
|
(SignalName)55,
|
||||||
56,
|
(SignalName)56,
|
||||||
57,
|
(SignalName)57,
|
||||||
58,
|
(SignalName)58,
|
||||||
59
|
(SignalName)59,
|
||||||
|
SignalName.WhiteHole_WH,
|
||||||
|
SignalName.WhiteHole_SS_Receiver,
|
||||||
|
SignalName.WhiteHole_CT_Receiver,
|
||||||
|
SignalName.WhiteHole_CT_Experiment,
|
||||||
|
SignalName.WhiteHole_TT_Receiver,
|
||||||
|
SignalName.WhiteHole_TT_TimeLoopCore,
|
||||||
|
SignalName.WhiteHole_TH_Receiver,
|
||||||
|
SignalName.WhiteHole_BH_NorthPoleReceiver,
|
||||||
|
SignalName.WhiteHole_BH_ForgeReceiver,
|
||||||
|
SignalName.WhiteHole_GD_Receiver,
|
||||||
});
|
});
|
||||||
|
SignalFrequencyOverrides = new Dictionary<SignalFrequency, string>() {
|
||||||
|
{ SignalFrequency.Statue, "NOMAI STATUE" },
|
||||||
|
{ SignalFrequency.Default, "???" },
|
||||||
|
{ SignalFrequency.WarpCore, "ANTI-MASS FLUCTUATIONS" }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SignalName AddSignalName(string str)
|
public static SignalName AddSignalName(string str)
|
||||||
@ -61,15 +76,16 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.Log($"Registering new signal name [{str}]");
|
Logger.Log($"Registering new signal name [{str}]");
|
||||||
var newName = (SignalName)_availableSignalNames.Pop();
|
var newName = _availableSignalNames.Pop();
|
||||||
_customSignalNames.Add(newName, str.ToUpper());
|
_customSignalNames.Add(newName, str.ToUpper());
|
||||||
return newName;
|
return newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetCustomSignalName(SignalName signalName)
|
public static string GetCustomSignalName(SignalName signalName)
|
||||||
{
|
{
|
||||||
if (_customSignalNames.ContainsKey(signalName)) return _customSignalNames[signalName];
|
string name = null;
|
||||||
return null;
|
_customSignalNames.TryGetValue(signalName, out name);
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject body, Sector sector, SignalModule module)
|
public static void Make(GameObject body, Sector sector, SignalModule module)
|
||||||
@ -84,12 +100,16 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
var signalGO = new GameObject($"Signal_{info.Name}");
|
var signalGO = new GameObject($"Signal_{info.Name}");
|
||||||
signalGO.SetActive(false);
|
signalGO.SetActive(false);
|
||||||
signalGO.transform.parent = sector.transform;
|
signalGO.transform.parent = body.transform;
|
||||||
signalGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
|
signalGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
|
||||||
|
signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||||
|
|
||||||
var source = signalGO.AddComponent<AudioSource>();
|
var source = signalGO.AddComponent<AudioSource>();
|
||||||
var owAudioSource = signalGO.AddComponent<OWAudioSource>();
|
var owAudioSource = signalGO.AddComponent<OWAudioSource>();
|
||||||
var audioSignal = signalGO.AddComponent<AudioSignal>();
|
|
||||||
|
AudioSignal audioSignal = null;
|
||||||
|
if (info.InsideCloak) audioSignal = signalGO.AddComponent<CloakedAudioSignal>();
|
||||||
|
else audioSignal = signalGO.AddComponent<AudioSignal>();
|
||||||
|
|
||||||
var frequency = StringToFrequency(info.Frequency);
|
var frequency = StringToFrequency(info.Frequency);
|
||||||
var name = StringToSignalName(info.Name);
|
var name = StringToSignalName(info.Name);
|
||||||
@ -107,6 +127,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
audioSignal._name = name;
|
audioSignal._name = name;
|
||||||
audioSignal._sourceRadius = info.SourceRadius;
|
audioSignal._sourceRadius = info.SourceRadius;
|
||||||
audioSignal._onlyAudibleToScope = info.OnlyAudibleToScope;
|
audioSignal._onlyAudibleToScope = info.OnlyAudibleToScope;
|
||||||
|
audioSignal._identificationDistance = info.IdentificationRadius;
|
||||||
|
|
||||||
source.clip = clip;
|
source.clip = clip;
|
||||||
source.loop = true;
|
source.loop = true;
|
||||||
@ -122,10 +143,28 @@ namespace NewHorizons.Builder.Props
|
|||||||
source.playOnAwake = false;
|
source.playOnAwake = false;
|
||||||
source.spatialBlend = 1f;
|
source.spatialBlend = 1f;
|
||||||
source.volume = 0.5f;
|
source.volume = 0.5f;
|
||||||
|
source.dopplerLevel = 0;
|
||||||
|
|
||||||
owAudioSource.SetTrack(OWAudioMixer.TrackName.Signal);
|
owAudioSource.SetTrack(OWAudioMixer.TrackName.Signal);
|
||||||
|
|
||||||
|
// Frequency detection trigger volume
|
||||||
|
|
||||||
|
var signalDetectionGO = new GameObject($"SignalDetectionTrigger_{info.Name}");
|
||||||
|
signalDetectionGO.SetActive(false);
|
||||||
|
signalDetectionGO.transform.parent = body.transform;
|
||||||
|
signalDetectionGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
|
||||||
|
signalDetectionGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||||
|
|
||||||
|
var sphereShape = signalDetectionGO.AddComponent<SphereShape>();
|
||||||
|
var owTriggerVolume = signalDetectionGO.AddComponent<OWTriggerVolume>();
|
||||||
|
var audioSignalDetectionTrigger = signalDetectionGO.AddComponent<AudioSignalDetectionTrigger>();
|
||||||
|
|
||||||
|
sphereShape.radius = info.DetectionRadius == 0 ? info.SourceRadius + 30 : info.DetectionRadius;
|
||||||
|
audioSignalDetectionTrigger._signal = audioSignal;
|
||||||
|
audioSignalDetectionTrigger._trigger = owTriggerVolume;
|
||||||
|
|
||||||
signalGO.SetActive(true);
|
signalGO.SetActive(true);
|
||||||
|
signalDetectionGO.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SignalFrequency StringToFrequency(string str)
|
private static SignalFrequency StringToFrequency(string str)
|
||||||
|
|||||||
78
NewHorizons/Components/CloakedAudioSignal.cs
Normal file
78
NewHorizons/Components/CloakedAudioSignal.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Components
|
||||||
|
{
|
||||||
|
public class CloakedAudioSignal : AudioSignal
|
||||||
|
{
|
||||||
|
public new void UpdateSignalStrength(Signalscope scope, float distToClosestScopeObstruction)
|
||||||
|
{
|
||||||
|
this._canBePickedUpByScope = false;
|
||||||
|
if (!PlayerState.InCloakingField())
|
||||||
|
{
|
||||||
|
this._signalStrength = 0f;
|
||||||
|
this._degreesFromScope = 180f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this._sunController != null && this._sunController.IsPointInsideSupernova(base.transform.position))
|
||||||
|
{
|
||||||
|
this._signalStrength = 0f;
|
||||||
|
this._degreesFromScope = 180f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Locator.GetQuantumMoon() != null && Locator.GetQuantumMoon().IsPlayerInside() && this._name != SignalName.Quantum_QM)
|
||||||
|
{
|
||||||
|
this._signalStrength = 0f;
|
||||||
|
this._degreesFromScope = 180f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this._active || !base.gameObject.activeInHierarchy || this._outerFogWarpVolume != PlayerState.GetOuterFogWarpVolume() || (scope.GetFrequencyFilter() & this._frequency) != this._frequency)
|
||||||
|
{
|
||||||
|
this._signalStrength = 0f;
|
||||||
|
this._degreesFromScope = 180f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._scopeToSignal = base.transform.position - scope.transform.position;
|
||||||
|
this._distToScope = this._scopeToSignal.magnitude;
|
||||||
|
if (this._outerFogWarpVolume == null && distToClosestScopeObstruction < 1000f && this._distToScope > 1000f)
|
||||||
|
{
|
||||||
|
this._signalStrength = 0f;
|
||||||
|
this._degreesFromScope = 180f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._canBePickedUpByScope = true;
|
||||||
|
if (this._distToScope < this._sourceRadius)
|
||||||
|
{
|
||||||
|
this._signalStrength = 1f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._degreesFromScope = Vector3.Angle(scope.GetScopeDirection(), this._scopeToSignal);
|
||||||
|
float t = Mathf.InverseLerp(2000f, 1000f, this._distToScope);
|
||||||
|
float a = Mathf.Lerp(45f, 90f, t);
|
||||||
|
float a2 = 57.29578f * Mathf.Atan2(this._sourceRadius, this._distToScope);
|
||||||
|
float b = Mathf.Lerp(Mathf.Max(a2, 5f), Mathf.Max(a2, 1f), scope.GetZoomFraction());
|
||||||
|
this._signalStrength = Mathf.Clamp01(Mathf.InverseLerp(a, b, this._degreesFromScope));
|
||||||
|
}
|
||||||
|
if (this._distToScope < this._identificationDistance + this._sourceRadius && this._signalStrength > 0.9f)
|
||||||
|
{
|
||||||
|
if (!PlayerData.KnowsFrequency(this._frequency) && !this._preventIdentification)
|
||||||
|
{
|
||||||
|
this.IdentifyFrequency();
|
||||||
|
}
|
||||||
|
if (!PlayerData.KnowsSignal(this._name) && !this._preventIdentification)
|
||||||
|
{
|
||||||
|
this.IdentifySignal();
|
||||||
|
}
|
||||||
|
if (this._revealFactID.Length > 0)
|
||||||
|
{
|
||||||
|
Locator.GetShipLogManager().RevealFact(this._revealFactID, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
116
NewHorizons/External/NewHorizonsData.cs
vendored
Normal file
116
NewHorizons/External/NewHorizonsData.cs
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
|
namespace NewHorizons.External
|
||||||
|
{
|
||||||
|
public static class NewHorizonsData
|
||||||
|
{
|
||||||
|
private static NewHorizonsSaveFile _saveFile;
|
||||||
|
private static NewHorizonsProfile _activeProfile;
|
||||||
|
private static string _fileName = "save.json";
|
||||||
|
|
||||||
|
public static void Load()
|
||||||
|
{
|
||||||
|
var profileName = StandaloneProfileManager.SharedInstance.currentProfile.profileName;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_saveFile = Main.Instance.ModHelper.Storage.Load<NewHorizonsSaveFile>(_fileName);
|
||||||
|
if (!_saveFile.Profiles.ContainsKey(profileName)) _saveFile.Profiles.Add(profileName, new NewHorizonsProfile());
|
||||||
|
_activeProfile = _saveFile.Profiles[profileName];
|
||||||
|
Logger.Log($"Loaded save data for {profileName}");
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Logger.Log($"Couldn't load save data from {_fileName}, creating a new file");
|
||||||
|
_saveFile = new NewHorizonsSaveFile();
|
||||||
|
_saveFile.Profiles.Add(profileName, new NewHorizonsProfile());
|
||||||
|
_activeProfile = _saveFile.Profiles[profileName];
|
||||||
|
Main.Instance.ModHelper.Storage.Save(_saveFile, _fileName);
|
||||||
|
Logger.Log($"Loaded save data for {profileName}");
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't create save data {e.Message}, {e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Save()
|
||||||
|
{
|
||||||
|
if (_saveFile == null) return;
|
||||||
|
Main.Instance.ModHelper.Storage.Save(_saveFile, _fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Reset()
|
||||||
|
{
|
||||||
|
if (_saveFile == null || _activeProfile == null) return;
|
||||||
|
_activeProfile = new NewHorizonsProfile();
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool KnowsFrequency(string frequency)
|
||||||
|
{
|
||||||
|
if (_activeProfile == null) return true;
|
||||||
|
return _activeProfile.KnownFrequencies.Contains(frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LearnFrequency(string frequency)
|
||||||
|
{
|
||||||
|
if (_activeProfile == null) return;
|
||||||
|
if (!KnowsFrequency(frequency))
|
||||||
|
{
|
||||||
|
_activeProfile.KnownFrequencies.Add(frequency);
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool KnowsSignal(string signal)
|
||||||
|
{
|
||||||
|
if (_activeProfile == null) return true;
|
||||||
|
return _activeProfile.KnownSignals.Contains(signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LearnSignal(string signal)
|
||||||
|
{
|
||||||
|
if (_activeProfile == null) return;
|
||||||
|
if (!KnowsSignal(signal))
|
||||||
|
{
|
||||||
|
_activeProfile.KnownSignals.Add(signal);
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool KnowsMultipleFrequencies()
|
||||||
|
{
|
||||||
|
return (_activeProfile != null && _activeProfile.KnownFrequencies.Count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NewHorizonsSaveFile
|
||||||
|
{
|
||||||
|
public NewHorizonsSaveFile()
|
||||||
|
{
|
||||||
|
Profiles = new Dictionary<string, NewHorizonsProfile>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, NewHorizonsProfile> Profiles { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NewHorizonsProfile
|
||||||
|
{
|
||||||
|
public NewHorizonsProfile()
|
||||||
|
{
|
||||||
|
KnownFrequencies = new List<string>();
|
||||||
|
KnownSignals = new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> KnownFrequencies { get; set; }
|
||||||
|
public List<string> KnownSignals { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
NewHorizons/External/SignalModule.cs
vendored
3
NewHorizons/External/SignalModule.cs
vendored
@ -18,7 +18,10 @@ namespace NewHorizons.External
|
|||||||
public string Name;
|
public string Name;
|
||||||
public string AudioClip;
|
public string AudioClip;
|
||||||
public float SourceRadius = 1f;
|
public float SourceRadius = 1f;
|
||||||
|
public float DetectionRadius = 0f;
|
||||||
|
public float IdentificationRadius = 10f;
|
||||||
public bool OnlyAudibleToScope = true;
|
public bool OnlyAudibleToScope = true;
|
||||||
|
public bool InsideCloak = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,8 @@ namespace NewHorizons
|
|||||||
|
|
||||||
if (scene.name != "SolarSystem") { return; }
|
if (scene.name != "SolarSystem") { return; }
|
||||||
|
|
||||||
|
NewHorizonsData.Load();
|
||||||
|
|
||||||
// Need to manage this when there are multiple stars
|
// Need to manage this when there are multiple stars
|
||||||
var sun = GameObject.Find("Sun_Body");
|
var sun = GameObject.Find("Sun_Body");
|
||||||
var starController = sun.AddComponent<StarController>();
|
var starController = sun.AddComponent<StarController>();
|
||||||
@ -162,10 +164,12 @@ namespace NewHorizons
|
|||||||
|
|
||||||
var map = GameObject.FindObjectOfType<MapController>();
|
var map = GameObject.FindObjectOfType<MapController>();
|
||||||
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
||||||
|
/*
|
||||||
foreach(var cam in GameObject.FindObjectsOfType<OWCamera>())
|
foreach(var cam in GameObject.FindObjectsOfType<OWCamera>())
|
||||||
{
|
{
|
||||||
cam.farClipPlane = FurthestOrbit * 3f;
|
cam.farClipPlane = FurthestOrbit * 3f;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
private bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||||
@ -177,15 +181,17 @@ namespace NewHorizons
|
|||||||
if (stringID.Equals("EMBER_TWIN")) stringID = "CAVE_TWIN";
|
if (stringID.Equals("EMBER_TWIN")) stringID = "CAVE_TWIN";
|
||||||
if (stringID.Equals("INTERLOPER")) stringID = "COMET";
|
if (stringID.Equals("INTERLOPER")) stringID = "COMET";
|
||||||
|
|
||||||
AstroObject existingPlanet = null;
|
GameObject existingPlanet = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
existingPlanet = AstroObjectLocator.GetAstroObject(stringID);
|
existingPlanet = AstroObjectLocator.GetAstroObject(stringID).gameObject;
|
||||||
if (existingPlanet == null) existingPlanet = AstroObjectLocator.GetAstroObject(body.Config.Name.Replace(" ", ""));
|
if (existingPlanet == null) existingPlanet = AstroObjectLocator.GetAstroObject(body.Config.Name.Replace(" ", "")).gameObject;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.LogWarning($"Error when looking for {body.Config.Name}: {e.Message}, {e.StackTrace}");
|
existingPlanet = GameObject.Find(body.Config.Name.Replace(" ", "") + "_Body");
|
||||||
|
|
||||||
|
if(existingPlanet == null) Logger.LogWarning($"Error when looking for {body.Config.Name}: {e.Message}, {e.StackTrace}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingPlanet != null)
|
if (existingPlanet != null)
|
||||||
@ -194,7 +200,9 @@ namespace NewHorizons
|
|||||||
{
|
{
|
||||||
if (body.Config.Destroy)
|
if (body.Config.Destroy)
|
||||||
{
|
{
|
||||||
Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestroyer.RemoveBody(existingPlanet), 2);
|
var ao = existingPlanet.GetComponent<AstroObject>();
|
||||||
|
if (ao != null) Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestroyer.RemoveBody(ao), 2);
|
||||||
|
else Instance.ModHelper.Events.Unity.FireInNUpdates(() => existingPlanet.SetActive(false), 2);
|
||||||
}
|
}
|
||||||
else UpdateBody(body, existingPlanet);
|
else UpdateBody(body, existingPlanet);
|
||||||
}
|
}
|
||||||
@ -239,17 +247,15 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject UpdateBody(NewHorizonsBody body, AstroObject ao)
|
public GameObject UpdateBody(NewHorizonsBody body, GameObject go)
|
||||||
{
|
{
|
||||||
Logger.Log($"Updating existing AstroObject {ao}");
|
Logger.Log($"Updating existing Object {go.name}");
|
||||||
|
|
||||||
var go = ao.gameObject;
|
|
||||||
|
|
||||||
var sector = go.GetComponentInChildren<Sector>();
|
var sector = go.GetComponentInChildren<Sector>();
|
||||||
var rb = go.GetAttachedOWRigidbody();
|
var rb = go.GetAttachedOWRigidbody();
|
||||||
|
|
||||||
// Do stuff that's shared between generating new planets and updating old ones
|
// Do stuff that's shared between generating new planets and updating old ones
|
||||||
return SharedGenerateBody(body, go, sector, rb, ao);
|
return SharedGenerateBody(body, go, sector, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
public GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||||
@ -323,11 +329,8 @@ namespace NewHorizons
|
|||||||
if (body.Config.FocalPoint != null)
|
if (body.Config.FocalPoint != null)
|
||||||
FocalPointBuilder.Make(go, body.Config.FocalPoint);
|
FocalPointBuilder.Make(go, body.Config.FocalPoint);
|
||||||
|
|
||||||
if (body.Config.Signal != null)
|
|
||||||
SignalBuilder.Make(go, sector, body.Config.Signal);
|
|
||||||
|
|
||||||
// Do stuff that's shared between generating new planets and updating old ones
|
// Do stuff that's shared between generating new planets and updating old ones
|
||||||
go = SharedGenerateBody(body, go, sector, owRigidBody, ao);
|
go = SharedGenerateBody(body, go, sector, owRigidBody);
|
||||||
|
|
||||||
body.Object = go;
|
body.Object = go;
|
||||||
|
|
||||||
@ -359,7 +362,7 @@ namespace NewHorizons
|
|||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb, AstroObject ao)
|
private GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb)
|
||||||
{
|
{
|
||||||
if (body.Config.Ring != null)
|
if (body.Config.Ring != null)
|
||||||
RingBuilder.Make(go, body.Config.Ring, body.Assets);
|
RingBuilder.Make(go, body.Config.Ring, body.Assets);
|
||||||
@ -370,13 +373,10 @@ namespace NewHorizons
|
|||||||
if (body.Config.Base.HasCometTail)
|
if (body.Config.Base.HasCometTail)
|
||||||
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||||
|
|
||||||
if (body.Config.Base != null)
|
|
||||||
{
|
|
||||||
if (body.Config.Base.LavaSize != 0)
|
if (body.Config.Base.LavaSize != 0)
|
||||||
LavaBuilder.Make(go, sector, rb, body.Config.Base.LavaSize);
|
LavaBuilder.Make(go, sector, rb, body.Config.Base.LavaSize);
|
||||||
if (body.Config.Base.WaterSize != 0)
|
if (body.Config.Base.WaterSize != 0)
|
||||||
WaterBuilder.Make(go, sector, rb, body.Config.Base.WaterSize);
|
WaterBuilder.Make(go, sector, rb, body.Config.Base.WaterSize);
|
||||||
}
|
|
||||||
|
|
||||||
if (body.Config.Atmosphere != null)
|
if (body.Config.Atmosphere != null)
|
||||||
{
|
{
|
||||||
@ -398,18 +398,10 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (body.Config.Props != null)
|
if (body.Config.Props != null)
|
||||||
{
|
|
||||||
PropBuilder.Make(go, sector, body.Config);
|
PropBuilder.Make(go, sector, body.Config);
|
||||||
/*
|
|
||||||
if (body.Config.Props.Rafts != null)
|
if (body.Config.Signal != null)
|
||||||
{
|
SignalBuilder.Make(go, sector, body.Config.Signal);
|
||||||
foreach(var v in body.Config.Props.Rafts)
|
|
||||||
{
|
|
||||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => RaftBuilder.Make(go, v, sector, rb, ao));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,4 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="NewHorizons.csproj.user" />
|
<Content Include="NewHorizons.csproj.user" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Components\" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
@ -22,20 +22,6 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
if (Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame)
|
if (Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
var soundSources = GameObject.FindObjectsOfType<AudioSource>();
|
|
||||||
foreach(var s in soundSources)
|
|
||||||
{
|
|
||||||
if (s.isPlaying)
|
|
||||||
{
|
|
||||||
Logger.Log($"{s.name}, {s.gameObject.name}");
|
|
||||||
Logger.LogPath(s.gameObject);
|
|
||||||
s.loop = false;
|
|
||||||
s.Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Raycast
|
// Raycast
|
||||||
_rb.DisableCollisionDetection();
|
_rb.DisableCollisionDetection();
|
||||||
int layerMask = OWLayerMask.physicalMask;
|
int layerMask = OWLayerMask.physicalMask;
|
||||||
@ -43,7 +29,8 @@ namespace NewHorizons.Utility
|
|||||||
var direction = Locator.GetActiveCamera().transform.TransformDirection(Vector3.forward);
|
var direction = Locator.GetActiveCamera().transform.TransformDirection(Vector3.forward);
|
||||||
if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask))
|
if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask))
|
||||||
{
|
{
|
||||||
Logger.Log($"Raycast hit [{hitInfo.transform.InverseTransformPoint(hitInfo.point)}] on [{hitInfo.transform.gameObject.name}]");
|
var pos = hitInfo.transform.InverseTransformPoint(hitInfo.point);
|
||||||
|
Logger.Log($"Raycast hit {{\"x\": {pos.x}, \"y\": {pos.y}, \"z\": {pos.z}}} on [{hitInfo.transform.gameObject.name}]");
|
||||||
}
|
}
|
||||||
_rb.EnableCollisionDetection();
|
_rb.EnableCollisionDetection();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using NewHorizons.Builder.Props;
|
using NewHorizons.Builder.Props;
|
||||||
|
using NewHorizons.Components;
|
||||||
|
using NewHorizons.External;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,15 +20,28 @@ namespace NewHorizons.Utility
|
|||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<PlayerState>("CheckShipOutsideSolarSystem", typeof(Patches), nameof(Patches.CheckShipOutersideSolarSystem));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<PlayerState>("CheckShipOutsideSolarSystem", typeof(Patches), nameof(Patches.CheckShipOutersideSolarSystem));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SunLightParamUpdater>("LateUpdate", typeof(Patches), nameof(Patches.OnSunLightParamUpdaterLateUpdate));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SunLightParamUpdater>("LateUpdate", typeof(Patches), nameof(Patches.OnSunLightParamUpdaterLateUpdate));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SunSurfaceAudioController>("Update", typeof(Patches), nameof(Patches.OnSunSurfaceAudioControllerUpdate));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SunSurfaceAudioController>("Update", typeof(Patches), nameof(Patches.OnSunSurfaceAudioControllerUpdate));
|
||||||
|
|
||||||
|
// Lot of audio signal stuff
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<AudioSignal>("SignalNameToString", typeof(Patches), nameof(Patches.OnAudioSignalSignalNameToString));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<AudioSignal>("SignalNameToString", typeof(Patches), nameof(Patches.OnAudioSignalSignalNameToString));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<AudioSignal>("IndexToFrequency", typeof(Patches), nameof(Patches.OnAudioSignalIndexToFrequency));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<AudioSignal>("FrequencyToIndex", typeof(Patches), nameof(Patches.OnAudioSignalFrequencyToIndex));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<AudioSignal>("FrequencyToString", typeof(Patches), nameof(Patches.OnAudioSignalFrequencyToString));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<Signalscope>("Awake", typeof(Patches), nameof(Patches.OnSignalscopeAwake));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<Signalscope>("SwitchFrequencyFilter", typeof(Patches), nameof(Patches.OnSignalscopeSwitchFrequencyFilter));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<AudioSignal>("UpdateSignalStrength", typeof(Patches), nameof(Patches.OnAudioSignalUpdateSignalStrength));
|
||||||
|
|
||||||
var playerDataKnowsSignal = typeof(PlayerData).GetMethod("KnowsSignal");
|
var playerDataKnowsSignal = typeof(PlayerData).GetMethod("KnowsSignal");
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataKnowsSignal, typeof(Patches), nameof(Patches.OnPlayerDataKnowsSignal));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataKnowsSignal, typeof(Patches), nameof(Patches.OnPlayerDataKnowsSignal));
|
||||||
var playerDataLearnSignal = typeof(PlayerData).GetMethod("LearnSignal");
|
var playerDataLearnSignal = typeof(PlayerData).GetMethod("LearnSignal");
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataLearnSignal, typeof(Patches), nameof(Patches.OnPlayerDataLearnSignal));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataLearnSignal, typeof(Patches), nameof(Patches.OnPlayerDataLearnSignal));
|
||||||
|
var playerDataKnowsFrequency = typeof(PlayerData).GetMethod("KnowsFrequency");
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataKnowsFrequency, typeof(Patches), nameof(Patches.OnPlayerDataKnowsFrequency));
|
||||||
|
var playerDataLearnFrequency = typeof(PlayerData).GetMethod("LearnFrequency");
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataLearnFrequency, typeof(Patches), nameof(Patches.OnPlayerDataLearnFrequency));
|
||||||
|
var playerDataKnowsMultipleFrequencies = typeof(PlayerData).GetMethod("KnowsMultipleFrequencies");
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataKnowsMultipleFrequencies, typeof(Patches), nameof(Patches.OnPlayerDataKnowsMultipleFrequencies));
|
||||||
|
|
||||||
// Postfixes
|
// Postfixes
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<EllipticOrbitLine>("Start", typeof(Patches), nameof(Patches.OnEllipticOrbitLineStart));
|
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
||||||
}
|
}
|
||||||
@ -42,20 +57,12 @@ namespace NewHorizons.Utility
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CheckShipOutersideSolarSystem(PlayerState __instance, bool __result)
|
public static bool CheckShipOutersideSolarSystem(PlayerState __instance, ref bool __result)
|
||||||
{
|
{
|
||||||
__result = false;
|
__result = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnEllipticOrbitLineStart(EllipticOrbitLine __instance, ref Vector3 ____upAxisDir, AstroObject ____astroObject)
|
|
||||||
{
|
|
||||||
if (____astroObject.GetAstroObjectName() == AstroObject.Name.Comet) return;
|
|
||||||
|
|
||||||
// For some reason other planets do this idk
|
|
||||||
____upAxisDir *= -1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void OnMapControllerAwake(MapController __instance, ref float ____maxPanDistance, ref float ____maxZoomDistance, ref float ____minPitchAngle, ref float ____zoomSpeed)
|
public static void OnMapControllerAwake(MapController __instance, ref float ____maxPanDistance, ref float ____maxZoomDistance, ref float ____minPitchAngle, ref float ____zoomSpeed)
|
||||||
{
|
{
|
||||||
____maxPanDistance = Main.FurthestOrbit * 1.5f;
|
____maxPanDistance = Main.FurthestOrbit * 1.5f;
|
||||||
@ -66,7 +73,7 @@ namespace NewHorizons.Utility
|
|||||||
|
|
||||||
public static void OnOWCameraAwake(OWCamera __instance)
|
public static void OnOWCameraAwake(OWCamera __instance)
|
||||||
{
|
{
|
||||||
__instance.farClipPlane = Main.FurthestOrbit * 3f;
|
__instance.farClipPlane *= 4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnSunLightParamUpdaterLateUpdate(SunLightParamUpdater __instance)
|
public static bool OnSunLightParamUpdaterLateUpdate(SunLightParamUpdater __instance)
|
||||||
@ -101,38 +108,10 @@ namespace NewHorizons.Utility
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region AudioSignal
|
||||||
|
|
||||||
public static bool OnAudioSignalSignalNameToString(SignalName __0, ref string __result)
|
public static bool OnAudioSignalSignalNameToString(SignalName __0, ref string __result)
|
||||||
{
|
{
|
||||||
switch(__0)
|
|
||||||
{
|
|
||||||
case SignalName.WhiteHole_SS_Receiver:
|
|
||||||
__result = "Sun Station Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_CT_Receiver:
|
|
||||||
__result = "Ember Twin Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_CT_Experiment:
|
|
||||||
__result = "White Hole Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_TT_Receiver:
|
|
||||||
__result = "Ash Twin Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_TT_TimeLoopCore:
|
|
||||||
__result = "Ash Twin Project";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_TH_Receiver:
|
|
||||||
__result = "Timber Hearth Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_BH_NorthPoleReceiver:
|
|
||||||
__result = "North Pole Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_BH_ForgeReceiver:
|
|
||||||
__result = "Black Hole Forge Receiver";
|
|
||||||
return false;
|
|
||||||
case SignalName.WhiteHole_GD_Receiver:
|
|
||||||
__result = "Giant's Deep Receiver";
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
|
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
|
||||||
if (customSignalName == null) return true;
|
if (customSignalName == null) return true;
|
||||||
else
|
else
|
||||||
@ -141,6 +120,150 @@ namespace NewHorizons.Utility
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool OnAudioSignalIndexToFrequency(int __0, ref SignalFrequency __result) {
|
||||||
|
switch (__0)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
__result = SignalFrequency.Traveler;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
__result = SignalFrequency.Quantum;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
__result = SignalFrequency.EscapePod;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
__result = SignalFrequency.WarpCore;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
__result = SignalFrequency.HideAndSeek;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
__result = SignalFrequency.Radio;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
__result = SignalFrequency.Statue;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
__result = SignalFrequency.Default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnAudioSignalFrequencyToIndex(SignalFrequency __0, ref int __result)
|
||||||
|
{
|
||||||
|
var frequency = __0;
|
||||||
|
if (frequency <= SignalFrequency.EscapePod)
|
||||||
|
{
|
||||||
|
if(frequency == SignalFrequency.Default)
|
||||||
|
{
|
||||||
|
__result = 0;
|
||||||
|
}
|
||||||
|
else if (frequency == SignalFrequency.Traveler)
|
||||||
|
{
|
||||||
|
__result = 1;
|
||||||
|
}
|
||||||
|
else if (frequency == SignalFrequency.Quantum)
|
||||||
|
{
|
||||||
|
__result = 2;
|
||||||
|
}
|
||||||
|
else if (frequency == SignalFrequency.EscapePod)
|
||||||
|
{
|
||||||
|
__result = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (frequency == SignalFrequency.WarpCore)
|
||||||
|
{
|
||||||
|
__result = 4;
|
||||||
|
}
|
||||||
|
else if (frequency == SignalFrequency.HideAndSeek)
|
||||||
|
{
|
||||||
|
__result = 5;
|
||||||
|
}
|
||||||
|
else if (frequency == SignalFrequency.Radio)
|
||||||
|
{
|
||||||
|
__result = 6;
|
||||||
|
}
|
||||||
|
else if (frequency == SignalFrequency.Statue)
|
||||||
|
{
|
||||||
|
__result = 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnAudioSignalFrequencyToString(SignalFrequency __0, ref string __result)
|
||||||
|
{
|
||||||
|
SignalBuilder.SignalFrequencyOverrides.TryGetValue(__0, out string customName);
|
||||||
|
if (customName != null)
|
||||||
|
{
|
||||||
|
if (NewHorizonsData.KnowsFrequency(customName)) __result = customName;
|
||||||
|
else __result = UITextLibrary.GetString(UITextType.SignalFreqUnidentified);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnAudioSignalUpdateSignalStrength(AudioSignal __instance, Signalscope __0, float __1)
|
||||||
|
{
|
||||||
|
// I hate this
|
||||||
|
if(__instance is CloakedAudioSignal)
|
||||||
|
{
|
||||||
|
((CloakedAudioSignal)__instance).UpdateSignalStrength(__0, __1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Signalscope
|
||||||
|
public static bool OnSignalscopeAwake(Signalscope __instance, ref AudioSignal[] ____strongestSignals)
|
||||||
|
{
|
||||||
|
____strongestSignals = new AudioSignal[8];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnSignalscopeSwitchFrequencyFilter(Signalscope __instance, int __0)
|
||||||
|
{
|
||||||
|
var increment = __0;
|
||||||
|
var count = Enum.GetValues(typeof(SignalFrequency)).Length;
|
||||||
|
__instance._frequencyFilterIndex += increment;
|
||||||
|
__instance._frequencyFilterIndex = ((__instance._frequencyFilterIndex >= count) ? 0 : __instance._frequencyFilterIndex);
|
||||||
|
__instance._frequencyFilterIndex = ((__instance._frequencyFilterIndex < 0) ? count - 1 : __instance._frequencyFilterIndex);
|
||||||
|
SignalFrequency signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex);
|
||||||
|
if (!PlayerData.KnowsFrequency(signalFrequency) && (!__instance._isUnknownFreqNearby || __instance._unknownFrequency != signalFrequency))
|
||||||
|
{
|
||||||
|
__instance.SwitchFrequencyFilter(increment);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PlayerData
|
||||||
|
public static bool OnPlayerDataKnowsFrequency(SignalFrequency __0, ref bool __result)
|
||||||
|
{
|
||||||
|
SignalBuilder.SignalFrequencyOverrides.TryGetValue(__0, out string freqString);
|
||||||
|
if (freqString != null)
|
||||||
|
{
|
||||||
|
__result = NewHorizonsData.KnowsFrequency(freqString);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnPlayerDataLearnFrequency(SignalFrequency __0)
|
||||||
|
{
|
||||||
|
SignalBuilder.SignalFrequencyOverrides.TryGetValue(__0, out string freqString);
|
||||||
|
if (freqString != null)
|
||||||
|
{
|
||||||
|
NewHorizonsData.LearnFrequency(freqString);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result)
|
public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result)
|
||||||
@ -148,7 +271,7 @@ namespace NewHorizons.Utility
|
|||||||
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
|
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
|
||||||
if (customSignalName != null)
|
if (customSignalName != null)
|
||||||
{
|
{
|
||||||
__result = SignalBuilder.KnownSignals.Contains(customSignalName);
|
__result = NewHorizonsData.KnowsSignal(customSignalName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -159,10 +282,21 @@ namespace NewHorizons.Utility
|
|||||||
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
|
var customSignalName = SignalBuilder.GetCustomSignalName(__0);
|
||||||
if (customSignalName != null)
|
if (customSignalName != null)
|
||||||
{
|
{
|
||||||
if(!SignalBuilder.KnownSignals.Contains(customSignalName)) SignalBuilder.KnownSignals.Add(customSignalName);
|
if (!NewHorizonsData.KnowsSignal(customSignalName)) NewHorizonsData.LearnSignal(customSignalName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool OnPlayerDataKnowsMultipleFrequencies(ref bool __result)
|
||||||
|
{
|
||||||
|
if (NewHorizonsData.KnowsMultipleFrequencies())
|
||||||
|
{
|
||||||
|
__result = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user