mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
v1.6.3 (#412)
## Improvements - Internally use OWML EnumUtils for better mod compatibility in the future! - Use the new [Custom Ship Log Modes](https://github.com/dgarroDC/CustomShipLogModes) utility mod to add the Interstellar Mode for better compatibility and functionality with other mods adding modes. - Minutely improve signalscope lag maybe - Remove unused `buildPriority` field ## Bug fixes - Fixed "hide in map" option for reference frames - Fixed Interstellar Mode not selectable when Rumor Mode was disabled by the user - Fixed spawned items becoming impossible to pick up after dropping them once
This commit is contained in:
commit
0f50c3dce9
@ -18,14 +18,25 @@ namespace NewHorizons.Builder.General
|
||||
// This radius ends up being set by min and max collider radius on the RFV but we set it anyway because why fix what aint broke
|
||||
SC.radius = sphereOfInfluence * 2;
|
||||
|
||||
var RFV = rfGO.AddComponent<ReferenceFrameVolume>();
|
||||
float targetDistance = module.maxTargetDistance;
|
||||
|
||||
ReferenceFrameVolume RFV;
|
||||
if (module.hideInMap)
|
||||
{
|
||||
var mapRFV = rfGO.AddComponent<MapReferenceFrameVolume>();
|
||||
mapRFV._defaultMaxTargetDistance = targetDistance;
|
||||
mapRFV._mapMaxTargetDistance = 0.001f; // Setting to 0 makes it targetable at any distance, so lets make this as small as possible.
|
||||
RFV = mapRFV;
|
||||
}
|
||||
else
|
||||
RFV = rfGO.AddComponent<ReferenceFrameVolume>();
|
||||
|
||||
var minTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence;
|
||||
|
||||
var RV = new ReferenceFrame(owrb);
|
||||
RV._minSuitTargetDistance = minTargetDistance;
|
||||
// The game raycasts to 100km, but if the target is farther than this max distance it ignores it
|
||||
RV._maxTargetDistance = module.maxTargetDistance;
|
||||
RV._maxTargetDistance = targetDistance;
|
||||
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
|
||||
RV._autoAlignmentDistance = sphereOfInfluence * 1.5f;
|
||||
|
||||
@ -51,7 +62,6 @@ namespace NewHorizons.Builder.General
|
||||
owrb.SetAttachedReferenceFrameVolume(RFV);
|
||||
|
||||
if (!module.enabled) GameObject.Destroy(rfGO);
|
||||
else rfGO.SetActive(!module.hideInMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
using OWML.Utils;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
public static class SectorBuilder
|
||||
{
|
||||
private static readonly Sector.Name Name = EnumUtils.Create<Sector.Name>("NewHorizons");
|
||||
|
||||
public static Sector Make(GameObject planetBody, OWRigidbody owRigidBody, float sphereOfInfluence)
|
||||
{
|
||||
GameObject sectorGO = new GameObject("Sector");
|
||||
var sectorGO = new GameObject("Sector");
|
||||
sectorGO.SetActive(false);
|
||||
sectorGO.transform.parent = planetBody.transform;
|
||||
sectorGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
SphereShape SS = sectorGO.AddComponent<SphereShape>();
|
||||
var SS = sectorGO.AddComponent<SphereShape>();
|
||||
SS.SetCollisionMode(Shape.CollisionMode.Volume);
|
||||
SS.SetLayer(Shape.Layer.Sector);
|
||||
SS.layerMask = -1;
|
||||
@ -21,8 +24,8 @@ namespace NewHorizons.Builder.General
|
||||
|
||||
sectorGO.AddComponent<OWTriggerVolume>();
|
||||
|
||||
Sector S = sectorGO.AddComponent<Sector>();
|
||||
S._name = (Sector.Name)24;
|
||||
var S = sectorGO.AddComponent<Sector>();
|
||||
S._name = Name;
|
||||
S._attachedOWRigidbody = owRigidBody;
|
||||
S._subsectors = new List<Sector>();
|
||||
|
||||
@ -36,12 +39,12 @@ namespace NewHorizons.Builder.General
|
||||
{
|
||||
if (parent == null) return null;
|
||||
|
||||
GameObject sectorGO = new GameObject("Sector");
|
||||
var sectorGO = new GameObject("Sector");
|
||||
sectorGO.SetActive(false);
|
||||
sectorGO.transform.parent = planetBody.transform;
|
||||
sectorGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
Sector S = sectorGO.AddComponent<Sector>();
|
||||
var S = sectorGO.AddComponent<Sector>();
|
||||
S._idString = parent._idString;
|
||||
S._name = parent._name;
|
||||
S._attachedOWRigidbody = owRigidBody;
|
||||
|
||||
@ -70,10 +70,14 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
StreamingHandler.SetUpStreaming(prop, sector);
|
||||
|
||||
// Could check this in the for loop but I'm not sure what order we need to know about this in
|
||||
var isTorch = prop.GetComponent<VisionTorchItem>() != null;
|
||||
var isItem = false;
|
||||
|
||||
foreach (var component in prop.GetComponentsInChildren<Component>(true))
|
||||
{
|
||||
if (component.gameObject == prop && component is OWItem) isItem = true;
|
||||
|
||||
if (sector == null)
|
||||
{
|
||||
if (FixUnsectoredComponent(component)) continue;
|
||||
@ -83,6 +87,9 @@ namespace NewHorizons.Builder.Props
|
||||
FixComponent(component, go);
|
||||
}
|
||||
|
||||
// Items shouldn't use these else they get weird
|
||||
if (isItem) detail.keepLoaded = true;
|
||||
|
||||
prop.transform.position = detail.position == null ? go.transform.position : go.transform.TransformPoint(detail.position);
|
||||
|
||||
Quaternion rot = detail.rotation == null ? Quaternion.identity : Quaternion.Euler(detail.rotation);
|
||||
@ -156,6 +163,13 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
}
|
||||
|
||||
if (isItem)
|
||||
{
|
||||
// Else when you put them down you can't pick them back up
|
||||
var col = prop.GetComponent<OWCollider>();
|
||||
if (col != null) col._physicsRemoved = false;
|
||||
}
|
||||
|
||||
if (!detail.keepLoaded) GroupsBuilder.Make(prop, sector);
|
||||
prop.SetActive(true);
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ using UnityEngine;
|
||||
using Enum = System.Enum;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using Random = UnityEngine.Random;
|
||||
using OWML.Utils;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
public static class NomaiTextBuilder
|
||||
@ -281,7 +283,7 @@ namespace NewHorizons.Builder.Props
|
||||
var computer = computerObject.GetComponent<NomaiComputer>();
|
||||
computer.SetSector(sector);
|
||||
|
||||
computer._location = (NomaiText.Location)Enum.Parse(typeof(NomaiText.Location), Enum.GetName(typeof(PropModule.NomaiTextInfo.NomaiTextLocation), info.location));
|
||||
computer._location = EnumUtils.Parse<NomaiText.Location>(info.location.ToString());
|
||||
computer._dictNomaiTextData = MakeNomaiTextDict(xmlPath);
|
||||
computer._nomaiTextAsset = new TextAsset(xmlPath);
|
||||
computer._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile);
|
||||
@ -329,7 +331,7 @@ namespace NewHorizons.Builder.Props
|
||||
var computer = computerObject.GetComponent<NomaiVesselComputer>();
|
||||
computer.SetSector(sector);
|
||||
|
||||
computer._location = (NomaiText.Location)Enum.Parse(typeof(NomaiText.Location), Enum.GetName(typeof(PropModule.NomaiTextInfo.NomaiTextLocation), info.location));
|
||||
computer._location = EnumUtils.Parse<NomaiText.Location>(info.location.ToString());
|
||||
computer._dictNomaiTextData = MakeNomaiTextDict(xmlPath);
|
||||
computer._nomaiTextAsset = new TextAsset(xmlPath);
|
||||
computer._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile);
|
||||
@ -418,7 +420,7 @@ namespace NewHorizons.Builder.Props
|
||||
var nomaiWallText = cairnObject.transform.Find("Props_TH_ClutterSmall/Arc_Short").GetComponent<NomaiWallText>();
|
||||
nomaiWallText.SetSector(sector);
|
||||
|
||||
nomaiWallText._location = (NomaiText.Location)Enum.Parse(typeof(NomaiText.Location), Enum.GetName(typeof(PropModule.NomaiTextInfo.NomaiTextLocation), info.location));
|
||||
nomaiWallText._location = EnumUtils.Parse<NomaiText.Location>(info.location.ToString());
|
||||
nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlPath);
|
||||
nomaiWallText._nomaiTextAsset = new TextAsset(xmlPath);
|
||||
nomaiWallText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile);
|
||||
@ -458,7 +460,7 @@ namespace NewHorizons.Builder.Props
|
||||
var nomaiText = recorderObject.GetComponentInChildren<NomaiText>();
|
||||
nomaiText.SetSector(sector);
|
||||
|
||||
nomaiText._location = (NomaiText.Location)Enum.Parse(typeof(NomaiText.Location), Enum.GetName(typeof(PropModule.NomaiTextInfo.NomaiTextLocation), info.location));
|
||||
nomaiText._location = EnumUtils.Parse<NomaiText.Location>(info.location.ToString());
|
||||
nomaiText._dictNomaiTextData = MakeNomaiTextDict(xmlPath);
|
||||
nomaiText._nomaiTextAsset = new TextAsset(xmlPath);
|
||||
nomaiText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile);
|
||||
@ -520,7 +522,7 @@ namespace NewHorizons.Builder.Props
|
||||
var nomaiWallText = trailmarkerObject.transform.Find("Arc_Short").GetComponent<NomaiWallText>();
|
||||
nomaiWallText.SetSector(sector);
|
||||
|
||||
nomaiWallText._location = (NomaiText.Location)Enum.Parse(typeof(NomaiText.Location), Enum.GetName(typeof(PropModule.NomaiTextInfo.NomaiTextLocation), info.location));
|
||||
nomaiWallText._location = EnumUtils.Parse<NomaiText.Location>(info.location.ToString());
|
||||
nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlPath);
|
||||
nomaiWallText._nomaiTextAsset = new TextAsset(xmlPath);
|
||||
nomaiWallText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile);
|
||||
@ -553,7 +555,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
var nomaiWallText = nomaiWallTextObj.AddComponent<NomaiWallText>();
|
||||
|
||||
nomaiWallText._location = (NomaiText.Location)Enum.Parse(typeof(NomaiText.Location), Enum.GetName(typeof(PropModule.NomaiTextInfo.NomaiTextLocation), info.location));
|
||||
nomaiWallText._location = EnumUtils.Parse<NomaiText.Location>(info.location.ToString());
|
||||
|
||||
var text = new TextAsset(xmlPath);
|
||||
|
||||
|
||||
@ -7,6 +7,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using OWML.Utils;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
public static class SignalBuilder
|
||||
@ -14,16 +16,13 @@ namespace NewHorizons.Builder.Props
|
||||
private static AnimationCurve _customCurve = null;
|
||||
|
||||
private static Dictionary<SignalName, string> _customSignalNames;
|
||||
private static Stack<SignalName> _availableSignalNames;
|
||||
private static int _nextCustomSignalName;
|
||||
|
||||
private static Dictionary<SignalFrequency, string> _customFrequencyNames;
|
||||
private static int _nextCustomFrequencyName;
|
||||
|
||||
public static int NumberOfFrequencies;
|
||||
|
||||
public static List<SignalName> QMSignals { get; private set; }
|
||||
public static List<SignalName> CloakedSignals { get; private set; }
|
||||
private static List<SignalName> _qmSignals;
|
||||
private static List<SignalName> _cloakedSignals;
|
||||
|
||||
public static bool Initialized;
|
||||
|
||||
@ -31,60 +30,34 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
Logger.LogVerbose($"Initializing SignalBuilder");
|
||||
_customSignalNames = new Dictionary<SignalName, string>();
|
||||
_availableSignalNames = new Stack<SignalName>(new SignalName[]
|
||||
{
|
||||
(SignalName)17,
|
||||
(SignalName)18,
|
||||
(SignalName)19,
|
||||
(SignalName)26,
|
||||
(SignalName)27,
|
||||
(SignalName)28,
|
||||
(SignalName)29,
|
||||
(SignalName)33,
|
||||
(SignalName)34,
|
||||
(SignalName)35,
|
||||
(SignalName)36,
|
||||
(SignalName)37,
|
||||
(SignalName)38,
|
||||
(SignalName)39,
|
||||
(SignalName)50,
|
||||
(SignalName)51,
|
||||
(SignalName)52,
|
||||
(SignalName)53,
|
||||
(SignalName)54,
|
||||
(SignalName)55,
|
||||
(SignalName)56,
|
||||
(SignalName)57,
|
||||
(SignalName)58,
|
||||
(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,
|
||||
});
|
||||
_customFrequencyNames = new Dictionary<SignalFrequency, string>() {
|
||||
{ SignalFrequency.Statue, "FREQ_STATUE" },
|
||||
{ SignalFrequency.Default, "FREQ_UNKNOWN" },
|
||||
{ SignalFrequency.WarpCore, "FREQ_WARP_CORE" }
|
||||
};
|
||||
_nextCustomSignalName = 200;
|
||||
_nextCustomFrequencyName = 256;
|
||||
NumberOfFrequencies = 8;
|
||||
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
||||
|
||||
QMSignals = new List<SignalName>() { SignalName.Quantum_QM };
|
||||
CloakedSignals = new List<SignalName>();
|
||||
_qmSignals = new List<SignalName>() { SignalName.Quantum_QM };
|
||||
_cloakedSignals = new List<SignalName>();
|
||||
|
||||
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)
|
||||
{
|
||||
var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
|
||||
if (freq != default) return freq;
|
||||
|
||||
Logger.Log($"Registering new frequency name [{str}]");
|
||||
|
||||
if (NumberOfFrequencies == 31)
|
||||
@ -93,17 +66,10 @@ namespace NewHorizons.Builder.Props
|
||||
return SignalFrequency.Default;
|
||||
}
|
||||
|
||||
var freq = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
|
||||
if (freq != default)
|
||||
{
|
||||
return freq;
|
||||
}
|
||||
|
||||
freq = (SignalFrequency)_nextCustomFrequencyName;
|
||||
_nextCustomFrequencyName *= 2;
|
||||
freq = EnumUtilities.Create<SignalFrequency>(str);
|
||||
_customFrequencyNames.Add(freq, str);
|
||||
|
||||
NumberOfFrequencies++;
|
||||
NumberOfFrequencies = EnumUtils.GetValues<SignalFrequency>().Length;
|
||||
|
||||
// This stuff happens after the signalscope is Awake so we have to change the number of frequencies now
|
||||
GameObject.FindObjectOfType<Signalscope>()._strongestSignals = new AudioSignal[NumberOfFrequencies + 1];
|
||||
@ -119,14 +85,15 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
public static SignalName AddSignalName(string str)
|
||||
{
|
||||
var name = CollectionUtilities.KeyByValue(_customSignalNames, str);
|
||||
if (name != default) return name;
|
||||
|
||||
Logger.Log($"Registering new signal name [{str}]");
|
||||
SignalName newName;
|
||||
|
||||
if (_availableSignalNames.Count == 0) newName = (SignalName)_nextCustomSignalName++;
|
||||
else newName = _availableSignalNames.Pop();
|
||||
name = EnumUtilities.Create<SignalName>(str);
|
||||
_customSignalNames.Add(name, str);
|
||||
|
||||
_customSignalNames.Add(newName, str);
|
||||
return newName;
|
||||
return name;
|
||||
}
|
||||
|
||||
public static string GetCustomSignalName(SignalName signalName)
|
||||
@ -220,35 +187,20 @@ namespace NewHorizons.Builder.Props
|
||||
signalGO.SetActive(true);
|
||||
|
||||
// Track certain special signal things
|
||||
if (planetGO.GetComponent<AstroObject>()?.GetAstroObjectName() == AstroObject.Name.QuantumMoon) QMSignals.Add(name);
|
||||
if (info.insideCloak) CloakedSignals.Add(name);
|
||||
if (planetGO.GetComponent<AstroObject>()?.GetAstroObjectName() == AstroObject.Name.QuantumMoon) _qmSignals.Add(name);
|
||||
if (info.insideCloak) _cloakedSignals.Add(name);
|
||||
|
||||
return signalGO;
|
||||
}
|
||||
|
||||
private static SignalFrequency StringToFrequency(string str)
|
||||
{
|
||||
foreach (SignalFrequency freq in Enum.GetValues(typeof(SignalFrequency)))
|
||||
{
|
||||
if (str.Equals(freq.ToString())) return freq;
|
||||
}
|
||||
var customName = CollectionUtilities.KeyByValue(_customFrequencyNames, str);
|
||||
|
||||
if (customName == default) customName = AddFrequency(str);
|
||||
|
||||
return customName;
|
||||
return EnumUtils.TryParse<SignalFrequency>(str, out SignalFrequency frequency) ? frequency : AddFrequency(str);
|
||||
}
|
||||
|
||||
public static SignalName StringToSignalName(string str)
|
||||
{
|
||||
foreach (SignalName name in Enum.GetValues(typeof(SignalName)))
|
||||
{
|
||||
if (str.Equals(name.ToString())) return name;
|
||||
}
|
||||
var customName = CollectionUtilities.KeyByValue(_customSignalNames, str);
|
||||
if (customName == default) customName = AddSignalName(str);
|
||||
|
||||
return customName;
|
||||
return EnumUtils.TryParse<SignalName>(str, out SignalName name) ? name : AddSignalName(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -14,14 +15,12 @@ namespace NewHorizons.Builder.ShipLog
|
||||
{
|
||||
private static Dictionary<CuriosityName, Color> _curiosityColors;
|
||||
private static Dictionary<CuriosityName, Color> _curiosityHighlightColors;
|
||||
private static Dictionary<string, CuriosityName> _rawNameToCuriosityName;
|
||||
private static Dictionary<string, string> _entryIdToRawName;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_curiosityColors = new Dictionary<CuriosityName, Color>();
|
||||
_curiosityHighlightColors = new Dictionary<CuriosityName, Color>();
|
||||
_rawNameToCuriosityName = new Dictionary<string, CuriosityName>();
|
||||
_entryIdToRawName = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
@ -29,10 +28,9 @@ namespace NewHorizons.Builder.ShipLog
|
||||
{
|
||||
foreach (ShipLogModule.CuriosityColorInfo newColor in newColors)
|
||||
{
|
||||
if (_rawNameToCuriosityName.ContainsKey(newColor.id) == false)
|
||||
if (!EnumUtils.IsDefined<CuriosityName>(newColor.id))
|
||||
{
|
||||
CuriosityName newName = (CuriosityName)8 + _rawNameToCuriosityName.Count;
|
||||
_rawNameToCuriosityName.Add(newColor.id, newName);
|
||||
CuriosityName newName = EnumUtilities.Create<CuriosityName>(newColor.id);
|
||||
_curiosityColors.Add(newName, newColor.color.ToColor());
|
||||
_curiosityHighlightColors.Add(newName, newColor.highlightColor.ToColor());
|
||||
}
|
||||
@ -193,9 +191,9 @@ namespace NewHorizons.Builder.ShipLog
|
||||
if (_entryIdToRawName.ContainsKey(entry._id))
|
||||
{
|
||||
var raw = _entryIdToRawName[entry._id];
|
||||
if (_rawNameToCuriosityName.ContainsKey(raw))
|
||||
if (EnumUtils.TryParse<CuriosityName>(raw, out CuriosityName name))
|
||||
{
|
||||
entry._curiosity = _rawNameToCuriosityName[raw];
|
||||
entry._curiosity = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -47,7 +48,7 @@ namespace NewHorizons.Builder.Volumes
|
||||
owAudioSource._audioSource = audioSource;
|
||||
owAudioSource.loop = info.loop;
|
||||
owAudioSource.SetMaxVolume(info.volume);
|
||||
owAudioSource.SetTrack((OWAudioMixer.TrackName)Enum.Parse(typeof(OWAudioMixer.TrackName), Enum.GetName(typeof(AudioMixerTrackName), info.track)));
|
||||
owAudioSource.SetTrack(EnumUtils.Parse<OWAudioMixer.TrackName>(info.track.ToString()));
|
||||
AudioUtilities.SetAudioClip(owAudioSource, info.audio, mod);
|
||||
|
||||
var audioVolume = go.AddComponent<AudioVolume>();
|
||||
|
||||
@ -21,10 +21,8 @@ namespace NewHorizons.Components.ShipLog
|
||||
private Vector2 _panRootPos = Vector2.zero;
|
||||
private Vector2 _startPanPos;
|
||||
|
||||
private ScreenPromptList _upperRightPromptList;
|
||||
private ScreenPromptList _centerPromptList;
|
||||
|
||||
private ScreenPrompt _detectiveModePrompt;
|
||||
private ScreenPrompt _targetSystemPrompt;
|
||||
private ScreenPrompt _warpPrompt = new ScreenPrompt(InputLibrary.autopilot, "<CMD> Warp to system");
|
||||
|
||||
@ -45,9 +43,7 @@ namespace NewHorizons.Components.ShipLog
|
||||
_oneShotSource = oneShotSource;
|
||||
|
||||
_centerPromptList = centerPromptList;
|
||||
_upperRightPromptList = upperRightPromptList;
|
||||
|
||||
_detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, UITextLibrary.GetString(UITextType.LogRumorModePrompt), 0, ScreenPrompt.DisplayState.Normal, false);
|
||||
_targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, TranslationHandler.GetTranslation("LOCK_AUTOPILOT_WARP", TranslationHandler.TextType.UI), 0, ScreenPrompt.DisplayState.Normal, false);
|
||||
|
||||
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||
@ -166,7 +162,7 @@ namespace NewHorizons.Components.ShipLog
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
Locator.GetPromptManager().AddScreenPrompt(_detectiveModePrompt, _upperRightPromptList, TextAnchor.MiddleRight, -1, true);
|
||||
_oneShotSource.PlayOneShot(AudioType.ShipLogEnterMapMode);
|
||||
Locator.GetPromptManager().AddScreenPrompt(_targetSystemPrompt, _centerPromptList, TextAnchor.MiddleCenter, -1, true);
|
||||
}
|
||||
|
||||
@ -174,7 +170,6 @@ namespace NewHorizons.Components.ShipLog
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
|
||||
Locator.GetPromptManager().RemoveScreenPrompt(_detectiveModePrompt);
|
||||
Locator.GetPromptManager().RemoveScreenPrompt(_targetSystemPrompt);
|
||||
}
|
||||
|
||||
|
||||
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
5
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -47,11 +47,6 @@ namespace NewHorizons.External.Configs
|
||||
/// </summary>
|
||||
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>
|
||||
/// Should this planet ever be shown on the title screen?
|
||||
/// </summary>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -13,7 +14,6 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
private static Dictionary<string, AudioType> _customAudioTypes;
|
||||
private static List<AudioLibrary.AudioEntry> _audioEntries;
|
||||
private static int _startingInt = 4000;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@ -48,7 +48,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
else
|
||||
{
|
||||
return (AudioType)Enum.Parse(typeof(AudioType), audio);
|
||||
return EnumUtils.Parse<AudioType>(audio);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -80,9 +80,9 @@ namespace NewHorizons.Handlers
|
||||
// Create a custom audio type from a set of audio clips. Needs a unique ID
|
||||
public static AudioType AddCustomAudioType(string id, AudioClip[] audioClips)
|
||||
{
|
||||
var audioType = (AudioType)_startingInt + _customAudioTypes.Count();
|
||||
Logger.LogVerbose($"Registering new audio type [{id}]");
|
||||
|
||||
Logger.LogVerbose($"Registering custom audio type {id} as {audioType}");
|
||||
var audioType = EnumUtilities.Create<AudioType>(id);
|
||||
|
||||
_audioEntries.Add(new AudioLibrary.AudioEntry(audioType, audioClips));
|
||||
_customAudioTypes.Add(id, audioType);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -11,7 +12,6 @@ namespace NewHorizons.Handlers
|
||||
public static class RemoteHandler
|
||||
{
|
||||
private static Dictionary<string, NomaiRemoteCameraPlatform.ID> _customPlatformIDs;
|
||||
private static readonly int _startingInt = 19;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@ -41,7 +41,7 @@ namespace NewHorizons.Handlers
|
||||
try
|
||||
{
|
||||
NomaiRemoteCameraPlatform.ID platformID;
|
||||
if (_customPlatformIDs.TryGetValue(id, out platformID) || Enum.TryParse(id, true, out platformID))
|
||||
if (_customPlatformIDs.TryGetValue(id, out platformID) || EnumUtils.TryParse<NomaiRemoteCameraPlatform.ID>(id, out platformID))
|
||||
{
|
||||
return platformID;
|
||||
}
|
||||
@ -52,16 +52,16 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load platform id:\n{e}");
|
||||
Logger.LogError($"Couldn't load platform id [{id}]:\n{e}");
|
||||
return NomaiRemoteCameraPlatform.ID.None;
|
||||
}
|
||||
}
|
||||
|
||||
public static NomaiRemoteCameraPlatform.ID AddCustomPlatformID(string id)
|
||||
{
|
||||
var platformID = (NomaiRemoteCameraPlatform.ID)_startingInt + _customPlatformIDs.Count();
|
||||
Logger.LogVerbose($"Registering new platform id [{id}]");
|
||||
|
||||
Logger.LogVerbose($"Registering custom platform id {id} as {platformID}");
|
||||
var platformID = EnumUtilities.Create<NomaiRemoteCameraPlatform.ID>(id);
|
||||
|
||||
_customPlatformIDs.Add(id, platformID);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.Components.ShipLog;
|
||||
using NewHorizons.Utility;
|
||||
using System.Collections.Generic;
|
||||
using NewHorizons.OtherMods.CustomShipLogModes;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
namespace NewHorizons.Handlers
|
||||
@ -45,14 +46,7 @@ namespace NewHorizons.Handlers
|
||||
panRoot.transform.localPosition = Vector3.zero;
|
||||
panRoot.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
|
||||
var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>();
|
||||
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
|
||||
var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
|
||||
|
||||
ShipLogStarChartMode.Initialize(
|
||||
centerPromptList,
|
||||
upperRightPromptList,
|
||||
oneShotSource);
|
||||
CustomShipLogModesHandler.AddInterstellarMode();
|
||||
}
|
||||
|
||||
_starSystemToFactID = new Dictionary<string, string>();
|
||||
|
||||
@ -17,6 +17,7 @@ using NewHorizons.Utility.DebugMenu;
|
||||
using NewHorizons.Utility.DebugUtilities;
|
||||
using OWML.Common;
|
||||
using OWML.ModHelper;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -241,6 +242,7 @@ namespace NewHorizons
|
||||
ImageUtilities.ClearCache();
|
||||
AudioUtilities.ClearCache();
|
||||
AssetBundleUtilities.ClearCache();
|
||||
EnumUtilities.ClearCache();
|
||||
IsSystemReady = false;
|
||||
}
|
||||
|
||||
@ -611,7 +613,7 @@ namespace NewHorizons
|
||||
private void LoadTranslations(string folder, IModBehaviour mod)
|
||||
{
|
||||
var foundFile = false;
|
||||
foreach (TextTranslation.Language language in Enum.GetValues(typeof(TextTranslation.Language)))
|
||||
foreach (TextTranslation.Language language in EnumUtils.GetValues<TextTranslation.Language>())
|
||||
{
|
||||
if (language is TextTranslation.Language.UNKNOWN or TextTranslation.Language.TOTAL) continue;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<LangVersion>default</LangVersion>
|
||||
@ -15,7 +15,6 @@
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HarmonyX" Version="2.10.0" />
|
||||
<PackageReference Include="OWML" Version="2.7.2" />
|
||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.393" />
|
||||
<Reference Include="../Lib/System.ComponentModel.Annotations.dll" />
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
using NewHorizons.Handlers;
|
||||
|
||||
namespace NewHorizons.OtherMods.CustomShipLogModes;
|
||||
|
||||
public static class CustomShipLogModesHandler
|
||||
{
|
||||
private static readonly ICustomShipLogModesAPI API;
|
||||
|
||||
static CustomShipLogModesHandler()
|
||||
{
|
||||
API = Main.Instance.ModHelper.Interaction.TryGetModApi<ICustomShipLogModesAPI>("dgarro.CustomShipLogModes");
|
||||
}
|
||||
|
||||
public static void AddInterstellarMode()
|
||||
{
|
||||
API.AddMode(StarChartHandler.ShipLogStarChartMode,
|
||||
() => Main.HasWarpDrive,
|
||||
() => TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace NewHorizons.OtherMods.CustomShipLogModes;
|
||||
|
||||
public interface ICustomShipLogModesAPI
|
||||
{
|
||||
public void AddMode(ShipLogMode mode, Func<bool> isEnabledSupplier, Func<string> nameSupplier);
|
||||
}
|
||||
@ -119,7 +119,10 @@ namespace NewHorizons.Patches
|
||||
{
|
||||
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;
|
||||
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
|
||||
if (Locator.GetQuantumMoon() != null && Locator.GetQuantumMoon().IsPlayerInside() && !SignalBuilder.QMSignals.Contains(__instance._name))
|
||||
if (Locator.GetQuantumMoon() != null && Locator.GetQuantumMoon().IsPlayerInside() && !isOnQuantumMoon)
|
||||
{
|
||||
__instance._signalStrength = 0f;
|
||||
__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 (SignalBuilder.CloakedSignals.Contains(__instance._name))
|
||||
if (isCloaked)
|
||||
{
|
||||
if (!PlayerState.InCloakingField())
|
||||
{
|
||||
|
||||
@ -7,18 +7,6 @@ namespace NewHorizons.Patches
|
||||
[HarmonyPatch]
|
||||
public static class WarpDrivePatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.EnterMode))]
|
||||
public static void ShipLogMapMode_EnterMode(ShipLogMapMode __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return;
|
||||
|
||||
var newPrompt = TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI);
|
||||
__instance._detectiveModePrompt.SetText(newPrompt);
|
||||
var text = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/ScreenPromptListScaleRoot/ScreenPromptList_UpperRight/ScreenPrompt/Text").GetComponent<UnityEngine.UI.Text>();
|
||||
text.text = newPrompt;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))]
|
||||
public static bool ShipCockpitController_Update(ShipCockpitController __instance)
|
||||
@ -37,42 +25,5 @@ namespace NewHorizons.Patches
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ShipLogController), nameof(ShipLogController.Update))]
|
||||
public static bool ShipLogController_Update(ShipLogController __instance)
|
||||
{
|
||||
if (!Main.HasWarpDrive) return true;
|
||||
|
||||
if (__instance._exiting
|
||||
|| OWInput.GetInputMode() != InputMode.ShipComputer
|
||||
|| __instance._currentMode.AllowCancelInput() && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.All)
|
||||
|| StarChartHandler.ShipLogStarChartMode == null)
|
||||
return true;
|
||||
|
||||
// Mostly copied from the base method but we're trying to fit in our new mode
|
||||
__instance._exitPrompt.SetVisibility(__instance._currentMode.AllowCancelInput());
|
||||
__instance._currentMode.UpdateMode();
|
||||
if (__instance._currentMode.AllowModeSwap() && OWInput.IsNewlyPressed(InputLibrary.swapShipLogMode, InputMode.All))
|
||||
{
|
||||
ShipLogMode currentMode = __instance._currentMode;
|
||||
string focusedEntryID = currentMode.GetFocusedEntryID();
|
||||
if (!focusedEntryID.Equals("")) return true;
|
||||
bool flag = currentMode.Equals(__instance._mapMode);
|
||||
__instance._currentMode = (flag ? __instance._detectiveMode : __instance._mapMode);
|
||||
|
||||
if (currentMode.Equals(__instance._mapMode))
|
||||
__instance._currentMode = StarChartHandler.ShipLogStarChartMode;
|
||||
else if (currentMode.Equals(StarChartHandler.ShipLogStarChartMode))
|
||||
__instance._currentMode = __instance._detectiveMode;
|
||||
else
|
||||
__instance._currentMode = __instance._mapMode;
|
||||
|
||||
currentMode.ExitMode();
|
||||
__instance._currentMode.EnterMode(focusedEntryID, null);
|
||||
__instance._oneShotSource.PlayOneShot(flag ? global::AudioType.ShipLogEnterDetectiveMode : global::AudioType.ShipLogEnterMapMode, 1f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,12 +34,6 @@
|
||||
"description": "Add bramble nodes to this planet and/or make this planet a bramble dimension",
|
||||
"$ref": "#/definitions/BrambleModule"
|
||||
},
|
||||
"buildPriority": {
|
||||
"type": "integer",
|
||||
"description": "Set to a higher number if you wish for this body to be built sooner",
|
||||
"format": "int32",
|
||||
"default": -1
|
||||
},
|
||||
"canShowOnTitle": {
|
||||
"type": "boolean",
|
||||
"description": "Should this planet ever be shown on the title screen?",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -34,12 +35,11 @@ namespace NewHorizons.Utility
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
if (EnumUtils.TryParse<AudioType>(audio, out AudioType type))
|
||||
{
|
||||
var audioType = (AudioType)Enum.Parse(typeof(AudioType), audio);
|
||||
source._audioLibraryClip = audioType;
|
||||
source._audioLibraryClip = type;
|
||||
}
|
||||
catch
|
||||
else
|
||||
{
|
||||
var audioClip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(audio);
|
||||
if (audioClip == null) Logger.Log($"Couldn't find audio clip {audio}");
|
||||
|
||||
48
NewHorizons/Utility/EnumUtilities.cs
Normal file
48
NewHorizons/Utility/EnumUtilities.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OWML.Utils;
|
||||
|
||||
namespace NewHorizons.Utility
|
||||
{
|
||||
public static class EnumUtilities
|
||||
{
|
||||
private static List<Enum> Enums = new List<Enum>();
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
foreach (var @enum in Enums)
|
||||
{
|
||||
if (@enum == null) continue;
|
||||
EnumUtils.Remove(@enum.GetType(), @enum);
|
||||
}
|
||||
Enums.Clear();
|
||||
}
|
||||
|
||||
public static T Create<T>(string name) where T : Enum
|
||||
{
|
||||
T @enum = EnumUtils.Create<T>(name);
|
||||
Enums.SafeAdd(@enum);
|
||||
return @enum;
|
||||
}
|
||||
|
||||
public static void Create<T>(string name, T value) where T : Enum
|
||||
{
|
||||
EnumUtils.Create(name, value);
|
||||
Enums.SafeAdd(value);
|
||||
}
|
||||
|
||||
public static void Remove<T>(string name) where T : Enum
|
||||
{
|
||||
T @enum = EnumUtils.Parse<T>(name);
|
||||
Enums.Remove(@enum);
|
||||
EnumUtils.Remove<T>(name);
|
||||
}
|
||||
|
||||
public static void Remove<T>(T value) where T : Enum
|
||||
{
|
||||
Enums.Remove(value);
|
||||
EnumUtils.Remove<T>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using Newtonsoft.Json;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -217,17 +218,6 @@ namespace NewHorizons.Utility
|
||||
return xCorrect && yCorrect && zCorrect;
|
||||
}
|
||||
|
||||
public static FluidVolume.Type ConvertToOW(this FluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(FluidType), fluidType).ToUpper());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Couldn't parse fluid volume type [{fluidType}]:\n{ex}");
|
||||
return @default;
|
||||
}
|
||||
}
|
||||
public static FluidVolume.Type ConvertToOW(this FluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE) => EnumUtils.Parse(fluidType.ToString().ToUpper(), @default);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
"author": "xen, Bwc9876, clay, MegaPiggy, John, Hawkbar, Trifid, Book",
|
||||
"name": "New Horizons",
|
||||
"uniqueName": "xen.NewHorizons",
|
||||
"version": "1.6.2",
|
||||
"version": "1.6.3",
|
||||
"owmlVersion": "2.7.2",
|
||||
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility" ],
|
||||
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
|
||||
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ],
|
||||
"pathsToPreserve": [ "planets", "systems", "translations" ]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user