From f7b59cfd62bf591c25b9d7c5f9a86f203b00d154 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 20 Nov 2022 14:51:16 -0500 Subject: [PATCH 01/43] Add shuttle handler --- NewHorizons/Handlers/ShuttleHandler.cs | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 NewHorizons/Handlers/ShuttleHandler.cs diff --git a/NewHorizons/Handlers/ShuttleHandler.cs b/NewHorizons/Handlers/ShuttleHandler.cs new file mode 100644 index 000000000..e728851d2 --- /dev/null +++ b/NewHorizons/Handlers/ShuttleHandler.cs @@ -0,0 +1,42 @@ +using NewHorizons.Utility; +using OWML.Common; +using OWML.Utils; +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Handlers +{ + public static class ShuttleHandler + { + public static NomaiShuttleController.ShuttleID GetShuttleID(string id) + { + try + { + NomaiShuttleController.ShuttleID shuttleID; + if (EnumUtils.TryParse(id, out shuttleID)) + { + return shuttleID; + } + else + { + return AddCustomShuttleID(id); + } + } + catch (Exception e) + { + Logger.LogError($"Couldn't load shuttle id [{id}]:\n{e}"); + return EnumUtils.FromObject(-1); + } + } + + public static NomaiShuttleController.ShuttleID AddCustomShuttleID(string id) + { + Logger.LogVerbose($"Registering new shuttle id [{id}]"); + + return EnumUtilities.Create(id); + } + } +} From 9d4dd66ea13b58b6506aba41b0316a096e36d4da Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Mon, 21 Nov 2022 00:06:04 -0500 Subject: [PATCH 02/43] Add shuttle builder --- NewHorizons/Builder/Props/PropBuildManager.cs | 14 ++ NewHorizons/Builder/Props/ShuttleBuilder.cs | 122 ++++++++++++++++++ NewHorizons/Components/NHShuttleController.cs | 17 +++ NewHorizons/External/Modules/PropModule.cs | 39 ++++++ NewHorizons/Main.cs | 1 + 5 files changed, 193 insertions(+) create mode 100644 NewHorizons/Builder/Props/ShuttleBuilder.cs create mode 100644 NewHorizons/Components/NHShuttleController.cs diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index d3dcbf4ff..7f7f54bbb 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -12,6 +12,20 @@ public static class PropBuildManager { public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, PlanetConfig config, IModBehaviour mod) { + if (config.Props.shuttles != null) + { + foreach (var shuttleInfo in config.Props.shuttles) + { + try + { + ShuttleBuilder.Make(go, sector, shuttleInfo); + } + catch (Exception ex) + { + Logger.LogError($"Couldn't make shuttle [{shuttleInfo.id}] for [{go.name}]:\n{ex}"); + } + } + } if (config.Props.scatter != null) { try diff --git a/NewHorizons/Builder/Props/ShuttleBuilder.cs b/NewHorizons/Builder/Props/ShuttleBuilder.cs new file mode 100644 index 000000000..39adfba4b --- /dev/null +++ b/NewHorizons/Builder/Props/ShuttleBuilder.cs @@ -0,0 +1,122 @@ +using NewHorizons.Components; +using NewHorizons.Components.Volumes; +using NewHorizons.External.Modules; +using NewHorizons.Handlers; +using NewHorizons.Utility; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Builder.Props +{ + public static class ShuttleBuilder + { + private static GameObject _prefab; + private static GameObject _orbPrefab; + private static GameObject _bodyPrefab; + + internal static void InitPrefab() + { + if (_prefab == null) + { + _prefab = SearchUtilities.Find("QuantumMoon_Body/Sector_QuantumMoon/QuantumShuttle/Prefab_NOM_Shuttle")?.InstantiateInactive()?.Rename("Prefab_QM_Shuttle")?.DontDestroyOnLoad(); + NomaiShuttleController shuttleController = _prefab.GetComponent(); + NHShuttleController nhShuttleController = _prefab.AddComponent(); + nhShuttleController._exteriorSector = _prefab.FindChild("Sector_Shuttle").GetComponent(); + nhShuttleController._interiorSector = _prefab.FindChild("Sector_NomaiShuttleInterior").GetComponent(); + nhShuttleController._shuttleBody = shuttleController._shuttleBody; + nhShuttleController._retrievalLength = shuttleController._retrievalLength; + nhShuttleController._launchSlot = shuttleController._launchSlot; + nhShuttleController._retrieveSlot = shuttleController._retrieveSlot; + nhShuttleController._landSlot = shuttleController._landSlot; + nhShuttleController._triggerVolume = shuttleController._triggerVolume; + nhShuttleController._beamResetVolume = shuttleController._beamResetVolume; + nhShuttleController._tractorBeam = shuttleController._tractorBeam; + nhShuttleController._forceVolume = shuttleController._forceVolume; + nhShuttleController._exteriorCollisionGroup = shuttleController._exteriorCollisionGroup; + nhShuttleController._exteriorColliderRoot = shuttleController._exteriorColliderRoot; + nhShuttleController._landingBeamRoot = shuttleController._landingBeamRoot; + nhShuttleController._warpEffect = _prefab.GetComponentInChildren(); + nhShuttleController._exteriorLegColliders = shuttleController._exteriorLegColliders; + nhShuttleController._id = NomaiShuttleController.ShuttleID.HourglassShuttle; + nhShuttleController._cannon = null; + GameObject slots = _prefab.FindChild("Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/ControlPanel/Slots"); + GameObject neutralSlotObject = new GameObject("Slot_Neutral", typeof(NomaiInterfaceSlot)); + neutralSlotObject.transform.SetParent(slots.transform, false); + neutralSlotObject.transform.localPosition = new Vector3(-0.0153f, -0.2386f, 0.0205f); + neutralSlotObject.transform.localRotation = Quaternion.identity; + NomaiInterfaceSlot neutralSlot = neutralSlotObject.GetComponent(); + neutralSlot._exitRadius = 0.1f; + neutralSlot._radius = 0.05f; + neutralSlot._attractive = true; + neutralSlot._muteAudio = true; + nhShuttleController._neutralSlot = neutralSlot; + _orbPrefab = shuttleController._orb.gameObject?.InstantiateInactive()?.Rename("Prefab_QM_Shuttle_InterfaceOrbSmall")?.DontDestroyOnLoad(); + nhShuttleController._orb = _orbPrefab.GetComponent(); + nhShuttleController._orb._sector = nhShuttleController._interiorSector; + nhShuttleController._orb._slotRoot = slots; + nhShuttleController._orb._safetyRails = slots.GetComponentsInChildren(); + nhShuttleController._orb._slots = slots.GetComponentsInChildren(); + _bodyPrefab = shuttleController._shuttleBody.gameObject?.InstantiateInactive()?.Rename("Prefab_QM_Shuttle_Body")?.DontDestroyOnLoad(); + nhShuttleController._shuttleBody = _bodyPrefab.GetComponent(); + nhShuttleController._impactSensor = _bodyPrefab.GetComponent(); + nhShuttleController._forceApplier = _bodyPrefab.GetComponentInChildren(); + nhShuttleController._detectorObj = nhShuttleController._forceApplier.gameObject; + GameObject.DestroyImmediate(shuttleController); + GameObject.DestroyImmediate(_prefab.FindChild("Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder")); + } + } + + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.ShuttleInfo info) + { + InitPrefab(); + + if (_prefab == null || planetGO == null || sector == null) return null; + + var detailInfo = new PropModule.DetailInfo() + { + position = info.position, + rotation = info.rotation, + parentPath = info.parentPath, + isRelativeToParent = info.isRelativeToParent, + rename = info.rename + }; + var shuttleObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); + shuttleObject.SetActive(false); + + StreamingHandler.SetUpStreaming(shuttleObject, sector); + + NHShuttleController shuttleController = shuttleObject.GetComponent(); + NomaiShuttleController.ShuttleID id = ShuttleHandler.GetShuttleID(info.id); + shuttleController._id = id; + shuttleController._cannon = Locator.GetGravityCannon(id); + + GameObject slots = shuttleObject.FindChild("Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/ControlPanel/Slots"); + GameObject orbObject = _orbPrefab.InstantiateInactive().Rename("InterfaceOrbSmall"); + orbObject.transform.SetParent(slots.transform, false); + orbObject.transform.localPosition = new Vector3(-0.0153f, -0.2386f, 0.0205f); + shuttleController._orb = orbObject.GetComponent(); + shuttleController._orb._sector = shuttleController._interiorSector; + shuttleController._orb._slotRoot = slots; + shuttleController._orb._safetyRails = slots.GetComponentsInChildren(); + shuttleController._orb._slots = slots.GetComponentsInChildren(); + + StreamingHandler.SetUpStreaming(orbObject, sector); + + GameObject bodyObject = _bodyPrefab.InstantiateInactive().Rename("Shuttle_Body"); + bodyObject.transform.SetParent(shuttleObject.transform, false); + bodyObject.transform.localPosition = Vector3.zero; + bodyObject.transform.localEulerAngles = Vector3.zero; + shuttleController._shuttleBody = bodyObject.GetComponent(); + shuttleController._impactSensor = bodyObject.GetComponent(); + shuttleController._forceApplier = bodyObject.GetComponentInChildren(); + shuttleController._detectorObj = shuttleController._forceApplier.gameObject; + + shuttleObject.SetActive(true); + bodyObject.SetActive(true); + orbObject.SetActive(true); + shuttleController._orb.RemoveAllLocks(); + + return shuttleObject; + } + } +} diff --git a/NewHorizons/Components/NHShuttleController.cs b/NewHorizons/Components/NHShuttleController.cs new file mode 100644 index 000000000..522bce798 --- /dev/null +++ b/NewHorizons/Components/NHShuttleController.cs @@ -0,0 +1,17 @@ +using NewHorizons.Utility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace NewHorizons.Components +{ + public class NHShuttleController : NomaiShuttleController + { + public NomaiInterfaceSlot _neutralSlot; + public Sector _exteriorSector; + public Sector _interiorSector; + } +} diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 839f75b62..df59a7ec8 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -83,6 +83,11 @@ public class PropModule /// public SignalModule.SignalInfo[] signals; + /// + /// Add shuttles to this planet + /// + public ShuttleInfo[] shuttles; + /// /// Add projection pools/platforms, whiteboards, and stones to this planet /// @@ -1000,5 +1005,39 @@ public class StoneInfo public string rename; } } + + [JsonObject] + public class ShuttleInfo + { + /// + /// The unique shuttle id + /// + public string id; + + /// + /// The location of this shuttle. + /// + public MVector3 position; + + /// + /// The rotation of this shuttle. + /// + public MVector3 rotation; + + /// + /// The relative path from the planet to the parent of this object. Optional (will default to the root sector). + /// + public string parentPath; + + /// + /// Whether the positional and rotational coordinates are relative to parent instead of the root planet object. + /// + public bool isRelativeToParent; + + /// + /// An optional rename of this object + /// + public string rename; + } } } \ No newline at end of file diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 4f74a5530..fcac259d1 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -288,6 +288,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) VolcanoBuilder.InitPrefab(); VolumesBuilder.InitPrefabs(); WaterBuilder.InitPrefabs(); + ShuttleBuilder.InitPrefab(); ProjectionBuilder.InitPrefabs(); CloakBuilder.InitPrefab(); From 32378ce7781c3aba0ca2ac6fd4fff4a0d2d29d62 Mon Sep 17 00:00:00 2001 From: Ben C Date: Mon, 21 Nov 2022 05:08:52 +0000 Subject: [PATCH 03/43] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index f84505df7..40f372693 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -989,6 +989,13 @@ "$ref": "#/definitions/SignalInfo" } }, + "shuttles": { + "type": "array", + "description": "Add shuttles to this planet", + "items": { + "$ref": "#/definitions/ShuttleInfo" + } + }, "remotes": { "type": "array", "description": "Add projection pools/platforms, whiteboards, and stones to this planet", @@ -1881,6 +1888,36 @@ } } }, + "ShuttleInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "description": "The unique shuttle id" + }, + "position": { + "description": "The location of this shuttle.", + "$ref": "#/definitions/MVector3" + }, + "rotation": { + "description": "The rotation of this shuttle.", + "$ref": "#/definitions/MVector3" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." + }, + "isRelativeToParent": { + "type": "boolean", + "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." + }, + "rename": { + "type": "string", + "description": "An optional rename of this object" + } + } + }, "RemoteInfo": { "type": "object", "additionalProperties": false, From 53474c63c3f7cc7fede200cc4e889cff440cf7d0 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 24 Nov 2022 18:58:49 -0500 Subject: [PATCH 04/43] check for NomaiObject --- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index f108edaac..b35b1f89d 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -716,6 +716,12 @@ internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObje XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlPath); XmlNode rootNode = xmlDocument.SelectSingleNode("NomaiObject"); + + if (rootNode == null) + { + Logger.LogError($"Couldn't find NomaiObject in [{xmlPath}]"); + return dict; + } foreach (object obj in rootNode.SelectNodes("TextBlock")) { From 44358865bf20ed41145d63cf93deebeb0a23b308 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 24 Nov 2022 18:59:11 -0500 Subject: [PATCH 05/43] Add gravity cannons --- NewHorizons/Assets/GravityCannonComputer.xml | 6 + .../Builder/Props/GravityCannonBuilder.cs | 92 ++++++++++++++++ NewHorizons/Builder/Props/PropBuildManager.cs | 14 +++ NewHorizons/External/Modules/PropModule.cs | 104 ++++++++++++++++++ NewHorizons/Main.cs | 1 + 5 files changed, 217 insertions(+) create mode 100644 NewHorizons/Assets/GravityCannonComputer.xml create mode 100644 NewHorizons/Builder/Props/GravityCannonBuilder.cs diff --git a/NewHorizons/Assets/GravityCannonComputer.xml b/NewHorizons/Assets/GravityCannonComputer.xml new file mode 100644 index 000000000..3c357b14e --- /dev/null +++ b/NewHorizons/Assets/GravityCannonComputer.xml @@ -0,0 +1,6 @@ + + + 1 + The shuttle]]> is currently resting at ???]]>. + + \ No newline at end of file diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs new file mode 100644 index 000000000..4201c6c6d --- /dev/null +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -0,0 +1,92 @@ +using NewHorizons.Components; +using NewHorizons.Components.Volumes; +using NewHorizons.External.Modules; +using NewHorizons.Handlers; +using NewHorizons.Utility; +using OWML.Common; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Builder.Props +{ + public static class GravityCannonBuilder + { + private static GameObject _prefab; + + internal static void InitPrefab() + { + if (_prefab == null) + { + var original = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_GravityCannonInterface"); + _prefab = original?.InstantiateInactive()?.Rename("Prefab_GravityCannon")?.DontDestroyOnLoad(); + _prefab.transform.position = original.transform.position; + _prefab.transform.rotation = original.transform.rotation; + var gravityCannonController = _prefab.GetComponent(); + gravityCannonController._shuttleID = NomaiShuttleController.ShuttleID.HourglassShuttle; + gravityCannonController._shuttleSocket = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_ShuttleSocket"), _prefab.transform, true).Rename("ShuttleSocket").transform; + gravityCannonController._warpEffect = gravityCannonController._shuttleSocket.GetComponentInChildren(); + gravityCannonController._recallProxyGeometry = gravityCannonController._shuttleSocket.gameObject.FindChild("ShuttleRecallProxy"); + gravityCannonController._forceVolume = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/CannonForceVolume"), _prefab.transform, true).Rename("ForceVolume").GetComponent(); + gravityCannonController._platformTrigger = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _prefab.transform, true).Rename("PlatformTrigger").GetComponent(); + gravityCannonController._nomaiComputer = null; + } + } + + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.GravityCannonInfo info, IModBehaviour mod) + { + InitPrefab(); + + if (_prefab == null || planetGO == null || sector == null) return null; + + var detailInfo = new PropModule.DetailInfo() + { + position = info.position, + rotation = info.rotation, + parentPath = info.parentPath, + isRelativeToParent = info.isRelativeToParent, + rename = info.rename + }; + var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); + gravityCannonObject.SetActive(false); + + StreamingHandler.SetUpStreaming(gravityCannonObject, sector); + + var gravityCannonController = gravityCannonObject.GetComponent(); + gravityCannonController._shuttleID = ShuttleHandler.GetShuttleID(info.shuttleID); + gravityCannonController._retrieveShipLogFact = info.retrieveReveal; + gravityCannonController._launchShipLogFact = info.launchReveal; + if (info.computer != null) + { + gravityCannonController._nomaiComputer = NomaiTextBuilder.Make(planetGO, sector, new PropModule.NomaiTextInfo + { + type = PropModule.NomaiTextInfo.NomaiTextType.Computer, + position = info.computer.position, + rotation = info.computer.rotation, + normal = info.computer.normal, + isRelativeToParent = info.computer.isRelativeToParent, + rename = info.computer.rename, + location = info.computer.location, + xmlFile = info.computer.xmlFile, + parentPath = info.computer.parentPath + }, mod).GetComponent(); + } + else + { + gravityCannonController._nomaiComputer = NomaiTextBuilder.Make(planetGO, sector, new PropModule.NomaiTextInfo + { + type = PropModule.NomaiTextInfo.NomaiTextType.Computer, + position = new MVector3(-2.556838f, -0.8018004f, 10.01348f), + rotation = new MVector3(8.293f, 2.403f, 0.9f), + isRelativeToParent = true, + rename = "Computer", + xmlFile = "Assets/GravityCannonComputer.xml", + parentPath = gravityCannonObject.transform.GetPath().Remove(0, planetGO.name.Length + 1) + }, Main.Instance).GetComponent(); + } + + gravityCannonObject.SetActive(true); + + return gravityCannonObject; + } + } +} diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index 7f7f54bbb..dbfc18eac 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -12,6 +12,20 @@ public static class PropBuildManager { public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, PlanetConfig config, IModBehaviour mod) { + if (config.Props.gravityCannons != null) + { + foreach (var gravityCannonInfo in config.Props.gravityCannons) + { + try + { + GravityCannonBuilder.Make(go, sector, gravityCannonInfo, mod); + } + catch (Exception ex) + { + Logger.LogError($"Couldn't make gravity cannon [{gravityCannonInfo.shuttleID}] for [{go.name}]:\n{ex}"); + } + } + } if (config.Props.shuttles != null) { foreach (var shuttleInfo in config.Props.shuttles) diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index df59a7ec8..48420d2ba 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -83,6 +83,11 @@ public class PropModule /// public SignalModule.SignalInfo[] signals; + /// + /// Add gravity cannons to this planet + /// + public GravityCannonInfo[] gravityCannons; + /// /// Add shuttles to this planet /// @@ -1039,5 +1044,104 @@ public class ShuttleInfo /// public string rename; } + + [JsonObject] + public class GravityCannonInfo + { + /// + /// The id of the shuttle to link this cannon to + /// + public string shuttleID; + + /// + /// Ship log fact revealed when retrieving the linked shuttle + /// + public string retrieveReveal; + + /// + /// Ship log fact revealed when launching the linked shuttle + /// + public string launchReveal; + + /// + /// The location of this gravity cannon. + /// + public MVector3 position; + + /// + /// The rotation of this gravity cannon. + /// + public MVector3 rotation; + + /// + /// The relative path from the planet to the parent of this object. Optional (will default to the root sector). + /// + public string parentPath; + + /// + /// Whether the positional and rotational coordinates are relative to parent instead of the root planet object. + /// + public bool isRelativeToParent; + + /// + /// An optional rename of this object + /// + public string rename; + + /// + /// + /// + public ComputerInfo computer; + + [JsonObject] + public class ComputerInfo + { + /// + /// The location of this computer. + /// + [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; + + /// + /// The relative path to the xml file for this computer. + /// + public string xmlFile; + + /// + /// The normal vector for this computer. Used for positioning. + /// + public MVector3 normal; + + /// + /// Position of the root of this computer + /// + public MVector3 position; + + /// + /// The euler angle rotation of this computer. Not required if setting the normal. Computers will orient + /// themselves to the surface of the planet automatically. + /// + public MVector3 rotation; + + /// + /// The relative path from the planet to the parent of this computer. Optional (will default to the root sector). + /// + public string parentPath; + + /// + /// Whether the positional and rotational coordinates are relative to parent instead of the root planet object. + /// + public bool isRelativeToParent; + + /// + /// An optional rename of this computer + /// + public string rename; + + /// + /// Whether to use the escape pod computers or not. + /// + public bool isPreCrash; + } + } } } \ No newline at end of file diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 958912612..1f4357751 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -288,6 +288,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) VolcanoBuilder.InitPrefab(); VolumesBuilder.InitPrefabs(); WaterBuilder.InitPrefabs(); + GravityCannonBuilder.InitPrefab(); ShuttleBuilder.InitPrefab(); ProjectionBuilder.InitPrefabs(); From a4fdff5c30c25684d08e34dca25a750b9167b6f8 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 25 Nov 2022 00:39:55 +0000 Subject: [PATCH 06/43] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 91 ++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 40f372693..e432d386f 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -989,6 +989,13 @@ "$ref": "#/definitions/SignalInfo" } }, + "gravityCannons": { + "type": "array", + "description": "Add gravity cannons to this planet", + "items": { + "$ref": "#/definitions/GravityCannonInfo" + } + }, "shuttles": { "type": "array", "description": "Add shuttles to this planet", @@ -1888,6 +1895,90 @@ } } }, + "GravityCannonInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "shuttleID": { + "type": "string", + "description": "The id of the shuttle to link this cannon to" + }, + "retrieveReveal": { + "type": "string", + "description": "Ship log fact revealed when retrieving the linked shuttle" + }, + "launchReveal": { + "type": "string", + "description": "Ship log fact revealed when launching the linked shuttle" + }, + "position": { + "description": "The location of this gravity cannon.", + "$ref": "#/definitions/MVector3" + }, + "rotation": { + "description": "The rotation of this gravity cannon.", + "$ref": "#/definitions/MVector3" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." + }, + "isRelativeToParent": { + "type": "boolean", + "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." + }, + "rename": { + "type": "string", + "description": "An optional rename of this object" + }, + "computer": { + "$ref": "#/definitions/ComputerInfo" + } + } + }, + "ComputerInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "location": { + "description": "The location of this computer. ", + "default": "unspecified", + "$ref": "#/definitions/NomaiTextLocation" + }, + "xmlFile": { + "type": "string", + "description": "The relative path to the xml file for this computer." + }, + "normal": { + "description": "The normal vector for this computer. Used for positioning.", + "$ref": "#/definitions/MVector3" + }, + "position": { + "description": "Position of the root of this computer", + "$ref": "#/definitions/MVector3" + }, + "rotation": { + "description": "The euler angle rotation of this computer. Not required if setting the normal. Computers will orient\nthemselves to the surface of the planet automatically.", + "$ref": "#/definitions/MVector3" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this computer. Optional (will default to the root sector)." + }, + "isRelativeToParent": { + "type": "boolean", + "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." + }, + "rename": { + "type": "string", + "description": "An optional rename of this computer" + }, + "isPreCrash": { + "type": "boolean", + "description": "Whether to use the escape pod computers or not." + } + } + }, "ShuttleInfo": { "type": "object", "additionalProperties": false, From ed66cb06650414e2c1bc540f540fd8f559fd01c4 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Jul 2023 12:04:02 -0400 Subject: [PATCH 07/43] Fix update from dev --- .../Builder/Props/GravityCannonBuilder.cs | 65 +++++++++---------- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 2 +- NewHorizons/Builder/Props/PropBuildManager.cs | 4 +- NewHorizons/Builder/Props/ShuttleBuilder.cs | 16 ++--- .../TranslatorText/TranslatorTextBuilder.cs | 8 +-- NewHorizons/Builder/Props/WarpPadBuilder.cs | 11 +++- NewHorizons/External/Modules/PropModule.cs | 11 ++++ .../Modules/Props/NomaiComputerInfo.cs | 23 +++++++ .../Props/Shuttle/GravityCannonInfo.cs | 33 ++++++++++ .../Modules/Props/Shuttle/ShuttleInfo.cs | 18 +++++ .../Modules/WarpPad/NomaiWarpComputerInfo.cs | 9 --- .../WarpPad/NomaiWarpPadReceiverInfo.cs | 3 +- NewHorizons/Handlers/ShuttleHandler.cs | 14 ++-- 13 files changed, 141 insertions(+), 76 deletions(-) create mode 100644 NewHorizons/External/Modules/Props/NomaiComputerInfo.cs create mode 100644 NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs create mode 100644 NewHorizons/External/Modules/Props/Shuttle/ShuttleInfo.cs delete mode 100644 NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 4201c6c6d..cc62756e6 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -1,11 +1,11 @@ -using NewHorizons.Components; -using NewHorizons.Components.Volumes; -using NewHorizons.External.Modules; +using NewHorizons.Builder.Props.TranslatorText; +using NewHorizons.External.Modules.Props; +using NewHorizons.External.Modules.Props.Shuttle; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWML; using OWML.Common; using UnityEngine; -using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Props { @@ -32,20 +32,13 @@ internal static void InitPrefab() } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.GravityCannonInfo info, IModBehaviour mod) + public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonInfo info, IModBehaviour mod) { InitPrefab(); if (_prefab == null || planetGO == null || sector == null) return null; - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; + var detailInfo = new DetailInfo(info); var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); gravityCannonObject.SetActive(false); @@ -55,38 +48,40 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Gra gravityCannonController._shuttleID = ShuttleHandler.GetShuttleID(info.shuttleID); gravityCannonController._retrieveShipLogFact = info.retrieveReveal; gravityCannonController._launchShipLogFact = info.launchReveal; + if (info.computer != null) { - gravityCannonController._nomaiComputer = NomaiTextBuilder.Make(planetGO, sector, new PropModule.NomaiTextInfo - { - type = PropModule.NomaiTextInfo.NomaiTextType.Computer, - position = info.computer.position, - rotation = info.computer.rotation, - normal = info.computer.normal, - isRelativeToParent = info.computer.isRelativeToParent, - rename = info.computer.rename, - location = info.computer.location, - xmlFile = info.computer.xmlFile, - parentPath = info.computer.parentPath - }, mod).GetComponent(); + gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer); } else { - gravityCannonController._nomaiComputer = NomaiTextBuilder.Make(planetGO, sector, new PropModule.NomaiTextInfo - { - type = PropModule.NomaiTextInfo.NomaiTextType.Computer, - position = new MVector3(-2.556838f, -0.8018004f, 10.01348f), - rotation = new MVector3(8.293f, 2.403f, 0.9f), - isRelativeToParent = true, - rename = "Computer", - xmlFile = "Assets/GravityCannonComputer.xml", - parentPath = gravityCannonObject.transform.GetPath().Remove(0, planetGO.name.Length + 1) - }, Main.Instance).GetComponent(); + gravityCannonController._nomaiComputer = null; } gravityCannonObject.SetActive(true); return gravityCannonObject; } + + private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, NomaiComputerInfo computerInfo) + { + var prefab = computerInfo.type switch + { + NomaiComputerType.NORMAL => TranslatorTextBuilder.ComputerPrefab, + NomaiComputerType.PRECRASH => TranslatorTextBuilder.PreCrashComputerPrefab, + _ => throw new System.NotImplementedException() + }; + + var computerObject = DetailBuilder.Make(planetGO, sector, prefab, new DetailInfo(computerInfo)); + + var computer = computerObject.GetComponentInChildren(); + computer.SetSector(sector); + + Delay.FireOnNextUpdate(computer.ClearAllEntries); + + computerObject.SetActive(true); + + return computer; + } } } diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 6dd557614..e70353651 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -747,7 +747,7 @@ internal static GameObject MakeArc(NomaiTextArcInfo arcInfo, GameObject conversa if (rootNode == null) { - Logger.LogError($"Couldn't find NomaiObject in [{xmlPath}]"); + NHLogger.LogError($"Couldn't find NomaiObject in [{xmlPath}]"); return dict; } diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index 8c6b1c4cd..af781f529 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -29,7 +29,7 @@ public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, Ne } catch (Exception ex) { - Logger.LogError($"Couldn't make gravity cannon [{gravityCannonInfo.shuttleID}] for [{go.name}]:\n{ex}"); + NHLogger.LogError($"Couldn't make gravity cannon [{gravityCannonInfo.shuttleID}] for [{go.name}]:\n{ex}"); } } } @@ -43,7 +43,7 @@ public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, Ne } catch (Exception ex) { - Logger.LogError($"Couldn't make shuttle [{shuttleInfo.id}] for [{go.name}]:\n{ex}"); + NHLogger.LogError($"Couldn't make shuttle [{shuttleInfo.id}] for [{go.name}]:\n{ex}"); } } } diff --git a/NewHorizons/Builder/Props/ShuttleBuilder.cs b/NewHorizons/Builder/Props/ShuttleBuilder.cs index 39adfba4b..cc0cde184 100644 --- a/NewHorizons/Builder/Props/ShuttleBuilder.cs +++ b/NewHorizons/Builder/Props/ShuttleBuilder.cs @@ -1,10 +1,9 @@ using NewHorizons.Components; -using NewHorizons.Components.Volumes; -using NewHorizons.External.Modules; +using NewHorizons.External.Modules.Props; +using NewHorizons.External.Modules.Props.Shuttle; using NewHorizons.Handlers; using NewHorizons.Utility; using UnityEngine; -using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Props { @@ -66,20 +65,13 @@ internal static void InitPrefab() } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.ShuttleInfo info) + public static GameObject Make(GameObject planetGO, Sector sector, ShuttleInfo info) { InitPrefab(); if (_prefab == null || planetGO == null || sector == null) return null; - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; + var detailInfo = new DetailInfo(info); var shuttleObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); shuttleObject.SetActive(false); diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 862257ed6..b189ee758 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -26,7 +26,7 @@ public static class TranslatorTextBuilder private static Material _childArcMaterial; private static GameObject _scrollPrefab; public static GameObject ComputerPrefab { get; private set; } - private static GameObject _preCrashComputerPrefab; + public static GameObject PreCrashComputerPrefab { get; private set; } private static GameObject _cairnBHPrefab; private static GameObject _cairnTHPrefab; private static GameObject _cairnCTPrefab; @@ -89,9 +89,9 @@ internal static void InitPrefabs() ComputerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive().Rename("Prefab_NOM_Computer").DontDestroyOnLoad(); } - if (_preCrashComputerPrefab == null) + if (PreCrashComputerPrefab == null) { - _preCrashComputerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/EscapePod_Socket/Interactibles_EscapePod/Prefab_NOM_Vessel_Computer").InstantiateInactive().Rename("Prefab_NOM_Vessel_Computer").DontDestroyOnLoad(); + PreCrashComputerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/EscapePod_Socket/Interactibles_EscapePod/Prefab_NOM_Vessel_Computer").InstantiateInactive().Rename("Prefab_NOM_Vessel_Computer").DontDestroyOnLoad(); } if (_cairnBHPrefab == null) @@ -238,7 +238,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, TranslatorText } case NomaiTextType.PreCrashComputer: { - var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, new DetailInfo(info)); + var computerObject = DetailBuilder.Make(planetGO, sector, PreCrashComputerPrefab, new DetailInfo(info)); computerObject.SetActive(false); var computer = computerObject.GetComponent(); diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index 41bf6ed6a..5cc6c5117 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -144,9 +144,16 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitter transmitterObject.SetActive(true); } - private static void CreateComputer(GameObject planetGO, Sector sector, NomaiWarpComputerLoggerInfo computerInfo, NomaiWarpReceiver receiver) + private static void CreateComputer(GameObject planetGO, Sector sector, NomaiComputerInfo computerInfo, NomaiWarpReceiver receiver) { - var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new DetailInfo(computerInfo)); + var prefab = computerInfo.type switch + { + NomaiComputerType.NORMAL => TranslatorTextBuilder.ComputerPrefab, + NomaiComputerType.PRECRASH => TranslatorTextBuilder.PreCrashComputerPrefab, + _ => throw new System.NotImplementedException() + }; + + var computerObject = DetailBuilder.Make(planetGO, sector, prefab, new DetailInfo(computerInfo)); var computer = computerObject.GetComponentInChildren(); computer.SetSector(sector); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index e6bc7d5eb..b77c2f68e 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -4,6 +4,7 @@ using NewHorizons.External.Modules.Props.EchoesOfTheEye; using NewHorizons.External.Modules.Props.Quantum; using NewHorizons.External.Modules.Props.Remote; +using NewHorizons.External.Modules.Props.Shuttle; using NewHorizons.External.Modules.TranslatorText; using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.Volumes.VolumeInfos; @@ -112,6 +113,16 @@ public class PropModule /// public AudioSourceInfo[] audioSources; + /// + /// Add a gravity cannon to this planet. Must be paired to a new shuttle, which can be placed on this planet or elsewhere. + /// + public GravityCannonInfo[] gravityCannons; + + /// + /// Add a Nomai shuttle to this planet. Can be paired to a gravity cannon on this planet or elsewhere. + /// + public ShuttleInfo[] shuttles; + [Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public RevealVolumeInfo[] reveal; [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public AudioVolumeInfo[] audioVolumes; diff --git a/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs b/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs new file mode 100644 index 000000000..90b58c348 --- /dev/null +++ b/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Modules.Props +{ + [JsonObject] + public class NomaiComputerInfo : GeneralPropInfo + { + /// + /// What design the computer will use. + /// + [DefaultValue(NomaiComputerType.NORMAL)] public NomaiComputerType type = NomaiComputerType.NORMAL; + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiComputerType + { + [EnumMember(Value = @"normal")] NORMAL = 0, + [EnumMember(Value = @"precrash")] PRECRASH = 1 + } +} diff --git a/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs b/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs new file mode 100644 index 000000000..7f6a3b84b --- /dev/null +++ b/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs @@ -0,0 +1,33 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.External.Modules.Props.Shuttle +{ + [JsonObject] + public class GravityCannonInfo : GeneralPropInfo + { + /// + /// Unique ID for the shuttle that pairs with this gravity cannon + /// + public string shuttleID; + + /// + /// Ship log fact revealed when retrieving the shuttle to this pad. Optional. + /// + public string retrieveReveal; + + /// + /// Ship log fact revealed when launching from this pad. Optional. + /// + public string launchReveal; + + /// + /// Will create a modern Nomai computer linked to this gravity cannon. + /// + public NomaiComputerInfo computer; + } +} diff --git a/NewHorizons/External/Modules/Props/Shuttle/ShuttleInfo.cs b/NewHorizons/External/Modules/Props/Shuttle/ShuttleInfo.cs new file mode 100644 index 000000000..8bf959c1f --- /dev/null +++ b/NewHorizons/External/Modules/Props/Shuttle/ShuttleInfo.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.External.Modules.Props.Shuttle +{ + [JsonObject] + public class ShuttleInfo : GeneralPropInfo + { + /// + /// Unique ID for this shuttle + /// + public string id; + } +} diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs deleted file mode 100644 index bd2bb6d75..000000000 --- a/NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Newtonsoft.Json; - -namespace NewHorizons.External.Modules.WarpPad -{ - [JsonObject] - public class NomaiWarpComputerLoggerInfo : GeneralPropInfo - { - } -} diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs index 6680284c1..05b0b20aa 100644 --- a/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs @@ -1,3 +1,4 @@ +using NewHorizons.External.Modules.Props; using Newtonsoft.Json; namespace NewHorizons.External.Modules.WarpPad @@ -14,7 +15,7 @@ public class NomaiWarpReceiverInfo : NomaiWarpPadInfo /// /// Will create a modern Nomai computer linked to this receiver. /// - public NomaiWarpComputerLoggerInfo computer; + public NomaiComputerInfo computer; /// /// Set to true if you want to include Nomai ruin details around the warp pad. diff --git a/NewHorizons/Handlers/ShuttleHandler.cs b/NewHorizons/Handlers/ShuttleHandler.cs index e728851d2..60f4493fc 100644 --- a/NewHorizons/Handlers/ShuttleHandler.cs +++ b/NewHorizons/Handlers/ShuttleHandler.cs @@ -1,11 +1,6 @@ -using NewHorizons.Utility; -using OWML.Common; +using NewHorizons.Utility.OWML; using OWML.Utils; using System; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Handlers { @@ -15,8 +10,7 @@ public static NomaiShuttleController.ShuttleID GetShuttleID(string id) { try { - NomaiShuttleController.ShuttleID shuttleID; - if (EnumUtils.TryParse(id, out shuttleID)) + if (EnumUtils.TryParse(id, out NomaiShuttleController.ShuttleID shuttleID)) { return shuttleID; } @@ -27,14 +21,14 @@ public static NomaiShuttleController.ShuttleID GetShuttleID(string id) } catch (Exception e) { - Logger.LogError($"Couldn't load shuttle id [{id}]:\n{e}"); + NHLogger.LogError($"Couldn't load shuttle id [{id}]:\n{e}"); return EnumUtils.FromObject(-1); } } public static NomaiShuttleController.ShuttleID AddCustomShuttleID(string id) { - Logger.LogVerbose($"Registering new shuttle id [{id}]"); + NHLogger.LogVerbose($"Registering new shuttle id [{id}]"); return EnumUtilities.Create(id); } From e809a7b4f0239c7a400a8e321f7745fdf6310b32 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 22 Jul 2023 16:06:48 +0000 Subject: [PATCH 08/43] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 249 +++++++++++++-------------- 1 file changed, 119 insertions(+), 130 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index ce47f6e85..fee1f373a 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1211,20 +1211,6 @@ "$ref": "#/definitions/SignalInfo" } }, - "gravityCannons": { - "type": "array", - "description": "Add gravity cannons to this planet", - "items": { - "$ref": "#/definitions/GravityCannonInfo" - } - }, - "shuttles": { - "type": "array", - "description": "Add shuttles to this planet", - "items": { - "$ref": "#/definitions/ShuttleInfo" - } - }, "remotes": { "type": "array", "description": "Add projection pools/platforms, whiteboards, and stones to this planet", @@ -1252,6 +1238,20 @@ "items": { "$ref": "#/definitions/AudioSourceInfo" } + }, + "gravityCannons": { + "type": "array", + "description": "Add a gravity cannon to this planet. Must be paired to a new shuttle, which can be placed on this planet or elsewhere.", + "items": { + "$ref": "#/definitions/GravityCannonInfo" + } + }, + "shuttles": { + "type": "array", + "description": "Add a Nomai shuttle to this planet. Can be paired to a gravity cannon on this planet or elsewhere.", + "items": { + "$ref": "#/definitions/ShuttleInfo" + } } } }, @@ -2482,120 +2482,6 @@ } } }, - "GravityCannonInfo": { - "type": "object", - "additionalProperties": false, - "properties": { - "shuttleID": { - "type": "string", - "description": "The id of the shuttle to link this cannon to" - }, - "retrieveReveal": { - "type": "string", - "description": "Ship log fact revealed when retrieving the linked shuttle" - }, - "launchReveal": { - "type": "string", - "description": "Ship log fact revealed when launching the linked shuttle" - }, - "position": { - "description": "The location of this gravity cannon.", - "$ref": "#/definitions/MVector3" - }, - "rotation": { - "description": "The rotation of this gravity cannon.", - "$ref": "#/definitions/MVector3" - }, - "parentPath": { - "type": "string", - "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." - }, - "isRelativeToParent": { - "type": "boolean", - "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." - }, - "rename": { - "type": "string", - "description": "An optional rename of this object" - }, - "computer": { - "$ref": "#/definitions/ComputerInfo" - } - } - }, - "ComputerInfo": { - "type": "object", - "additionalProperties": false, - "properties": { - "location": { - "description": "The location of this computer. ", - "default": "unspecified", - "$ref": "#/definitions/NomaiTextLocation" - }, - "xmlFile": { - "type": "string", - "description": "The relative path to the xml file for this computer." - }, - "normal": { - "description": "The normal vector for this computer. Used for positioning.", - "$ref": "#/definitions/MVector3" - }, - "position": { - "description": "Position of the root of this computer", - "$ref": "#/definitions/MVector3" - }, - "rotation": { - "description": "The euler angle rotation of this computer. Not required if setting the normal. Computers will orient\nthemselves to the surface of the planet automatically.", - "$ref": "#/definitions/MVector3" - }, - "parentPath": { - "type": "string", - "description": "The relative path from the planet to the parent of this computer. Optional (will default to the root sector)." - }, - "isRelativeToParent": { - "type": "boolean", - "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." - }, - "rename": { - "type": "string", - "description": "An optional rename of this computer" - }, - "isPreCrash": { - "type": "boolean", - "description": "Whether to use the escape pod computers or not." - } - } - }, - "ShuttleInfo": { - "type": "object", - "additionalProperties": false, - "properties": { - "id": { - "type": "string", - "description": "The unique shuttle id" - }, - "position": { - "description": "The location of this shuttle.", - "$ref": "#/definitions/MVector3" - }, - "rotation": { - "description": "The rotation of this shuttle.", - "$ref": "#/definitions/MVector3" - }, - "parentPath": { - "type": "string", - "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." - }, - "isRelativeToParent": { - "type": "boolean", - "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." - }, - "rename": { - "type": "string", - "description": "An optional rename of this object" - } - } - }, "RemoteInfo": { "type": "object", "additionalProperties": false, @@ -2824,7 +2710,7 @@ }, "computer": { "description": "Will create a modern Nomai computer linked to this receiver.", - "$ref": "#/definitions/NomaiWarpComputerLoggerInfo" + "$ref": "#/definitions/NomaiComputerInfo" }, "detailed": { "type": "boolean", @@ -2832,7 +2718,7 @@ } } }, - "NomaiWarpComputerLoggerInfo": { + "NomaiComputerInfo": { "type": "object", "additionalProperties": false, "properties": { @@ -2862,9 +2748,26 @@ "rename": { "type": "string", "description": "An optional rename of this object" + }, + "type": { + "description": "What design the computer will use.", + "default": "NORMAL", + "$ref": "#/definitions/NomaiComputerType" } } }, + "NomaiComputerType": { + "type": "string", + "description": "", + "x-enumNames": [ + "NORMAL", + "PRECRASH" + ], + "enum": [ + "normal", + "precrash" + ] + }, "NomaiWarpTransmitterInfo": { "type": "object", "additionalProperties": false, @@ -3000,6 +2903,92 @@ "slideReelMusic" ] }, + "GravityCannonInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "rotation": { + "description": "Rotation of the object", + "$ref": "#/definitions/MVector3" + }, + "alignRadial": { + "type": [ + "boolean", + "null" + ], + "description": "Do we try to automatically align this object to stand upright relative to the body's center? Stacks with rotation.\nDefaults to true for geysers, tornados, and volcanoes, and false for everything else." + }, + "position": { + "description": "Position of the object", + "$ref": "#/definitions/MVector3" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." + }, + "isRelativeToParent": { + "type": "boolean", + "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." + }, + "rename": { + "type": "string", + "description": "An optional rename of this object" + }, + "shuttleID": { + "type": "string", + "description": "Unique ID for the shuttle that pairs with this gravity cannon" + }, + "retrieveReveal": { + "type": "string", + "description": "Ship log fact revealed when retrieving the shuttle to this pad. Optional." + }, + "launchReveal": { + "type": "string", + "description": "Ship log fact revealed when launching from this pad. Optional." + }, + "computer": { + "description": "Will create a modern Nomai computer linked to this gravity cannon.", + "$ref": "#/definitions/NomaiComputerInfo" + } + } + }, + "ShuttleInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "rotation": { + "description": "Rotation of the object", + "$ref": "#/definitions/MVector3" + }, + "alignRadial": { + "type": [ + "boolean", + "null" + ], + "description": "Do we try to automatically align this object to stand upright relative to the body's center? Stacks with rotation.\nDefaults to true for geysers, tornados, and volcanoes, and false for everything else." + }, + "position": { + "description": "Position of the object", + "$ref": "#/definitions/MVector3" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." + }, + "isRelativeToParent": { + "type": "boolean", + "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." + }, + "rename": { + "type": "string", + "description": "An optional rename of this object" + }, + "id": { + "type": "string", + "description": "Unique ID for this shuttle" + } + } + }, "ReferenceFrameModule": { "type": "object", "additionalProperties": false, From 1f68a122966d6f9c7a82e7ee0c708d44bd6f74a4 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Jul 2023 12:18:25 -0400 Subject: [PATCH 09/43] Can't use vessel computers --- NewHorizons/Builder/Props/GravityCannonBuilder.cs | 12 +++--------- NewHorizons/Builder/Props/WarpPadBuilder.cs | 12 +++--------- .../External/Modules/Props/NomaiComputerInfo.cs | 14 -------------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index cc62756e6..271c9699b 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.Builder.Props.TranslatorText; +using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props.Shuttle; using NewHorizons.Handlers; @@ -63,16 +64,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI return gravityCannonObject; } - private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, NomaiComputerInfo computerInfo) + private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, GeneralPropInfo computerInfo) { - var prefab = computerInfo.type switch - { - NomaiComputerType.NORMAL => TranslatorTextBuilder.ComputerPrefab, - NomaiComputerType.PRECRASH => TranslatorTextBuilder.PreCrashComputerPrefab, - _ => throw new System.NotImplementedException() - }; - - var computerObject = DetailBuilder.Make(planetGO, sector, prefab, new DetailInfo(computerInfo)); + var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new DetailInfo(computerInfo)); var computer = computerObject.GetComponentInChildren(); computer.SetSector(sector); diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index 5cc6c5117..4c5a9ae8b 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.Components; +using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.WarpPad; using NewHorizons.Utility; @@ -144,16 +145,9 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitter transmitterObject.SetActive(true); } - private static void CreateComputer(GameObject planetGO, Sector sector, NomaiComputerInfo computerInfo, NomaiWarpReceiver receiver) + private static void CreateComputer(GameObject planetGO, Sector sector, GeneralPropInfo computerInfo, NomaiWarpReceiver receiver) { - var prefab = computerInfo.type switch - { - NomaiComputerType.NORMAL => TranslatorTextBuilder.ComputerPrefab, - NomaiComputerType.PRECRASH => TranslatorTextBuilder.PreCrashComputerPrefab, - _ => throw new System.NotImplementedException() - }; - - var computerObject = DetailBuilder.Make(planetGO, sector, prefab, new DetailInfo(computerInfo)); + var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new DetailInfo(computerInfo)); var computer = computerObject.GetComponentInChildren(); computer.SetSector(sector); diff --git a/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs b/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs index 90b58c348..6b17b0323 100644 --- a/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs +++ b/NewHorizons/External/Modules/Props/NomaiComputerInfo.cs @@ -1,23 +1,9 @@ using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; namespace NewHorizons.External.Modules.Props { [JsonObject] public class NomaiComputerInfo : GeneralPropInfo { - /// - /// What design the computer will use. - /// - [DefaultValue(NomaiComputerType.NORMAL)] public NomaiComputerType type = NomaiComputerType.NORMAL; - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiComputerType - { - [EnumMember(Value = @"normal")] NORMAL = 0, - [EnumMember(Value = @"precrash")] PRECRASH = 1 } } From cd774016b3fa9b40b4915e826156a7044c7a7130 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 22 Jul 2023 16:20:41 +0000 Subject: [PATCH 10/43] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index fee1f373a..07db879d2 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2748,26 +2748,9 @@ "rename": { "type": "string", "description": "An optional rename of this object" - }, - "type": { - "description": "What design the computer will use.", - "default": "NORMAL", - "$ref": "#/definitions/NomaiComputerType" } } }, - "NomaiComputerType": { - "type": "string", - "description": "", - "x-enumNames": [ - "NORMAL", - "PRECRASH" - ], - "enum": [ - "normal", - "precrash" - ] - }, "NomaiWarpTransmitterInfo": { "type": "object", "additionalProperties": false, From 615fe2f47c7aa1cedd1dd2a1f6d6ea298fcc4304 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Jul 2023 12:29:54 -0400 Subject: [PATCH 11/43] Keep shuttles/cannons loaded, fix cannon fact NRE --- NewHorizons/Builder/Props/GravityCannonBuilder.cs | 10 +++++----- NewHorizons/Builder/Props/ShuttleBuilder.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 271c9699b..ea88c56e4 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -39,16 +39,16 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI if (_prefab == null || planetGO == null || sector == null) return null; - var detailInfo = new DetailInfo(info); + var detailInfo = new DetailInfo(info) { keepLoaded = true }; var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); gravityCannonObject.SetActive(false); - StreamingHandler.SetUpStreaming(gravityCannonObject, sector); - var gravityCannonController = gravityCannonObject.GetComponent(); gravityCannonController._shuttleID = ShuttleHandler.GetShuttleID(info.shuttleID); - gravityCannonController._retrieveShipLogFact = info.retrieveReveal; - gravityCannonController._launchShipLogFact = info.launchReveal; + + // Gravity controller checks string length instead of isnullorempty + gravityCannonController._retrieveShipLogFact = info.retrieveReveal ?? string.Empty; + gravityCannonController._launchShipLogFact = info.launchReveal ?? string.Empty; if (info.computer != null) { diff --git a/NewHorizons/Builder/Props/ShuttleBuilder.cs b/NewHorizons/Builder/Props/ShuttleBuilder.cs index cc0cde184..8ea32716f 100644 --- a/NewHorizons/Builder/Props/ShuttleBuilder.cs +++ b/NewHorizons/Builder/Props/ShuttleBuilder.cs @@ -71,7 +71,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, ShuttleInfo in if (_prefab == null || planetGO == null || sector == null) return null; - var detailInfo = new DetailInfo(info); + var detailInfo = new DetailInfo(info) { keepLoaded = true }; var shuttleObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); shuttleObject.SetActive(false); From 56c463fbee337baaa3eecfbe546baa2ebbd6e0eb Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Jul 2023 13:57:37 -0400 Subject: [PATCH 12/43] Fix gravity cannon orb --- .../Builder/Props/GravityCannonBuilder.cs | 52 +++++++++++++++++++ NewHorizons/Main.cs | 2 +- NewHorizons/Utility/OWML/Delay.cs | 17 +++++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index ea88c56e4..3ccb0ada0 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -6,13 +6,16 @@ using NewHorizons.Utility; using NewHorizons.Utility.OWML; using OWML.Common; +using System; using UnityEngine; +using UnityEngine.InputSystem.XR; namespace NewHorizons.Builder.Props { public static class GravityCannonBuilder { private static GameObject _prefab; + private static GameObject _orb; internal static void InitPrefab() { @@ -31,6 +34,13 @@ internal static void InitPrefab() gravityCannonController._platformTrigger = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _prefab.transform, true).Rename("PlatformTrigger").GetComponent(); gravityCannonController._nomaiComputer = null; } + if (_orb == null) + { + _orb = SearchUtilities.Find("Prefab_NOM_InterfaceOrb") + .InstantiateInactive() + .Rename("Prefab_NOM_InterfaceOrb") + .DontDestroyOnLoad(); + } } public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonInfo info, IModBehaviour mod) @@ -59,11 +69,53 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI gravityCannonController._nomaiComputer = null; } + CreateOrb(planetGO, gravityCannonController); + gravityCannonObject.SetActive(true); return gravityCannonObject; } + private static void CreateOrb(GameObject planetGO, GravityCannonController gravityCannonController) + { + var orb = _orb.InstantiateInactive().Rename(_orb.name); + orb.transform.parent = gravityCannonController.transform; + orb.transform.localPosition = new Vector3(0f, 0.9673f, 0f); + orb.transform.localScale = Vector3.one; + orb.SetActive(true); + + var planetBody = planetGO.GetComponent(); + var orbBody = orb.GetComponent(); + + var nomaiInterfaceOrb = orb.GetComponent(); + nomaiInterfaceOrb._orbBody = orbBody; + nomaiInterfaceOrb._slotRoot = gravityCannonController.gameObject; + orbBody._origParent = planetGO.transform; + orbBody._origParentBody = planetBody; + nomaiInterfaceOrb._slots = nomaiInterfaceOrb._slotRoot.GetComponentsInChildren(); + nomaiInterfaceOrb.SetParentBody(planetBody); + nomaiInterfaceOrb._safetyRails = new OWRail[0]; + nomaiInterfaceOrb.RemoveAllLocks(); + + var spawnVelocity = planetBody.GetVelocity(); + var spawnAngularVelocity = planetBody.GetPointTangentialVelocity(orbBody.transform.position); + var velocity = spawnVelocity + spawnAngularVelocity; + + orbBody._lastVelocity = velocity; + orbBody._currentVelocity = velocity; + + orb.GetComponent()._detectableFields = new ForceVolume[] { planetGO.GetComponentInChildren() }; + + Delay.RunWhenAndInNUpdates(() => + { + foreach (var component in orb.GetComponents()) + { + component.enabled = true; + } + nomaiInterfaceOrb.RemoveAllLocks(); + }, () => Main.IsSystemReady, 10); + } + private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, GeneralPropInfo computerInfo) { var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new DetailInfo(computerInfo)); diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 2a0c59141..93c1cbcda 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -548,7 +548,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) } // Wait for player to be awake and also for frames to pass - Delay.RunWhenAndInNUpdates(() => OnSystemReady(DidWarpFromShip, DidWarpFromVessel), () => _playerAwake && PlayerSpawned, 30); + Delay.RunWhenOrInNUpdates(() => OnSystemReady(DidWarpFromShip, DidWarpFromVessel), () => _playerAwake && PlayerSpawned, 30); } else { diff --git a/NewHorizons/Utility/OWML/Delay.cs b/NewHorizons/Utility/OWML/Delay.cs index e25dc9287..ea400a651 100644 --- a/NewHorizons/Utility/OWML/Delay.cs +++ b/NewHorizons/Utility/OWML/Delay.cs @@ -22,7 +22,8 @@ public static class Delay public static void FireOnNextUpdate(Action action) => FireInNUpdates(action, 1); - public static void RunWhenAndInNUpdates(Action action, Func predicate, int n) => Delay.StartCoroutine(RunWhenOrInNUpdatesCoroutine(action, predicate, n)); + public static void RunWhenOrInNUpdates(Action action, Func predicate, int n) => Delay.StartCoroutine(RunWhenOrInNUpdatesCoroutine(action, predicate, n)); + public static void RunWhenAndInNUpdates(Action action, Func predicate, int n) => Delay.StartCoroutine(RunWhenAndInNUpdatesCoroutine(action, predicate, n)); #endregion #region Coroutines @@ -58,6 +59,20 @@ private static IEnumerator RunWhenOrInNUpdatesCoroutine(Action action, Func predicate, int n) + { + while (!predicate.Invoke()) + { + yield return new WaitForEndOfFrame(); + } + for (int i = 0; i < n; i++) + { + yield return new WaitForEndOfFrame(); + } + + action.Invoke(); + } #endregion } } From e4c8b14f6fbaf9736a459e4cd3bc0bb255e92b23 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Jul 2023 14:41:01 -0400 Subject: [PATCH 13/43] Add in the platform, allow separately placing the cannon and the controls --- .../Builder/Props/GravityCannonBuilder.cs | 71 +++++++++++++------ .../External/Modules/GeneralPropInfo.cs | 2 +- .../Props/Shuttle/GravityCannonInfo.cs | 7 ++ 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 3ccb0ada0..39ae8bdfe 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -6,37 +6,47 @@ using NewHorizons.Utility; using NewHorizons.Utility.OWML; using OWML.Common; -using System; using UnityEngine; -using UnityEngine.InputSystem.XR; namespace NewHorizons.Builder.Props { public static class GravityCannonBuilder { - private static GameObject _prefab; - private static GameObject _orb; + private static GameObject _interfacePrefab; + private static GameObject _platformPrefab; + private static GameObject _orbPrefab; internal static void InitPrefab() { - if (_prefab == null) + if (_interfacePrefab == null) { - var original = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_GravityCannonInterface"); - _prefab = original?.InstantiateInactive()?.Rename("Prefab_GravityCannon")?.DontDestroyOnLoad(); - _prefab.transform.position = original.transform.position; - _prefab.transform.rotation = original.transform.rotation; - var gravityCannonController = _prefab.GetComponent(); - gravityCannonController._shuttleID = NomaiShuttleController.ShuttleID.HourglassShuttle; - gravityCannonController._shuttleSocket = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_ShuttleSocket"), _prefab.transform, true).Rename("ShuttleSocket").transform; - gravityCannonController._warpEffect = gravityCannonController._shuttleSocket.GetComponentInChildren(); - gravityCannonController._recallProxyGeometry = gravityCannonController._shuttleSocket.gameObject.FindChild("ShuttleRecallProxy"); - gravityCannonController._forceVolume = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/CannonForceVolume"), _prefab.transform, true).Rename("ForceVolume").GetComponent(); - gravityCannonController._platformTrigger = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _prefab.transform, true).Rename("PlatformTrigger").GetComponent(); - gravityCannonController._nomaiComputer = null; + _interfacePrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_GravityCannonInterface") + .InstantiateInactive() + .Rename("Prefab_GravityCannon") + .DontDestroyOnLoad(); + } + if (_platformPrefab == null) + { + // Creating it in the original position so we can instantiate the other parts in the right relative positions + var original = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Geometry_GravityCannon/ControlledByProxy_OPC/Structure_NOM_GravityCannon_BH"); + _platformPrefab = original + .InstantiateInactive() + .Rename("Prefab_GravityCannonPlatform") + .DontDestroyOnLoad(); + _platformPrefab.transform.position = original.transform.position; + _platformPrefab.transform.rotation = original.transform.rotation; + + GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_ShuttleSocket"), _platformPrefab.transform, true) + .Rename("ShuttleSocket"); + GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/CannonForceVolume"), _platformPrefab.transform, true) + .Rename("ForceVolume"); + GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _platformPrefab.transform, true) + .Rename("PlatformTrigger"); } - if (_orb == null) + + if (_orbPrefab == null) { - _orb = SearchUtilities.Find("Prefab_NOM_InterfaceOrb") + _orbPrefab = SearchUtilities.Find("Prefab_NOM_InterfaceOrb") .InstantiateInactive() .Rename("Prefab_NOM_InterfaceOrb") .DontDestroyOnLoad(); @@ -47,10 +57,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI { InitPrefab(); - if (_prefab == null || planetGO == null || sector == null) return null; + if (_interfacePrefab == null || planetGO == null || sector == null || _platformPrefab == null || _orbPrefab == null) return null; - var detailInfo = new DetailInfo(info) { keepLoaded = true }; - var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); + var detailInfo = new DetailInfo(info.controls) { keepLoaded = true }; + var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _interfacePrefab, detailInfo); gravityCannonObject.SetActive(false); var gravityCannonController = gravityCannonObject.GetComponent(); @@ -60,6 +70,8 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI gravityCannonController._retrieveShipLogFact = info.retrieveReveal ?? string.Empty; gravityCannonController._launchShipLogFact = info.launchReveal ?? string.Empty; + CreatePlatform(planetGO, sector, gravityCannonController, info); + if (info.computer != null) { gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer); @@ -78,7 +90,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI private static void CreateOrb(GameObject planetGO, GravityCannonController gravityCannonController) { - var orb = _orb.InstantiateInactive().Rename(_orb.name); + var orb = _orbPrefab.InstantiateInactive().Rename(_orbPrefab.name); orb.transform.parent = gravityCannonController.transform; orb.transform.localPosition = new Vector3(0f, 0.9673f, 0f); orb.transform.localScale = Vector3.one; @@ -129,5 +141,18 @@ private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, return computer; } + + private static GameObject CreatePlatform(GameObject planetGO, Sector sector, GravityCannonController gravityCannonController, GeneralPropInfo platformInfo) + { + var platform = DetailBuilder.Make(planetGO, sector, _platformPrefab, new DetailInfo(platformInfo) { keepLoaded = true }); + + gravityCannonController._forceVolume = platform.FindChild("ForceVolume").GetComponent(); + gravityCannonController._platformTrigger = platform.FindChild("PlatformTrigger").GetComponent(); + gravityCannonController._shuttleSocket = platform.FindChild("ShuttleSocket").transform; + gravityCannonController._warpEffect = gravityCannonController._shuttleSocket.GetComponentInChildren(); + gravityCannonController._recallProxyGeometry = gravityCannonController._shuttleSocket.gameObject.FindChild("ShuttleRecallProxy"); + + return platform; + } } } diff --git a/NewHorizons/External/Modules/GeneralPropInfo.cs b/NewHorizons/External/Modules/GeneralPropInfo.cs index 5b4d9b02e..fc855f9af 100644 --- a/NewHorizons/External/Modules/GeneralPropInfo.cs +++ b/NewHorizons/External/Modules/GeneralPropInfo.cs @@ -29,7 +29,7 @@ public abstract class GeneralPointPropInfo } [JsonObject] - public abstract class GeneralPropInfo : GeneralPointPropInfo + public class GeneralPropInfo : GeneralPointPropInfo { /// /// Rotation of the object diff --git a/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs b/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs index 7f6a3b84b..1e296f602 100644 --- a/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs +++ b/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs @@ -1,7 +1,9 @@ using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -29,5 +31,10 @@ public class GravityCannonInfo : GeneralPropInfo /// Will create a modern Nomai computer linked to this gravity cannon. /// public NomaiComputerInfo computer; + + /// + /// Position of the interface used to launc the shuttle + /// + public GeneralPropInfo controls; } } From 8f394fd458140c160a7178ca4177afbc0949039f Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 22 Jul 2023 18:43:04 +0000 Subject: [PATCH 14/43] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 07db879d2..ac0f2c7d5 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2932,6 +2932,43 @@ "computer": { "description": "Will create a modern Nomai computer linked to this gravity cannon.", "$ref": "#/definitions/NomaiComputerInfo" + }, + "controls": { + "description": "Position of the interface used to launc the shuttle", + "$ref": "#/definitions/GeneralPropInfo" + } + } + }, + "GeneralPropInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "position": { + "description": "Position of the object", + "$ref": "#/definitions/MVector3" + }, + "parentPath": { + "type": "string", + "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." + }, + "isRelativeToParent": { + "type": "boolean", + "description": "Whether the positional and rotational coordinates are relative to parent instead of the root planet object." + }, + "rename": { + "type": "string", + "description": "An optional rename of this object" + }, + "rotation": { + "description": "Rotation of the object", + "$ref": "#/definitions/MVector3" + }, + "alignRadial": { + "type": [ + "boolean", + "null" + ], + "description": "Do we try to automatically align this object to stand upright relative to the body's center? Stacks with rotation.\nDefaults to true for geysers, tornados, and volcanoes, and false for everything else." } } }, From fc903b4117b36fe5981824e958a2932a448da164 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 2 Aug 2023 23:21:24 -0400 Subject: [PATCH 15/43] Make setting default system less garbage --- NewHorizons/Main.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 499c2468a..092c0284b 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -121,7 +121,7 @@ public override void Configure(IModConfig config) // Else it doesn't get set idk if (currentScene == "TitleScreen" && SystemDict.ContainsKey(_defaultSystemOverride)) { - _currentStarSystem = _defaultSystemOverride; + _currentStarSystem = string.IsNullOrEmpty(_defaultSystemOverride) ? "SolarSystem" : _defaultSystemOverride; } var wasUsingCustomTitleScreen = _useCustomTitleScreen; @@ -811,7 +811,14 @@ public NewHorizonsBody RegisterPlanetConfig(PlanetConfig config, IModBehaviour m public void SetDefaultSystem(string defaultSystem) { - _defaultStarSystem = defaultSystem; + if (string.IsNullOrEmpty(defaultSystem)) + { + _defaultStarSystem = "SolarSystem"; + } + else + { + _defaultStarSystem = defaultSystem; + } } #endregion Load From 61d9947d8e4dcc9191e44f01fda59a970e373c8f Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 2 Aug 2023 23:25:32 -0400 Subject: [PATCH 16/43] Let center of the universe be deactivated when it needs to be --- NewHorizons/Components/PreserveActiveCenterOfTheUniverse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Components/PreserveActiveCenterOfTheUniverse.cs b/NewHorizons/Components/PreserveActiveCenterOfTheUniverse.cs index 0e8cd3c01..a6d658ea8 100644 --- a/NewHorizons/Components/PreserveActiveCenterOfTheUniverse.cs +++ b/NewHorizons/Components/PreserveActiveCenterOfTheUniverse.cs @@ -16,9 +16,9 @@ public static void Apply(GameObject center) public void Update() { - if (!_centerOfTheUniverse.activeInHierarchy) + if (!_centerOfTheUniverse.activeInHierarchy && !CenterOfTheUniverse.IsUniverseDeactivated()) { - NHLogger.LogWarning("Center of the universe cannot be inactive."); + NHLogger.LogWarning("Center of the universe cannot be inactive until the universe is deactivated."); _centerOfTheUniverse.SetActive(true); } } From 331211cb4f70c1a44e82ab42f5a59b98b372914c Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 20:37:58 -0400 Subject: [PATCH 17/43] Remove unnecessary null or empty check --- NewHorizons/Main.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 092c0284b..e5801dc54 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -121,7 +121,7 @@ public override void Configure(IModConfig config) // Else it doesn't get set idk if (currentScene == "TitleScreen" && SystemDict.ContainsKey(_defaultSystemOverride)) { - _currentStarSystem = string.IsNullOrEmpty(_defaultSystemOverride) ? "SolarSystem" : _defaultSystemOverride; + _currentStarSystem = _defaultSystemOverride; } var wasUsingCustomTitleScreen = _useCustomTitleScreen; From fba6b1ea366d4a5196fb43cacc139e1fb616bf9e Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 20:49:13 -0400 Subject: [PATCH 18/43] Delete entire solar system using cool EOTS method thanks John --- .../Handlers/PlanetDestructionHandler.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index a5f7add75..9fa47805e 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -55,19 +55,22 @@ public static void RemoveStockPlanets() public static void RemoveSolarSystem() { // Stop the sun from killing the player if they spawn at the center of the solar system - var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN"); - sunVolumes.SetActive(false); + SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN").SetActive(false); - // Random shit breaks if we don't wait idk why - foreach (var name in _solarSystemBodies) + Delay.FireInNUpdates(() => { - var ao = AstroObjectLocator.GetAstroObject(name); - if (ao != null) Delay.FireInNUpdates(() => RemoveBody(ao, false), 2); - else NHLogger.LogError($"Couldn't find [{name}]"); - } - - // Bring the sun back - Delay.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 3); + // From EOTS thanks corby + foreach (var rigidbody in CenterOfTheUniverse.s_rigidbodies) + if (rigidbody.name is not "Player_Body" or "Ship_Body") + rigidbody.gameObject.SetActive(false); + + foreach (var proxyBody in GameObject.FindObjectsOfType()) + proxyBody.gameObject.SetActive(false); + GameObject.FindObjectOfType().gameObject.SetActive(false); + + foreach (var streamingAssetBundle in StreamingManager.s_activeBundles) + streamingAssetBundle.Unload(); + }, 2); // Random shit breaks if we don't wait idk why } public static void RemoveEyeOfTheUniverse() From 59980f8635fe0b2dcbfcc61b683e89a739158716 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 21:15:28 -0400 Subject: [PATCH 19/43] Do non detailed --- .../Builder/Props/GravityCannonBuilder.cs | 35 ++++++++++++------- .../Props/Shuttle/GravityCannonInfo.cs | 6 ++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 39ae8bdfe..54d5ce5b9 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -13,7 +13,7 @@ namespace NewHorizons.Builder.Props public static class GravityCannonBuilder { private static GameObject _interfacePrefab; - private static GameObject _platformPrefab; + private static GameObject _detailedPlatformPrefab, _platformPrefab; private static GameObject _orbPrefab; internal static void InitPrefab() @@ -25,25 +25,36 @@ internal static void InitPrefab() .Rename("Prefab_GravityCannon") .DontDestroyOnLoad(); } - if (_platformPrefab == null) + if (_detailedPlatformPrefab == null) { // Creating it in the original position so we can instantiate the other parts in the right relative positions var original = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Geometry_GravityCannon/ControlledByProxy_OPC/Structure_NOM_GravityCannon_BH"); - _platformPrefab = original + _detailedPlatformPrefab = original .InstantiateInactive() - .Rename("Prefab_GravityCannonPlatform") + .Rename("Prefab_GravityCannonPlatform_Detailed") .DontDestroyOnLoad(); - _platformPrefab.transform.position = original.transform.position; - _platformPrefab.transform.rotation = original.transform.rotation; + _detailedPlatformPrefab.transform.position = original.transform.position; + _detailedPlatformPrefab.transform.rotation = original.transform.rotation; - GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_ShuttleSocket"), _platformPrefab.transform, true) + GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_ShuttleSocket"), _detailedPlatformPrefab.transform, true) .Rename("ShuttleSocket"); - GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/CannonForceVolume"), _platformPrefab.transform, true) + GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/CannonForceVolume"), _detailedPlatformPrefab.transform, true) .Rename("ForceVolume"); - GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _platformPrefab.transform, true) + GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _detailedPlatformPrefab.transform, true) .Rename("PlatformTrigger"); } + if (_platformPrefab == null) + { + _platformPrefab = _detailedPlatformPrefab + .InstantiateInactive() + .Rename("Prefab_GravityCannonPlatform") + .DontDestroyOnLoad(); + GameObject.Destroy(_platformPrefab.transform.Find("Structure_NOM_GravityCannon_Collider").gameObject); + GameObject.Destroy(_platformPrefab.transform.Find("Structure_NOM_GravityCannon_Crystals").gameObject); + GameObject.Destroy(_platformPrefab.transform.Find("Structure_NOM_GravityCannon_Geo").gameObject); + } + if (_orbPrefab == null) { _orbPrefab = SearchUtilities.Find("Prefab_NOM_InterfaceOrb") @@ -57,7 +68,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI { InitPrefab(); - if (_interfacePrefab == null || planetGO == null || sector == null || _platformPrefab == null || _orbPrefab == null) return null; + if (_interfacePrefab == null || planetGO == null || sector == null || _detailedPlatformPrefab == null || _platformPrefab == null || _orbPrefab == null) return null; var detailInfo = new DetailInfo(info.controls) { keepLoaded = true }; var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _interfacePrefab, detailInfo); @@ -142,9 +153,9 @@ private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, return computer; } - private static GameObject CreatePlatform(GameObject planetGO, Sector sector, GravityCannonController gravityCannonController, GeneralPropInfo platformInfo) + private static GameObject CreatePlatform(GameObject planetGO, Sector sector, GravityCannonController gravityCannonController, GravityCannonInfo platformInfo) { - var platform = DetailBuilder.Make(planetGO, sector, _platformPrefab, new DetailInfo(platformInfo) { keepLoaded = true }); + var platform = DetailBuilder.Make(planetGO, sector, platformInfo.detailed ? _detailedPlatformPrefab : _platformPrefab, new DetailInfo(platformInfo) { keepLoaded = true }); gravityCannonController._forceVolume = platform.FindChild("ForceVolume").GetComponent(); gravityCannonController._platformTrigger = platform.FindChild("PlatformTrigger").GetComponent(); diff --git a/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs b/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs index 1e296f602..ffdcb0de4 100644 --- a/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs +++ b/NewHorizons/External/Modules/Props/Shuttle/GravityCannonInfo.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.Serialization; using System.Text; @@ -27,6 +28,11 @@ public class GravityCannonInfo : GeneralPropInfo /// public string launchReveal; + /// + /// Hide the lattice cage around the platform. Defaults to true. + /// + [DefaultValue(true)] public bool detailed = true; + /// /// Will create a modern Nomai computer linked to this gravity cannon. /// From 7c745b92c4046194db92fd411c8cb2e0b3b66383 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 21:39:20 -0400 Subject: [PATCH 20/43] Fix destruction --- NewHorizons/Handlers/PlanetCreationHandler.cs | 12 +++--- .../Handlers/PlanetDestructionHandler.cs | 37 +++++++++++++------ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 38958aa27..aca59e135 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -36,6 +36,12 @@ public static class PlanetCreationHandler public static void Init(List bodies) { + // Start by destroying all planets if need be + if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) + { + PlanetDestructionHandler.RemoveStockPlanets(); + } + // Base game value SolarSystemRadius = DefaultFurthestOrbit; @@ -60,7 +66,7 @@ public static void Init(List bodies) var starLightGO = UnityEngine.Object.Instantiate(sun.GetComponentInChildren().gameObject); foreach (var comp in starLightGO.GetComponents()) { - if (!(comp is SunLightController) && !(comp is SunLightParamUpdater) && !(comp is Light) && !(comp is Transform)) + if (comp is not SunLightController && comp is not SunLightParamUpdater && comp is not Light && comp is not Transform) { UnityEngine.Object.Destroy(comp); } @@ -138,10 +144,6 @@ public static void Init(List bodies) NHLogger.Log("Done loading bodies"); SingularityBuilder.PairAllSingularities(); - - // Events.FireOnNextUpdate(PlanetDestroyer.RemoveAllProxies); - - if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveStockPlanets(); } public static bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 9fa47805e..79f65cb69 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -54,23 +54,36 @@ public static void RemoveStockPlanets() public static void RemoveSolarSystem() { - // Stop the sun from killing the player if they spawn at the center of the solar system - SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN").SetActive(false); + // Adapted from EOTS thanks corby + var toDisable = new List(); - Delay.FireInNUpdates(() => + // Collect all rigid bodies and proxies + foreach (var rigidbody in CenterOfTheUniverse.s_rigidbodies) { - // From EOTS thanks corby - foreach (var rigidbody in CenterOfTheUniverse.s_rigidbodies) - if (rigidbody.name is not "Player_Body" or "Ship_Body") - rigidbody.gameObject.SetActive(false); + if (rigidbody.name is not "Player_Body" && rigidbody.name is not "Ship_Body") + { + toDisable.Add(rigidbody.gameObject); + } + } + + foreach (var proxyBody in GameObject.FindObjectsOfType()) + { + toDisable.Add(proxyBody.gameObject); + } - foreach (var proxyBody in GameObject.FindObjectsOfType()) - proxyBody.gameObject.SetActive(false); + Delay.FireInNUpdates(() => + { + foreach (var gameObject in toDisable) + { + gameObject.SetActive(false); + } GameObject.FindObjectOfType().gameObject.SetActive(false); + }, 2); // Have to wait or shit goes wild - foreach (var streamingAssetBundle in StreamingManager.s_activeBundles) - streamingAssetBundle.Unload(); - }, 2); // Random shit breaks if we don't wait idk why + foreach (var streamingAssetBundle in StreamingManager.s_activeBundles) + { + //streamingAssetBundle.Unload(); + } } public static void RemoveEyeOfTheUniverse() From 6c18dd279785ccfd445f90e2feb867c3637855f9 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 21:39:28 -0400 Subject: [PATCH 21/43] Fix undetailed prefab --- NewHorizons/Builder/Props/GravityCannonBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 54d5ce5b9..d41515d31 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -50,9 +50,9 @@ internal static void InitPrefab() .InstantiateInactive() .Rename("Prefab_GravityCannonPlatform") .DontDestroyOnLoad(); - GameObject.Destroy(_platformPrefab.transform.Find("Structure_NOM_GravityCannon_Collider").gameObject); - GameObject.Destroy(_platformPrefab.transform.Find("Structure_NOM_GravityCannon_Crystals").gameObject); - GameObject.Destroy(_platformPrefab.transform.Find("Structure_NOM_GravityCannon_Geo").gameObject); + GameObject.Destroy(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Collider")); + GameObject.Destroy(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Crystals")); + GameObject.Destroy(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Geo")); } if (_orbPrefab == null) From 6de73282390f829fcefc5f8431e2c149fa2699a4 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 5 Aug 2023 01:41:35 +0000 Subject: [PATCH 22/43] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index ac0f2c7d5..62a2069cb 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2929,6 +2929,11 @@ "type": "string", "description": "Ship log fact revealed when launching from this pad. Optional." }, + "detailed": { + "type": "boolean", + "description": "Hide the lattice cage around the platform. Defaults to true.", + "default": true + }, "computer": { "description": "Will create a modern Nomai computer linked to this gravity cannon.", "$ref": "#/definitions/NomaiComputerInfo" From 963c67210cc7a4e4fe331aa37d179aba8efe9ccd Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 22:04:22 -0400 Subject: [PATCH 23/43] Don't replace sectors inside details if the sector is in that detail --- NewHorizons/Builder/Props/DetailBuilder.cs | 19 ++++++++++++------- .../Builder/Props/GravityCannonBuilder.cs | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 1dca98824..02342aac6 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -112,6 +112,8 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D // Could check this in the for loop but I'm not sure what order we need to know about this in isItem = false; + var existingSectors = new HashSet(prop.GetComponentsInChildren()); + foreach (var component in prop.GetComponentsInChildren(true)) { // Components can come through as null here (yes, really), @@ -127,7 +129,10 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D { if (FixUnsectoredComponent(component)) continue; } - else FixSectoredComponent(component, sector, detail.keepLoaded); + else + { + FixSectoredComponent(component, sector, existingSectors, detail.keepLoaded); + } FixComponent(component, go, detail.ignoreSun); } @@ -235,7 +240,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D /// /// Fix components that have sectors. Has a specific fix if there is a VisionTorchItem on the object. /// - private static void FixSectoredComponent(Component component, Sector sector, bool keepLoaded) + private static void FixSectoredComponent(Component component, Sector sector, HashSet existingSectors, bool keepLoaded) { // keepLoaded should remove existing groups // renderers/colliders get enabled later so we dont have to do that here @@ -246,14 +251,14 @@ private static void FixSectoredComponent(Component component, Sector sector, boo } // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) - if (component is ISectorGroup sectorGroup) + if (component is ISectorGroup sectorGroup && !existingSectors.Contains(sectorGroup.GetSector())) { sectorGroup.SetSector(sector); } // Not doing else if here because idk if any of the classes below implement ISectorGroup - if (component is Sector s) + if (component is Sector s && existingSectors.Contains(s.GetParentSector())) { s.SetParentSector(sector); } @@ -269,14 +274,14 @@ private static void FixSectoredComponent(Component component, Sector sector, boo sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false); } - else if(component is SectoredMonoBehaviour behaviour) + else if(component is SectoredMonoBehaviour behaviour && !existingSectors.Contains(behaviour._sector)) { // not using SetSector here because it registers the events twice // perhaps this happens with ISectorGroup.SetSector or Sector.SetParentSector too? idk and nothing seems to break because of it yet behaviour._sector = sector; } - else if(component is OWItemSocket socket) + else if(component is OWItemSocket socket && !existingSectors.Contains(socket._sector)) { socket._sector = sector; } @@ -287,7 +292,7 @@ private static void FixSectoredComponent(Component component, Sector sector, boo } - else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform) + else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform && !existingSectors.Contains(remoteCameraPlatform._visualSector)) { remoteCameraPlatform._visualSector = sector; } diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index d41515d31..5158a21c5 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -25,6 +25,7 @@ internal static void InitPrefab() .Rename("Prefab_GravityCannon") .DontDestroyOnLoad(); } + if (_detailedPlatformPrefab == null) { // Creating it in the original position so we can instantiate the other parts in the right relative positions From 76705a5b3799dffc8d518a0fdbf09ddd64173e92 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 22:10:40 -0400 Subject: [PATCH 24/43] Fix the not detailed prefab --- NewHorizons/Builder/Props/GravityCannonBuilder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 5158a21c5..0ff5e845f 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -51,9 +51,9 @@ internal static void InitPrefab() .InstantiateInactive() .Rename("Prefab_GravityCannonPlatform") .DontDestroyOnLoad(); - GameObject.Destroy(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Collider")); - GameObject.Destroy(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Crystals")); - GameObject.Destroy(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Geo")); + GameObject.DestroyImmediate(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Collider")); + GameObject.DestroyImmediate(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Crystals")); + GameObject.DestroyImmediate(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Geo")); } if (_orbPrefab == null) From 42bbe4bcceb89543d57a26ac7b46a1015782dd1c Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 4 Aug 2023 19:31:41 -0700 Subject: [PATCH 25/43] planet destruction: also exclude probe --- NewHorizons/Handlers/PlanetDestructionHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 79f65cb69..ec9d16748 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -60,7 +60,7 @@ public static void RemoveSolarSystem() // Collect all rigid bodies and proxies foreach (var rigidbody in CenterOfTheUniverse.s_rigidbodies) { - if (rigidbody.name is not "Player_Body" && rigidbody.name is not "Ship_Body") + if (rigidbody.name is not ("Player_Body" or "Probe_Body" or "Ship_Body")) { toDisable.Add(rigidbody.gameObject); } From 0ce611e36f3cf3a6e05458f0ef6e9074145dbbb9 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 4 Aug 2023 19:32:36 -0700 Subject: [PATCH 26/43] simplify another pattern --- NewHorizons/Handlers/PlanetCreationHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index aca59e135..45520195a 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -66,7 +66,7 @@ public static void Init(List bodies) var starLightGO = UnityEngine.Object.Instantiate(sun.GetComponentInChildren().gameObject); foreach (var comp in starLightGO.GetComponents()) { - if (comp is not SunLightController && comp is not SunLightParamUpdater && comp is not Light && comp is not Transform) + if (comp is not (SunLightController or SunLightParamUpdater or Light or Transform)) { UnityEngine.Object.Destroy(comp); } From d284380f9e359922618a6c9f6fb0aa291e5bdbfc Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 23:48:11 -0400 Subject: [PATCH 27/43] Gravity cannon computer will write the planet the Shuttle starts on --- NewHorizons/Assets/translations/english.json | 3 +- .../Builder/Props/GravityCannonBuilder.cs | 32 +++++++++++++++---- NewHorizons/Builder/Props/ShuttleBuilder.cs | 5 +++ .../TranslatorText/TranslatorTextBuilder.cs | 16 ++++++---- NewHorizons/Handlers/TranslationHandler.cs | 11 ++++--- .../Utility/OuterWilds/AstroObjectLocator.cs | 29 +++++++++++++++++ 6 files changed, 77 insertions(+), 19 deletions(-) diff --git a/NewHorizons/Assets/translations/english.json b/NewHorizons/Assets/translations/english.json index 9d1a4c281..c5e6db886 100644 --- a/NewHorizons/Assets/translations/english.json +++ b/NewHorizons/Assets/translations/english.json @@ -22,7 +22,8 @@ "DEBUG_PLACE_TEXT": "Place Nomai Text", "DEBUG_UNDO": "Undo", "DEBUG_REDO": "Redo", - "Vessel": "Vessel" + "Vessel": "Vessel", + "NOMAI_SHUTTLE_COMPUTER": "The shuttle]]> is currently resting at {0}]]>." }, "AchievementTranslations": { "NH_EATEN_OUTSIDE_BRAMBLE": { diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 0ff5e845f..9979e7ecb 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -1,10 +1,14 @@ using NewHorizons.Builder.Props.TranslatorText; +using NewHorizons.Components.Orbital; using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props.Shuttle; +using NewHorizons.External.Modules.TranslatorText; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OuterWilds; using NewHorizons.Utility.OWML; +using Newtonsoft.Json; using OWML.Common; using UnityEngine; @@ -76,7 +80,8 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI gravityCannonObject.SetActive(false); var gravityCannonController = gravityCannonObject.GetComponent(); - gravityCannonController._shuttleID = ShuttleHandler.GetShuttleID(info.shuttleID); + var id = ShuttleHandler.GetShuttleID(info.shuttleID); + gravityCannonController._shuttleID = id; // Gravity controller checks string length instead of isnullorempty gravityCannonController._retrieveShipLogFact = info.retrieveReveal ?? string.Empty; @@ -86,7 +91,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonI if (info.computer != null) { - gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer); + // Do it next update so that the shuttle has been made + Delay.FireOnNextUpdate(() => + { + gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer, id); + }); } else { @@ -140,14 +149,23 @@ private static void CreateOrb(GameObject planetGO, GravityCannonController gravi }, () => Main.IsSystemReady, 10); } - private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, GeneralPropInfo computerInfo) + private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, GeneralPropInfo computerInfo, NomaiShuttleController.ShuttleID id) { - var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new DetailInfo(computerInfo)); + // Load the position info from the GeneralPropInfo + var translatorTextInfo = new TranslatorTextInfo(); + JsonConvert.PopulateObject(JsonConvert.SerializeObject(computerInfo), translatorTextInfo); + translatorTextInfo.type = NomaiTextType.Computer; - var computer = computerObject.GetComponentInChildren(); - computer.SetSector(sector); + var shuttle = ShuttleBuilder.Shuttles[id]; + var planet = AstroObjectLocator.GetPlanetName(shuttle.GetComponentInParent()); + + var displayText = TranslationHandler.GetTranslation("NOMAI_SHUTTLE_COMPUTER", TranslationHandler.TextType.UI).Replace("{0}", planet); + NHLogger.Log(displayText); + var xmlContent = $"\r\n \r\n 1\r\n {displayText}\r\n \r\n"; - Delay.FireOnNextUpdate(computer.ClearAllEntries); + var computerObject = TranslatorTextBuilder.Make(planetGO, sector, translatorTextInfo, null, xmlContent); + + var computer = computerObject.GetComponentInChildren(); computerObject.SetActive(true); diff --git a/NewHorizons/Builder/Props/ShuttleBuilder.cs b/NewHorizons/Builder/Props/ShuttleBuilder.cs index 8ea32716f..06d8dabbc 100644 --- a/NewHorizons/Builder/Props/ShuttleBuilder.cs +++ b/NewHorizons/Builder/Props/ShuttleBuilder.cs @@ -3,6 +3,7 @@ using NewHorizons.External.Modules.Props.Shuttle; using NewHorizons.Handlers; using NewHorizons.Utility; +using System.Collections.Generic; using UnityEngine; namespace NewHorizons.Builder.Props @@ -13,6 +14,8 @@ public static class ShuttleBuilder private static GameObject _orbPrefab; private static GameObject _bodyPrefab; + public static Dictionary Shuttles { get; } = new(); + internal static void InitPrefab() { if (_prefab == null) @@ -108,6 +111,8 @@ public static GameObject Make(GameObject planetGO, Sector sector, ShuttleInfo in orbObject.SetActive(true); shuttleController._orb.RemoveAllLocks(); + Shuttles[id] = shuttleController; + return shuttleObject; } } diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index b189ee758..42769576b 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -1,7 +1,7 @@ using NewHorizons.External; using NewHorizons.External.Modules.Props; -using NewHorizons.External.SerializableData; using NewHorizons.External.Modules.TranslatorText; +using NewHorizons.External.SerializableData; using NewHorizons.Handlers; using NewHorizons.Utility; using NewHorizons.Utility.Geometry; @@ -14,7 +14,6 @@ using System.Linq; using System.Xml; using UnityEngine; - using Random = UnityEngine.Random; namespace NewHorizons.Builder.Props.TranslatorText @@ -137,6 +136,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, TranslatorText return null; } + return Make(planetGO, sector, info, nhBody, xmlContent); + } + + public static GameObject Make(GameObject planetGO, Sector sector, TranslatorTextInfo info, NewHorizonsBody nhBody, string xmlContent) + { switch (info.type) { case NomaiTextType.Wall: @@ -401,7 +405,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, TranslatorText } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, TranslatorTextInfo info, string xmlPath, NewHorizonsBody nhBody) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, TranslatorTextInfo info, string xmlContent, NewHorizonsBody nhBody) { GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); nomaiWallTextObj.SetActive(false); @@ -418,13 +422,13 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, Translat nomaiWallText._location = EnumUtils.Parse(info.location.ToString()); - var text = new TextAsset(xmlPath); + var text = new TextAsset(xmlContent); // Text assets need a name to be used with VoiceMod text.name = Path.GetFileNameWithoutExtension(info.xmlFile); - BuildArcs(xmlPath, nomaiWallText, nomaiWallTextObj, info, nhBody); - AddTranslation(xmlPath); + BuildArcs(xmlContent, nomaiWallText, nomaiWallTextObj, info, nhBody); + AddTranslation(xmlContent); nomaiWallText._nomaiTextAsset = text; nomaiWallText.SetTextAsset(text); diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 3447c7259..62da21ab9 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -8,9 +8,9 @@ namespace NewHorizons.Handlers { public static class TranslationHandler { - private static Dictionary> _shipLogTranslationDictionary = new Dictionary>(); - private static Dictionary> _dialogueTranslationDictionary = new Dictionary>(); - private static Dictionary> _uiTranslationDictionary = new Dictionary>(); + private static Dictionary> _shipLogTranslationDictionary = new(); + private static Dictionary> _dialogueTranslationDictionary = new(); + private static Dictionary> _uiTranslationDictionary = new(); public enum TextType { @@ -93,8 +93,9 @@ public static void RegisterTranslation(TextTranslation.Language language, Transl if (!_uiTranslationDictionary.ContainsKey(language)) _uiTranslationDictionary.Add(language, new Dictionary()); foreach (var originalKey in config.UIDictionary.Keys) { - var key = originalKey.Replace("<", "<").Replace(">", ">").Replace("", ""); - var value = config.UIDictionary[originalKey].Replace("<", "<").Replace(">", ">").Replace("", ""); + // Don't remove CDATA from UI + var key = originalKey.Replace("<", "<").Replace(">", ">"); + var value = config.UIDictionary[originalKey].Replace("<", "<").Replace(">", ">"); if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, value); else _uiTranslationDictionary[language][key] = value; diff --git a/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs b/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs index 88d46e517..b1aba93ec 100644 --- a/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs +++ b/NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; using System.Linq; +using NewHorizons.Components.Orbital; +using NewHorizons.Handlers; using NewHorizons.Utility.OWML; using UnityEngine; @@ -177,5 +179,32 @@ public static GameObject[] GetChildren(AstroObject primary) return otherChildren.ToArray(); } + + public static string GetPlanetName(AstroObject astroObject) + { + if (astroObject != null) + { + if (astroObject is NHAstroObject nhAstroObject) + { + var customName = nhAstroObject.GetCustomName(); + + if (!string.IsNullOrWhiteSpace(customName)) + { + return TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI, false); + } + } + else + { + AstroObject.Name astroObjectName = astroObject.GetAstroObjectName(); + + if (astroObjectName - AstroObject.Name.Sun <= 7 || astroObjectName - AstroObject.Name.TimberMoon <= 1) + { + return AstroObject.AstroObjectNameToString(astroObject.GetAstroObjectName()); + } + } + } + + return "???"; + } } } From 9bbfb8d4d85068ba3aae62b6ea3057a9e93b6f6d Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 4 Aug 2023 23:54:04 -0400 Subject: [PATCH 28/43] Add translator text to the API --- .../Props/TranslatorText/TranslatorTextBuilder.cs | 2 +- NewHorizons/INewHorizons.cs | 9 +++++++++ NewHorizons/NewHorizonsApi.cs | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 42769576b..48a1cc4e0 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -546,7 +546,7 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers // make an entry in the cache for all these spirals - if (nhBody.Cache != null) + if (nhBody?.Cache != null) { var cacheData = arranger.spirals.Select(spiralManipulator => new ArcCacheData() { diff --git a/NewHorizons/INewHorizons.cs b/NewHorizons/INewHorizons.cs index 717819c09..c4447d282 100644 --- a/NewHorizons/INewHorizons.cs +++ b/NewHorizons/INewHorizons.cs @@ -147,6 +147,15 @@ public interface INewHorizons /// (CharacterDialogueTree, RemoteDialogueTrigger) CreateDialogueFromXML(string textAssetID, string xml, string dialogueInfo, GameObject planetGO); + /// + /// Allows the creation of Nomai text by directly passing the xml and translatorTextInfo json contents as strings + /// + /// The contents of the translator text file as a string + /// The json translator text info as a string. See the documentation/schema for what this can contain. + /// The root planet rigidbody that this text is attached to. Any paths in the translatorTextInfo are relative to this body. + /// + GameObject CreateNomaiText(string xml, string textInfo, GameObject planetGO); + /// /// Directly add ship logs from XML. Call this method right before ShipLogManager awake. /// diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index e395bfa18..5eaf322eb 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.Builder.Props.Audio; +using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.Builder.ShipLog; using NewHorizons.External; using NewHorizons.External.Configs; @@ -7,6 +8,7 @@ using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props.Audio; using NewHorizons.External.Modules.Props.Dialogue; +using NewHorizons.External.Modules.TranslatorText; using NewHorizons.External.SerializableData; using NewHorizons.Utility; using NewHorizons.Utility.OWML; @@ -259,6 +261,12 @@ public void DefineStarSystem(string name, string config, IModBehaviour mod) return DialogueBuilder.Make(planetGO, null, info, xml, textAssetID); } + public GameObject CreateNomaiText(string xml, string textInfo, GameObject planetGO) + { + var info = JsonConvert.DeserializeObject(textInfo); + return TranslatorTextBuilder.Make(planetGO, null, info, null, xml); + } + public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder, Dictionary entryPositions, Dictionary curiousityColours) { // This method has to be called each time the ship log manager is created, i.e. each time a system loads so it will only ever be relevant to the current one. From 29fe5a9b84002becb174d49ceccb446da82792d3 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 5 Aug 2023 00:45:50 -0400 Subject: [PATCH 29/43] Fix typo, include inactive sectors --- NewHorizons/Builder/Props/DetailBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 02342aac6..26d9fae9c 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -112,7 +112,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D // Could check this in the for loop but I'm not sure what order we need to know about this in isItem = false; - var existingSectors = new HashSet(prop.GetComponentsInChildren()); + var existingSectors = new HashSet(prop.GetComponentsInChildren(true)); foreach (var component in prop.GetComponentsInChildren(true)) { @@ -258,7 +258,7 @@ private static void FixSectoredComponent(Component component, Sector sector, Has // Not doing else if here because idk if any of the classes below implement ISectorGroup - if (component is Sector s && existingSectors.Contains(s.GetParentSector())) + if (component is Sector s && !existingSectors.Contains(s.GetParentSector())) { s.SetParentSector(sector); } From 5a1c2fe7f9dbd5f3f59c59c9dbf9661491ee80f5 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 5 Aug 2023 00:46:41 -0400 Subject: [PATCH 30/43] Update manifest.json --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 273520daf..56cf858bc 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.13.0", + "version": "1.14.0", "owmlVersion": "2.9.3", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From 1289feca78bd99d8dc1669b399d5b05db119bed7 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 5 Aug 2023 01:08:01 -0400 Subject: [PATCH 31/43] Delete GravityCannonComputer.xml --- NewHorizons/Assets/GravityCannonComputer.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 NewHorizons/Assets/GravityCannonComputer.xml diff --git a/NewHorizons/Assets/GravityCannonComputer.xml b/NewHorizons/Assets/GravityCannonComputer.xml deleted file mode 100644 index 3c357b14e..000000000 --- a/NewHorizons/Assets/GravityCannonComputer.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 1 - The shuttle]]> is currently resting at ???]]>. - - \ No newline at end of file From 5e11e5f95a53fd4abe9f6c9623130e3c38937421 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 6 Aug 2023 22:45:56 -0700 Subject: [PATCH 32/43] use sphereOfInfluence for ProxyShadowCasterSuperGroup._bounds.radius --- NewHorizons/Builder/General/RigidBodyBuilder.cs | 5 ++--- NewHorizons/Handlers/PlanetCreationHandler.cs | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Builder/General/RigidBodyBuilder.cs b/NewHorizons/Builder/General/RigidBodyBuilder.cs index ebfcd11e5..9a0d51865 100644 --- a/NewHorizons/Builder/General/RigidBodyBuilder.cs +++ b/NewHorizons/Builder/General/RigidBodyBuilder.cs @@ -1,13 +1,12 @@ -using NewHorizons.External.Configs; using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Builder.General { public static class RigidBodyBuilder { - public static OWRigidbody Make(GameObject body, PlanetConfig config) + public static OWRigidbody Make(GameObject body, float sphereOfInfluence) { - body.AddComponent(); + body.AddComponent()._bounds.radius = sphereOfInfluence; Rigidbody rigidBody = body.AddComponent(); rigidBody.mass = 10000; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 45520195a..ea235665e 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -346,10 +346,12 @@ public static GameObject GenerateBrambleDimensionBody(NewHorizonsBody body) body.Config.Base.showMinimap = false; body.Config.Base.hasMapMarker = false; - var owRigidBody = RigidBodyBuilder.Make(go, body.Config); + const float sphereOfInfluence = 2000f; + + var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence); var ao = AstroObjectBuilder.Make(go, null, body.Config, false); - var sector = SectorBuilder.Make(go, owRigidBody, 2000f); + var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence); ao._rootSector = sector; ao._type = AstroObject.Type.None; @@ -419,10 +421,10 @@ public static GameObject GenerateStandardBody(NewHorizonsBody body, bool default }; } - var owRigidBody = RigidBodyBuilder.Make(go, body.Config); - var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config, false); - var sphereOfInfluence = GetSphereOfInfluence(body); + + var owRigidBody = RigidBodyBuilder.Make(go, sphereOfInfluence); + var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config, false); var sector = SectorBuilder.Make(go, owRigidBody, sphereOfInfluence * 2f); ao._rootSector = sector; From 9455c487551418ee75c8e8a07b410e6c4c35e283 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 6 Aug 2023 22:49:45 -0700 Subject: [PATCH 33/43] use * 2 --- NewHorizons/Builder/General/RigidBodyBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/General/RigidBodyBuilder.cs b/NewHorizons/Builder/General/RigidBodyBuilder.cs index 9a0d51865..f6b59569c 100644 --- a/NewHorizons/Builder/General/RigidBodyBuilder.cs +++ b/NewHorizons/Builder/General/RigidBodyBuilder.cs @@ -6,7 +6,7 @@ public static class RigidBodyBuilder { public static OWRigidbody Make(GameObject body, float sphereOfInfluence) { - body.AddComponent()._bounds.radius = sphereOfInfluence; + body.AddComponent()._bounds.radius = sphereOfInfluence * 2; Rigidbody rigidBody = body.AddComponent(); rigidBody.mass = 10000; From 01b8ac0b7a2f3bd6cc10461332078f995e8eb9d8 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sun, 6 Aug 2023 22:53:24 -0700 Subject: [PATCH 34/43] Revert "use * 2" This reverts commit 9455c487551418ee75c8e8a07b410e6c4c35e283. --- NewHorizons/Builder/General/RigidBodyBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/General/RigidBodyBuilder.cs b/NewHorizons/Builder/General/RigidBodyBuilder.cs index f6b59569c..9a0d51865 100644 --- a/NewHorizons/Builder/General/RigidBodyBuilder.cs +++ b/NewHorizons/Builder/General/RigidBodyBuilder.cs @@ -6,7 +6,7 @@ public static class RigidBodyBuilder { public static OWRigidbody Make(GameObject body, float sphereOfInfluence) { - body.AddComponent()._bounds.radius = sphereOfInfluence * 2; + body.AddComponent()._bounds.radius = sphereOfInfluence; Rigidbody rigidBody = body.AddComponent(); rigidBody.mass = 10000; From 789926d0126a846da3875e6cbc13cf10586ca46c Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 7 Aug 2023 15:12:26 -0700 Subject: [PATCH 35/43] dont use CopyPropertiesFrom for star light stuff --- NewHorizons/Builder/Body/StarBuilder.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index f4954af58..a22c7a522 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -178,14 +178,11 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( light.color = lightColour; ambientLight.color = new Color(lightColour.r, lightColour.g, lightColour.b, lightColour.a == 0 ? 0.0001f : lightColour.a); + // used to use CopyPropertiesFrom, but that doesnt work here. instead, just copy sun props from unity explorer var faceActiveCamera = sunLight.AddComponent(); - faceActiveCamera.CopyPropertiesFrom(_sunLight.GetComponent()); + faceActiveCamera._useLookAt = true; var csmTextureCacher = sunLight.AddComponent(); - csmTextureCacher.CopyPropertiesFrom(_sunLight.GetComponent()); - csmTextureCacher._light = light; var proxyShadowLight = sunLight.AddComponent(); - proxyShadowLight.CopyPropertiesFrom(_sunLight.GetComponent()); - proxyShadowLight._light = light; sunLight.name = "StarLight"; From fb4f4251000138451b47e0f127a0121bd778d8d4 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 7 Aug 2023 15:26:09 -0700 Subject: [PATCH 36/43] typo that i didnt catch before i pushed --- NewHorizons/Builder/Body/StarBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index a22c7a522..ecbbee5c1 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -178,7 +178,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( light.color = lightColour; ambientLight.color = new Color(lightColour.r, lightColour.g, lightColour.b, lightColour.a == 0 ? 0.0001f : lightColour.a); - // used to use CopyPropertiesFrom, but that doesnt work here. instead, just copy sun props from unity explorer + // used to use CopyPropertiesFrom, but that doesnt work here. instead, just copy settings from unity explorer var faceActiveCamera = sunLight.AddComponent(); faceActiveCamera._useLookAt = true; var csmTextureCacher = sunLight.AddComponent(); From b50cc53a4daa111c3a415ebd915e9686d38fb8ad Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 7 Aug 2023 19:12:12 -0700 Subject: [PATCH 37/43] force call SunLightEffectsController.Update to make it switch star --- NewHorizons/Handlers/PlanetDestructionHandler.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index ec9d16748..938877c34 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -78,6 +78,9 @@ public static void RemoveSolarSystem() gameObject.SetActive(false); } GameObject.FindObjectOfType().gameObject.SetActive(false); + + // force call update here to make it switch to an active star. idk why we didnt have to do this before + SunLightEffectsController.Instance.Update(); }, 2); // Have to wait or shit goes wild foreach (var streamingAssetBundle in StreamingManager.s_activeBundles) From 686e2394d61bb0b81b70c1e2a2d165c09ab41443 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 7 Aug 2023 22:15:43 -0400 Subject: [PATCH 38/43] Fix cloak not being disabled probably --- NewHorizons/Handlers/PlanetDestructionHandler.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 938877c34..bf683b916 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -81,6 +81,9 @@ public static void RemoveSolarSystem() // force call update here to make it switch to an active star. idk why we didnt have to do this before SunLightEffectsController.Instance.Update(); + + // Since we didn't call RemoveBody on the Stranger have to call this here + StrangerRemoved(); }, 2); // Have to wait or shit goes wild foreach (var streamingAssetBundle in StreamingManager.s_activeBundles) @@ -99,14 +102,23 @@ public static void RemoveEyeOfTheUniverse() } } + public static void StrangerRemoved() + { + CloakHandler.FlagStrangerDisabled = true; + + if (Locator._cloakFieldController?.GetComponentInParent()?.GetAstroObjectName() == AstroObject.Name.RingWorld) + { + Locator._cloakFieldController = null; + } + } + public static void RemoveBody(AstroObject ao, bool delete = false, List toDestroy = null) { NHLogger.LogVerbose($"Removing [{ao.name}]"); if (ao.GetAstroObjectName() == AstroObject.Name.RingWorld) { - CloakHandler.FlagStrangerDisabled = true; - if (Locator._cloakFieldController?.GetComponentInParent() == ao) Locator._cloakFieldController = null; + StrangerRemoved(); } if (ao.gameObject == null || !ao.gameObject.activeInHierarchy) From 7846ae1161f2178fdddc221bc72cb87be4ecf8b0 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 7 Aug 2023 19:24:15 -0700 Subject: [PATCH 39/43] add ProxyShadowCaster to groundsize --- NewHorizons/Builder/Body/GeometryBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/Builder/Body/GeometryBuilder.cs b/NewHorizons/Builder/Body/GeometryBuilder.cs index dc7c99cf6..1c59724bb 100644 --- a/NewHorizons/Builder/Body/GeometryBuilder.cs +++ b/NewHorizons/Builder/Body/GeometryBuilder.cs @@ -30,6 +30,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, float groundSc { groundGO.transform.localScale *= 2; // Multiply by 2 to match top layer } + + var superGroup = planetGO.GetComponent(); + // idk if we need to set _superGroup manually since it does that in Awake, but it's done everywhere else so wtv + if (superGroup != null) groundGO.AddComponent()._superGroup = superGroup; + groundGO.SetActive(true); return groundGO; From f765e078599e0e782b38d2435b3d1e19571fdd8c Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 8 Aug 2023 00:20:47 -0400 Subject: [PATCH 40/43] Add another translation dictionary that keeps CDATA --- NewHorizons/Assets/translations/english.json | 4 ++- .../Builder/Props/GravityCannonBuilder.cs | 2 +- .../External/Configs/TranslationConfig.cs | 9 +++++++ NewHorizons/Handlers/TranslationHandler.cs | 26 ++++++++++++++++--- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Assets/translations/english.json b/NewHorizons/Assets/translations/english.json index c5e6db886..48df51eef 100644 --- a/NewHorizons/Assets/translations/english.json +++ b/NewHorizons/Assets/translations/english.json @@ -22,7 +22,9 @@ "DEBUG_PLACE_TEXT": "Place Nomai Text", "DEBUG_UNDO": "Undo", "DEBUG_REDO": "Redo", - "Vessel": "Vessel", + "Vessel": "Vessel" + }, + "OtherDictionary": { "NOMAI_SHUTTLE_COMPUTER": "The shuttle]]> is currently resting at {0}]]>." }, "AchievementTranslations": { diff --git a/NewHorizons/Builder/Props/GravityCannonBuilder.cs b/NewHorizons/Builder/Props/GravityCannonBuilder.cs index 9979e7ecb..e86ccd42c 100644 --- a/NewHorizons/Builder/Props/GravityCannonBuilder.cs +++ b/NewHorizons/Builder/Props/GravityCannonBuilder.cs @@ -159,7 +159,7 @@ private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, var shuttle = ShuttleBuilder.Shuttles[id]; var planet = AstroObjectLocator.GetPlanetName(shuttle.GetComponentInParent()); - var displayText = TranslationHandler.GetTranslation("NOMAI_SHUTTLE_COMPUTER", TranslationHandler.TextType.UI).Replace("{0}", planet); + var displayText = TranslationHandler.GetTranslation("NOMAI_SHUTTLE_COMPUTER", TranslationHandler.TextType.OTHER).Replace("{0}", planet); NHLogger.Log(displayText); var xmlContent = $"\r\n \r\n 1\r\n {displayText}\r\n \r\n"; diff --git a/NewHorizons/External/Configs/TranslationConfig.cs b/NewHorizons/External/Configs/TranslationConfig.cs index 4f3371ca8..7341af9eb 100644 --- a/NewHorizons/External/Configs/TranslationConfig.cs +++ b/NewHorizons/External/Configs/TranslationConfig.cs @@ -23,6 +23,11 @@ public class TranslationConfig /// public Dictionary UIDictionary; + /// + /// Translation table for other text, will be taken verbatim without correcting CDATA + /// + public Dictionary OtherDictionary; + #region Achievements+ // This only exists for schema generation, Achievements+ handles the parsing #pragma warning disable 0169 @@ -63,6 +68,10 @@ public TranslationConfig(string filename) UIDictionary = (Dictionary) (dict[nameof(UIDictionary)] as JObject).ToObject( typeof(Dictionary)); + if (dict.ContainsKey(nameof(OtherDictionary))) + OtherDictionary = + (Dictionary)(dict[nameof(OtherDictionary)] as JObject).ToObject( + typeof(Dictionary)); } } } \ No newline at end of file diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 62da21ab9..2db44131b 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -11,12 +11,14 @@ public static class TranslationHandler private static Dictionary> _shipLogTranslationDictionary = new(); private static Dictionary> _dialogueTranslationDictionary = new(); private static Dictionary> _uiTranslationDictionary = new(); + private static Dictionary> _otherTranslationDictionary = new(); public enum TextType { SHIPLOG, DIALOGUE, - UI + UI, + OTHER } public static string GetTranslation(string text, TextType type) => GetTranslation(text, type, true); @@ -36,6 +38,9 @@ public static string GetTranslation(string text, TextType type, bool warn) break; case TextType.UI: dictionary = _uiTranslationDictionary; + break; + case TextType.OTHER: + dictionary = _otherTranslationDictionary; break; default: if (warn) NHLogger.LogVerbose($"Invalid TextType {type}"); @@ -93,14 +98,27 @@ public static void RegisterTranslation(TextTranslation.Language language, Transl if (!_uiTranslationDictionary.ContainsKey(language)) _uiTranslationDictionary.Add(language, new Dictionary()); foreach (var originalKey in config.UIDictionary.Keys) { - // Don't remove CDATA from UI - var key = originalKey.Replace("<", "<").Replace(">", ">"); - var value = config.UIDictionary[originalKey].Replace("<", "<").Replace(">", ">"); + var key = originalKey.Replace("<", "<").Replace(">", ">").Replace("", ""); + var value = config.UIDictionary[originalKey].Replace("<", "<").Replace(">", ">").Replace("", ""); if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, value); else _uiTranslationDictionary[language][key] = value; } } + + if (config.OtherDictionary != null && config.OtherDictionary.Count() > 0) + { + if (!_otherTranslationDictionary.ContainsKey(language)) _otherTranslationDictionary.Add(language, new Dictionary()); + foreach (var originalKey in config.OtherDictionary.Keys) + { + // Don't remove CDATA + var key = originalKey.Replace("<", "<").Replace(">", ">"); + var value = config.OtherDictionary[originalKey].Replace("<", "<").Replace(">", ">"); + + if (!_otherTranslationDictionary[language].ContainsKey(key)) _otherTranslationDictionary[language].Add(key, value); + else _otherTranslationDictionary[language][key] = value; + } + } } public static void AddDialogue(string rawText, bool trimRawTextForKey = false, params string[] rawPreText) From 9fe8e3164de072584575e053c095f3ff21c3c2cf Mon Sep 17 00:00:00 2001 From: Ben C Date: Tue, 8 Aug 2023 04:22:59 +0000 Subject: [PATCH 41/43] Updated Schemas --- NewHorizons/Schemas/translation_schema.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NewHorizons/Schemas/translation_schema.json b/NewHorizons/Schemas/translation_schema.json index 92a114ef2..da210c418 100644 --- a/NewHorizons/Schemas/translation_schema.json +++ b/NewHorizons/Schemas/translation_schema.json @@ -25,6 +25,13 @@ "type": "string" } }, + "OtherDictionary": { + "type": "object", + "description": "Translation table for other text, will be taken verbatim without correcting CDATA", + "additionalProperties": { + "type": "string" + } + }, "AchievementTranslations": { "type": "object", "description": "Translation table for achievements. The key is the unique ID of the achievement", From 894274cc17e92e7431146d87fce8148d41ce2f6b Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 8 Aug 2023 00:32:34 -0400 Subject: [PATCH 42/43] Needed null check for replacing parent sector --- NewHorizons/Builder/Props/DetailBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 26d9fae9c..db488f6ae 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -258,7 +258,7 @@ private static void FixSectoredComponent(Component component, Sector sector, Has // Not doing else if here because idk if any of the classes below implement ISectorGroup - if (component is Sector s && !existingSectors.Contains(s.GetParentSector())) + if (component is Sector s && s.GetParentSector() != null && !existingSectors.Contains(s.GetParentSector())) { s.SetParentSector(sector); } From 96339c8e21322a9ee67786f61e7c492f4e4af952 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 8 Aug 2023 00:40:24 -0400 Subject: [PATCH 43/43] Comment --- NewHorizons/Builder/Props/DetailBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index db488f6ae..6c762931a 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -257,7 +257,8 @@ private static void FixSectoredComponent(Component component, Sector sector, Has } // Not doing else if here because idk if any of the classes below implement ISectorGroup - + + // Null check else shuttles controls break if (component is Sector s && s.GetParentSector() != null && !existingSectors.Contains(s.GetParentSector())) { s.SetParentSector(sector);