From da470691eda3ced7d6818d96091998b8c3c23a6b Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 4 Mar 2023 21:44:53 -0500 Subject: [PATCH 001/119] Don't use delay, implement fixer components --- NewHorizons/Builder/Props/DetailBuilder.cs | 91 ++++++++++++++++------ 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 691712746..e10e05bc3 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -314,22 +314,19 @@ private static void FixComponent(Component component, GameObject planetGO) Component.DestroyImmediate(component); return; } - - if (component is DarkMatterVolume) + else if (component is DarkMatterVolume) { var probeVisuals = component.gameObject.transform.Find("ProbeVisuals"); if (probeVisuals != null) probeVisuals.gameObject.SetActive(true); } - - if (component is DarkMatterSubmergeController submergeController) + else if (component is DarkMatterSubmergeController submergeController) { var water = planetGO.GetComponentsInChildren().FirstOrDefault(x => x._fluidType == FluidVolume.Type.WATER); if (submergeController._fluidDetector) submergeController._fluidDetector._onlyDetectableFluid = water; } - // Fix anglerfish speed on orbiting planets - if (component is AnglerfishController angler) + else if (component is AnglerfishController angler) { try { @@ -342,50 +339,48 @@ private static void FixComponent(Component component, GameObject planetGO) } // fix campfires - if (component is InteractVolume interactVolume) + else if (component is InteractVolume) { - Delay.FireOnNextUpdate(() => interactVolume._playerCam = Locator.GetPlayerCamera()); + component.gameObject.AddComponent(); } - if (component is PlayerAttachPoint playerAttachPoint) + else if (component is PlayerAttachPoint) { - var playerBody = GameObject.Find("Player_Body"); - playerAttachPoint._playerController = playerBody.GetComponent(); - playerAttachPoint._playerOWRigidbody = playerBody.GetComponent(); - playerAttachPoint._playerTransform = playerBody.transform; - Delay.FireOnNextUpdate(() => playerAttachPoint._fpsCamController = Locator.GetPlayerCameraController()); + component.gameObject.AddComponent(); } - if (component is NomaiInterfaceOrb orb) + else if (component is NomaiInterfaceOrb orb) { orb._parentAstroObject = planetGO.GetComponent(); orb._parentBody = planetGO.GetComponent(); } - if (component is VisionTorchItem torchItem) + else if (component is VisionTorchItem torchItem) { torchItem.enabled = true; torchItem.mindProjectorTrigger.enabled = true; - Delay.FireOnNextUpdate(() => torchItem.mindSlideProjector._mindProjectorImageEffect = Locator.GetPlayerCamera().GetComponent()); + torchItem.gameObject.AddComponent(); } - if (component is Animator animator) animator.enabled = true; - if (component is Collider collider) collider.enabled = true; + else if (component is Animator animator) animator.enabled = true; + else if(component is Collider collider) collider.enabled = true; // Bug 533 - Don't show the electricity effect renderers - if (component is Renderer renderer && component.gameObject.GetComponent() == null) renderer.enabled = true; - if (component is Shape shape) shape.enabled = true; + else if (component is Renderer renderer && component.gameObject.GetComponent() == null) renderer.enabled = true; + else if(component is Shape shape) shape.enabled = true; // fixes sector cull group deactivating renderers on map view enter and fast foward // TODO: does this actually work? what? how? - if (component is SectorCullGroup sectorCullGroup) + else if(component is SectorCullGroup sectorCullGroup) { sectorCullGroup._inMapView = false; sectorCullGroup._isFastForwarding = false; sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false); } - + // If it's not a moving anglerfish make sure the anim controller is regular - if (component is AnglerfishAnimController && component.GetComponentInParent() == null) + else if(component is AnglerfishAnimController && component.GetComponentInParent() == null) + { component.gameObject.AddComponent(); + } } /// @@ -416,5 +411,53 @@ public void Start() Destroy(this); } } + + /// + /// Has to happen after 1 frame to work with VR + /// + [RequireComponent(typeof(InteractVolume))] + private class InteractVolumeFixer : MonoBehaviour + { + public void Start() + { + var interactVolume = GetComponent(); + interactVolume._playerCam = Locator.GetPlayerCamera(); + + Destroy(this); + } + } + + /// + /// Has to happen after 1 frame to work with VR + /// + [RequireComponent(typeof(PlayerAttachPoint))] + private class PlayerAttachPointFixer : MonoBehaviour + { + public void Start() + { + var playerAttachPoint = GetComponent(); + playerAttachPoint._playerController = Locator.GetPlayerController(); + playerAttachPoint._playerOWRigidbody = Locator.GetPlayerBody(); + playerAttachPoint._playerTransform = Locator.GetPlayerTransform(); + playerAttachPoint._fpsCamController = Locator.GetPlayerCameraController(); + + Destroy(this); + } + } + + /// + /// Has to happen after 1 frame to work with VR + /// + [RequireComponent(typeof(VisionTorchItem))] + private class VisionTorchItemFixer : MonoBehaviour + { + public void Start() + { + var torchItem = GetComponent(); + torchItem.mindSlideProjector._mindProjectorImageEffect = Locator.GetPlayerCamera().GetComponent(); + + Destroy(this); + } + } } } \ No newline at end of file From ffb8dc7ee57ad9e7e2340330bb918d93513ebccb Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 4 Mar 2023 21:47:37 -0500 Subject: [PATCH 002/119] Use else if on FixSectoredComponent --- NewHorizons/Builder/Props/DetailBuilder.cs | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index e10e05bc3..55406e64f 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -253,39 +253,41 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P /// private static void FixSectoredComponent(Component component, Sector sector, bool isTorch = false) { - if (component is Sector s) + // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) + if (component is ISectorGroup sectorGroup) { - s.SetParentSector(sector); + sectorGroup.SetSector(sector); } - if (component is SectorCullGroup sectorCullGroup) + // Not doing else if here because idk if any of the classes below implement ISectorGroup + + if (component is Sector s) { - sectorCullGroup._controllingProxy = null; + s.SetParentSector(sector); } - // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) - if (component is ISectorGroup sectorGroup) + else if (component is SectorCullGroup sectorCullGroup) { - sectorGroup.SetSector(sector); + sectorCullGroup._controllingProxy = null; } - if (component is SectoredMonoBehaviour behaviour) + else if(component is SectoredMonoBehaviour behaviour) { behaviour.SetSector(sector); } - if (component is OWItemSocket socket) + else if(component is OWItemSocket socket) { socket._sector = sector; } // Fix slide reel - Softlocks if this object is a vision torch - if (!isTorch && component is SlideCollectionContainer container) + else if(!isTorch && component is SlideCollectionContainer container) { sector.OnOccupantEnterSector.AddListener(_ => container.LoadStreamingTextures()); } - if (component is NomaiRemoteCameraPlatform remoteCameraPlatform) + else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform) { remoteCameraPlatform._visualSector = sector; } From 67495d89727a4e8212216851d608aa42b3c6814d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 16 Mar 2023 14:04:41 -0500 Subject: [PATCH 003/119] Gracefully log errors for missing script components when building details --- NewHorizons/Builder/Props/DetailBuilder.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 55406e64f..7d70f9ad5 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -85,6 +85,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P GameObject prop; bool isItem; + bool invalidComponentFound = false; // We save copies with all their components fixed, good if the user is placing the same detail more than once if (detail?.path != null && _fixedPrefabCache.TryGetValue((sector, detail.path), out var storedPrefab)) @@ -106,6 +107,13 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P foreach (var component in prop.GetComponentsInChildren(true)) { + // Components can come through as null here (yes, really), + // Usually if a script was added to a prefab in an asset bundle but isn't present in the loaded mod DLLs + if (component == null) + { + invalidComponentFound = true; + continue; + } if (component.gameObject == prop && component is OWItem) isItem = true; if (sector == null) @@ -126,6 +134,17 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P prop.transform.parent = sector?.transform ?? go.transform; + if (invalidComponentFound) + { + foreach (Transform t in prop.GetComponentsInChildren(true)) + { + if (t.GetComponents().Any(c => c == null)) + { + Logger.LogError($"Failed to instantiate component at {t.GetPath()}"); + } + } + } + // Items shouldn't use these else they get weird if (isItem) detail.keepLoaded = true; From e4d55f6b435c1fb42828c25ee05cbe02e611648a Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 16 Mar 2023 14:09:28 -0500 Subject: [PATCH 004/119] Orient ship spawn point, not just the ship itself --- NewHorizons/Builder/General/SpawnPointBuilder.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 437fb1b6b..d9aad42a1 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -53,11 +53,14 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo if (module.shipSpawnRotation != null) { - ship.transform.rotation = Quaternion.Euler(module.shipSpawnRotation); + spawnGO.transform.rotation = Quaternion.Euler(module.shipSpawnRotation); + ship.transform.rotation = spawnGO.transform.rotation; } else { - ship.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - planetGO.transform.position).normalized); + spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - planetGO.transform.position).normalized); + ship.transform.rotation = spawnGO.transform.rotation; + // Move it up a bit more when aligning to surface ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 4f; } From f98b33251dfa135326d516f1dd239e10e53016a7 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 16 Mar 2023 15:08:56 -0500 Subject: [PATCH 005/119] Consolidate prop info definitions and add support for missing properties to geyser and quantum sockets --- NewHorizons/Builder/Props/GeyserBuilder.cs | 2 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 26 +- NewHorizons/External/Modules/PropModule.cs | 326 +++----------------- 3 files changed, 73 insertions(+), 281 deletions(-) diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index 11c9f02cc..2077b1a78 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -35,7 +35,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf } } - var pos = (Vector3)info.position; + var pos = info.isRelativeToParent ? geyserGO.transform.parent.TransformPoint((Vector3)info.position) : (Vector3)info.position; // Offset height, default -97.5 pushes it underground so the spout is at the surface var length = pos.magnitude + info.offset; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 8a5a383b8..203845aee 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,12 +50,34 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = new GameObject("Socket " + i); + var socket = new GameObject(!string.IsNullOrEmpty(socketInfo.rename) ? socketInfo.rename : ("Socket " + i)); socket.SetActive(false); - socket.transform.parent = groupRoot.transform; + + socket.transform.parent = socketInfo.isRelativeToGroup ? groupRoot.transform : sector?.transform ?? go.transform; + + if (socketInfo.parentPath != null) + { + var newParent = go.transform.Find(socketInfo.parentPath); + if (newParent != null) + { + socket.transform.parent = newParent.transform; + } + else + { + Logger.LogError($"Cannot find parent object at path: {go.name}/{socketInfo.parentPath}"); + } + } + socket.transform.localPosition = socketInfo.position; socket.transform.localEulerAngles = socketInfo.rotation; + if (!socketInfo.isRelativeToParent && !socketInfo.isRelativeToGroup) + { + socket.transform.position = go.transform.TransformPoint(socketInfo.position); + Quaternion rot = socketInfo.rotation == null ? Quaternion.identity : Quaternion.Euler(socketInfo.rotation); + socket.transform.rotation = go.transform.TransformRotation(rot); + } + sockets[i] = socket.AddComponent(); sockets[i]._lightSources = new Light[0]; socket.SetActive(true); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 5ff5625ea..2360ca1a3 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -98,6 +98,39 @@ public class PropModule [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes; + [JsonObject] + public abstract class PositionedPropInfo + { + /// + /// Position of the prop + /// + public MVector3 position; + + /// + /// 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; + } + + [JsonObject] + public abstract class PositionedAndRotatedPropInfo : PositionedPropInfo + { + /// + /// Rotate this prop once it is placed + /// + public MVector3 rotation; + } + [JsonObject] public class ScatterInfo { @@ -163,12 +196,8 @@ public class ScatterInfo } [JsonObject] - public class DetailInfo + public class DetailInfo : PositionedAndRotatedPropInfo { - /// - /// An optional rename of the detail - /// - public string rename; /// /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? @@ -185,11 +214,6 @@ public class DetailInfo /// public string path; - /// - /// Position of this prop relative to the body's center - /// - public MVector3 position; - /// /// A list of children to remove from this detail /// @@ -201,11 +225,6 @@ public class DetailInfo /// public bool removeComponents; - /// - /// Rotate this prop - /// - public MVector3 rotation; - /// /// Scale the prop /// @@ -221,16 +240,6 @@ public class DetailInfo /// public string quantumGroupID; - /// - /// The path (not including the root planet object) of the parent of this game 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; - /// /// Should this detail stay loaded even if you're outside the sector (good for very large props) /// @@ -256,42 +265,17 @@ public class DetailInfo } [JsonObject] - public class RaftInfo + public class RaftInfo : PositionedPropInfo { - /// - /// Position of the raft - /// - public MVector3 position; - /// /// Acceleration of the raft. Default acceleration is 5. /// [DefaultValue(5f)] public float acceleration = 5f; - - /// - /// 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; } [JsonObject] - public class GeyserInfo + public class GeyserInfo : PositionedPropInfo { - /// - /// Position of the geyser - /// - public MVector3 position; - /// /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. /// @@ -326,20 +310,10 @@ public class GeyserInfo /// Loudness of the geyser /// [DefaultValue(0.7f)] public float volume = 0.7f; - - /// - /// The relative path from the planet to the parent of this object. Optional (will default to the root sector). - /// - public string parentPath; - - /// - /// An optional rename of this object - /// - public string rename; } [JsonObject] - public class TornadoInfo + public class TornadoInfo : PositionedPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum TornadoType @@ -363,11 +337,6 @@ public enum TornadoType /// [DefaultValue(30f)] public float height = 30f; - /// - /// Position of the tornado - /// - public MVector3 position; - /// /// The colour of the tornado. /// @@ -403,25 +372,10 @@ public enum TornadoType /// Fluid type for sounds/effects when colliding with this tornado. /// [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud; - - /// - /// 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; } [JsonObject] - public class VolcanoInfo + public class VolcanoInfo : PositionedPropInfo { /// /// The colour of the meteor's lava. @@ -452,11 +406,6 @@ public class VolcanoInfo [DefaultValue(50f)] public float minLaunchSpeed = 50f; - /// - /// Position of this volcano. - /// - public MVector3 position; - /// /// Scale of the meteors. /// @@ -466,25 +415,10 @@ public class VolcanoInfo /// The colour of the meteor's stone. /// public MColor stoneTint; - - /// - /// 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; } [JsonObject] - public class DialogueInfo + public class DialogueInfo : PositionedPropInfo { /// /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue @@ -506,11 +440,6 @@ public class DialogueInfo /// public string pathToAnimController; - /// - /// When you enter into dialogue, you will look here. - /// - public MVector3 position; - /// /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a /// remoteTriggerPosition, you can set this to 0 to make the dialogue only trigger remotely. @@ -542,21 +471,6 @@ public class DialogueInfo /// public string xmlFile; - /// - /// Whether the positional and rotational coordinates are relative to the animation controller instead of the root planet object. - /// - public bool isRelativeToParent; - - /// - /// Optionally rename the dialogue object. The remote trigger volume will be renamed to have this as a prefix. - /// - public string rename; - - /// - /// Optionally set the parent object that the dialogue and remote trigger will be attached to - /// - public string parentPath; - /// /// What type of flashlight toggle to do when dialogue is interacted with /// @@ -572,7 +486,7 @@ public enum FlashlightToggle } [JsonObject] - public class EntryLocationInfo + public class EntryLocationInfo : PositionedPropInfo { /// /// Whether this location is cloaked @@ -583,30 +497,10 @@ public class EntryLocationInfo /// ID of the entry this location relates to /// public string id; - - /// - /// The position of this entry location - /// - public MVector3 position; - - /// - /// 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; } [JsonObject] - public class NomaiTextInfo + public class NomaiTextInfo : PositionedPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum NomaiTextType @@ -650,11 +544,6 @@ public enum NomaiTextLocation /// public MVector3 normal; - /// - /// Position of the root of this text - /// - public MVector3 position; - /// /// The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient /// themselves to the surface of the planet automatically. @@ -680,21 +569,6 @@ public enum NomaiTextLocation /// The relative path to the xml file for this object. /// public string xmlFile; - - /// - /// 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; } [JsonObject] @@ -742,7 +616,7 @@ public enum NomaiTextArcType } [JsonObject] - public class ProjectionInfo + public class ProjectionInfo : PositionedAndRotatedPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SlideShowType @@ -757,11 +631,6 @@ public enum SlideShowType } - /// - /// The position of this slideshow. - /// - public MVector3 position; - /// /// The ship log facts revealed after finishing this slide reel. /// @@ -775,11 +644,6 @@ public enum SlideShowType /// public string[] playWithShipLogFacts; - /// - /// The rotation of this slideshow. - /// - public MVector3 rotation; - /// /// The list of slides for this object. /// @@ -789,21 +653,6 @@ public enum SlideShowType /// The type of object this is. /// [DefaultValue("slideReel")] public SlideShowType type = SlideShowType.SlideReel; - - /// - /// The relative path from the planet to the parent of this slideshow. 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; } [JsonObject] @@ -934,18 +783,12 @@ public class QuantumGroupInfo } [JsonObject] - public class QuantumSocketInfo + public class QuantumSocketInfo : PositionedAndRotatedPropInfo { /// - /// The location of this socket + /// Whether the socket will be placed relative to the group it belongs to /// - public MVector3 position; - - /// - /// The rotation the quantum object will take if it's occupying this socket - /// - public MVector3 rotation; - + [DefaultValue(true)] public bool isRelativeToGroup = true; /// /// The probability any props that are part of this group will occupy this socket /// @@ -981,38 +824,13 @@ public class RemoteInfo public StoneInfo[] stones; [JsonObject] - public class WhiteboardInfo + public class WhiteboardInfo : PositionedAndRotatedPropInfo { /// /// The text for each stone /// public SharedNomaiTextInfo[] nomaiText; - /// - /// The location of this platform. - /// - public MVector3 position; - - /// - /// The rotation of this platform. - /// - 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; - /// /// Disable the wall, leaving only the pedestal and text. /// @@ -1054,33 +872,8 @@ public class SharedNomaiTextInfo } [JsonObject] - public class PlatformInfo + public class PlatformInfo : PositionedAndRotatedPropInfo { - /// - /// The location of this platform. - /// - public MVector3 position; - - /// - /// The rotation of this platform. - /// - 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; - /// /// A ship log fact to reveal when the platform is connected to. /// @@ -1098,32 +891,9 @@ public class PlatformInfo } [JsonObject] - public class StoneInfo + public class StoneInfo : PositionedAndRotatedPropInfo { - /// - /// The location of this stone. - /// - public MVector3 position; - /// - /// The rotation of this stone. - /// - 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; } } } From 0cb69969dc8a448398f578a38e97d2ff36ad2cf2 Mon Sep 17 00:00:00 2001 From: Ben C Date: Thu, 16 Mar 2023 20:14:41 +0000 Subject: [PATCH 006/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 311 ++++++++++++++------------- 1 file changed, 166 insertions(+), 145 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 624fc8218..65c09f022 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1076,9 +1076,25 @@ "type": "object", "additionalProperties": false, "properties": { + "rotation": { + "description": "Rotate this prop once it is placed", + "$ref": "#/definitions/MVector3" + }, + "position": { + "description": "Position of the prop", + "$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 the detail" + "description": "An optional rename of this object" }, "alignToNormal": { "type": "boolean", @@ -1092,10 +1108,6 @@ "type": "string", "description": "Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle" }, - "position": { - "description": "Position of this prop relative to the body's center", - "$ref": "#/definitions/MVector3" - }, "removeChildren": { "type": "array", "description": "A list of children to remove from this detail", @@ -1107,10 +1119,6 @@ "type": "boolean", "description": "Do we reset all the components on this object? Useful for certain props that have dialogue components attached to\nthem." }, - "rotation": { - "description": "Rotate this prop", - "$ref": "#/definitions/MVector3" - }, "scale": { "type": "number", "description": "Scale the prop", @@ -1125,14 +1133,6 @@ "type": "string", "description": "If this value is not null, this prop will be quantum. Assign this field to the id of the quantum group it should be a part of. The group it is assigned to determines what kind of quantum object it is" }, - "parentPath": { - "type": "string", - "description": "The path (not including the root planet object) of the parent of this game 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." - }, "keepLoaded": { "type": "boolean", "description": "Should this detail stay loaded even if you're outside the sector (good for very large props)" @@ -1159,6 +1159,22 @@ "type": "object", "additionalProperties": false, "properties": { + "position": { + "description": "Position of the prop", + "$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" + }, "blockAfterPersistentCondition": { "type": "string", "description": "Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue\ntriggers that you want to have happen only once." @@ -1172,10 +1188,6 @@ "type": "string", "description": "If this dialogue is meant for a character, this is the relative path from the planet to that character's\nCharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController.\n\nIf none of those components are present it will add a FacePlayerWhenTalking component." }, - "position": { - "description": "When you enter into dialogue, you will look here.", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "Radius of the spherical collision volume where you get the \"talk to\" prompt when looking at. If you use a\nremoteTriggerPosition, you can set this to 0 to make the dialogue only trigger remotely.", @@ -1204,18 +1216,6 @@ "type": "string", "description": "Relative path to the xml file defining the dialogue." }, - "isRelativeToParent": { - "type": "boolean", - "description": "Whether the positional and rotational coordinates are relative to the animation controller instead of the root planet object." - }, - "rename": { - "type": "string", - "description": "Optionally rename the dialogue object. The remote trigger volume will be renamed to have this as a prefix." - }, - "parentPath": { - "type": "string", - "description": "Optionally set the parent object that the dialogue and remote trigger will be attached to" - }, "flashlightToggle": { "description": "What type of flashlight toggle to do when dialogue is interacted with", "default": "none", @@ -1241,16 +1241,8 @@ "type": "object", "additionalProperties": false, "properties": { - "cloaked": { - "type": "boolean", - "description": "Whether this location is cloaked" - }, - "id": { - "type": "string", - "description": "ID of the entry this location relates to" - }, "position": { - "description": "The position of this entry location", + "description": "Position of the prop", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1264,6 +1256,14 @@ "rename": { "type": "string", "description": "An optional rename of this object" + }, + "cloaked": { + "type": "boolean", + "description": "Whether this location is cloaked" + }, + "id": { + "type": "string", + "description": "ID of the entry this location relates to" } } }, @@ -1272,9 +1272,21 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the geyser", + "description": "Position of the prop", "$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" + }, "offset": { "type": "number", "description": "Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5.", @@ -1320,21 +1332,29 @@ "description": "Loudness of the geyser", "format": "float", "default": 0.7 + } + } + }, + "NomaiTextInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "position": { + "description": "Position of the prop", + "$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" - } - } - }, - "NomaiTextInfo": { - "type": "object", - "additionalProperties": false, - "properties": { + }, "arcInfo": { "type": "array", "description": "Additional information about each arc in the text", @@ -1346,10 +1366,6 @@ "description": "The normal vector for this object. Used for writing on walls and positioning computers.", "$ref": "#/definitions/MVector3" }, - "position": { - "description": "Position of the root of this text", - "$ref": "#/definitions/MVector3" - }, "rotation": { "description": "The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient\nthemselves to the surface of the planet automatically.", "$ref": "#/definitions/MVector3" @@ -1372,18 +1388,6 @@ "xmlFile": { "type": "string", "description": "The relative path to the xml file for this object." - }, - "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" } } }, @@ -1496,15 +1500,9 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the raft", + "description": "Position of the prop", "$ref": "#/definitions/MVector3" }, - "acceleration": { - "type": "number", - "description": "Acceleration of the raft. Default acceleration is 5.", - "format": "float", - "default": 5.0 - }, "parentPath": { "type": "string", "description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)." @@ -1516,6 +1514,12 @@ "rename": { "type": "string", "description": "An optional rename of this object" + }, + "acceleration": { + "type": "number", + "description": "Acceleration of the raft. Default acceleration is 5.", + "format": "float", + "default": 5.0 } } }, @@ -1590,10 +1594,26 @@ "type": "object", "additionalProperties": false, "properties": { + "rotation": { + "description": "Rotate this prop once it is placed", + "$ref": "#/definitions/MVector3" + }, "position": { - "description": "The position of this slideshow.", + "description": "Position of the prop", "$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" + }, "reveals": { "type": "array", "description": "The ship log facts revealed after finishing this slide reel.", @@ -1608,10 +1628,6 @@ "type": "string" } }, - "rotation": { - "description": "The rotation of this slideshow.", - "$ref": "#/definitions/MVector3" - }, "slides": { "type": "array", "description": "The list of slides for this object.", @@ -1623,18 +1639,6 @@ "description": "The type of object this is.", "default": "slideReel", "$ref": "#/definitions/SlideShowType" - }, - "parentPath": { - "type": "string", - "description": "The relative path from the planet to the parent of this slideshow. 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" } } }, @@ -1767,14 +1771,31 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this socket", + "rotation": { + "description": "Rotate this prop once it is placed", "$ref": "#/definitions/MVector3" }, - "rotation": { - "description": "The rotation the quantum object will take if it's occupying this socket", + "position": { + "description": "Position of the prop", "$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" + }, + "isRelativeToGroup": { + "type": "boolean", + "description": "Whether the socket will be placed relative to the group it belongs to", + "default": true + }, "probability": { "type": "number", "description": "The probability any props that are part of this group will occupy this socket", @@ -1787,6 +1808,22 @@ "type": "object", "additionalProperties": false, "properties": { + "position": { + "description": "Position of the prop", + "$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" + }, "elevation": { "type": "number", "description": "Alternative to setting the position. Will choose a random place at this elevation.", @@ -1798,10 +1835,6 @@ "format": "float", "default": 30.0 }, - "position": { - "description": "Position of the tornado", - "$ref": "#/definitions/MVector3" - }, "tint": { "description": "The colour of the tornado.", "$ref": "#/definitions/MColor" @@ -1837,18 +1870,6 @@ "description": "Fluid type for sounds/effects when colliding with this tornado.", "default": "cloud", "$ref": "#/definitions/FluidType" - }, - "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" } } }, @@ -1870,6 +1891,22 @@ "type": "object", "additionalProperties": false, "properties": { + "position": { + "description": "Position of the prop", + "$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" + }, "lavaTint": { "description": "The colour of the meteor's lava.", "$ref": "#/definitions/MColor" @@ -1898,10 +1935,6 @@ "format": "float", "default": 50.0 }, - "position": { - "description": "Position of this volcano.", - "$ref": "#/definitions/MVector3" - }, "scale": { "type": "number", "description": "Scale of the meteors.", @@ -1910,18 +1943,6 @@ "stoneTint": { "description": "The colour of the meteor's stone.", "$ref": "#/definitions/MColor" - }, - "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" } } }, @@ -2105,19 +2126,12 @@ "type": "object", "additionalProperties": false, "properties": { - "nomaiText": { - "type": "array", - "description": "The text for each stone", - "items": { - "$ref": "#/definitions/SharedNomaiTextInfo" - } - }, - "position": { - "description": "The location of this platform.", + "rotation": { + "description": "Rotate this prop once it is placed", "$ref": "#/definitions/MVector3" }, - "rotation": { - "description": "The rotation of this platform.", + "position": { + "description": "Position of the prop", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2132,6 +2146,13 @@ "type": "string", "description": "An optional rename of this object" }, + "nomaiText": { + "type": "array", + "description": "The text for each stone", + "items": { + "$ref": "#/definitions/SharedNomaiTextInfo" + } + }, "disableWall": { "type": "boolean", "description": "Disable the wall, leaving only the pedestal and text." @@ -2177,12 +2198,12 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this platform.", + "rotation": { + "description": "Rotate this prop once it is placed", "$ref": "#/definitions/MVector3" }, - "rotation": { - "description": "The rotation of this platform.", + "position": { + "description": "Position of the prop", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2216,12 +2237,12 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this stone.", + "rotation": { + "description": "Rotate this prop once it is placed", "$ref": "#/definitions/MVector3" }, - "rotation": { - "description": "The rotation of this stone.", + "position": { + "description": "Position of the prop", "$ref": "#/definitions/MVector3" }, "parentPath": { From 37e6c42b85632064e8799ac6462bef2747127b8d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 16 Mar 2023 17:15:06 -0500 Subject: [PATCH 007/119] Consolidating generic prop building into a single builder --- NewHorizons/Builder/Props/DetailBuilder.cs | 50 +------------ .../Builder/Props/GeneralPropBuilder.cs | 74 +++++++++++++++++++ NewHorizons/Builder/Props/GeyserBuilder.cs | 20 +---- .../Builder/Props/ProjectionBuilder.cs | 65 +--------------- NewHorizons/Builder/Props/QuantumBuilder.cs | 29 ++------ NewHorizons/Builder/Props/RaftBuilder.cs | 30 +------- NewHorizons/Builder/Props/TornadoBuilder.cs | 11 +-- NewHorizons/Builder/Props/VolcanoBuilder.cs | 26 +------ .../Builder/ShipLog/EntryLocationBuilder.cs | 24 +----- NewHorizons/External/Modules/PropModule.cs | 2 +- 10 files changed, 97 insertions(+), 234 deletions(-) create mode 100644 NewHorizons/Builder/Props/GeneralPropBuilder.cs diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 7d70f9ad5..c00bc2170 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -90,14 +90,12 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P // We save copies with all their components fixed, good if the user is placing the same detail more than once if (detail?.path != null && _fixedPrefabCache.TryGetValue((sector, detail.path), out var storedPrefab)) { - prop = storedPrefab.prefab.InstantiateInactive(); - prop.name = prefab.name; + prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail, detail.alignToNormal); isItem = storedPrefab.isItem; } else { - prop = prefab.InstantiateInactive(); - prop.name = prefab.name; + prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail, detail.alignToNormal); StreamingHandler.SetUpStreaming(prop, sector); @@ -132,8 +130,6 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P } } - prop.transform.parent = sector?.transform ?? go.transform; - if (invalidComponentFound) { foreach (Transform t in prop.GetComponentsInChildren(true)) @@ -148,21 +144,15 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P // Items shouldn't use these else they get weird if (isItem) detail.keepLoaded = true; - prop.transform.position = detail.position == null ? go.transform.position : go.transform.TransformPoint(detail.position); - - Quaternion rot = detail.rotation == null ? Quaternion.identity : Quaternion.Euler(detail.rotation); if (detail.alignToNormal) { + Quaternion rot = detail.rotation == null ? Quaternion.identity : Quaternion.Euler(detail.rotation); // Apply the rotation after aligning it with normal var up = (prop.transform.position - go.transform.position).normalized; prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); prop.transform.rotation *= rot; } - else - { - prop.transform.rotation = go.transform.TransformRotation(rot); - } prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale); @@ -206,40 +196,6 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P GameObject.Destroy(prop); prop = newDetailGO; } - - if (detail.rename != null) - { - prop.name = detail.rename; - } - - if (!string.IsNullOrEmpty(detail.parentPath)) - { - var newParent = go.transform.Find(detail.parentPath); - if (newParent != null) - { - prop.transform.parent = newParent.transform; - } - else - { - Logger.LogError($"Cannot find parent object at path: {go.name}/{detail.parentPath}"); - } - } - - if (detail.isRelativeToParent) - { - prop.transform.localPosition = detail.position == null ? Vector3.zero : detail.position; - if (detail.alignToNormal) - { - // Apply the rotation after aligning it with normal - var up = (prop.transform.position - go.transform.position).normalized; - prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); - prop.transform.rotation *= rot; - } - else - { - prop.transform.localRotation = rot; - } - } if (isItem) { diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs new file mode 100644 index 000000000..112191a2e --- /dev/null +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -0,0 +1,74 @@ +using NewHorizons.External.Modules; +using NewHorizons.Utility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Builder.Props +{ + public static class GeneralPropBuilder + { + public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody) + { + if (!string.IsNullOrEmpty(info.rename)) + { + go.name = info.rename; + } + + go.transform.parent = sector?.transform ?? planetGO.transform; + + if (!string.IsNullOrEmpty(info.parentPath)) + { + var newParent = go.transform.Find(info.parentPath); + if (newParent != null) + { + go.transform.parent = newParent.transform; + } + else + { + Logger.LogError($"Cannot find parent object at path: {go.name}/{info.parentPath}"); + } + } + + Vector3 pos = (Vector3)(info.position ?? Vector3.zero); + Quaternion rot = Quaternion.identity; + if (info is PropModule.PositionedAndRotatedPropInfo rotInfo) + { + rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; + } + if (info.isRelativeToParent) + { + go.transform.localPosition = pos; + go.transform.localRotation = rot; + } else + { + go.transform.position = planetGO.transform.TransformPoint(pos); + go.transform.rotation = planetGO.transform.TransformRotation(rot); + } + if (alignToBody) + { + var planetPos = planetGO.transform.InverseTransformPoint(go.transform.position); + go.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(planetPos.normalized)).normalized; + } + return go; + } + + public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody) + { + GameObject go = new GameObject(defaultName); + go.SetActive(false); + return MakeFromExisting(go, planetGO, sector, info, alignToBody); + } + + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody) + { + GameObject go = prefab.InstantiateInactive(); + go.name = defaultName; + return MakeFromExisting(go, planetGO, sector, info, alignToBody); + } + } +} diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index 2077b1a78..633e282ab 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -18,22 +18,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf { InitPrefab(); - var geyserGO = _geyserPrefab.InstantiateInactive(); - geyserGO.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "Geyser"; - geyserGO.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - geyserGO.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } + var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", planetGO, sector, info, true); var pos = info.isRelativeToParent ? geyserGO.transform.parent.TransformPoint((Vector3)info.position) : (Vector3)info.position; @@ -45,9 +30,6 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf geyserGO.transform.localScale = Vector3.one; - var up = planetGO.transform.TransformPoint(pos) - planetGO.transform.position; - geyserGO.transform.rotation = Quaternion.FromToRotation(geyserGO.transform.up, up) * geyserGO.transform.rotation; - var bubbles = geyserGO.FindChild("GeyserParticles/GeyserBubbles"); var shaft = geyserGO.FindChild("GeyserParticles/GeyserShaft"); var spout = geyserGO.FindChild("GeyserParticles/GeyserSpout"); diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 4531bab76..0057d2d46 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -93,8 +93,7 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Prop if (_slideReelPrefab == null) return null; - var slideReelObj = _slideReelPrefab.InstantiateInactive(); - slideReelObj.name = !string.IsNullOrEmpty(info.rename) ? info.rename : $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}"; + var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info, false); var slideReel = slideReelObj.GetComponent(); slideReel.SetSector(sector); @@ -107,34 +106,6 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Prop renderer.enabled = true; } - slideReelObj.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - slideReelObj.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - var rot = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero)); - if (info.isRelativeToParent) - { - slideReelObj.transform.localPosition = pos; - slideReelObj.transform.localRotation = rot; - } - else - { - slideReelObj.transform.position = planetGO.transform.TransformPoint(pos); - slideReelObj.transform.rotation = planetGO.transform.TransformRotation(rot); - } - // Now we replace the slides int slidesCount = info.slides.Length; var slideCollection = new SlideCollection(slidesCount); @@ -195,42 +166,13 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P if (_autoPrefab == null) return null; - var projectorObj = _autoPrefab.InstantiateInactive(); - projectorObj.name = !string.IsNullOrEmpty(info.rename) ? info.rename : $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}"; + var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info, false); var autoProjector = projectorObj.GetComponent(); autoProjector._sector = sector; var slideCollectionContainer = autoProjector.GetRequiredComponent(); - autoProjector.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - autoProjector.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - var rot = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero)); - if (info.isRelativeToParent) - { - autoProjector.transform.localPosition = pos; - autoProjector.transform.localRotation = rot; - } - else - { - autoProjector.transform.position = planetGO.transform.TransformPoint(pos); - autoProjector.transform.rotation = planetGO.transform.TransformRotation(rot); - } - // Now we replace the slides int slidesCount = info.slides.Length; var slideCollection = new SlideCollection(slidesCount); @@ -266,6 +208,7 @@ public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector rotation = info.rotation, parentPath = info.parentPath, isRelativeToParent = info.isRelativeToParent, + rename = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector", scale = 2 }; var g = DetailBuilder.Make(planetGO, sector, _visionTorchDetectorPrefab, detailInfo); @@ -276,8 +219,6 @@ public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector return null; } - g.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector"; - // The number of slides is unlimited, 15 is only for texturing the actual slide reel item. This is not a slide reel item var slides = info.slides; var slidesCount = slides.Length; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 203845aee..39665a904 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,32 +50,13 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = new GameObject(!string.IsNullOrEmpty(socketInfo.rename) ? socketInfo.rename : ("Socket " + i)); - socket.SetActive(false); + var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, false); - socket.transform.parent = socketInfo.isRelativeToGroup ? groupRoot.transform : sector?.transform ?? go.transform; - - if (socketInfo.parentPath != null) - { - var newParent = go.transform.Find(socketInfo.parentPath); - if (newParent != null) - { - socket.transform.parent = newParent.transform; - } - else - { - Logger.LogError($"Cannot find parent object at path: {go.name}/{socketInfo.parentPath}"); - } - } - - socket.transform.localPosition = socketInfo.position; - socket.transform.localEulerAngles = socketInfo.rotation; - - if (!socketInfo.isRelativeToParent && !socketInfo.isRelativeToGroup) + if (socketInfo.isRelativeToGroup) { - socket.transform.position = go.transform.TransformPoint(socketInfo.position); - Quaternion rot = socketInfo.rotation == null ? Quaternion.identity : Quaternion.Euler(socketInfo.rotation); - socket.transform.rotation = go.transform.TransformRotation(rot); + socket.transform.parent = groupRoot.transform; + socket.transform.localPosition = socketInfo.position; + socket.transform.localEulerAngles = socketInfo.rotation; } sockets[i] = socket.AddComponent(); diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index 11b40a267..b816c4009 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -52,35 +52,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Raf if (_prefab == null || sector == null) return null; - GameObject raftObject = _prefab.InstantiateInactive(); - raftObject.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "Raft_Body"; - raftObject.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - raftObject.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - var rot = Quaternion.identity; - if (info.isRelativeToParent) - { - raftObject.transform.localPosition = pos; - raftObject.transform.localRotation = rot; - } - else - { - raftObject.transform.position = planetGO.transform.TransformPoint(pos); - raftObject.transform.rotation = planetGO.transform.TransformRotation(rot); - } + GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info, false); StreamingHandler.SetUpStreaming(raftObject, sector); diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 2b63bd523..80e9aea3c 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -98,11 +98,12 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoIn private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { - var tornadoGO = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); - tornadoGO.name = !string.IsNullOrEmpty(info.rename) ? info.rename : (downwards ? "Tornado_Down" : "Tornado_Up"); - tornadoGO.transform.parent = sector?.transform ?? planetGO.transform; - tornadoGO.transform.position = planetGO.transform.TransformPoint(position); - tornadoGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(position.normalized)); + var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); + var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true); + if (info.position == null && !info.isRelativeToParent) + { + tornadoGO.transform.position = planetGO.transform.TransformPoint(position); + } // Add the sound thing before changing the scale var soundGO = _soundPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index e5e902355..c4bf04ce6 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -45,31 +45,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoIn { InitPrefab(); - var launcherGO = _meteorLauncherPrefab.InstantiateInactive(); - launcherGO.name = !string.IsNullOrEmpty(info.rename) ? info.rename : "MeteorLauncher"; - launcherGO.transform.parent = sector?.transform ?? planetGO.transform; - launcherGO.transform.position = planetGO.transform.TransformPoint(info.position == null ? Vector3.zero : (Vector3)info.position); - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - launcherGO.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) - launcherGO.transform.localPosition = pos; - else - launcherGO.transform.position = planetGO.transform.TransformPoint(pos); - - launcherGO.transform.rotation = Quaternion.FromToRotation(launcherGO.transform.TransformDirection(Vector3.up), pos.normalized).normalized; + var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info, true); var meteorLauncher = launcherGO.GetComponent(); meteorLauncher._audioSector = sector; diff --git a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs index e7d86a596..55f3e0c5b 100644 --- a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs +++ b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using OWML.Common; using System.Collections.Generic; @@ -11,28 +12,7 @@ public static class EntryLocationBuilder private static readonly List _locationsToInitialize = new List(); public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod) { - GameObject entryLocationGameObject = new GameObject(!string.IsNullOrEmpty(info.rename) ? info.rename : ("Entry Location (" + info.id + ")")); - entryLocationGameObject.SetActive(false); - entryLocationGameObject.transform.parent = sector?.transform ?? go.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = go.transform.Find(info.parentPath); - if (newParent != null) - { - entryLocationGameObject.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {go.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) - entryLocationGameObject.transform.localPosition = pos; - else - entryLocationGameObject.transform.position = go.transform.TransformPoint(pos); + GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info, false); ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent(); newLocation._entryID = info.id; diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 2360ca1a3..6d47ceb49 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -786,7 +786,7 @@ public class QuantumGroupInfo public class QuantumSocketInfo : PositionedAndRotatedPropInfo { /// - /// Whether the socket will be placed relative to the group it belongs to + /// Whether the socket will be placed relative to the group it belongs to. Overrides `isRelativeToParent` /// [DefaultValue(true)] public bool isRelativeToGroup = true; /// From 4682fc275fdce8342b2a69f4cfea662d642f549a Mon Sep 17 00:00:00 2001 From: Ben C Date: Thu, 16 Mar 2023 22:18:35 +0000 Subject: [PATCH 008/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 65c09f022..82696e362 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1793,7 +1793,7 @@ }, "isRelativeToGroup": { "type": "boolean", - "description": "Whether the socket will be placed relative to the group it belongs to", + "description": "Whether the socket will be placed relative to the group it belongs to. Overrides `isRelativeToParent`", "default": true }, "probability": { From 15961bed4bf4828de1b44544f3d5f5a124882174 Mon Sep 17 00:00:00 2001 From: Will Corby Date: Thu, 16 Mar 2023 16:02:21 -0700 Subject: [PATCH 009/119] bump version before i forget --- NewHorizons/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index c5bbf50d1..99486e9b2 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.9.0", + "version": "1.9.1", "owmlVersion": "2.9.0", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From 00729ef4ae454dcb69dcb4a08a3f9fb9c9d01591 Mon Sep 17 00:00:00 2001 From: Will Corby Date: Thu, 16 Mar 2023 16:04:52 -0700 Subject: [PATCH 010/119] Update DetailBuilder.cs --- 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 c00bc2170..b38c3f7a0 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -136,7 +136,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P { if (t.GetComponents().Any(c => c == null)) { - Logger.LogError($"Failed to instantiate component at {t.GetPath()}"); + Logger.LogError($"Failed to instantiate component at {t.GetPath()}. This usually means there's a missing script."); } } } @@ -437,4 +437,4 @@ public void Start() } } } -} \ No newline at end of file +} From ee99c5e937c354b7adffe717cb80bac3a80bb4b7 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Thu, 16 Mar 2023 20:14:22 -0500 Subject: [PATCH 011/119] Include rotation in body alignment calculations --- NewHorizons/Builder/Props/DetailBuilder.cs | 10 ---------- NewHorizons/Builder/Props/GeneralPropBuilder.cs | 5 +++-- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index c00bc2170..45b6df29c 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -144,16 +144,6 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P // Items shouldn't use these else they get weird if (isItem) detail.keepLoaded = true; - - if (detail.alignToNormal) - { - Quaternion rot = detail.rotation == null ? Quaternion.identity : Quaternion.Euler(detail.rotation); - // Apply the rotation after aligning it with normal - var up = (prop.transform.position - go.transform.position).normalized; - prop.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); - prop.transform.rotation *= rot; - } - prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale); if (detail.removeChildren != null) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 112191a2e..fa617c914 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -51,8 +51,9 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se } if (alignToBody) { - var planetPos = planetGO.transform.InverseTransformPoint(go.transform.position); - go.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(planetPos.normalized)).normalized; + var up = (go.transform.position - planetGO.transform.position).normalized; + go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); + go.transform.rotation *= rot; } return go; } From 3ca6d9a3dbf8303cc3b35b7d903655f599a8f711 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Fri, 17 Mar 2023 14:13:23 -0500 Subject: [PATCH 012/119] Migrate more modules to the GeneralPropBuilder --- .../Builder/Props/GeneralPropBuilder.cs | 11 +- .../Builder/Props/ProjectionBuilder.cs | 4 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 2 +- NewHorizons/Builder/Props/RaftBuilder.cs | 2 +- NewHorizons/Builder/Props/SignalBuilder.cs | 21 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 4 +- .../TranslatorText/TranslatorTextBuilder.cs | 227 ++---------------- .../Builder/ShipLog/EntryLocationBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 28 +-- NewHorizons/External/Modules/SignalModule.cs | 17 +- NewHorizons/External/Modules/VolumesModule.cs | 22 +- 11 files changed, 34 insertions(+), 306 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index fa617c914..ec6f9aa15 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody) + public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null) { if (!string.IsNullOrEmpty(info.rename)) { @@ -52,24 +52,25 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se if (alignToBody) { var up = (go.transform.position - planetGO.transform.position).normalized; + if (normal != null) up = planetGO.transform.TransformDirection(normal); go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); go.transform.rotation *= rot; } return go; } - public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody) + public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null) { GameObject go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, planetGO, sector, info, alignToBody); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null) { GameObject go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, planetGO, sector, info, alignToBody); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal); } } } diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 0057d2d46..19e1225ff 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -93,7 +93,7 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Prop if (_slideReelPrefab == null) return null; - var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info, false); + var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info); var slideReel = slideReelObj.GetComponent(); slideReel.SetSector(sector); @@ -166,7 +166,7 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P if (_autoPrefab == null) return null; - var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info, false); + var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info); var autoProjector = projectorObj.GetComponent(); autoProjector._sector = sector; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 39665a904..9c759808b 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,7 +50,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, false); + var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo); if (socketInfo.isRelativeToGroup) { diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index b816c4009..4440dbfab 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -52,7 +52,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Raf if (_prefab == null || sector == null) return null; - GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info, false); + GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info); StreamingHandler.SetUpStreaming(raftObject, sector); diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 876fc2c25..2cbf1118a 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -109,26 +109,7 @@ public static string GetCustomSignalName(SignalName signalName) public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) { - var signalGO = new GameObject($"Signal_{info.name}"); - signalGO.SetActive(false); - signalGO.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - signalGO.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) signalGO.transform.localPosition = pos; - else signalGO.transform.position = planetGO.transform.TransformPoint(pos); + var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", planetGO, sector, info); signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var source = signalGO.AddComponent(); diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 80e9aea3c..4ba7fa856 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -100,7 +100,9 @@ private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.T { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true); - if (info.position == null && !info.isRelativeToParent) + + // Override general prop position with randomized default position + if (info.position == null) { tornadoGO.transform.position = planetGO.transform.TransformPoint(position); } diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 96899393c..59a7b73d4 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -131,64 +131,25 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; - - if (!string.IsNullOrEmpty(info.rename)) + + if (info.normal != null) { - nomaiWallTextObj.name = info.rename; - } - - nomaiWallTextObj.transform.parent = sector?.transform ?? planetGO.transform; + // In global coordinates (normal was in local coordinates) + var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; + var forward = planetGO.transform.TransformDirection(info.normal).normalized; - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - nomaiWallTextObj.transform.parent = newParent; - } - else + if (info.isRelativeToParent) { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) - { - nomaiWallTextObj.transform.localPosition = pos; - if (info.normal != null) - { - // In global coordinates (normal was in local coordinates) - var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; - var forward = planetGO.transform.TransformDirection(info.normal).normalized; - nomaiWallTextObj.transform.up = up; nomaiWallTextObj.transform.forward = forward; - } - if (info.rotation != null) - { - nomaiWallTextObj.transform.localRotation = Quaternion.Euler(info.rotation); - } - } - else - { - nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(pos); - if (info.normal != null) + } else { - // In global coordinates (normal was in local coordinates) - var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; - var forward = planetGO.transform.TransformDirection(info.normal).normalized; - nomaiWallTextObj.transform.forward = forward; var desiredUp = Vector3.ProjectOnPlane(up, forward); var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward); nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); } - if (info.rotation != null) - { - nomaiWallTextObj.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); - } } // nomaiWallTextObj.GetComponent().DrawBoundsWithDebugSpheres(); @@ -200,16 +161,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { - var customScroll = _scrollPrefab.InstantiateInactive(); - - if (!string.IsNullOrEmpty(info.rename)) - { - customScroll.name = info.rename; - } - else - { - customScroll.name = _scrollPrefab.name; - } + var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); nomaiWallText.transform.parent = customScroll.transform; @@ -237,36 +189,6 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom // Else when you put them down you can't pick them back up customScroll.GetComponent()._physicsRemoved = false; - // Place scroll - customScroll.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - customScroll.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) customScroll.transform.localPosition = pos; - else customScroll.transform.position = planetGO.transform.TransformPoint(pos); - - var up = planetGO.transform.InverseTransformPoint(customScroll.transform.position).normalized; - if (info.rotation != null) - { - customScroll.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); - } - else - { - customScroll.transform.rotation = Quaternion.FromToRotation(customScroll.transform.up, up) * customScroll.transform.rotation; - } - customScroll.SetActive(true); Delay.FireOnNextUpdate( @@ -291,39 +213,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Computer: { - var computerObject = _computerPrefab.InstantiateInactive(); - - if (!string.IsNullOrEmpty(info.rename)) - { - computerObject.name = info.rename; - } - else - { - computerObject.name = _computerPrefab.name; - } - - computerObject.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - computerObject.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) computerObject.transform.localPosition = pos; - else computerObject.transform.position = planetGO.transform.TransformPoint(pos); - - var up = computerObject.transform.position - planetGO.transform.position; - if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal); - computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation; + var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info, true, info.normal); var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -395,48 +285,8 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.Cairn: case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: { - var cairnObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); - - if (!string.IsNullOrEmpty(info.rename)) - { - cairnObject.name = info.rename; - } - else - { - cairnObject.name = _cairnPrefab.name; - } - - cairnObject.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - cairnObject.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) cairnObject.transform.localPosition = pos; - else cairnObject.transform.position = planetGO.transform.TransformPoint(pos); - - if (info.rotation != null) - { - var rot = Quaternion.Euler(info.rotation); - if (info.isRelativeToParent) cairnObject.transform.localRotation = rot; - else cairnObject.transform.rotation = planetGO.transform.TransformRotation(rot); - } - else - { - // By default align it to normal - var up = (cairnObject.transform.position - planetGO.transform.position).normalized; - cairnObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * cairnObject.transform.rotation; - } + var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; + var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info, info.rotation == null); // Idk do we have to set it active before finding things? cairnObject.SetActive(true); @@ -476,17 +326,12 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom rotation = info.rotation, position = info.position, isRelativeToParent = info.isRelativeToParent, - rename = info.rename + rename = info.rename, + alignToNormal = info.rotation == null, }; var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo); recorderObject.SetActive(false); - if (info.rotation == null) - { - var up = recorderObject.transform.position - planetGO.transform.position; - recorderObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * recorderObject.transform.rotation; - } - var nomaiText = recorderObject.GetComponentInChildren(); nomaiText.SetSector(sector); @@ -504,52 +349,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: { - var trailmarkerObject = _trailmarkerPrefab.InstantiateInactive(); - - if (!string.IsNullOrEmpty(info.rename)) - { - trailmarkerObject.name = info.rename; - } - else - { - trailmarkerObject.name = _trailmarkerPrefab.name; - } - - trailmarkerObject.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - trailmarkerObject.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) trailmarkerObject.transform.localPosition = pos; - else trailmarkerObject.transform.position = planetGO.transform.TransformPoint(pos); + var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info, info.rotation == null); // shrink because that is what mobius does on all trailmarkers or else they are the size of the player trailmarkerObject.transform.localScale = Vector3.one * 0.75f; - if (info.rotation != null) - { - var rot = Quaternion.Euler(info.rotation); - if (info.isRelativeToParent) trailmarkerObject.transform.localRotation = rot; - else trailmarkerObject.transform.rotation = planetGO.transform.TransformRotation(rot); - } - else - { - // By default align it to normal - var up = (trailmarkerObject.transform.position - planetGO.transform.position).normalized; - trailmarkerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * trailmarkerObject.transform.rotation; - } - // Idk do we have to set it active before finding things? trailmarkerObject.SetActive(true); @@ -576,8 +380,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) { - GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); - nomaiWallTextObj.SetActive(false); + GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", go, sector, info); var box = nomaiWallTextObj.AddComponent(); box.center = new Vector3(-0.0643f, 1.1254f, 0f); diff --git a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs index 55f3e0c5b..ace39be31 100644 --- a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs +++ b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs @@ -12,7 +12,7 @@ public static class EntryLocationBuilder private static readonly List _locationsToInitialize = new List(); public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod) { - GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info, false); + GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info); ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent(); newLocation._entryID = info.id; diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index cc35c636c..a94a6c23e 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Modules; using UnityEngine; @@ -9,32 +10,7 @@ public static class VolumeBuilder { public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. { - var go = new GameObject(typeof(TVolume).Name); - go.SetActive(false); - - go.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.rename)) - { - go.name = info.rename; - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - go.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) go.transform.localPosition = pos; - else go.transform.position = planetGO.transform.TransformPoint(pos); + var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index 255ebc9b6..de5f474fa 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -15,7 +15,7 @@ public class SignalModule public SignalInfo[] signals; [JsonObject] - public class SignalInfo + public class SignalInfo : PropModule.PositionedPropInfo { [Obsolete("audioClip is deprecated, please use audio instead")] public string audioClip; @@ -61,11 +61,6 @@ public class SignalInfo /// [DefaultValue(true)] public bool onlyAudibleToScope = true; - /// - /// Position of the signal's source - /// - public MVector3 position; - /// /// A ship log fact to reveal when the signal is identified. /// @@ -75,16 +70,6 @@ public class SignalInfo /// Radius of the sphere giving off the signal. /// [DefaultValue(1f)] public float sourceRadius = 1f; - - /// - /// The relative path from the planet to the parent of this signal. 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; } } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 797428305..230665c08 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -117,33 +117,13 @@ public class VolumesModule public LoadCreditsVolumeInfo[] creditsVolume; [JsonObject] - public class VolumeInfo + public class VolumeInfo : PropModule.PositionedPropInfo { - /// - /// The location of this volume. Optional (will default to 0,0,0). - /// - public MVector3 position; - /// /// The radius of this volume. /// [DefaultValue(1f)] public float radius = 1f; - - /// - /// 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 coordinates are relative to parent instead of the root planet object. - /// - public bool isRelativeToParent; - - /// - /// An optional rename of this volume. - /// - public string rename; } [JsonObject] From 486032d3d1b76931fd20eeb372552985531bc301 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 17 Mar 2023 19:17:41 +0000 Subject: [PATCH 013/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 238 ++++++++++++++------------- 1 file changed, 121 insertions(+), 117 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 82696e362..26710fecb 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2034,6 +2034,22 @@ "type": "object", "additionalProperties": false, "properties": { + "position": { + "description": "Position of the prop", + "$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" + }, "audio": { "type": "string", "description": "The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list." @@ -2068,10 +2084,6 @@ "description": "`false` if the player can hear the signal without equipping the signal-scope.", "default": true }, - "position": { - "description": "Position of the signal's source", - "$ref": "#/definitions/MVector3" - }, "reveals": { "type": "string", "description": "A ship log fact to reveal when the signal is identified.", @@ -2082,14 +2094,6 @@ "description": "Radius of the sphere giving off the signal.", "format": "float", "default": 1.0 - }, - "parentPath": { - "type": "string", - "description": "The relative path from the planet to the parent of this signal. 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." } } }, @@ -2854,27 +2858,27 @@ "format": "int32", "default": 1 }, - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "audio": { "type": "string", @@ -2989,27 +2993,27 @@ "type": "boolean", "description": "Whether this volume only affects the player and ship." }, - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "deathType": { "description": "The type of death the player will have if they enter this volume.", @@ -3072,27 +3076,27 @@ "format": "int32", "default": 1 }, - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "density": { "type": "number", @@ -3145,27 +3149,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "type": { "description": "The type of hazard for this volume.", @@ -3235,26 +3239,26 @@ "additionalProperties": false, "properties": { "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", + "description": "Position of the prop", "$ref": "#/definitions/MVector3" }, - "radius": { - "type": "number", - "description": "The radius of this volume.", - "format": "float", - "default": 1.0 - }, "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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" + }, + "radius": { + "type": "number", + "description": "The radius of this volume.", + "format": "float", + "default": 1.0 } } }, @@ -3262,27 +3266,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "target": { "description": "What the notification will show for.", @@ -3333,27 +3337,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "treeVolume": { "type": "boolean", @@ -3390,27 +3394,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "maxAngle": { "type": "number", @@ -3513,27 +3517,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "minImpactSpeed": { "type": "number", @@ -3553,27 +3557,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "overrideProbeSpeed": { "type": "boolean", @@ -3603,27 +3607,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "thrustLimit": { "type": "number", @@ -3647,27 +3651,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "speedLimit": { "type": "number", @@ -3719,27 +3723,27 @@ "format": "int32", "default": 1 }, - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "frostRate": { "type": "number", @@ -3773,27 +3777,27 @@ "format": "int32", "default": 1 }, - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "dropletRate": { "type": "number", @@ -3813,27 +3817,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "layer": { "type": "integer", @@ -3853,27 +3857,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "targetStarSystem": { "type": "string", @@ -3886,27 +3890,27 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The location of this volume. Optional (will default to 0,0,0).", - "$ref": "#/definitions/MVector3" - }, "radius": { "type": "number", "description": "The radius of this volume.", "format": "float", "default": 1.0 }, + "position": { + "description": "Position of the prop", + "$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 coordinates are relative to parent instead of the root planet object." + "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 volume." + "description": "An optional rename of this object" }, "creditsType": { "default": "fast", From 049bb5ba33cf92372cca0637d9ab94782f29868d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Fri, 17 Mar 2023 14:32:18 -0500 Subject: [PATCH 014/119] Use GeneralPropBuilder for singularities --- .../Builder/Body/SingularityBuilder.cs | 33 +++++-------------- .../Modules/VariableSize/SingularityModule.cs | 32 ++++-------------- 2 files changed, 15 insertions(+), 50 deletions(-) diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 96466121b..1f913ec92 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -10,6 +10,7 @@ using System.Drawing; using Color = UnityEngine.Color; using NewHorizons.Components.Volumes; +using NewHorizons.Builder.Props; namespace NewHorizons.Builder.Body { @@ -139,26 +140,16 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam // polarity true = black, false = white - var singularity = new GameObject(!string.IsNullOrEmpty(rename) ? rename : (polarity ? "BlackHole" : "WhiteHole")); - singularity.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(parentPath)) + var info = new SingularityModule { - var newParent = planetGO.transform.Find(parentPath); - if (newParent != null) - { - singularity.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{parentPath}"); - } - } + position = position, + rotation = rotation, + isRelativeToParent = isRelativeToParent, + parentPath = parentPath, + rename = rename, + }; - if (isRelativeToParent) - singularity.transform.localPosition = position; - else - singularity.transform.position = planetGO.transform.TransformPoint(position); + var singularity = GeneralPropBuilder.MakeNew(polarity ? "BlackHole" : "WhiteHole", planetGO, sector, info); var singularityRenderer = MakeSingularityGraphics(singularity, polarity, horizon, distort, renderQueue); @@ -273,12 +264,6 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam whiteHoleFluidVolume.enabled = true; } - var rot = Quaternion.Euler(rotation); - if (isRelativeToParent) - singularity.transform.localRotation = rot; - else - singularity.transform.rotation = planetGO.transform.TransformRotation(rot); - singularity.SetActive(true); return singularity; } diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs index e0c1041dc..eaa1540c7 100644 --- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs @@ -9,7 +9,7 @@ namespace NewHorizons.External.Modules.VariableSize { [JsonObject] - public class SingularityModule : VariableSizeModule + public class SingularityModule : PropModule.PositionedAndRotatedPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SingularityType @@ -19,6 +19,11 @@ public enum SingularityType [EnumMember(Value = @"whiteHole")] WhiteHole = 1 } + /// + /// Scale this object over time + /// + public TimeValuePair[] curve; + /// /// The uniqueID of the white hole or black hole that is paired to this one. If you don't set a value, entering will kill /// the player @@ -30,16 +35,6 @@ public enum SingularityType /// public string uniqueID; - /// - /// Position of the singularity - /// - public MVector3 position; - - /// - /// Rotation of the singularity. Determines the direction you come out of a white hole - /// - public MVector3 rotation; - /// /// Radius of the singularity. Note that this isn't the same as the event horizon, but includes the entire volume that /// has warped effects in it. @@ -75,20 +70,5 @@ public enum SingularityType /// Optional override for the render queue. If the singularity is rendering oddly, increasing this to 3000 can help /// [Range(2501f, 3500f)] public int renderQueueOverride = 2985; - - /// - /// 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 From e732a01e025692b43a1018b32a39fdc52b75d066 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 03:58:26 -0500 Subject: [PATCH 015/119] Make bramble nodes use GeneralPropBuilder --- NewHorizons/Builder/Props/BrambleNodeBuilder.cs | 7 +------ NewHorizons/External/Modules/BrambleModule.cs | 12 +----------- NewHorizons/External/Modules/PropModule.cs | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 6b8415cd0..89c78c6c4 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -182,7 +182,7 @@ public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo conf var prefab = config.isSeed ? _brambleSeedPrefab : _brambleNodePrefab; // Spawn the bramble node - var brambleNode = prefab.InstantiateInactive(); + var brambleNode = GeneralPropBuilder.MakeFromPrefab(prefab, config.name ?? "Bramble Node to " + config.linksTo, go, sector, config); foreach (var collider in brambleNode.GetComponentsInChildren(true)) { collider.enabled = true; @@ -192,11 +192,6 @@ public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo conf var outerFogWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go); var fogLight = brambleNode.GetComponent(); - brambleNode.transform.parent = sector?.transform ?? go.transform; - brambleNode.transform.position = go.transform.TransformPoint(config.position ?? Vector3.zero); - brambleNode.transform.rotation = go.transform.TransformRotation(Quaternion.Euler(config.rotation ?? Vector3.zero)); - brambleNode.name = config.name ?? "Bramble Node to " + config.linksTo; - // This node comes with Feldspar's signal, we don't want that though GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica")); diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 9b98c0de3..6ace1ddd3 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -78,18 +78,8 @@ public class BrambleDimensionInfo [JsonObject] - public class BrambleNodeInfo + public class BrambleNodeInfo : PropModule.PositionedAndRotatedPropInfo { - /// - /// The physical position of the node - /// - public MVector3 position; - - /// - /// The physical rotation of the node - /// - public MVector3 rotation; - /// /// The physical scale of the node, as a multiplier of the original size. /// Nodes are 150m across, seeds are 10m across. diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 6d47ceb49..6ab14e1e1 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -126,7 +126,7 @@ public abstract class PositionedPropInfo public abstract class PositionedAndRotatedPropInfo : PositionedPropInfo { /// - /// Rotate this prop once it is placed + /// Rotation of the prop /// public MVector3 rotation; } From 49f839941d4a8bb1c8d4dd6fe1230240ca80e988 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 09:03:22 +0000 Subject: [PATCH 016/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 72 ++++++++++++++++------------ 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 26710fecb..8a52568d5 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -658,14 +658,26 @@ "type": "object", "additionalProperties": false, "properties": { - "position": { - "description": "The physical position of the node", + "rotation": { + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, - "rotation": { - "description": "The physical rotation of the node", + "position": { + "description": "Position of the prop", "$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" + }, "scale": { "type": "number", "description": "The physical scale of the node, as a multiplier of the original size. \nNodes are 150m across, seeds are 10m across.", @@ -1077,7 +1089,7 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotate this prop once it is placed", + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, "position": { @@ -1595,7 +1607,7 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotate this prop once it is placed", + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, "position": { @@ -1772,7 +1784,7 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotate this prop once it is placed", + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, "position": { @@ -1950,6 +1962,26 @@ "type": "object", "additionalProperties": false, "properties": { + "rotation": { + "description": "Rotation of the prop", + "$ref": "#/definitions/MVector3" + }, + "position": { + "description": "Position of the prop", + "$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" + }, "curve": { "type": "array", "description": "Scale this object over time", @@ -1965,14 +1997,6 @@ "type": "string", "description": "The uniqueID of this white hole or black hole. If not set it will default to the name of the planet" }, - "position": { - "description": "Position of the singularity", - "$ref": "#/definitions/MVector3" - }, - "rotation": { - "description": "Rotation of the singularity. Determines the direction you come out of a white hole", - "$ref": "#/definitions/MVector3" - }, "horizonRadius": { "type": "number", "description": "Radius of the event horizon (solid part)", @@ -2003,18 +2027,6 @@ "format": "int32", "maximum": 3500.0, "minimum": 2501.0 - }, - "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" } } }, @@ -2131,7 +2143,7 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotate this prop once it is placed", + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, "position": { @@ -2203,7 +2215,7 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotate this prop once it is placed", + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, "position": { @@ -2242,7 +2254,7 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotate this prop once it is placed", + "description": "Rotation of the prop", "$ref": "#/definitions/MVector3" }, "position": { From c8bd63e5d58ec579311cb26dab6e8a97d61ddf65 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 07:48:43 -0500 Subject: [PATCH 017/119] Change volumes to use GeneralPropBuilder and cleaned up some others --- .../Builder/Props/GeneralPropBuilder.cs | 26 +++++++------- NewHorizons/Builder/Props/RemoteBuilder.cs | 32 +---------------- NewHorizons/Builder/Props/TornadoBuilder.cs | 8 +---- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 34 ++----------------- .../Builder/Volumes/AudioVolumeBuilder.cs | 28 ++------------- .../Builder/Volumes/HazardVolumeBuilder.cs | 28 ++------------- .../Volumes/NotificationVolumeBuilder.cs | 28 ++------------- .../Builder/Volumes/VanishVolumeBuilder.cs | 28 ++------------- 8 files changed, 26 insertions(+), 186 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index ec6f9aa15..eb20dd1f2 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null) + public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { if (!string.IsNullOrEmpty(info.rename)) { @@ -21,21 +21,23 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se go.transform.parent = sector?.transform ?? planetGO.transform; - if (!string.IsNullOrEmpty(info.parentPath)) + var parentPath = info.parentPath ?? defaultParentPath; + + if (!string.IsNullOrEmpty(parentPath)) { - var newParent = go.transform.Find(info.parentPath); + var newParent = go.transform.Find(parentPath); if (newParent != null) { go.transform.parent = newParent.transform; } else { - Logger.LogError($"Cannot find parent object at path: {go.name}/{info.parentPath}"); + Logger.LogError($"Cannot find parent object at path: {go.name}/{parentPath}"); } } - Vector3 pos = (Vector3)(info.position ?? Vector3.zero); - Quaternion rot = Quaternion.identity; + var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); + var rot = Quaternion.identity; if (info is PropModule.PositionedAndRotatedPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; @@ -59,18 +61,18 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se return go; } - public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null) + public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { - GameObject go = new GameObject(defaultName); + var go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { - GameObject go = prefab.InstantiateInactive(); + var go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath); } } } diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 4fa179f38..2f77e21ae 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -251,37 +251,7 @@ public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraP public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.StoneInfo info, IModBehaviour mod) { - var shareStone = _shareStonePrefab.InstantiateInactive(); - - shareStone.name = !string.IsNullOrEmpty(info.rename) ? info.rename : ("ShareStone_" + id.ToString()); - - shareStone.transform.parent = sector?.transform ?? go.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = go.transform.Find(info.parentPath); - if (newParent != null) - { - shareStone.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {go.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - var rot = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero)); - if (info.isRelativeToParent) - { - shareStone.transform.localPosition = pos; - shareStone.transform.localRotation = rot; - } - else - { - shareStone.transform.position = go.transform.TransformPoint(pos); - shareStone.transform.rotation = go.transform.TransformRotation(rot); - } + var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), go, sector, info); shareStone.GetComponent()._connectedPlatform = id; diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 4ba7fa856..4fbf081d6 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -99,13 +99,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoIn private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); - var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true); - - // Override general prop position with randomized default position - if (info.position == null) - { - tornadoGO.transform.position = planetGO.transform.TransformPoint(position); - } + var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true, defaultPosition: position); // Add the sound thing before changing the scale var soundGO = _soundPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 87c2e1034..76fff0398 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.Components.Achievement; using NewHorizons.External.Modules; using OWML.Common; @@ -9,7 +10,7 @@ public static class RevealBuilder { public static void Make(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { - var newRevealGO = MakeGameObject(go, sector, info, mod); + var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", go, sector, info); switch (info.revealOn) { case VolumesModule.RevealVolumeInfo.RevealVolumeType.Enter: @@ -36,37 +37,6 @@ private static SphereShape MakeShape(GameObject go, VolumesModule.RevealVolumeIn return newShape; } - private static GameObject MakeGameObject(GameObject planetGO, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) - { - GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")"); - revealTriggerVolume.SetActive(false); - revealTriggerVolume.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.rename)) - { - revealTriggerVolume.name = info.rename; - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - revealTriggerVolume.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) revealTriggerVolume.transform.localPosition = pos; - else revealTriggerVolume.transform.position = planetGO.transform.TransformPoint(pos); - - return revealTriggerVolume; - } - private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { var shape = MakeShape(go, info, Shape.CollisionMode.Volume); diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 8711ddf78..1a5f2f2ab 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using NewHorizons.Utility; using OWML.Common; @@ -16,32 +17,7 @@ public static class AudioVolumeBuilder { public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule.AudioVolumeInfo info, IModBehaviour mod) { - var go = new GameObject("AudioVolume"); - go.SetActive(false); - - go.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.rename)) - { - go.name = info.rename; - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - go.transform.parent = newParent; - } - else - { - Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) go.transform.localPosition = pos; - else go.transform.position = planetGO.transform.TransformPoint(pos); + var go = GeneralPropBuilder.MakeNew("AudioVolume", planetGO, sector, info); go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var audioSource = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index 23a4f1bba..3a12aeb2a 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using OWML.Common; using OWML.Utils; @@ -13,32 +14,7 @@ public static class HazardVolumeBuilder { public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod) { - var go = new GameObject("HazardVolume"); - go.SetActive(false); - - go.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.rename)) - { - go.name = info.rename; - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - go.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) go.transform.localPosition = pos; - else go.transform.position = planetGO.transform.TransformPoint(pos); + var go = GeneralPropBuilder.MakeNew("HazardVolume", planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index 1e3f07b86..d9d6fa02a 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using NewHorizons.Utility; using OWML.Common; @@ -16,32 +17,7 @@ public static class NotificationVolumeBuilder { public static NHNotificationVolume Make(GameObject planetGO, Sector sector, VolumesModule.NotificationVolumeInfo info, IModBehaviour mod) { - var go = new GameObject("NotificationVolume"); - go.SetActive(false); - - go.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.rename)) - { - go.name = info.rename; - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - go.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) go.transform.localPosition = pos; - else go.transform.position = planetGO.transform.TransformPoint(pos); + var go = GeneralPropBuilder.MakeNew("NotificationVolume", planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index 2048159fa..fd625ccbb 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Modules; using UnityEngine; @@ -9,32 +10,7 @@ public static class VanishVolumeBuilder { public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VanishVolumeInfo info) where TVolume : VanishVolume { - var go = new GameObject(typeof(TVolume).Name); - go.SetActive(false); - - go.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.rename)) - { - go.name = info.rename; - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var newParent = planetGO.transform.Find(info.parentPath); - if (newParent != null) - { - go.transform.parent = newParent; - } - else - { - Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}"); - } - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) go.transform.localPosition = pos; - else go.transform.position = planetGO.transform.TransformPoint(pos); + var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var collider = go.AddComponent(); From 88f60f883c466aaece0cb339fa2ce9655e3207a7 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 08:15:56 -0500 Subject: [PATCH 018/119] Better name for base prop class --- .../Builder/Props/GeneralPropBuilder.cs | 8 ++--- NewHorizons/External/Modules/BrambleModule.cs | 2 +- NewHorizons/External/Modules/PropModule.cs | 34 +++++++++---------- NewHorizons/External/Modules/SignalModule.cs | 2 +- .../Modules/VariableSize/SingularityModule.cs | 2 +- NewHorizons/External/Modules/VolumesModule.cs | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index eb20dd1f2..36d1e539f 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { if (!string.IsNullOrEmpty(info.rename)) { @@ -38,7 +38,7 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); var rot = Quaternion.identity; - if (info is PropModule.PositionedAndRotatedPropInfo rotInfo) + if (info is PropModule.GeneralPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; } @@ -61,14 +61,14 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se return go; } - public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = new GameObject(defaultName); go.SetActive(false); return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.PositionedPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 6ace1ddd3..7fec298be 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -78,7 +78,7 @@ public class BrambleDimensionInfo [JsonObject] - public class BrambleNodeInfo : PropModule.PositionedAndRotatedPropInfo + public class BrambleNodeInfo : PropModule.GeneralPropInfo { /// /// The physical scale of the node, as a multiplier of the original size. diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 6ab14e1e1..2617717af 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -99,10 +99,10 @@ public class PropModule [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes; [JsonObject] - public abstract class PositionedPropInfo + public abstract class GeneralPointPropInfo { /// - /// Position of the prop + /// Position of the object /// public MVector3 position; @@ -123,10 +123,10 @@ public abstract class PositionedPropInfo } [JsonObject] - public abstract class PositionedAndRotatedPropInfo : PositionedPropInfo + public abstract class GeneralPropInfo : GeneralPointPropInfo { /// - /// Rotation of the prop + /// Rotation of the object /// public MVector3 rotation; } @@ -196,7 +196,7 @@ public class ScatterInfo } [JsonObject] - public class DetailInfo : PositionedAndRotatedPropInfo + public class DetailInfo : GeneralPropInfo { /// @@ -265,7 +265,7 @@ public class DetailInfo : PositionedAndRotatedPropInfo } [JsonObject] - public class RaftInfo : PositionedPropInfo + public class RaftInfo : GeneralPointPropInfo { /// /// Acceleration of the raft. Default acceleration is 5. @@ -274,7 +274,7 @@ public class RaftInfo : PositionedPropInfo } [JsonObject] - public class GeyserInfo : PositionedPropInfo + public class GeyserInfo : GeneralPointPropInfo { /// /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. @@ -313,7 +313,7 @@ public class GeyserInfo : PositionedPropInfo } [JsonObject] - public class TornadoInfo : PositionedPropInfo + public class TornadoInfo : GeneralPointPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum TornadoType @@ -375,7 +375,7 @@ public enum TornadoType } [JsonObject] - public class VolcanoInfo : PositionedPropInfo + public class VolcanoInfo : GeneralPointPropInfo { /// /// The colour of the meteor's lava. @@ -418,7 +418,7 @@ public class VolcanoInfo : PositionedPropInfo } [JsonObject] - public class DialogueInfo : PositionedPropInfo + public class DialogueInfo : GeneralPointPropInfo { /// /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue @@ -486,7 +486,7 @@ public enum FlashlightToggle } [JsonObject] - public class EntryLocationInfo : PositionedPropInfo + public class EntryLocationInfo : GeneralPointPropInfo { /// /// Whether this location is cloaked @@ -500,7 +500,7 @@ public class EntryLocationInfo : PositionedPropInfo } [JsonObject] - public class NomaiTextInfo : PositionedPropInfo + public class NomaiTextInfo : GeneralPointPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum NomaiTextType @@ -616,7 +616,7 @@ public enum NomaiTextArcType } [JsonObject] - public class ProjectionInfo : PositionedAndRotatedPropInfo + public class ProjectionInfo : GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SlideShowType @@ -783,7 +783,7 @@ public class QuantumGroupInfo } [JsonObject] - public class QuantumSocketInfo : PositionedAndRotatedPropInfo + public class QuantumSocketInfo : GeneralPropInfo { /// /// Whether the socket will be placed relative to the group it belongs to. Overrides `isRelativeToParent` @@ -824,7 +824,7 @@ public class RemoteInfo public StoneInfo[] stones; [JsonObject] - public class WhiteboardInfo : PositionedAndRotatedPropInfo + public class WhiteboardInfo : GeneralPropInfo { /// /// The text for each stone @@ -872,7 +872,7 @@ public class SharedNomaiTextInfo } [JsonObject] - public class PlatformInfo : PositionedAndRotatedPropInfo + public class PlatformInfo : GeneralPropInfo { /// /// A ship log fact to reveal when the platform is connected to. @@ -891,7 +891,7 @@ public class PlatformInfo : PositionedAndRotatedPropInfo } [JsonObject] - public class StoneInfo : PositionedAndRotatedPropInfo + public class StoneInfo : GeneralPropInfo { } diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index de5f474fa..cfa66a16f 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -15,7 +15,7 @@ public class SignalModule public SignalInfo[] signals; [JsonObject] - public class SignalInfo : PropModule.PositionedPropInfo + public class SignalInfo : PropModule.GeneralPointPropInfo { [Obsolete("audioClip is deprecated, please use audio instead")] public string audioClip; diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs index eaa1540c7..58b35b9a4 100644 --- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs @@ -9,7 +9,7 @@ namespace NewHorizons.External.Modules.VariableSize { [JsonObject] - public class SingularityModule : PropModule.PositionedAndRotatedPropInfo + public class SingularityModule : PropModule.GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SingularityType diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 230665c08..8b60df6ea 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -117,7 +117,7 @@ public class VolumesModule public LoadCreditsVolumeInfo[] creditsVolume; [JsonObject] - public class VolumeInfo : PropModule.PositionedPropInfo + public class VolumeInfo : PropModule.GeneralPointPropInfo { /// /// The radius of this volume. From e021523151a748358cd811eb9bbea107508fdce1 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 09:17:36 -0500 Subject: [PATCH 019/119] Using GeneralPropBuilder for spawn points, vessel and warp exit points, and remotr dialogue triggers --- .../Builder/Body/SingularityBuilder.cs | 2 +- .../Builder/General/SpawnPointBuilder.cs | 72 ++++++++++--------- .../Builder/Props/BrambleNodeBuilder.cs | 2 +- NewHorizons/Builder/Props/DetailBuilder.cs | 4 +- NewHorizons/Builder/Props/DialogueBuilder.cs | 66 +++++------------ .../Builder/Props/GeneralPropBuilder.cs | 38 +++++++--- NewHorizons/Builder/Props/GeyserBuilder.cs | 2 +- .../Builder/Props/ProjectionBuilder.cs | 4 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 2 +- NewHorizons/Builder/Props/RaftBuilder.cs | 2 +- NewHorizons/Builder/Props/RemoteBuilder.cs | 2 +- NewHorizons/Builder/Props/SignalBuilder.cs | 2 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 2 +- .../TranslatorText/TranslatorTextBuilder.cs | 10 +-- NewHorizons/Builder/Props/VolcanoBuilder.cs | 2 +- .../Builder/ShipLog/EntryLocationBuilder.cs | 2 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 2 +- .../Builder/Volumes/AudioVolumeBuilder.cs | 2 +- .../Builder/Volumes/HazardVolumeBuilder.cs | 2 +- .../Volumes/NotificationVolumeBuilder.cs | 2 +- .../Builder/Volumes/VanishVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 2 +- .../ShipLog/ShipLogStarChartMode.cs | 2 +- .../External/Configs/StarSystemConfig.cs | 71 +++++++++++++----- NewHorizons/External/Modules/PropModule.cs | 40 +++++++---- NewHorizons/External/Modules/SpawnModule.cs | 40 ++++++----- NewHorizons/Handlers/StarChartHandler.cs | 2 +- NewHorizons/Handlers/VesselWarpHandler.cs | 17 ++--- NewHorizons/NewHorizonsApi.cs | 9 ++- 29 files changed, 223 insertions(+), 184 deletions(-) diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 1f913ec92..97c530103 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -149,7 +149,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam rename = rename, }; - var singularity = GeneralPropBuilder.MakeNew(polarity ? "BlackHole" : "WhiteHole", planetGO, sector, info); + var singularity = GeneralPropBuilder.MakeNew(polarity ? "BlackHole" : "WhiteHole", sector?.transform ?? planetGO.transform, info); var singularityRenderer = MakeSingularityGraphics(singularity, polarity, horizon, distort, renderQueue); diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index d9aad42a1..6150de08d 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using NewHorizons.Utility; using System; @@ -12,36 +13,48 @@ public static class SpawnPointBuilder public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbody owRigidBody) { SpawnPoint playerSpawn = null; - if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && module.playerSpawnPoint != null) + + var playerSpawnInfo = module.playerSpawn; + var shipSpawnInfo = module.shipSpawn; + + // Backwards compatibility +#pragma warning disable 612, 618 + if (playerSpawnInfo == null && module.playerSpawnPoint != null) { - GameObject spawnGO = new GameObject("PlayerSpawnPoint"); - spawnGO.transform.parent = planetGO.transform; - spawnGO.layer = 8; + playerSpawnInfo = new SpawnModule.PlayerSpawnPoint() + { + position = module.playerSpawnPoint, + rotation = module.playerSpawnRotation, + startWithSuit = module.startWithSuit, + }; + } + if (shipSpawnInfo == null && module.shipSpawnPoint != null) + { + shipSpawnInfo = new SpawnModule.ShipSpawnPoint() + { + position = module.shipSpawnPoint, + rotation = module.shipSpawnRotation, + }; + } +#pragma warning restore 612, 618 - spawnGO.transform.localPosition = module.playerSpawnPoint; + if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && playerSpawnInfo != null) + { + bool alignToBody = playerSpawnInfo.rotation == null; + GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO.transform, playerSpawnInfo, alignToBody); + spawnGO.layer = 8; playerSpawn = spawnGO.AddComponent(); playerSpawn._triggerVolumes = new OWTriggerVolume[0]; - if (module.playerSpawnRotation != null) - { - spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation); - } - else - { - spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (playerSpawn.transform.position - planetGO.transform.position).normalized); - } - - spawnGO.transform.position = spawnGO.transform.position + spawnGO.transform.TransformDirection(Vector3.up) * 4f; + spawnGO.transform.position += spawnGO.transform.up * 4f; } - if (module.shipSpawnPoint != null) + if (shipSpawnInfo != null) { - GameObject spawnGO = new GameObject("ShipSpawnPoint"); - spawnGO.transform.parent = planetGO.transform; + bool alignToBody = shipSpawnInfo.rotation == null; + GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO.transform, shipSpawnInfo, alignToBody); spawnGO.layer = 8; - spawnGO.transform.localPosition = module.shipSpawnPoint; - var spawnPoint = spawnGO.AddComponent(); spawnPoint._isShipSpawn = true; spawnPoint._triggerVolumes = new OWTriggerVolume[0]; @@ -49,20 +62,13 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo var ship = SearchUtilities.Find("Ship_Body"); if (ship != null) { - ship.transform.position = spawnPoint.transform.position; + ship.transform.position = spawnGO.transform.position; + ship.transform.rotation = spawnGO.transform.rotation; - if (module.shipSpawnRotation != null) - { - spawnGO.transform.rotation = Quaternion.Euler(module.shipSpawnRotation); - ship.transform.rotation = spawnGO.transform.rotation; - } - else + // Move it up a bit more when aligning to surface + if (alignToBody) { - spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - planetGO.transform.position).normalized); - ship.transform.rotation = spawnGO.transform.rotation; - - // Move it up a bit more when aligning to surface - ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 4f; + ship.transform.position += ship.transform.up * 4f; } ship.GetRequiredComponent().SetBodyToMatch(owRigidBody); @@ -83,7 +89,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo } } - if ((Main.Instance.IsWarpingFromVessel || (!Main.Instance.IsWarpingFromShip && module.startWithSuit)) && !suitUpQueued) + if ((Main.Instance.IsWarpingFromVessel || (!Main.Instance.IsWarpingFromShip && (playerSpawnInfo?.startWithSuit ?? false))) && !suitUpQueued) { suitUpQueued = true; Delay.RunWhen(() => Main.IsSystemReady, () => SuitUp()); diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 89c78c6c4..4a836fb4b 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -182,7 +182,7 @@ public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo conf var prefab = config.isSeed ? _brambleSeedPrefab : _brambleNodePrefab; // Spawn the bramble node - var brambleNode = GeneralPropBuilder.MakeFromPrefab(prefab, config.name ?? "Bramble Node to " + config.linksTo, go, sector, config); + var brambleNode = GeneralPropBuilder.MakeFromPrefab(prefab, config.name ?? "Bramble Node to " + config.linksTo, sector?.transform ?? go.transform, config); foreach (var collider in brambleNode.GetComponentsInChildren(true)) { collider.enabled = true; diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 4a89431a1..88aa7db54 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -90,12 +90,12 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P // We save copies with all their components fixed, good if the user is placing the same detail more than once if (detail?.path != null && _fixedPrefabCache.TryGetValue((sector, detail.path), out var storedPrefab)) { - prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail, detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, sector?.transform ?? go.transform, detail, detail.alignToNormal); isItem = storedPrefab.isItem; } else { - prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail, detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, sector?.transform ?? go.transform, detail, detail.alignToNormal); StreamingHandler.SetUpStreaming(prop, sector); diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index d412e839e..da4357267 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -22,36 +22,23 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, var dialogue = MakeConversationZone(go, sector, info, mod.ModHelper); RemoteDialogueTrigger remoteTrigger = null; - if (info.remoteTriggerPosition != null || info.remoteTriggerRadius != 0) + if (info.remoteTrigger != null) { - remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, dialogue); + remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, info.remoteTrigger, dialogue); } - - if (!string.IsNullOrEmpty(info.rename)) + // Backwards compatibility +#pragma warning disable 612, 618 + if (remoteTrigger == null && (info.remoteTriggerPosition != null || info.remoteTriggerRadius != 0)) { - dialogue.name = info.rename; - if (remoteTrigger != null) + var remoteInfo = new PropModule.DialogueInfo.RemoteTriggerInfo { - remoteTrigger.name = $"{info.rename}_{remoteTrigger.name}"; - } - } - - if (!string.IsNullOrEmpty(info.parentPath)) - { - var parent = go.transform.Find(info.parentPath); - if (parent != null) - { - dialogue.transform.parent = parent; - if (remoteTrigger != null) - { - remoteTrigger.transform.parent = parent; - } - } - else - { - Logger.LogError($"Cannot find parent object at path: {go.name}/{info.parentPath}"); - } + position = info.remoteTriggerPosition, + radius = info.remoteTriggerRadius, + prereqCondition = info.remoteTriggerPrereqCondition, + }; + remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, remoteInfo, dialogue); } +#pragma warning restore 612, 618 // Make the character look at the player // Useful for dialogue replacement @@ -64,10 +51,9 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, return (dialogue, remoteTrigger); } - private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue) + private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, PropModule.DialogueInfo.RemoteTriggerInfo remoteTriggerInfo, CharacterDialogueTree dialogue) { - var conversationTrigger = new GameObject("ConversationTrigger"); - conversationTrigger.SetActive(false); + var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", sector?.transform ?? planetGO.transform, remoteTriggerInfo, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); var remoteDialogueTrigger = conversationTrigger.AddComponent(); var sphereCollider = conversationTrigger.AddComponent(); @@ -81,7 +67,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet dialogue = dialogue, prereqConditionType = RemoteDialogueTrigger.MultiConditionType.AND, // Base game never uses more than one condition anyone so we'll keep it simple - prereqConditions = string.IsNullOrEmpty(info.remoteTriggerPrereqCondition) ? new string[]{ } : new string[] { info.remoteTriggerPrereqCondition }, + prereqConditions = string.IsNullOrEmpty(remoteTriggerInfo.prereqCondition) ? new string[]{ } : new string[] { remoteTriggerInfo.prereqCondition }, // Just set your enter conditions in XML instead of complicating it with this onTriggerEnterConditions = new string[]{ } } @@ -89,10 +75,8 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet remoteDialogueTrigger._activatedDialogues = new bool[1]; remoteDialogueTrigger._deactivateTriggerPostConversation = true; - sphereCollider.radius = info.remoteTriggerRadius == 0 ? info.radius : info.remoteTriggerRadius; + sphereCollider.radius = remoteTriggerInfo.radius == 0 ? info.radius : remoteTriggerInfo.radius; - conversationTrigger.transform.parent = sector?.transform ?? planetGO.transform; - conversationTrigger.transform.position = planetGO.transform.TransformPoint(info.remoteTriggerPosition ?? info.position); conversationTrigger.SetActive(true); return remoteDialogueTrigger; @@ -100,8 +84,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, IModHelper mod) { - var conversationZone = new GameObject("ConversationZone"); - conversationZone.SetActive(false); + var conversationZone = GeneralPropBuilder.MakeNew("ConversationZone", sector?.transform ?? planetGO.transform, info, defaultParentPath: info.pathToAnimController); conversationZone.layer = LayerMask.NameToLayer("Interactible"); @@ -150,21 +133,6 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S break; } - conversationZone.transform.parent = sector?.transform ?? planetGO.transform; - - if (!string.IsNullOrEmpty(info.parentPath)) - { - conversationZone.transform.parent = planetGO.transform.Find(info.parentPath); - } - else if (!string.IsNullOrEmpty(info.pathToAnimController)) - { - conversationZone.transform.parent = planetGO.transform.Find(info.pathToAnimController); - } - - var pos = (Vector3)(info.position ?? Vector3.zero); - if (info.isRelativeToParent) conversationZone.transform.localPosition = pos; - else conversationZone.transform.position = planetGO.transform.TransformPoint(pos); - conversationZone.SetActive(true); return dialogueTree; diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 36d1e539f..adefa07f2 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,14 +12,28 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromExisting(GameObject go, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { + if (info == null) return go; + + if (info is PropModule.GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) + { + var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody); + if (targetPlanet != null) + { + parent = targetPlanet.transform; + } else + { + Logger.LogError($"Cannot find parent body named {solarSystemInfo.parentBody}"); + } + } + if (!string.IsNullOrEmpty(info.rename)) { go.name = info.rename; } - go.transform.parent = sector?.transform ?? planetGO.transform; + go.transform.parent = parent; var parentPath = info.parentPath ?? defaultParentPath; @@ -46,33 +60,37 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se { go.transform.localPosition = pos; go.transform.localRotation = rot; + } else if (parent) + { + go.transform.position = parent.TransformPoint(pos); + go.transform.rotation = parent.TransformRotation(rot); } else { - go.transform.position = planetGO.transform.TransformPoint(pos); - go.transform.rotation = planetGO.transform.TransformRotation(rot); + go.transform.position = pos; + go.transform.rotation = rot; } if (alignToBody) { - var up = (go.transform.position - planetGO.transform.position).normalized; - if (normal != null) up = planetGO.transform.TransformDirection(normal); + var up = (go.transform.position - parent.position).normalized; + if (normal != null) up = parent.TransformDirection(normal); go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); go.transform.rotation *= rot; } return go; } - public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeNew(string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath); + return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath); + return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); } } } diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index 633e282ab..2b4819fd0 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -18,7 +18,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf { InitPrefab(); - var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", planetGO, sector, info, true); + var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", sector?.transform ?? planetGO.transform, info, true); var pos = info.isRelativeToParent ? geyserGO.transform.parent.TransformPoint((Vector3)info.position) : (Vector3)info.position; diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 19e1225ff..d7fd2668c 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -93,7 +93,7 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Prop if (_slideReelPrefab == null) return null; - var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info); + var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", sector?.transform ?? planetGO.transform, info); var slideReel = slideReelObj.GetComponent(); slideReel.SetSector(sector); @@ -166,7 +166,7 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P if (_autoPrefab == null) return null; - var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info); + var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", sector?.transform ?? planetGO.transform, info); var autoProjector = projectorObj.GetComponent(); autoProjector._sector = sector; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 9c759808b..9a1381203 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,7 +50,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo); + var socket = GeneralPropBuilder.MakeNew("Socket " + i, sector?.transform ?? go.transform, socketInfo); if (socketInfo.isRelativeToGroup) { diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index 4440dbfab..663fa27e1 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -52,7 +52,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Raf if (_prefab == null || sector == null) return null; - GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info); + GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", sector?.transform ?? planetGO.transform, info); StreamingHandler.SetUpStreaming(raftObject, sector); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 2f77e21ae..75e273748 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -251,7 +251,7 @@ public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraP public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.StoneInfo info, IModBehaviour mod) { - var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), go, sector, info); + var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), sector?.transform ?? go.transform, info); shareStone.GetComponent()._connectedPlatform = id; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 2cbf1118a..1665c33cc 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -109,7 +109,7 @@ public static string GetCustomSignalName(SignalName signalName) public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) { - var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", planetGO, sector, info); + var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", sector?.transform ?? planetGO.transform, info); signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var source = signalGO.AddComponent(); diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 4fbf081d6..1aad9a6e8 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -99,7 +99,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoIn private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); - var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true, defaultPosition: position); + var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", sector?.transform ?? planetGO.transform, info, true, defaultPosition: position); // Add the sound thing before changing the scale var soundGO = _soundPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 59a7b73d4..1d4a29fcc 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -161,7 +161,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { - var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); + var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, sector?.transform ?? planetGO.transform, info); var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); nomaiWallText.transform.parent = customScroll.transform; @@ -213,7 +213,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Computer: { - var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info, true, info.normal); + var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, sector?.transform ?? planetGO.transform, info, true, info.normal); var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -286,7 +286,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: { var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; - var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info, info.rotation == null); + var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); // Idk do we have to set it active before finding things? cairnObject.SetActive(true); @@ -349,7 +349,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: { - var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info, info.rotation == null); + var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); // shrink because that is what mobius does on all trailmarkers or else they are the size of the player trailmarkerObject.transform.localScale = Vector3.one * 0.75f; @@ -380,7 +380,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) { - GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", go, sector, info); + GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", sector?.transform ?? go.transform, info); var box = nomaiWallTextObj.AddComponent(); box.center = new Vector3(-0.0643f, 1.1254f, 0f); diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index c4bf04ce6..ced0ad9c2 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -45,7 +45,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoIn { InitPrefab(); - var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info, true); + var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", sector?.transform ?? planetGO.transform, info, true); var meteorLauncher = launcherGO.GetComponent(); meteorLauncher._audioSector = sector; diff --git a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs index ace39be31..7f6d591f2 100644 --- a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs +++ b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs @@ -12,7 +12,7 @@ public static class EntryLocationBuilder private static readonly List _locationsToInitialize = new List(); public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod) { - GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info); + GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", sector?.transform ?? go.transform, info); ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent(); newLocation._entryID = info.id; diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 76fff0398..349c3649a 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -10,7 +10,7 @@ public static class RevealBuilder { public static void Make(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { - var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", go, sector, info); + var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", sector?.transform ?? go.transform, info); switch (info.revealOn) { case VolumesModule.RevealVolumeInfo.RevealVolumeType.Enter: diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 1a5f2f2ab..34269fe67 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -17,7 +17,7 @@ public static class AudioVolumeBuilder { public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule.AudioVolumeInfo info, IModBehaviour mod) { - var go = GeneralPropBuilder.MakeNew("AudioVolume", planetGO, sector, info); + var go = GeneralPropBuilder.MakeNew("AudioVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var audioSource = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index 3a12aeb2a..bb82013ce 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -14,7 +14,7 @@ public static class HazardVolumeBuilder { public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod) { - var go = GeneralPropBuilder.MakeNew("HazardVolume", planetGO, sector, info); + var go = GeneralPropBuilder.MakeNew("HazardVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index d9d6fa02a..574aa6daa 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -17,7 +17,7 @@ public static class NotificationVolumeBuilder { public static NHNotificationVolume Make(GameObject planetGO, Sector sector, VolumesModule.NotificationVolumeInfo info, IModBehaviour mod) { - var go = GeneralPropBuilder.MakeNew("NotificationVolume", planetGO, sector, info); + var go = GeneralPropBuilder.MakeNew("NotificationVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index fd625ccbb..23628b122 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -10,7 +10,7 @@ public static class VanishVolumeBuilder { public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VanishVolumeInfo info) where TVolume : VanishVolume { - var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); + var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var collider = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index a94a6c23e..8d29c9a95 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -10,7 +10,7 @@ public static class VolumeBuilder { public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. { - var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); + var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs index 03510628e..dfc389bea 100644 --- a/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs @@ -61,7 +61,7 @@ public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptL var flag = false; if (starSystem.Equals("SolarSystem")) flag = true; else if (starSystem.Equals("EyeOfTheUniverse")) flag = false; - else if (config.Spawn?.shipSpawnPoint != null) flag = true; + else if (config.Spawn?.shipSpawn != null) flag = true; if (!StarChartHandler.HasUnlockedSystem(starSystem)) continue; diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 5b4c8a231..c9307b984 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -2,6 +2,7 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; +using NewHorizons.External.Modules; using NewHorizons.Utility; using Newtonsoft.Json; using static NewHorizons.External.Modules.ShipLogModule; @@ -185,29 +186,39 @@ public class VesselModule public NomaiCoordinates coords; /// - /// The position in the solar system the vessel will warp to. + /// A ship log fact which will make a prompt appear showing the coordinates when you're in the Vessel. /// - public MVector3 vesselPosition; + public string promptFact; /// - /// Euler angles by which the vessel will be oriented. + /// The location that the vessel will warp to. /// - public MVector3 vesselRotation; + public VesselInfo vessel; /// - /// The relative position to the vessel that you will be teleported to when you exit the vessel through the black hole. + /// The location that you will be teleported to when you exit the vessel through the black hole. /// - public MVector3 warpExitPosition; + public WarpExitInfo warpExit; - /// - /// Euler angles by which the warp exit will be oriented. - /// - public MVector3 warpExitRotation; + [Obsolete("vesselPosition is deprecated, use vessel.position instead")] public MVector3 vesselPosition; + [Obsolete("vesselRotation is deprecated, use vessel.rotation instead")] public MVector3 vesselRotation; + [Obsolete("warpExitPosition is deprecated, use warpExit.position instead")] public MVector3 warpExitPosition; + [Obsolete("warpExitRotation is deprecated, use warpExit.rotation instead")] public MVector3 warpExitRotation; - /// - /// A ship log fact which will make a prompt appear showing the coordinates when you're in the Vessel. - /// - public string promptFact; + [JsonObject] + public class VesselInfo : PropModule.GeneralSolarSystemPropInfo + { + + } + + [JsonObject] + public class WarpExitInfo : PropModule.GeneralSolarSystemPropInfo + { + /// + /// If set, keeps the warp exit attached to the vessel. Overrides `parentPath`. + /// + public bool attachToVessel; + } } /// @@ -270,11 +281,33 @@ public void Migrate() { Vessel = new VesselModule(); } - Vessel.coords = Vessel.coords ?? coords; - Vessel.vesselPosition = Vessel.vesselPosition ?? vesselPosition; - Vessel.vesselRotation = Vessel.vesselRotation ?? vesselRotation; - Vessel.warpExitPosition = Vessel.warpExitPosition ?? warpExitPosition; - Vessel.warpExitRotation = Vessel.warpExitRotation ?? warpExitRotation; + Vessel.coords ??= coords; + Vessel.vesselPosition ??= vesselPosition; + Vessel.vesselRotation ??= vesselRotation; + Vessel.warpExitPosition ??= warpExitPosition; + Vessel.warpExitRotation ??= warpExitRotation; + } + if (Vessel != null) + { + if (Vessel.vesselPosition != null || Vessel.vesselRotation != null) + { + if (Vessel.vessel == null) + { + Vessel.vessel = new VesselModule.VesselInfo(); + } + Vessel.vessel.position ??= Vessel.vesselPosition; + Vessel.vessel.rotation ??= Vessel.vesselRotation; + } + if (Vessel.warpExitPosition != null || Vessel.warpExitRotation != null) + { + if (Vessel.warpExit == null) + { + Vessel.warpExit = new VesselModule.WarpExitInfo(); + } + Vessel.warpExit.position ??= Vessel.warpExitPosition; + Vessel.warpExit.rotation ??= Vessel.warpExitRotation; + Vessel.warpExit.attachToVessel = true; + } } } } diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 2617717af..b402046ad 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -131,6 +131,15 @@ public abstract class GeneralPropInfo : GeneralPointPropInfo public MVector3 rotation; } + [JsonObject] + public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo + { + /// + /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. + /// + public string parentBody; + } + [JsonObject] public class ScatterInfo { @@ -442,29 +451,23 @@ public class DialogueInfo : GeneralPointPropInfo /// /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a - /// remoteTriggerPosition, you can set this to 0 to make the dialogue only trigger remotely. + /// remoteTrigger, you can set this to 0 to make the dialogue only trigger remotely. /// public float radius = 1f; - /// - /// Allows you to trigger dialogue from a distance when you walk into an area. - /// - public MVector3 remoteTriggerPosition; - /// /// Distance from radius the prompt appears /// [DefaultValue(2f)] public float range = 2f; /// - /// The radius of the remote trigger volume. + /// Allows you to trigger dialogue from a distance when you walk into an area. /// - public float remoteTriggerRadius; + public RemoteTriggerInfo remoteTrigger; - /// - /// If setting up a remote trigger volume, this conditions must be met for it to trigger. Note: This is a dialogue condition, not a persistent condition. - /// - public string remoteTriggerPrereqCondition; + [Obsolete("remoteTriggerPosition is deprecated. Use remoteTrigger.position instead")] public MVector3 remoteTriggerPosition; + [Obsolete("remoteTriggerRadius is deprecated. Use remoteTrigger.radius instead")] public float remoteTriggerRadius; + [Obsolete("remoteTriggerPrereqCondition is deprecated. Use remoteTrigger.prereqCondition instead")] public string remoteTriggerPrereqCondition; /// /// Relative path to the xml file defining the dialogue. @@ -483,6 +486,19 @@ public enum FlashlightToggle [EnumMember(Value = @"turnOff")] TurnOff = 0, [EnumMember(Value = @"turnOffThenOn")] TurnOffThenOn = 1, } + + [JsonObject] + public class RemoteTriggerInfo : GeneralPointPropInfo + { + /// + /// The radius of the remote trigger volume. + /// + public float radius; + /// + /// This condition must be met for the remote trigger volume to trigger. + /// + public string prereqCondition; + } } [JsonObject] diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index be6c2bfd9..ea8067c14 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -1,5 +1,6 @@ -using NewHorizons.Utility; +using NewHorizons.Utility; using Newtonsoft.Json; +using System; namespace NewHorizons.External.Modules { @@ -7,29 +8,32 @@ namespace NewHorizons.External.Modules public class SpawnModule { /// - /// If you want the player to spawn on the new body, set a value for this. Press `P` in game with Debug mode on to have - /// the game log the position you're looking at to find a good value for this. + /// If you want the player to spawn on the new body, set a value for this. /// - public MVector3 playerSpawnPoint; - - /// - /// Euler angles by which the player will be oriented. - /// - public MVector3 playerSpawnRotation; + public PlayerSpawnPoint playerSpawn; /// /// Required for the system to be accessible by warp drive. /// - public MVector3 shipSpawnPoint; + public ShipSpawnPoint shipSpawn; - /// - /// Euler angles by which the ship will be oriented. - /// - public MVector3 shipSpawnRotation; + [Obsolete("playerSpawnPoint is deprecated. Use playerSpawn.position instead")] public MVector3 playerSpawnPoint; + [Obsolete("playerSpawnRotation is deprecated. Use playerSpawn.rotation instead")] public MVector3 playerSpawnRotation; + [Obsolete("shipSpawnPoint is deprecated. Use shipSpawn.position instead")] public MVector3 shipSpawnPoint; + [Obsolete("shipSpawnRotation is deprecated. Use shipSpawn.rotation instead")] public MVector3 shipSpawnRotation; + [Obsolete("startWithSuit is deprecated. Use playerSpawn.startWithSuit instead")] public bool startWithSuit; - /// - /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) - /// - public bool startWithSuit; + [JsonObject] + public class PlayerSpawnPoint : PropModule.GeneralPropInfo { + /// + /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) + /// + public bool startWithSuit; + } + + [JsonObject] + public class ShipSpawnPoint : PropModule.GeneralPropInfo { + + } } } \ No newline at end of file diff --git a/NewHorizons/Handlers/StarChartHandler.cs b/NewHorizons/Handlers/StarChartHandler.cs index e4942499f..65ae35159 100644 --- a/NewHorizons/Handlers/StarChartHandler.cs +++ b/NewHorizons/Handlers/StarChartHandler.cs @@ -66,7 +66,7 @@ public static bool CanWarp() { foreach (var system in _systems) { - if (system.Config.canEnterViaWarpDrive && system.Spawn?.shipSpawnPoint != null && HasUnlockedSystem(system.UniqueID)) + if (system.Config.canEnterViaWarpDrive && system.Spawn?.shipSpawn != null && HasUnlockedSystem(system.UniqueID)) { return true; } diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index adcbf3fb5..032533847 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -7,6 +7,7 @@ using Logger = NewHorizons.Utility.Logger; using static NewHorizons.Main; using NewHorizons.Components.Orbital; +using NewHorizons.Builder.Props; namespace NewHorizons.Handlers { @@ -84,9 +85,9 @@ public static EyeSpawnPoint CreateVessel() if (VesselPrefab == null) return null; Logger.LogVerbose("Creating Vessel"); - var vesselObject = VesselPrefab.InstantiateInactive(); + var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, system.Config.Vessel?.vessel); VesselObject = vesselObject; - vesselObject.name = VesselPrefab.name; + vesselObject.transform.parent = null; var vesselAO = vesselObject.AddComponent(); @@ -98,12 +99,6 @@ public static EyeSpawnPoint CreateVessel() vesselAO.Register(); vesselObject.GetComponentInChildren(true)._referenceFrame._attachedAstroObject = vesselAO; - if (system.Config.Vessel?.vesselPosition != null) - vesselObject.transform.position = system.Config.Vessel.vesselPosition; - - if (system.Config.Vessel?.vesselRotation != null) - vesselObject.transform.eulerAngles = system.Config.Vessel.vesselRotation; - VesselSingularityRoot singularityRoot = vesselObject.GetComponentInChildren(true); VesselWarpController vesselWarpController = vesselObject.GetComponentInChildren(true); @@ -147,11 +142,7 @@ public static EyeSpawnPoint CreateVessel() vesselWarpController._targetWarpPlatform.OnReceiveWarpedBody += OnReceiveWarpedBody; - if (system.Config.Vessel?.warpExitPosition != null) - vesselWarpController._targetWarpPlatform.transform.localPosition = system.Config.Vessel.warpExitPosition; - - if (system.Config.Vessel?.warpExitRotation != null) - vesselWarpController._targetWarpPlatform.transform.localEulerAngles = system.Config.Vessel.warpExitRotation; + GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, vesselWarpController._targetWarpPlatform.transform.parent, system.Config.Vessel?.warpExit); vesselObject.GetComponent()._labelID = (UITextType)TranslationHandler.AddUI("Vessel"); diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index 1ea6b8693..ce358343a 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -199,10 +199,13 @@ public object QuerySystem(Type outType, string jsonPath) pathToAnimController = pathToAnimController, position = Vector3.zero, radius = radius, - remoteTriggerPosition = null, range = range, - remoteTriggerRadius = remoteTriggerRadius, - xmlFile = xmlFile + xmlFile = xmlFile, + remoteTrigger = new PropModule.DialogueInfo.RemoteTriggerInfo() + { + position = null, + radius = remoteTriggerRadius, + }, }; return DialogueBuilder.Make(root, null, info, mod); From fdd300d964080479ec943c9e227bf9c786480e40 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 14:20:14 +0000 Subject: [PATCH 020/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 194 +++++++++++++------- NewHorizons/Schemas/star_system_schema.json | 88 +++++++-- 2 files changed, 202 insertions(+), 80 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 8a52568d5..d25f9db34 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -659,11 +659,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1089,11 +1089,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1172,7 +1172,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1202,27 +1202,18 @@ }, "radius": { "type": "number", - "description": "Radius of the spherical collision volume where you get the \"talk to\" prompt when looking at. If you use a\nremoteTriggerPosition, you can set this to 0 to make the dialogue only trigger remotely.", + "description": "Radius of the spherical collision volume where you get the \"talk to\" prompt when looking at. If you use a\nremoteTrigger, you can set this to 0 to make the dialogue only trigger remotely.", "format": "float" }, - "remoteTriggerPosition": { - "description": "Allows you to trigger dialogue from a distance when you walk into an area.", - "$ref": "#/definitions/MVector3" - }, "range": { "type": "number", "description": "Distance from radius the prompt appears", "format": "float", "default": 2.0 }, - "remoteTriggerRadius": { - "type": "number", - "description": "The radius of the remote trigger volume.", - "format": "float" - }, - "remoteTriggerPrereqCondition": { - "type": "string", - "description": "If setting up a remote trigger volume, this conditions must be met for it to trigger. Note: This is a dialogue condition, not a persistent condition." + "remoteTrigger": { + "description": "Allows you to trigger dialogue from a distance when you walk into an area.", + "$ref": "#/definitions/RemoteTriggerInfo" }, "xmlFile": { "type": "string", @@ -1235,6 +1226,37 @@ } } }, + "RemoteTriggerInfo": { + "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" + }, + "radius": { + "type": "number", + "description": "The radius of the remote trigger volume.", + "format": "float" + }, + "prereqCondition": { + "type": "string", + "description": "This condition must be met for the remote trigger volume to trigger." + } + } + }, "FlashlightToggle": { "type": "string", "description": "", @@ -1254,7 +1276,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1284,7 +1306,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1352,7 +1374,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1512,7 +1534,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1607,11 +1629,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1784,11 +1806,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1821,7 +1843,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1904,7 +1926,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -1963,11 +1985,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2047,7 +2069,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2143,11 +2165,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2215,11 +2237,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2254,11 +2276,11 @@ "additionalProperties": false, "properties": { "rotation": { - "description": "Rotation of the prop", + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -2527,28 +2549,72 @@ "type": "object", "additionalProperties": false, "properties": { - "playerSpawnPoint": { - "description": "If you want the player to spawn on the new body, set a value for this. Press `P` in game with Debug mode on to have\nthe game log the position you're looking at to find a good value for this.", - "$ref": "#/definitions/MVector3" - }, - "playerSpawnRotation": { - "description": "Euler angles by which the player will be oriented.", - "$ref": "#/definitions/MVector3" + "playerSpawn": { + "description": "If you want the player to spawn on the new body, set a value for this.", + "$ref": "#/definitions/PlayerSpawnPoint" }, - "shipSpawnPoint": { + "shipSpawn": { "description": "Required for the system to be accessible by warp drive.", + "$ref": "#/definitions/ShipSpawnPoint" + } + } + }, + "PlayerSpawnPoint": { + "type": "object", + "additionalProperties": false, + "properties": { + "rotation": { + "description": "Rotation of the object", "$ref": "#/definitions/MVector3" }, - "shipSpawnRotation": { - "description": "Euler angles by which the ship will be oriented.", + "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" + }, "startWithSuit": { "type": "boolean", "description": "If you spawn on a planet with no oxygen, you probably want to set this to true ;;)" } } }, + "ShipSpawnPoint": { + "type": "object", + "additionalProperties": false, + "properties": { + "rotation": { + "description": "Rotation of the object", + "$ref": "#/definitions/MVector3" + }, + "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" + } + } + }, "StarModule": { "type": "object", "additionalProperties": false, @@ -2877,7 +2943,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3012,7 +3078,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3095,7 +3161,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3168,7 +3234,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3251,7 +3317,7 @@ "additionalProperties": false, "properties": { "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3285,7 +3351,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3356,7 +3422,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3413,7 +3479,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3536,7 +3602,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3576,7 +3642,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3626,7 +3692,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3670,7 +3736,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3742,7 +3808,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3796,7 +3862,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3836,7 +3902,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3876,7 +3942,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { @@ -3909,7 +3975,7 @@ "default": 1.0 }, "position": { - "description": "Position of the prop", + "description": "Position of the object", "$ref": "#/definitions/MVector3" }, "parentPath": { diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index a4185c828..e7a3c72fa 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -139,25 +139,17 @@ "description": "Coordinates that the vessel can use to warp to your solar system.", "$ref": "#/definitions/NomaiCoordinates" }, - "vesselPosition": { - "description": "The position in the solar system the vessel will warp to.", - "$ref": "#/definitions/MVector3" - }, - "vesselRotation": { - "description": "Euler angles by which the vessel will be oriented.", - "$ref": "#/definitions/MVector3" - }, - "warpExitPosition": { - "description": "The relative position to the vessel that you will be teleported to when you exit the vessel through the black hole.", - "$ref": "#/definitions/MVector3" - }, - "warpExitRotation": { - "description": "Euler angles by which the warp exit will be oriented.", - "$ref": "#/definitions/MVector3" - }, "promptFact": { "type": "string", "description": "A ship log fact which will make a prompt appear showing the coordinates when you're in the Vessel." + }, + "vessel": { + "description": "The location that the vessel will warp to.", + "$ref": "#/definitions/VesselInfo" + }, + "warpExit": { + "description": "The location that you will be teleported to when you exit the vessel through the black hole.", + "$ref": "#/definitions/WarpExitInfo" } } }, @@ -197,6 +189,36 @@ } } }, + "VesselInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "parentBody": { + "type": "string", + "description": "The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set." + }, + "rotation": { + "description": "Rotation of the object", + "$ref": "#/definitions/MVector3" + }, + "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" + } + } + }, "MVector3": { "type": "object", "additionalProperties": false, @@ -215,6 +237,40 @@ } } }, + "WarpExitInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "parentBody": { + "type": "string", + "description": "The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set." + }, + "rotation": { + "description": "Rotation of the object", + "$ref": "#/definitions/MVector3" + }, + "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" + }, + "attachToVessel": { + "type": "boolean", + "description": "If set, keeps the warp exit attached to the vessel. Overrides `parentPath`." + } + } + }, "EntryPositionInfo": { "type": "object", "additionalProperties": false, From f92830959617ee656a4e16a6f4c123c3fc7e5a44 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 09:29:48 -0500 Subject: [PATCH 021/119] Vessel prop tweaks --- .../Builder/Props/GeneralPropBuilder.cs | 4 +-- .../External/Configs/StarSystemConfig.cs | 26 +++++++++---------- NewHorizons/Handlers/VesselWarpHandler.cs | 10 +++++-- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index adefa07f2..691f10831 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -62,8 +62,8 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM go.transform.localRotation = rot; } else if (parent) { - go.transform.position = parent.TransformPoint(pos); - go.transform.rotation = parent.TransformRotation(rot); + go.transform.position = parent.root.TransformPoint(pos); + go.transform.rotation = parent.root.TransformRotation(rot); } else { go.transform.position = pos; diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index c9307b984..0830d0336 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -85,16 +85,16 @@ public class StarSystemConfig [Obsolete("coords is deprecated, please use Vessel.coords instead")] public NomaiCoordinates coords; - [Obsolete("vesselPosition is deprecated, please use Vessel.vesselPosition instead")] + [Obsolete("vesselPosition is deprecated, please use Vessel.vesselSpawn.position instead")] public MVector3 vesselPosition; - [Obsolete("vesselRotation is deprecated, please use Vessel.vesselRotation instead")] + [Obsolete("vesselRotation is deprecated, please use Vessel.vesselSpawn.rotation instead")] public MVector3 vesselRotation; - [Obsolete("warpExitPosition is deprecated, please use Vessel.warpExitPosition instead")] + [Obsolete("warpExitPosition is deprecated, please use Vessel.warpExit.position instead")] public MVector3 warpExitPosition; - [Obsolete("warpExitRotation is deprecated, please use Vessel.warpExitRotation instead")] + [Obsolete("warpExitRotation is deprecated, please use Vessel.warpExit.rotation instead")] public MVector3 warpExitRotation; /// @@ -193,17 +193,17 @@ public class VesselModule /// /// The location that the vessel will warp to. /// - public VesselInfo vessel; + public VesselInfo vesselSpawn; /// /// The location that you will be teleported to when you exit the vessel through the black hole. /// public WarpExitInfo warpExit; - [Obsolete("vesselPosition is deprecated, use vessel.position instead")] public MVector3 vesselPosition; - [Obsolete("vesselRotation is deprecated, use vessel.rotation instead")] public MVector3 vesselRotation; - [Obsolete("warpExitPosition is deprecated, use warpExit.position instead")] public MVector3 warpExitPosition; - [Obsolete("warpExitRotation is deprecated, use warpExit.rotation instead")] public MVector3 warpExitRotation; + [Obsolete("vesselPosition is deprecated, use vesselSpawn.position instead")] public MVector3 vesselPosition; + [Obsolete("vesselRotation is deprecated, use vesselSpawn.rotation instead")] public MVector3 vesselRotation; + [Obsolete("warpExitPosition is deprecated, use vesselSpawn.position instead")] public MVector3 warpExitPosition; + [Obsolete("warpExitRotation is deprecated, use vesselSpawn.rotation instead")] public MVector3 warpExitRotation; [JsonObject] public class VesselInfo : PropModule.GeneralSolarSystemPropInfo @@ -291,12 +291,12 @@ public void Migrate() { if (Vessel.vesselPosition != null || Vessel.vesselRotation != null) { - if (Vessel.vessel == null) + if (Vessel.vesselSpawn == null) { - Vessel.vessel = new VesselModule.VesselInfo(); + Vessel.vesselSpawn = new VesselModule.VesselInfo(); } - Vessel.vessel.position ??= Vessel.vesselPosition; - Vessel.vessel.rotation ??= Vessel.vesselRotation; + Vessel.vesselSpawn.position ??= Vessel.vesselPosition; + Vessel.vesselSpawn.rotation ??= Vessel.vesselRotation; } if (Vessel.warpExitPosition != null || Vessel.warpExitRotation != null) { diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 032533847..01e19c5cc 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -85,7 +85,7 @@ public static EyeSpawnPoint CreateVessel() if (VesselPrefab == null) return null; Logger.LogVerbose("Creating Vessel"); - var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, system.Config.Vessel?.vessel); + var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, system.Config.Vessel?.vesselSpawn); VesselObject = vesselObject; vesselObject.transform.parent = null; @@ -142,7 +142,13 @@ public static EyeSpawnPoint CreateVessel() vesselWarpController._targetWarpPlatform.OnReceiveWarpedBody += OnReceiveWarpedBody; - GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, vesselWarpController._targetWarpPlatform.transform.parent, system.Config.Vessel?.warpExit); + var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false; + var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent; + var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, attachWarpExitToVessel ? warpExitParent : null, system.Config.Vessel?.warpExit); + if (attachWarpExitToVessel) + { + warpExit.transform.parent = warpExitParent; + } vesselObject.GetComponent()._labelID = (UITextType)TranslationHandler.AddUI("Vessel"); From f4be589d8d5ea4d161a79f697c62487119d2fab5 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 14:32:43 +0000 Subject: [PATCH 022/119] Updated Schemas --- NewHorizons/Schemas/star_system_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index e7a3c72fa..12b9eaafd 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -143,7 +143,7 @@ "type": "string", "description": "A ship log fact which will make a prompt appear showing the coordinates when you're in the Vessel." }, - "vessel": { + "vesselSpawn": { "description": "The location that the vessel will warp to.", "$ref": "#/definitions/VesselInfo" }, From 62dcc92dbbf9587f057282bd794aa7d7e01b1416 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 10:52:57 -0500 Subject: [PATCH 023/119] Allow removing vessel rigidbody --- NewHorizons/External/Configs/StarSystemConfig.cs | 5 ++++- NewHorizons/Handlers/VesselWarpHandler.cs | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 0830d0336..587944039 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -208,7 +208,10 @@ public class VesselModule [JsonObject] public class VesselInfo : PropModule.GeneralSolarSystemPropInfo { - + /// + /// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body. + /// + [DefaultValue(true)] public bool hasPhysics = true; } [JsonObject] diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 01e19c5cc..c18c27c61 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -88,10 +88,12 @@ public static EyeSpawnPoint CreateVessel() var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, system.Config.Vessel?.vesselSpawn); VesselObject = vesselObject; - vesselObject.transform.parent = null; - var vesselAO = vesselObject.AddComponent(); - vesselAO._owRigidbody = vesselObject.GetComponent(); + if (system.Config.Vessel?.vesselSpawn.hasPhysics ?? true) + { + vesselAO._owRigidbody = vesselObject.GetComponent(); + vesselObject.transform.parent = null; + } vesselAO._rootSector = vesselObject.GetComponentInChildren(true); vesselAO._customName = "Vessel"; vesselAO._name = AstroObject.Name.CustomString; From 1c0466f04fdcac7ea5648a407f831cbb156851b4 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 10:54:51 -0500 Subject: [PATCH 024/119] Remove unncessary isRelativeToGroup property on quantum sockets --- NewHorizons/Builder/Props/QuantumBuilder.cs | 9 +-------- NewHorizons/External/Modules/PropModule.cs | 4 ---- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 9a1381203..0697c5a0a 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,14 +50,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = GeneralPropBuilder.MakeNew("Socket " + i, sector?.transform ?? go.transform, socketInfo); - - if (socketInfo.isRelativeToGroup) - { - socket.transform.parent = groupRoot.transform; - socket.transform.localPosition = socketInfo.position; - socket.transform.localEulerAngles = socketInfo.rotation; - } + var socket = GeneralPropBuilder.MakeNew("Socket " + i, groupRoot.transform, socketInfo); sockets[i] = socket.AddComponent(); sockets[i]._lightSources = new Light[0]; diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index b402046ad..9c21b454a 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -801,10 +801,6 @@ public class QuantumGroupInfo [JsonObject] public class QuantumSocketInfo : GeneralPropInfo { - /// - /// Whether the socket will be placed relative to the group it belongs to. Overrides `isRelativeToParent` - /// - [DefaultValue(true)] public bool isRelativeToGroup = true; /// /// The probability any props that are part of this group will occupy this socket /// From 1c3c085967f5fc8e58c41b49cebea0f799119c7d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 11:09:05 -0500 Subject: [PATCH 025/119] Move backwards compatibility fixes to Migrate methods --- .../Builder/General/SpawnPointBuilder.cs | 38 ++++--------------- NewHorizons/Builder/Props/DialogueBuilder.cs | 23 +++-------- NewHorizons/External/Configs/PlanetConfig.cs | 37 ++++++++++++++++++ 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 6150de08d..7c1421eb5 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -14,34 +14,10 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo { SpawnPoint playerSpawn = null; - var playerSpawnInfo = module.playerSpawn; - var shipSpawnInfo = module.shipSpawn; - - // Backwards compatibility -#pragma warning disable 612, 618 - if (playerSpawnInfo == null && module.playerSpawnPoint != null) - { - playerSpawnInfo = new SpawnModule.PlayerSpawnPoint() - { - position = module.playerSpawnPoint, - rotation = module.playerSpawnRotation, - startWithSuit = module.startWithSuit, - }; - } - if (shipSpawnInfo == null && module.shipSpawnPoint != null) - { - shipSpawnInfo = new SpawnModule.ShipSpawnPoint() - { - position = module.shipSpawnPoint, - rotation = module.shipSpawnRotation, - }; - } -#pragma warning restore 612, 618 - - if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && playerSpawnInfo != null) + if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && module.playerSpawn != null) { - bool alignToBody = playerSpawnInfo.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO.transform, playerSpawnInfo, alignToBody); + bool alignToBody = module.playerSpawn.rotation == null; + GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO.transform, module.playerSpawn, alignToBody); spawnGO.layer = 8; playerSpawn = spawnGO.AddComponent(); @@ -49,10 +25,10 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo spawnGO.transform.position += spawnGO.transform.up * 4f; } - if (shipSpawnInfo != null) + if (module.shipSpawn != null) { - bool alignToBody = shipSpawnInfo.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO.transform, shipSpawnInfo, alignToBody); + bool alignToBody = module.shipSpawn.rotation == null; + GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO.transform, module.shipSpawn, alignToBody); spawnGO.layer = 8; var spawnPoint = spawnGO.AddComponent(); @@ -89,7 +65,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo } } - if ((Main.Instance.IsWarpingFromVessel || (!Main.Instance.IsWarpingFromShip && (playerSpawnInfo?.startWithSuit ?? false))) && !suitUpQueued) + if ((Main.Instance.IsWarpingFromVessel || (!Main.Instance.IsWarpingFromShip && (module.playerSpawn?.startWithSuit ?? false))) && !suitUpQueued) { suitUpQueued = true; Delay.RunWhen(() => Main.IsSystemReady, () => SuitUp()); diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index da4357267..f81d8ac29 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -24,21 +24,8 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, RemoteDialogueTrigger remoteTrigger = null; if (info.remoteTrigger != null) { - remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, info.remoteTrigger, dialogue); + remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, dialogue); } - // Backwards compatibility -#pragma warning disable 612, 618 - if (remoteTrigger == null && (info.remoteTriggerPosition != null || info.remoteTriggerRadius != 0)) - { - var remoteInfo = new PropModule.DialogueInfo.RemoteTriggerInfo - { - position = info.remoteTriggerPosition, - radius = info.remoteTriggerRadius, - prereqCondition = info.remoteTriggerPrereqCondition, - }; - remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, remoteInfo, dialogue); - } -#pragma warning restore 612, 618 // Make the character look at the player // Useful for dialogue replacement @@ -51,9 +38,9 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, return (dialogue, remoteTrigger); } - private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, PropModule.DialogueInfo.RemoteTriggerInfo remoteTriggerInfo, CharacterDialogueTree dialogue) + private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue) { - var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", sector?.transform ?? planetGO.transform, remoteTriggerInfo, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); + var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", sector?.transform ?? planetGO.transform, info.remoteTrigger, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); var remoteDialogueTrigger = conversationTrigger.AddComponent(); var sphereCollider = conversationTrigger.AddComponent(); @@ -67,7 +54,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet dialogue = dialogue, prereqConditionType = RemoteDialogueTrigger.MultiConditionType.AND, // Base game never uses more than one condition anyone so we'll keep it simple - prereqConditions = string.IsNullOrEmpty(remoteTriggerInfo.prereqCondition) ? new string[]{ } : new string[] { remoteTriggerInfo.prereqCondition }, + prereqConditions = string.IsNullOrEmpty(info.remoteTrigger.prereqCondition) ? new string[]{ } : new string[] { info.remoteTrigger.prereqCondition }, // Just set your enter conditions in XML instead of complicating it with this onTriggerEnterConditions = new string[]{ } } @@ -75,7 +62,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet remoteDialogueTrigger._activatedDialogues = new bool[1]; remoteDialogueTrigger._deactivateTriggerPostConversation = true; - sphereCollider.radius = remoteTriggerInfo.radius == 0 ? info.radius : remoteTriggerInfo.radius; + sphereCollider.radius = info.remoteTrigger.radius == 0 ? info.radius : info.remoteTrigger.radius; conversationTrigger.SetActive(true); diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 20ca31da0..3330a4ada 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -1,3 +1,4 @@ +using Epic.OnlineServices.Presence; using NewHorizons.External.Modules; using NewHorizons.External.Modules.VariableSize; using Newtonsoft.Json; @@ -465,6 +466,42 @@ public void Migrate() { ShockEffect = new ShockEffectModule() { hasSupernovaShockEffect = true }; } + + // Spawn points reorganized to use GenericPropInfo + if (Spawn.playerSpawn == null && Spawn.playerSpawnPoint != null) + { + Spawn.playerSpawn = new SpawnModule.PlayerSpawnPoint() + { + position = Spawn.playerSpawnPoint, + rotation = Spawn.playerSpawnRotation, + startWithSuit = Spawn.startWithSuit, + }; + } + if (Spawn.shipSpawn == null && Spawn.shipSpawnPoint != null) + { + Spawn.shipSpawn = new SpawnModule.ShipSpawnPoint() + { + position = Spawn.shipSpawnPoint, + rotation = Spawn.shipSpawnRotation, + }; + } + + // Remote dialogue trigger reorganized to use GenericPropInfo + if (Props.dialogue != null) + { + foreach (var dialogue in Props.dialogue) + { + if (dialogue.remoteTrigger == null && (dialogue.remoteTriggerPosition != null || dialogue.remoteTriggerRadius != 0)) + { + dialogue.remoteTrigger = new PropModule.DialogueInfo.RemoteTriggerInfo + { + position = dialogue.remoteTriggerPosition, + radius = dialogue.remoteTriggerRadius, + prereqCondition = dialogue.remoteTriggerPrereqCondition, + }; + } + } + } } } } \ No newline at end of file From 550c96d1678a0969edaa40c7266d9459ccd4c2f8 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 11:40:21 -0500 Subject: [PATCH 026/119] Moved prop info and volume info classes to their own files --- .../Builder/Body/BrambleDimensionBuilder.cs | 3 +- NewHorizons/Builder/Body/ProxyBuilder.cs | 4 +- .../Builder/Body/SingularityBuilder.cs | 8 +- .../Builder/Props/BrambleNodeBuilder.cs | 1 + NewHorizons/Builder/Props/DetailBuilder.cs | 11 +- NewHorizons/Builder/Props/DialogueBuilder.cs | 15 +- .../Builder/Props/GeneralPropBuilder.cs | 11 +- NewHorizons/Builder/Props/GeyserBuilder.cs | 3 +- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 55 +- .../Builder/Props/ProjectionBuilder.cs | 25 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 15 +- NewHorizons/Builder/Props/RaftBuilder.cs | 3 +- NewHorizons/Builder/Props/RemoteBuilder.cs | 17 +- NewHorizons/Builder/Props/ScatterBuilder.cs | 5 +- NewHorizons/Builder/Props/SignalBuilder.cs | 3 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 13 +- .../TranslatorText/TranslatorTextBuilder.cs | 55 +- NewHorizons/Builder/Props/VolcanoBuilder.cs | 5 +- .../Builder/ShipLog/EntryLocationBuilder.cs | 3 +- NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 6 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 29 +- .../Builder/Volumes/AudioVolumeBuilder.cs | 3 +- .../Volumes/ChangeStarSystemVolumeBuilder.cs | 3 +- .../Builder/Volumes/CreditsVolumeBuilder.cs | 3 +- .../Volumes/DestructionVolumeBuilder.cs | 3 +- .../Builder/Volumes/FluidVolumeBuilder.cs | 3 +- .../Builder/Volumes/HazardVolumeBuilder.cs | 11 +- .../Volumes/NotificationVolumeBuilder.cs | 3 +- .../Builder/Volumes/OxygenVolumeBuilder.cs | 3 +- .../Builder/Volumes/PriorityVolumeBuilder.cs | 3 +- .../Rulesets/PlayerImpactRulesetBuilder.cs | 2 +- .../Volumes/Rulesets/ProbeRulesetBuilder.cs | 2 +- .../Volumes/Rulesets/ThrustRulesetBuilder.cs | 2 +- .../Builder/Volumes/SpeedTrapVolumeBuilder.cs | 3 +- .../Builder/Volumes/VanishVolumeBuilder.cs | 3 +- .../VisorFrostEffectVolumeBuilder.cs | 2 +- .../VisorRainEffectVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 3 +- .../Builder/Volumes/ZeroGVolumeBuilder.cs | 3 +- .../Components/Volumes/LoadCreditsVolume.cs | 9 +- .../Components/Volumes/NotificationVolume.cs | 3 +- NewHorizons/External/Configs/PlanetConfig.cs | 42 +- .../External/Configs/StarSystemConfig.cs | 5 +- NewHorizons/External/Modules/BrambleModule.cs | 62 +- NewHorizons/External/Modules/ProbeModule.cs | 20 + NewHorizons/External/Modules/PropModule.cs | 828 +----------------- NewHorizons/External/Modules/RulesetModule.cs | 90 ++ NewHorizons/External/Modules/SignalModule.cs | 59 +- NewHorizons/External/Modules/SpawnModule.cs | 5 +- .../External/Modules/VisorEffectModule.cs | 55 ++ NewHorizons/External/Modules/VolumesModule.cs | 536 +----------- NewHorizons/External/Props/BrambleNodeInfo.cs | 73 ++ NewHorizons/External/Props/DetailInfo.cs | 76 ++ NewHorizons/External/Props/DialogueInfo.cs | 85 ++ .../External/Props/EntryLocationInfo.cs | 18 + .../External/Props/GeneralPointPropInfo.cs | 29 + NewHorizons/External/Props/GeneralPropInfo.cs | 14 + .../Props/GeneralSolarSystemPropInfo.cs | 13 + NewHorizons/External/Props/GeyserInfo.cs | 46 + .../External/Props/NomaiTextArcInfo.cs | 54 ++ NewHorizons/External/Props/NomaiTextInfo.cs | 81 ++ NewHorizons/External/Props/ProjectionInfo.cs | 47 + .../External/Props/QuantumGroupInfo.cs | 51 ++ .../External/Props/QuantumSocketInfo.cs | 14 + NewHorizons/External/Props/RaftInfo.cs | 14 + NewHorizons/External/Props/RemoteInfo.cs | 107 +++ NewHorizons/External/Props/ScatterInfo.cs | 71 ++ NewHorizons/External/Props/SignalInfo.cs | 71 ++ .../SingularityInfo.cs} | 6 +- NewHorizons/External/Props/SlideInfo.cs | 85 ++ NewHorizons/External/Props/TornadoInfo.cs | 73 ++ NewHorizons/External/Props/VolcanoInfo.cs | 50 ++ .../External/Volumes/AudioVolumeInfo.cs | 88 ++ .../Volumes/ChangeStarSystemVolumeInfo.cs | 16 + .../External/Volumes/DestructionVolumeInfo.cs | 37 + .../External/Volumes/FluidVolumeInfo.cs | 49 ++ .../External/Volumes/HazardVolumeInfo.cs | 54 ++ .../External/Volumes/LoadCreditsVolumeInfo.cs | 25 + .../Volumes/NotificationVolumeInfo.cs | 50 ++ .../External/Volumes/OxygenVolumeInfo.cs | 20 + .../External/Volumes/PriorityVolumeInfo.cs | 23 + .../External/Volumes/RevealVolumeInfo.cs | 64 ++ .../External/Volumes/SpeedTrapVolumeInfo.cs | 22 + .../External/Volumes/VanishVolumeInfo.cs | 20 + NewHorizons/External/Volumes/VolumeInfo.cs | 121 +++ NewHorizons/NewHorizonsApi.cs | 9 +- .../Utility/DebugUtilities/DebugPropPlacer.cs | 15 +- 87 files changed, 2076 insertions(+), 1676 deletions(-) create mode 100644 NewHorizons/External/Modules/ProbeModule.cs create mode 100644 NewHorizons/External/Modules/RulesetModule.cs create mode 100644 NewHorizons/External/Modules/VisorEffectModule.cs create mode 100644 NewHorizons/External/Props/BrambleNodeInfo.cs create mode 100644 NewHorizons/External/Props/DetailInfo.cs create mode 100644 NewHorizons/External/Props/DialogueInfo.cs create mode 100644 NewHorizons/External/Props/EntryLocationInfo.cs create mode 100644 NewHorizons/External/Props/GeneralPointPropInfo.cs create mode 100644 NewHorizons/External/Props/GeneralPropInfo.cs create mode 100644 NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs create mode 100644 NewHorizons/External/Props/GeyserInfo.cs create mode 100644 NewHorizons/External/Props/NomaiTextArcInfo.cs create mode 100644 NewHorizons/External/Props/NomaiTextInfo.cs create mode 100644 NewHorizons/External/Props/ProjectionInfo.cs create mode 100644 NewHorizons/External/Props/QuantumGroupInfo.cs create mode 100644 NewHorizons/External/Props/QuantumSocketInfo.cs create mode 100644 NewHorizons/External/Props/RaftInfo.cs create mode 100644 NewHorizons/External/Props/RemoteInfo.cs create mode 100644 NewHorizons/External/Props/ScatterInfo.cs create mode 100644 NewHorizons/External/Props/SignalInfo.cs rename NewHorizons/External/{Modules/VariableSize/SingularityModule.cs => Props/SingularityInfo.cs} (92%) create mode 100644 NewHorizons/External/Props/SlideInfo.cs create mode 100644 NewHorizons/External/Props/TornadoInfo.cs create mode 100644 NewHorizons/External/Props/VolcanoInfo.cs create mode 100644 NewHorizons/External/Volumes/AudioVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/DestructionVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/FluidVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/HazardVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/NotificationVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/OxygenVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/PriorityVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/RevealVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/VanishVolumeInfo.cs create mode 100644 NewHorizons/External/Volumes/VolumeInfo.cs diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 02f32731e..4501dce38 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -10,6 +10,7 @@ using UnityEngine; using Logger = NewHorizons.Utility.Logger; using static NewHorizons.Main; +using NewHorizons.External.Props; namespace NewHorizons.Builder.Body { @@ -103,7 +104,7 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject default: geometryPrefab = _hubGeometry; break; } - var detailInfo = new PropModule.DetailInfo(); + var detailInfo = new DetailInfo(); var geometry = DetailBuilder.Make(go, sector, geometryPrefab, detailInfo); var exitWarps = _exitWarps.InstantiateInactive(); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index f2a76bced..6b085afff 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -2,7 +2,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.Components.SizeControllers; -using NewHorizons.External.Modules.VariableSize; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using System; @@ -187,7 +187,7 @@ private static bool SharedMake(GameObject planetGO, GameObject proxy, NHProxy pr { foreach (var singularity in body.Config.Props.singularities) { - var polarity = singularity.type == SingularityModule.SingularityType.BlackHole; + var polarity = singularity.type == SingularityInfo.SingularityType.BlackHole; SingularityBuilder.MakeSingularityProxy(proxy, singularity.position, polarity, singularity.horizonRadius, singularity.distortRadius, singularity.curve, singularity.renderQueueOverride); if (realSize < singularity.distortRadius) realSize = singularity.distortRadius; } diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 97c530103..0c2e4df2b 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -1,7 +1,6 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; using System; -using NewHorizons.External.Modules.VariableSize; using UnityEngine; using Logger = NewHorizons.Utility.Logger; using System.Collections.Generic; @@ -11,6 +10,7 @@ using Color = UnityEngine.Color; using NewHorizons.Components.Volumes; using NewHorizons.Builder.Props; +using NewHorizons.External.Props; namespace NewHorizons.Builder.Body { @@ -70,7 +70,7 @@ internal static void InitPrefabs() if (_whiteHoleVolume == null) _whiteHoleVolume = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVolume").InstantiateInactive().Rename("WhiteHoleVolume").DontDestroyOnLoad(); } - public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityModule singularity) + public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityInfo singularity) { InitPrefabs(); @@ -81,7 +81,7 @@ public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetCo var distortRadius = singularity.distortRadius != 0f ? singularity.distortRadius : horizonRadius * 2.5f; var pairedSingularity = singularity.pairedSingularity; - bool polarity = singularity.type == SingularityModule.SingularityType.BlackHole; + bool polarity = singularity.type == SingularityInfo.SingularityType.BlackHole; bool isWormHole = singularity?.targetStarSystem != null; bool hasHazardVolume = !isWormHole && (pairedSingularity == null); @@ -140,7 +140,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam // polarity true = black, false = white - var info = new SingularityModule + var info = new SingularityInfo { position = position, rotation = rotation, diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 4a836fb4b..8996604eb 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Body; using NewHorizons.Components; using NewHorizons.External.Configs; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 88aa7db54..00d7888aa 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.General; using NewHorizons.Components; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -15,7 +16,7 @@ namespace NewHorizons.Builder.Props { public static class DetailBuilder { - private static readonly Dictionary _detailInfoToCorrespondingSpawnedGameObject = new(); + private static readonly Dictionary _detailInfoToCorrespondingSpawnedGameObject = new(); private static readonly Dictionary<(Sector, string), (GameObject prefab, bool isItem)> _fixedPrefabCache = new(); static DetailBuilder() @@ -33,7 +34,7 @@ private static void SceneManager_sceneUnloaded(Scene scene) _detailInfoToCorrespondingSpawnedGameObject.Clear(); } - public static GameObject GetSpawnedGameObjectByDetailInfo(PropModule.DetailInfo detail) + public static GameObject GetSpawnedGameObjectByDetailInfo(DetailInfo detail) { if (!_detailInfoToCorrespondingSpawnedGameObject.ContainsKey(detail)) { @@ -48,7 +49,7 @@ public static GameObject GetSpawnedGameObjectByDetailInfo(PropModule.DetailInfo /// /// Create a detail using an asset bundle or a path in the scene hierarchy of the item to copy. /// - public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, PropModule.DetailInfo detail) + public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, DetailInfo detail) { if (detail.assetBundle != null) { @@ -64,7 +65,7 @@ public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, P /// /// Create a detail using a path in the scene hierarchy of the item to copy. /// - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.DetailInfo info) + public static GameObject Make(GameObject planetGO, Sector sector, DetailInfo info) { var prefab = SearchUtilities.Find(info.path); if (prefab == null) @@ -79,7 +80,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Det /// /// Create a detail using a prefab. /// - public static GameObject Make(GameObject go, Sector sector, GameObject prefab, PropModule.DetailInfo detail) + public static GameObject Make(GameObject go, Sector sector, GameObject prefab, DetailInfo detail) { if (prefab == null) return null; diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index f81d8ac29..028cbc9d9 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -7,13 +7,14 @@ using NewHorizons.Utility; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components; +using NewHorizons.External.Props; namespace NewHorizons.Builder.Props { public static class DialogueBuilder { // Returns the character dialogue tree and remote dialogue trigger, if applicable. - public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, Sector sector, PropModule.DialogueInfo info, IModBehaviour mod) + public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, Sector sector, DialogueInfo info, IModBehaviour mod) { // In stock I think they disable dialogue stuff with conditions // Here we just don't make it at all @@ -38,7 +39,7 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, return (dialogue, remoteTrigger); } - private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue) + private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, DialogueInfo info, CharacterDialogueTree dialogue) { var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", sector?.transform ?? planetGO.transform, info.remoteTrigger, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); @@ -69,7 +70,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet return remoteDialogueTrigger; } - private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, IModHelper mod) + private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, DialogueInfo info, IModHelper mod) { var conversationZone = GeneralPropBuilder.MakeNew("ConversationZone", sector?.transform ?? planetGO.transform, info, defaultParentPath: info.pathToAnimController); @@ -105,15 +106,15 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S switch (info.flashlightToggle) { - case PropModule.DialogueInfo.FlashlightToggle.TurnOff: + case DialogueInfo.FlashlightToggle.TurnOff: dialogueTree._turnOffFlashlight = true; dialogueTree._turnOnFlashlight = false; break; - case PropModule.DialogueInfo.FlashlightToggle.TurnOffThenOn: + case DialogueInfo.FlashlightToggle.TurnOffThenOn: dialogueTree._turnOffFlashlight = true; dialogueTree._turnOnFlashlight = true; break; - case PropModule.DialogueInfo.FlashlightToggle.None: + case DialogueInfo.FlashlightToggle.None: default: dialogueTree._turnOffFlashlight = false; dialogueTree._turnOnFlashlight = false; @@ -125,7 +126,7 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S return dialogueTree; } - private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree dialogue, PropModule.DialogueInfo info) + private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree dialogue, DialogueInfo info) { var character = go.transform.Find(info.pathToAnimController); diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 691f10831..5b8228423 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using System; using System.Collections.Generic; @@ -12,11 +13,11 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromExisting(GameObject go, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { if (info == null) return go; - if (info is PropModule.GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) + if (info is GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) { var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody); if (targetPlanet != null) @@ -52,7 +53,7 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); var rot = Quaternion.identity; - if (info is PropModule.GeneralPropInfo rotInfo) + if (info is GeneralPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; } @@ -79,14 +80,14 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM return go; } - public static GameObject MakeNew(string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeNew(string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = new GameObject(defaultName); go.SetActive(false); return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index 2b4819fd0..eb1f1c99d 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -14,7 +15,7 @@ internal static void InitPrefab() if (_geyserPrefab == null) _geyserPrefab = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village").InstantiateInactive().Rename("Prefab_TH_Geyser").DontDestroyOnLoad(); } - public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info) + public static void Make(GameObject planetGO, Sector sector, GeyserInfo info) { InitPrefab(); diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 5e630fec9..571e58ac3 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -32,16 +33,16 @@ public static class NomaiTextBuilder private static GameObject _preCrashRecorderPrefab; private static GameObject _trailmarkerPrefab; - private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(PropModule.NomaiTextArcInfo arc) + private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); + public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(NomaiTextArcInfo arc) { if (!arcInfoToCorrespondingSpawnedGameObject.ContainsKey(arc)) return null; return arcInfoToCorrespondingSpawnedGameObject[arc]; } - private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) + public static GameObject GetSpawnedGameObjectByNomaiTextInfo(NomaiTextInfo convo) { Logger.LogVerbose("Retrieving wall text obj for " + convo); if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; @@ -142,7 +143,7 @@ internal static void InitPrefabs() } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, IModBehaviour mod) + public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo info, IModBehaviour mod) { InitPrefabs(); @@ -150,7 +151,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom switch (info.type) { - case PropModule.NomaiTextInfo.NomaiTextType.Wall: + case NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject; @@ -215,7 +216,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return nomaiWallTextObj; } - case PropModule.NomaiTextInfo.NomaiTextType.Scroll: + case NomaiTextInfo.NomaiTextType.Scroll: { var customScroll = _scrollPrefab.InstantiateInactive(); @@ -304,7 +305,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return customScroll; } - case PropModule.NomaiTextInfo.NomaiTextType.Computer: + case NomaiTextInfo.NomaiTextType.Computer: { var computerObject = _computerPrefab.InstantiateInactive(); @@ -357,9 +358,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: + case NomaiTextInfo.NomaiTextType.PreCrashComputer: { - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = info.position, parentPath = info.parentPath, @@ -407,10 +408,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Cairn: - case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: + case NomaiTextInfo.NomaiTextType.Cairn: + case NomaiTextInfo.NomaiTextType.CairnVariant: { - var cairnObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); + var cairnObject = (info.type == NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); if (!string.IsNullOrEmpty(info.rename)) { @@ -482,11 +483,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return cairnObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case PropModule.NomaiTextInfo.NomaiTextType.Recorder: + case NomaiTextInfo.NomaiTextType.PreCrashRecorder: + case NomaiTextInfo.NomaiTextType.Recorder: { - var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); - var detailInfo = new PropModule.DetailInfo { + var prefab = (info.type == NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var detailInfo = new DetailInfo { parentPath = info.parentPath, rotation = info.rotation, position = info.position, @@ -517,7 +518,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: + case NomaiTextInfo.NomaiTextType.Trailmarker: { var trailmarkerObject = _trailmarkerPrefab.InstantiateInactive(); @@ -589,7 +590,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTextInfo info, string xmlPath) { GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); nomaiWallTextObj.SetActive(false); @@ -618,7 +619,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModu nomaiWallText.SetTextAsset(text); // #433 fuzzy stranger text - if (info.arcInfo != null && info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger)) + if (info.arcInfo != null && info.arcInfo.Any(x => x.type == NomaiTextArcInfo.NomaiTextArcType.Stranger)) { StreamingHandler.SetUpStreaming(AstroObject.Name.RingWorld, sector); } @@ -626,7 +627,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModu return nomaiWallText; } - internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info) + internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info) { var dict = MakeNomaiTextDict(xml); @@ -635,7 +636,7 @@ internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObje RefreshArcs(nomaiWallText, conversationZone, info); } - internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info) + internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info) { var dict = nomaiWallText._dictNomaiTextData; Random.InitState(info.seed); @@ -666,26 +667,26 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers } } - internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID) + internal static GameObject MakeArc(NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID) { GameObject arc; - var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; + var type = arcInfo != null ? arcInfo.type : NomaiTextArcInfo.NomaiTextArcType.Adult; var variation = arcInfo != null ? arcInfo.variation : -1; switch (type) { - case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: + case NomaiTextArcInfo.NomaiTextArcType.Child: variation = variation < 0 ? Random.Range(0, _childArcPrefabs.Count()) : (variation % _childArcPrefabs.Count()); arc = _childArcPrefabs[variation].InstantiateInactive(); break; - case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): + case NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): variation = variation < 0 ? Random.Range(0, _ghostArcPrefabs.Count()) : (variation % _ghostArcPrefabs.Count()); arc = _ghostArcPrefabs[variation].InstantiateInactive(); break; - case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: + case NomaiTextArcInfo.NomaiTextArcType.Adult: default: variation = variation < 0 ? Random.Range(0, _arcPrefabs.Count()) diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index d7fd2668c..737387294 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -65,20 +66,20 @@ internal static void InitPrefabs() } } - public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) + public static void Make(GameObject go, Sector sector, ProjectionInfo info, IModBehaviour mod) { switch (info.type) { - case PropModule.ProjectionInfo.SlideShowType.AutoProjector: + case ProjectionInfo.SlideShowType.AutoProjector: MakeAutoProjector(go, sector, info, mod); break; - case PropModule.ProjectionInfo.SlideShowType.SlideReel: + case ProjectionInfo.SlideShowType.SlideReel: MakeSlideReel(go, sector, info, mod); break; - case PropModule.ProjectionInfo.SlideShowType.VisionTorchTarget: + case ProjectionInfo.SlideShowType.VisionTorchTarget: MakeMindSlidesTarget(go, sector, info, mod); break; - case PropModule.ProjectionInfo.SlideShowType.StandingVisionTorch: + case ProjectionInfo.SlideShowType.StandingVisionTorch: MakeStandingVisionTorch(go, sector, info, mod); break; default: @@ -87,7 +88,7 @@ public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo } } - private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) + private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); @@ -160,7 +161,7 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Prop return slideReelObj; } - public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) + public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); @@ -195,14 +196,14 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P } // Makes a target for a vision torch to scan - public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) + public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); if (_visionTorchDetectorPrefab == null) return null; // spawn a trigger for the vision torch - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = info.position, rotation = info.rotation, @@ -241,14 +242,14 @@ public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector return g; } - public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) + public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); if (_standingVisionTorchPrefab == null) return null; // Spawn the torch itself - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = info.position, rotation = info.rotation, @@ -344,7 +345,7 @@ private static ImageUtilities.AsyncImageLoader AddAsyncLoader(GameObject gameObj return imageLoader; } - private static void AddModules(PropModule.SlideInfo slideInfo, ref Slide slide, IModBehaviour mod) + private static void AddModules(SlideInfo slideInfo, ref Slide slide, IModBehaviour mod) { var modules = new List(); if (!String.IsNullOrEmpty(slideInfo.beatAudio)) diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 0697c5a0a..8db6f2fd6 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.Components.Quantum; using NewHorizons.External.Configs; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using OWML.Common; using System; @@ -28,17 +29,17 @@ namespace NewHorizons.Builder.Props public static class QuantumBuilder { - public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { switch(quantumGroup.type) { - case PropModule.QuantumGroupType.Sockets: MakeSocketGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; - case PropModule.QuantumGroupType.States: MakeStateGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; - // case PropModule.QuantumGroupType.Shuffle: MakeShuffleGroup(go, sector, config, mod, quantumGroup, propsInGroup); return; + case QuantumGroupType.Sockets: MakeSocketGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; + case QuantumGroupType.States: MakeStateGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; + // case QuantumGroupType.Shuffle: MakeShuffleGroup(go, sector, config, mod, quantumGroup, propsInGroup); return; } } - public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id); groupRoot.transform.parent = sector?.transform ?? go.transform; @@ -72,7 +73,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co } } - public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { var groupRoot = new GameObject("Quantum States - " + quantumGroup.id); groupRoot.transform.parent = sector?.transform ?? go.transform; @@ -119,7 +120,7 @@ public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig con groupRoot.SetActive(true); } - public static void MakeShuffleGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeShuffleGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { //var averagePosition = propsInGroup.Aggregate(Vector3.zero, (avg, prop) => avg + prop.transform.position) / propsInGroup.Count(); GameObject shuffleParent = new GameObject("Quantum Shuffle - " + quantumGroup.id); diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index 663fa27e1..587ab4647 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.Components.Achievement; using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using UnityEngine; @@ -46,7 +47,7 @@ internal static void InitPrefab() } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.RaftInfo info, OWRigidbody planetBody) + public static GameObject Make(GameObject planetGO, Sector sector, RaftInfo info, OWRigidbody planetBody) { InitPrefab(); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 75e273748..e0c3801b6 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -116,7 +117,7 @@ internal static void InitPrefabs() } } - public static void Make(GameObject go, Sector sector, PropModule.RemoteInfo info, NewHorizonsBody nhBody) + public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizonsBody nhBody) { InitPrefabs(); @@ -167,9 +168,9 @@ public static void Make(GameObject go, Sector sector, PropModule.RemoteInfo info } } - public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.WhiteboardInfo info, NewHorizonsBody nhBody) + public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteInfo.WhiteboardInfo info, NewHorizonsBody nhBody) { - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = info.position, rotation = info.rotation, @@ -194,7 +195,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer { var textInfo = info.nomaiText[i]; component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id); - var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.NomaiTextInfo + var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new NomaiTextInfo { arcInfo = textInfo.arcInfo, location = textInfo.location, @@ -203,7 +204,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer rename = textInfo.rename, rotation = Vector3.zero, seed = textInfo.seed, - type = PropModule.NomaiTextInfo.NomaiTextType.Wall, + type = NomaiTextInfo.NomaiTextType.Wall, xmlFile = textInfo.xmlFile }, nhBody).GetComponent(); wallText._showTextOnStart = false; @@ -215,9 +216,9 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer whiteboard.SetActive(true); } - public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.PlatformInfo info, IModBehaviour mod) + public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteInfo.PlatformInfo info, IModBehaviour mod) { - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = info.position, rotation = info.rotation, @@ -249,7 +250,7 @@ public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraP platform.SetActive(true); } - public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.StoneInfo info, IModBehaviour mod) + public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteInfo.StoneInfo info, IModBehaviour mod) { var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), sector?.transform ?? go.transform, info); diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index f6583c4d2..be162319e 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using OWML.Common; using System; @@ -17,7 +18,7 @@ public static void Make(GameObject go, Sector sector, PlanetConfig config, IModB MakeScatter(go, config.Props.scatter, config.Base.surfaceSize, sector, mod, config); } - private static void MakeScatter(GameObject go, PropModule.ScatterInfo[] scatterInfo, float radius, Sector sector, IModBehaviour mod, PlanetConfig config) + private static void MakeScatter(GameObject go, ScatterInfo[] scatterInfo, float radius, Sector sector, IModBehaviour mod, PlanetConfig config) { var heightMap = config.HeightMap; @@ -69,7 +70,7 @@ private static void MakeScatter(GameObject go, PropModule.ScatterInfo[] scatterI else prefab = SearchUtilities.Find(propInfo.path); // Run all the make detail stuff on it early and just copy it over and over instead - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { scale = propInfo.scale, stretch = propInfo.stretch, diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 1665c33cc..f51bfce0d 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using OWML.Common; using OWML.Utils; @@ -107,7 +108,7 @@ public static string GetCustomSignalName(SignalName signalName) return name; } - public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) + public static GameObject Make(GameObject planetGO, Sector sector, SignalInfo info, IModBehaviour mod) { var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", sector?.transform ?? planetGO.transform, info); signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 1aad9a6e8..5a6fae48c 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using System; @@ -73,7 +74,7 @@ internal static void InitPrefabs() if (_soundPrefab == null) _soundPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive().Rename("AudioRail_Prefab").DontDestroyOnLoad(); } - public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, bool hasClouds) + public static void Make(GameObject planetGO, Sector sector, TornadoInfo info, bool hasClouds) { InitPrefabs(); @@ -92,11 +93,11 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoIn return; } - if (info.type == PropModule.TornadoInfo.TornadoType.Hurricane) MakeHurricane(planetGO, sector, info, position, hasClouds); - else MakeTornado(planetGO, sector, info, position, info.type == PropModule.TornadoInfo.TornadoType.Downwards); + if (info.type == TornadoInfo.TornadoType.Hurricane) MakeHurricane(planetGO, sector, info, position, hasClouds); + else MakeTornado(planetGO, sector, info, position, info.type == TornadoInfo.TornadoType.Downwards); } - private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) + private static void MakeTornado(GameObject planetGO, Sector sector, TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", sector?.transform ?? planetGO.transform, info, true, defaultPosition: position); @@ -172,7 +173,7 @@ private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.T tornadoGO.SetActive(true); } - private static void MakeHurricane(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool hasClouds) + private static void MakeHurricane(GameObject planetGO, Sector sector, TornadoInfo info, Vector3 position, bool hasClouds) { var hurricaneGO = _hurricanePrefab.InstantiateInactive(); hurricaneGO.name = "Hurricane"; @@ -260,7 +261,7 @@ private static void ApplyTint(GameObject go, Color colour, bool hurricane, bool } } - private static void ApplyWanderer(GameObject go, GameObject planetGO, PropModule.TornadoInfo info) + private static void ApplyWanderer(GameObject go, GameObject planetGO, TornadoInfo info) { var wanderer = go.AddComponent(); wanderer.wanderRate = info.wanderRate; diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 1d4a29fcc..9dff7d380 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -13,6 +13,7 @@ using OWML.Utils; using Newtonsoft.Json; using System; +using NewHorizons.External.Props; namespace NewHorizons.Builder.Props { @@ -30,16 +31,16 @@ public static class TranslatorTextBuilder private static GameObject _preCrashRecorderPrefab; private static GameObject _trailmarkerPrefab; - private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(PropModule.NomaiTextArcInfo arc) + private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); + public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(NomaiTextArcInfo arc) { if (!arcInfoToCorrespondingSpawnedGameObject.ContainsKey(arc)) return null; return arcInfoToCorrespondingSpawnedGameObject[arc]; } - private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) + public static GameObject GetSpawnedGameObjectByNomaiTextInfo(NomaiTextInfo convo) { Logger.LogVerbose("Retrieving wall text obj for " + convo); if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; @@ -120,7 +121,7 @@ internal static void InitPrefabs() } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) + public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo info, NewHorizonsBody nhBody) { InitPrefabs(); @@ -128,7 +129,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom switch (info.type) { - case PropModule.NomaiTextInfo.NomaiTextType.Wall: + case NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; @@ -159,7 +160,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return nomaiWallTextObj; } - case PropModule.NomaiTextInfo.NomaiTextType.Scroll: + case NomaiTextInfo.NomaiTextType.Scroll: { var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, sector?.transform ?? planetGO.transform, info); @@ -211,7 +212,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return customScroll; } - case PropModule.NomaiTextInfo.NomaiTextType.Computer: + case NomaiTextInfo.NomaiTextType.Computer: { var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, sector?.transform ?? planetGO.transform, info, true, info.normal); @@ -232,9 +233,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: + case NomaiTextInfo.NomaiTextType.PreCrashComputer: { - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = info.position, parentPath = info.parentPath, @@ -282,10 +283,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Cairn: - case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: + case NomaiTextInfo.NomaiTextType.Cairn: + case NomaiTextInfo.NomaiTextType.CairnVariant: { - var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; + var cairnPrefab = info.type == NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); // Idk do we have to set it active before finding things? @@ -317,11 +318,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return cairnObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case PropModule.NomaiTextInfo.NomaiTextType.Recorder: + case NomaiTextInfo.NomaiTextType.PreCrashRecorder: + case NomaiTextInfo.NomaiTextType.Recorder: { - var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); - var detailInfo = new PropModule.DetailInfo { + var prefab = (info.type == NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var detailInfo = new DetailInfo { parentPath = info.parentPath, rotation = info.rotation, position = info.position, @@ -347,7 +348,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: + case NomaiTextInfo.NomaiTextType.Trailmarker: { var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); @@ -378,7 +379,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) { GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", sector?.transform ?? go.transform, info); @@ -406,7 +407,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModu nomaiWallText.SetTextAsset(text); // #433 fuzzy stranger text - if (info.arcInfo != null && info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger)) + if (info.arcInfo != null && info.arcInfo.Any(x => x.type == NomaiTextArcInfo.NomaiTextArcType.Stranger)) { StreamingHandler.SetUpStreaming(AstroObject.Name.RingWorld, sector); } @@ -414,7 +415,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModu return nomaiWallText; } - internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) + internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info, NewHorizonsBody nhBody) { var dict = MakeNomaiTextDict(xml); @@ -434,7 +435,7 @@ private struct ArcCacheData public bool mirrored; } - internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey) + internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey) { var dict = nomaiWallText._dictNomaiTextData; Random.InitState(info.seed == 0 ? info.xmlFile.GetHashCode() : info.seed); @@ -536,27 +537,27 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers } } - internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID, GameObject prebuiltArc = null) + internal static GameObject MakeArc(NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID, GameObject prebuiltArc = null) { GameObject arc; - var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; + var type = arcInfo != null ? arcInfo.type : NomaiTextArcInfo.NomaiTextArcType.Adult; NomaiTextArcBuilder.SpiralProfile profile; Material mat; Mesh overrideMesh = null; Color? overrideColor = null; switch (type) { - case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: + case NomaiTextArcInfo.NomaiTextArcType.Child: profile = NomaiTextArcBuilder.childSpiralProfile; mat = _childArcMaterial; break; - case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcMaterial != null: + case NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcMaterial != null: profile = NomaiTextArcBuilder.strangerSpiralProfile; mat = _ghostArcMaterial; overrideMesh = MeshUtilities.RectangleMeshFromCorners(new Vector3[]{ new Vector3(-0.9f, 0.0f, 0.0f), new Vector3(0.9f, 0.0f, 0.0f), new Vector3(-0.9f, 2.0f, 0.0f), new Vector3(0.9f, 2.0f, 0.0f) }); overrideColor = new Color(0.0158f, 1.0f, 0.5601f, 1f); break; - case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: + case NomaiTextArcInfo.NomaiTextArcType.Adult: default: profile = NomaiTextArcBuilder.adultSpiralProfile; mat = _adultArcMaterial; diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index ced0ad9c2..770ef4882 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -41,7 +42,7 @@ internal static void InitPrefab() } } - public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info) + public static void Make(GameObject planetGO, Sector sector, VolcanoInfo info) { InitPrefab(); @@ -72,7 +73,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoIn }); } - private static void FixMeteor(MeteorController meteor, PropModule.VolcanoInfo info) + private static void FixMeteor(MeteorController meteor, VolcanoInfo info) { meteor.transform.localScale = Vector3.one * info.scale; diff --git a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs index 7f6d591f2..29181df07 100644 --- a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs +++ b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using OWML.Common; using System.Collections.Generic; using UnityEngine; @@ -10,7 +11,7 @@ namespace NewHorizons.Builder.ShipLog public static class EntryLocationBuilder { private static readonly List _locationsToInitialize = new List(); - public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod) + public static void Make(GameObject go, Sector sector, EntryLocationInfo info, IModBehaviour mod) { GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", sector?.transform ?? go.transform, info); diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index 0eaf91aab..5731a6ac1 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -4,11 +4,11 @@ using System; using System.Collections.Generic; using System.Linq; -using NewHorizons.External.Modules.VariableSize; using UnityEngine; using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components.ShipLog; +using NewHorizons.External.Props; namespace NewHorizons.Builder.ShipLog { @@ -552,9 +552,9 @@ private static Color GetDominantPlanetColor(NewHorizonsBody body) switch (body.Config?.Props?.singularities?.FirstOrDefault()?.type) { - case SingularityModule.SingularityType.BlackHole: + case SingularityInfo.SingularityType.BlackHole: return Color.black; - case SingularityModule.SingularityType.WhiteHole: + case SingularityInfo.SingularityType.WhiteHole: return Color.white; } } diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 349c3649a..66ab38370 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components.Achievement; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using OWML.Common; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -8,18 +9,18 @@ namespace NewHorizons.Builder.ShipLog { public static class RevealBuilder { - public static void Make(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) + public static void Make(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) { var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", sector?.transform ?? go.transform, info); switch (info.revealOn) { - case VolumesModule.RevealVolumeInfo.RevealVolumeType.Enter: + case RevealVolumeInfo.RevealVolumeType.Enter: MakeTrigger(newRevealGO, sector, info, mod); break; - case VolumesModule.RevealVolumeInfo.RevealVolumeType.Observe: + case RevealVolumeInfo.RevealVolumeType.Observe: MakeObservable(newRevealGO, sector, info, mod); break; - case VolumesModule.RevealVolumeInfo.RevealVolumeType.Snapshot: + case RevealVolumeInfo.RevealVolumeType.Snapshot: MakeSnapshot(newRevealGO, sector, info, mod); break; default: @@ -29,7 +30,7 @@ public static void Make(GameObject go, Sector sector, VolumesModule.RevealVolume newRevealGO.SetActive(true); } - private static SphereShape MakeShape(GameObject go, VolumesModule.RevealVolumeInfo info, Shape.CollisionMode collisionMode) + private static SphereShape MakeShape(GameObject go, RevealVolumeInfo info, Shape.CollisionMode collisionMode) { SphereShape newShape = go.AddComponent(); newShape.radius = info.radius; @@ -37,7 +38,7 @@ private static SphereShape MakeShape(GameObject go, VolumesModule.RevealVolumeIn return newShape; } - private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) + private static void MakeTrigger(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) { var shape = MakeShape(go, info, Shape.CollisionMode.Volume); @@ -50,15 +51,15 @@ private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.Reve factRevealVolume._factIDs = info.reveals; switch (info.revealFor) { - case VolumesModule.RevealVolumeInfo.EnterType.Player: + case RevealVolumeInfo.EnterType.Player: factRevealVolume._player = true; factRevealVolume._probe = false; break; - case VolumesModule.RevealVolumeInfo.EnterType.Probe: + case RevealVolumeInfo.EnterType.Probe: factRevealVolume._player = false; factRevealVolume._probe = true; break; - case VolumesModule.RevealVolumeInfo.EnterType.Both: + case RevealVolumeInfo.EnterType.Both: default: // if you want both player and probe to able to trigger the thing you have to set both player and probe to false. setting both to true will make nothing trigger it factRevealVolume._player = false; @@ -73,15 +74,15 @@ private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.Reve achievementVolume.achievementID = info.achievementID; switch (info.revealFor) { - case VolumesModule.RevealVolumeInfo.EnterType.Player: + case RevealVolumeInfo.EnterType.Player: achievementVolume.player = true; achievementVolume.probe = false; break; - case VolumesModule.RevealVolumeInfo.EnterType.Probe: + case RevealVolumeInfo.EnterType.Probe: achievementVolume.player = false; achievementVolume.probe = true; break; - case VolumesModule.RevealVolumeInfo.EnterType.Both: + case RevealVolumeInfo.EnterType.Both: default: achievementVolume.player = true; achievementVolume.probe = true; @@ -90,7 +91,7 @@ private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.Reve } } - private static void MakeObservable(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) + private static void MakeObservable(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) { go.layer = LayerMask.NameToLayer("Interactible"); @@ -121,7 +122,7 @@ private static void MakeObservable(GameObject go, Sector sector, VolumesModule.R } } - private static void MakeSnapshot(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) + private static void MakeSnapshot(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) { var shape = MakeShape(go, info, Shape.CollisionMode.Manual); diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 34269fe67..8303d3fa4 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using NewHorizons.Utility; using OWML.Common; using OWML.Utils; @@ -15,7 +16,7 @@ namespace NewHorizons.Builder.Volumes { public static class AudioVolumeBuilder { - public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule.AudioVolumeInfo info, IModBehaviour mod) + public static AudioVolume Make(GameObject planetGO, Sector sector, AudioVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("AudioVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs b/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs index 2d97bbd36..c66742fcd 100644 --- a/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs @@ -1,12 +1,13 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { internal static class ChangeStarSystemVolumeBuilder { - public static WarpVolume Make(GameObject planetGO, Sector sector, VolumesModule.ChangeStarSystemVolumeInfo info) + public static WarpVolume Make(GameObject planetGO, Sector sector, ChangeStarSystemVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs index c34745c1b..1fa4f985a 100644 --- a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs @@ -1,12 +1,13 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { internal static class CreditsVolumeBuilder { - public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, VolumesModule.LoadCreditsVolumeInfo info) + public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, LoadCreditsVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs b/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs index b657cce0f..9305af6f7 100644 --- a/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using OWML.Utils; using UnityEngine; @@ -6,7 +7,7 @@ namespace NewHorizons.Builder.Volumes { public static class DestructionVolumeBuilder { - public static DestructionVolume Make(GameObject planetGO, Sector sector, VolumesModule.DestructionVolumeInfo info) + public static DestructionVolume Make(GameObject planetGO, Sector sector, DestructionVolumeInfo info) { var volume = VanishVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs b/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs index 623a561ad..83ea1fa97 100644 --- a/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using OWML.Utils; using UnityEngine; @@ -7,7 +8,7 @@ namespace NewHorizons.Builder.Volumes { public static class FluidVolumeBuilder { - public static FluidVolume Make(GameObject planetGO, Sector sector, VolumesModule.FluidVolumeInfo info) + public static FluidVolume Make(GameObject planetGO, Sector sector, FluidVolumeInfo info) { var type = EnumUtils.Parse(info.type.ToString(), FluidVolume.Type.NONE); FluidVolume volume = null; diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index bb82013ce..2485613af 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using OWML.Common; using OWML.Utils; using System; @@ -12,7 +13,7 @@ namespace NewHorizons.Builder.Volumes { public static class HazardVolumeBuilder { - public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod) + public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, HazardVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("HazardVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); @@ -24,15 +25,15 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owTriggerVolume._shape = shape; HazardVolume hazardVolume = null; - if (info.type == VolumesModule.HazardVolumeInfo.HazardType.RIVERHEAT) + if (info.type == HazardVolumeInfo.HazardType.RIVERHEAT) { hazardVolume = go.AddComponent(); } - else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.HEAT) + else if (info.type == HazardVolumeInfo.HazardType.HEAT) { hazardVolume = go.AddComponent(); } - else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.DARKMATTER) + else if (info.type == HazardVolumeInfo.HazardType.DARKMATTER) { hazardVolume = go.AddComponent(); var visorFrostEffectVolume = go.AddComponent(); @@ -60,7 +61,7 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody submerge._fluidDetector = detector; } } - else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.ELECTRICITY) + else if (info.type == HazardVolumeInfo.HazardType.ELECTRICITY) { var electricityVolume = go.AddComponent(); electricityVolume._shockAudioPool = new OWAudioSource[0]; diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index 574aa6daa..7cf56bccc 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using NewHorizons.Utility; using OWML.Common; using System; @@ -15,7 +16,7 @@ namespace NewHorizons.Builder.Volumes { public static class NotificationVolumeBuilder { - public static NHNotificationVolume Make(GameObject planetGO, Sector sector, VolumesModule.NotificationVolumeInfo info, IModBehaviour mod) + public static NHNotificationVolume Make(GameObject planetGO, Sector sector, NotificationVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("NotificationVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs b/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs index 0722fbaf5..bcf1f4064 100644 --- a/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs @@ -1,11 +1,12 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class OxygenVolumeBuilder { - public static OxygenVolume Make(GameObject planetGO, Sector sector, VolumesModule.OxygenVolumeInfo info) + public static OxygenVolume Make(GameObject planetGO, Sector sector, OxygenVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs b/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs index 994b1c91f..b38c966eb 100644 --- a/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs @@ -1,11 +1,12 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class PriorityVolumeBuilder { - public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.PriorityVolumeInfo info) where TVolume : PriorityVolume + public static TVolume Make(GameObject planetGO, Sector sector, PriorityVolumeInfo info) where TVolume : PriorityVolume { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs index 9ef330de7..db1c8e3aa 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class PlayerImpactRulesetBuilder { - public static PlayerImpactRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.PlayerImpactRulesetInfo info) + public static PlayerImpactRuleset Make(GameObject planetGO, Sector sector, RulesetModule.PlayerImpactRulesetInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs index b8293d944..1b17d62fa 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class ProbeRulesetBuilder { - public static ProbeRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.ProbeRulesetInfo info) + public static ProbeRuleset Make(GameObject planetGO, Sector sector, RulesetModule.ProbeRulesetInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs index 8541f516b..9543fad9a 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class ThrustRulesetBuilder { - public static ThrustRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.ThrustRulesetInfo info) + public static ThrustRuleset Make(GameObject planetGO, Sector sector, RulesetModule.ThrustRulesetInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs b/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs index 3e264604e..d9ae1893a 100644 --- a/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs @@ -1,11 +1,12 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class SpeedTrapVolumeBuilder { - public static SpeedTrapVolume Make(GameObject planetGO, Sector sector, VolumesModule.SpeedTrapVolumeInfo info) + public static SpeedTrapVolume Make(GameObject planetGO, Sector sector, SpeedTrapVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index 23628b122..8cda0d15e 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -8,7 +9,7 @@ namespace NewHorizons.Builder.Volumes { public static class VanishVolumeBuilder { - public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VanishVolumeInfo info) where TVolume : VanishVolume + public static TVolume Make(GameObject planetGO, Sector sector, VanishVolumeInfo info) where TVolume : VanishVolume { var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs index 139e09f90..c38e0a807 100644 --- a/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class VisorFrostEffectVolumeBuilder { - public static VisorFrostEffectVolume Make(GameObject planetGO, Sector sector, VolumesModule.VisorEffectModule.FrostEffectVolumeInfo info) + public static VisorFrostEffectVolume Make(GameObject planetGO, Sector sector, VisorEffectModule.FrostEffectVolumeInfo info) { var volume = PriorityVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs index bf268c8ec..cf7d66e91 100644 --- a/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class VisorRainEffectVolumeBuilder { - public static VisorRainEffectVolume Make(GameObject planetGO, Sector sector, VolumesModule.VisorEffectModule.RainEffectVolumeInfo info) + public static VisorRainEffectVolume Make(GameObject planetGO, Sector sector, VisorEffectModule.RainEffectVolumeInfo info) { var volume = PriorityVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index 8d29c9a95..ca273c99c 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -8,7 +9,7 @@ namespace NewHorizons.Builder.Volumes { public static class VolumeBuilder { - public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. + public static TVolume Make(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. { var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs b/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs index 931d16086..da50d8c97 100644 --- a/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs @@ -1,11 +1,12 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class ZeroGVolumeBuilder { - public static ZeroGVolume Make(GameObject planetGO, Sector sector, VolumesModule.PriorityVolumeInfo info) + public static ZeroGVolume Make(GameObject planetGO, Sector sector, PriorityVolumeInfo info) { var volume = PriorityVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index 119908406..f852917fb 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -1,11 +1,12 @@ using NewHorizons.External.Modules; +using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Components.Volumes { internal class LoadCreditsVolume : BaseVolume { - public VolumesModule.LoadCreditsVolumeInfo.CreditsType creditsType = VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast; + public LoadCreditsVolumeInfo.CreditsType creditsType = LoadCreditsVolumeInfo.CreditsType.Fast; public override void OnTriggerVolumeEntry(GameObject hitObj) { @@ -13,13 +14,13 @@ public override void OnTriggerVolumeEntry(GameObject hitObj) { switch(creditsType) { - case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: + case LoadCreditsVolumeInfo.CreditsType.Fast: LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); break; - case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final: + case LoadCreditsVolumeInfo.CreditsType.Final: LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack); break; - case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo: + case LoadCreditsVolumeInfo.CreditsType.Kazoo: TimelineObliterationController.s_hasRealityEnded = true; LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); break; diff --git a/NewHorizons/Components/Volumes/NotificationVolume.cs b/NewHorizons/Components/Volumes/NotificationVolume.cs index 70543449f..9aa4f3f8f 100644 --- a/NewHorizons/Components/Volumes/NotificationVolume.cs +++ b/NewHorizons/Components/Volumes/NotificationVolume.cs @@ -1,3 +1,4 @@ +using NewHorizons.External.Volumes; using NewHorizons.Handlers; using OWML.Utils; using System; @@ -16,7 +17,7 @@ public class NotificationVolume : BaseVolume public void SetPinned(bool pin) => _pin = pin; - public void SetTarget(External.Modules.VolumesModule.NotificationVolumeInfo.NotificationTarget target) => SetTarget(EnumUtils.Parse(target.ToString(), NotificationTarget.All)); + public void SetTarget(NotificationVolumeInfo.NotificationTarget target) => SetTarget(EnumUtils.Parse(target.ToString(), NotificationTarget.All)); public void SetTarget(NotificationTarget target) => _target = target; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 3330a4ada..6de974db7 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -1,6 +1,8 @@ using Epic.OnlineServices.Presence; using NewHorizons.External.Modules; using NewHorizons.External.Modules.VariableSize; +using NewHorizons.External.Props; +using NewHorizons.External.Volumes; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -64,7 +66,7 @@ public class PlanetConfig public string[] childrenToDestroy; [Obsolete("Singularity is deprecated, please use Props->singularities")] - public SingularityModule Singularity; + public SingularityInfo Singularity; [Obsolete("Signal is deprecated, please use Props->signals")] public SignalModule Signal; @@ -213,21 +215,21 @@ public void Validate() // if detail.quantumGroupID != null, there exists a quantum group with that id if (Props?.quantumGroups != null && Props?.details != null) { - Dictionary existingGroups = new Dictionary(); + Dictionary existingGroups = new Dictionary(); foreach (var quantumGroup in Props.quantumGroups) { - if (existingGroups.ContainsKey(quantumGroup.id)) { Logger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } + if (existingGroups.ContainsKey(quantumGroup.id)) { Logger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = QuantumGroupType.FailedValidation; } existingGroups[quantumGroup.id] = quantumGroup; - if (quantumGroup.type == PropModule.QuantumGroupType.Sockets) + if (quantumGroup.type == QuantumGroupType.Sockets) { - if (quantumGroup.sockets?.Length == 0) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } + if (quantumGroup.sockets?.Length == 0) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = QuantumGroupType.FailedValidation; } else { foreach (var socket in quantumGroup.sockets) { if (socket.rotation == null) socket.rotation = UnityEngine.Vector3.zero; - if (socket.position == null) { Logger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } + if (socket.position == null) { Logger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = QuantumGroupType.FailedValidation; } } } } @@ -243,10 +245,10 @@ public void Validate() foreach (var quantumGroup in Props.quantumGroups) { - if (quantumGroup.type == PropModule.QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length) + if (quantumGroup.type == QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" and has more props than sockets."); - quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; + quantumGroup.type = QuantumGroupType.FailedValidation; } } } @@ -274,9 +276,9 @@ public void Migrate() }; if (Base.blackHoleSize != 0) - Singularity = new SingularityModule + Singularity = new SingularityInfo { - type = SingularityModule.SingularityType.BlackHole, + type = SingularityInfo.SingularityType.BlackHole, size = Base.blackHoleSize }; @@ -329,19 +331,19 @@ public void Migrate() if (Props?.tornados != null) foreach (var tornado in Props.tornados) if (tornado.downwards) - tornado.type = PropModule.TornadoInfo.TornadoType.Downwards; + tornado.type = TornadoInfo.TornadoType.Downwards; if (Props?.audioVolumes != null) { if (Volumes == null) Volumes = new VolumesModule(); - if (Volumes.audioVolumes == null) Volumes.audioVolumes = new VolumesModule.AudioVolumeInfo[0]; + if (Volumes.audioVolumes == null) Volumes.audioVolumes = new AudioVolumeInfo[0]; Volumes.audioVolumes = Volumes.audioVolumes.Concat(Props.audioVolumes).ToArray(); } if (Props?.reveal != null) { if (Volumes == null) Volumes = new VolumesModule(); - if (Volumes.revealVolumes == null) Volumes.revealVolumes = new VolumesModule.RevealVolumeInfo[0]; + if (Volumes.revealVolumes == null) Volumes.revealVolumes = new RevealVolumeInfo[0]; Volumes.revealVolumes = Volumes.revealVolumes.Concat(Props.reveal).ToArray(); } @@ -375,7 +377,7 @@ public void Migrate() if (Singularity != null) { if (Props == null) Props = new PropModule(); - if (Props.singularities == null) Props.singularities = new SingularityModule[0]; + if (Props.singularities == null) Props.singularities = new SingularityInfo[0]; Props.singularities = Props.singularities.Append(Singularity).ToArray(); } @@ -389,10 +391,10 @@ public void Migrate() singularity.horizonRadius = singularity.size * 0.4f; switch (singularity.type) { - case SingularityModule.SingularityType.BlackHole: + case SingularityInfo.SingularityType.BlackHole: singularity.distortRadius = singularity.size * 0.95f; break; - case SingularityModule.SingularityType.WhiteHole: + case SingularityInfo.SingularityType.WhiteHole: singularity.distortRadius = singularity.size * 2.8f; break; } @@ -404,7 +406,7 @@ public void Migrate() if (Signal?.signals != null) { if (Props == null) Props = new PropModule(); - if (Props.signals == null) Props.signals = new SignalModule.SignalInfo[0]; + if (Props.signals == null) Props.signals = new SignalInfo[0]; Props.signals = Props.signals.Concat(Signal.signals).ToArray(); } @@ -450,9 +452,9 @@ public void Migrate() if (Base.zeroGravityRadius != 0f) { Volumes ??= new VolumesModule(); - Volumes.zeroGravityVolumes ??= new VolumesModule.PriorityVolumeInfo[0]; + Volumes.zeroGravityVolumes ??= new PriorityVolumeInfo[0]; - Volumes.zeroGravityVolumes = Volumes.zeroGravityVolumes.Append(new VolumesModule.PriorityVolumeInfo() + Volumes.zeroGravityVolumes = Volumes.zeroGravityVolumes.Append(new PriorityVolumeInfo() { priority = 1, rename = "ZeroGVolume", @@ -493,7 +495,7 @@ public void Migrate() { if (dialogue.remoteTrigger == null && (dialogue.remoteTriggerPosition != null || dialogue.remoteTriggerRadius != 0)) { - dialogue.remoteTrigger = new PropModule.DialogueInfo.RemoteTriggerInfo + dialogue.remoteTrigger = new DialogueInfo.RemoteTriggerInfo { position = dialogue.remoteTriggerPosition, radius = dialogue.remoteTriggerRadius, diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 587944039..b5a4dff82 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Utility; using Newtonsoft.Json; using static NewHorizons.External.Modules.ShipLogModule; @@ -206,7 +207,7 @@ public class VesselModule [Obsolete("warpExitRotation is deprecated, use vesselSpawn.rotation instead")] public MVector3 warpExitRotation; [JsonObject] - public class VesselInfo : PropModule.GeneralSolarSystemPropInfo + public class VesselInfo : GeneralSolarSystemPropInfo { /// /// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body. @@ -215,7 +216,7 @@ public class VesselInfo : PropModule.GeneralSolarSystemPropInfo } [JsonObject] - public class WarpExitInfo : PropModule.GeneralSolarSystemPropInfo + public class WarpExitInfo : GeneralSolarSystemPropInfo { /// /// If set, keeps the warp exit attached to the vessel. Overrides `parentPath`. diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 7fec298be..64207cbcd 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using NewHorizons.External.Props; namespace NewHorizons.External.Modules { @@ -76,66 +77,5 @@ public class BrambleDimensionInfo public int[] allowedEntrances; } - - [JsonObject] - public class BrambleNodeInfo : PropModule.GeneralPropInfo - { - /// - /// The physical scale of the node, as a multiplier of the original size. - /// Nodes are 150m across, seeds are 10m across. - /// - [DefaultValue(1f)] public float scale = 1f; - - /// - /// The name of the planet that hosts the dimension this node links to - /// - public string linksTo; - - /// - /// The name of this node. Only required if this node should serve as an exit. - /// - public string name; - - /// - /// Set this to true to make this node a seed instead of a node the player can enter - /// - [DefaultValue(false)] public bool isSeed = false; - - /// - /// The color of the fog inside the node. - /// Leave blank for the default yellowish white color: (255, 245, 217, 255) - /// - public MColor fogTint; - - /// - /// The color of the light from the node. Alpha controls brightness. - /// Leave blank for the default white color. - /// - public MColor lightTint; - - /// - /// Should this node have a point of light from afar? - /// By default, nodes will have a foglight, while seeds won't, and neither will if not in a dimension. - /// - public bool? hasFogLight; - - /// - /// An array of integers from 0-5. By default, all exits are allowed. To force this node to warp players out from only one hole set this value to [3], [5], or similar. Values of 0-5 only. - /// - public int[] possibleExits; - - /// - /// If your game hard crashes upon entering bramble, it's most likely because you have indirectly recursive dimensions, i.e. one leads to another that leads back to the first one. - /// Set this to true for one of the nodes in the recursion to fix this, at the cost of it no longer showing markers for the scout, ship, etc. - /// - [DefaultValue(false)] public bool preventRecursionCrash = false; - - #region Obsolete - - [Obsolete("farFogTint is deprecated, please use fogTint instead")] - public MColor farFogTint; - - #endregion Obsolete - } } } diff --git a/NewHorizons/External/Modules/ProbeModule.cs b/NewHorizons/External/Modules/ProbeModule.cs new file mode 100644 index 000000000..79384968a --- /dev/null +++ b/NewHorizons/External/Modules/ProbeModule.cs @@ -0,0 +1,20 @@ +using NewHorizons.External.Volumes; +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules +{ + [JsonObject] + public class ProbeModule + { + /// + /// Add probe destruction volumes to this planet. These will delete your probe. + /// + public VolumeInfo[] destructionVolumes; + + /// + /// Add probe safety volumes to this planet. These will stop the probe destruction volumes from working. + /// + public VolumeInfo[] safetyVolumes; + } + } + diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 9c21b454a..301c88f7a 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -1,12 +1,7 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; using Newtonsoft.Json; -using Newtonsoft.Json.Converters; using System; -using NewHorizons.External.Modules.VariableSize; +using NewHorizons.External.Props; +using NewHorizons.External.Volumes; namespace NewHorizons.External.Modules { @@ -82,831 +77,20 @@ public class PropModule /// /// Add black/white-holes to this planet /// - public SingularityModule[] singularities; + public SingularityInfo[] singularities; /// /// Add signalscope signals to this planet /// - public SignalModule.SignalInfo[] signals; + public SignalInfo[] signals; /// /// Add projection pools/platforms, whiteboards, and stones to this planet /// public RemoteInfo[] remotes; - [Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public VolumesModule.RevealVolumeInfo[] reveal; - - [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes; - - [JsonObject] - public abstract class GeneralPointPropInfo - { - /// - /// Position of the object - /// - public MVector3 position; - - /// - /// 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; - } - - [JsonObject] - public abstract class GeneralPropInfo : GeneralPointPropInfo - { - /// - /// Rotation of the object - /// - public MVector3 rotation; - } - - [JsonObject] - public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo - { - /// - /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. - /// - public string parentBody; - } - - [JsonObject] - public class ScatterInfo - { - /// - /// Relative filepath to an asset-bundle - /// - public string assetBundle; - - /// - /// Number of props to scatter - /// - public int count; - - /// - /// Offset this prop once it is placed - /// - public MVector3 offset; - - /// - /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle - /// - public string path; - - /// - /// Rotate this prop once it is placed - /// - public MVector3 rotation; - - /// - /// Scale this prop once it is placed - /// - [DefaultValue(1f)] public float scale = 1f; - - /// - /// Scale each axis of the prop. Overrides `scale`. - /// - public MVector3 stretch; - - /// - /// The number used as entropy for scattering the props - /// - public int seed; - - /// - /// The lowest height that these object will be placed at (only relevant if there's a heightmap) - /// - public float? minHeight; - - /// - /// The highest height that these objects will be placed at (only relevant if there's a heightmap) - /// - public float? maxHeight; - - /// - /// Should we try to prevent overlap between the scattered details? True by default. If it's affecting load times turn it off. - /// - [DefaultValue(true)] public bool preventOverlap = true; - - /// - /// Should this detail stay loaded even if you're outside the sector (good for very large props) - /// - public bool keepLoaded; - } - - [JsonObject] - public class DetailInfo : GeneralPropInfo - { - - /// - /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? - /// - public bool alignToNormal; - - /// - /// Relative filepath to an asset-bundle to load the prefab defined in `path` from - /// - public string assetBundle; - - /// - /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle - /// - public string path; - - /// - /// A list of children to remove from this detail - /// - public string[] removeChildren; - - /// - /// Do we reset all the components on this object? Useful for certain props that have dialogue components attached to - /// them. - /// - public bool removeComponents; - - /// - /// Scale the prop - /// - [DefaultValue(1f)] public float scale = 1f; - - /// - /// Scale each axis of the prop. Overrides `scale`. - /// - public MVector3 stretch; - - /// - /// If this value is not null, this prop will be quantum. Assign this field to the id of the quantum group it should be a part of. The group it is assigned to determines what kind of quantum object it is - /// - public string quantumGroupID; - - /// - /// Should this detail stay loaded even if you're outside the sector (good for very large props) - /// - public bool keepLoaded; - - /// - /// Should this object dynamically move around? - /// This tries to make all mesh colliders convex, as well as adding a sphere collider in case the detail has no others. - /// - public bool hasPhysics; - - /// - /// The mass of the physics object. - /// Most pushable props use the default value, which matches the player mass. - /// - [DefaultValue(0.001f)] public float physicsMass = 0.001f; - - /// - /// The radius that the added sphere collider will use for physics collision. - /// If there's already good colliders on the detail, you can make this 0. - /// - [DefaultValue(1f)] public float physicsRadius = 1f; - } - - [JsonObject] - public class RaftInfo : GeneralPointPropInfo - { - /// - /// Acceleration of the raft. Default acceleration is 5. - /// - [DefaultValue(5f)] public float acceleration = 5f; - } - - [JsonObject] - public class GeyserInfo : GeneralPointPropInfo - { - /// - /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. - /// - [DefaultValue(-97.5f)] public float offset = -97.5f; - - /// - /// Force of the geyser on objects - /// - [DefaultValue(55f)] public float force = 55f; - - /// - /// Time in seconds eruptions last for - /// - [DefaultValue(10f)] public float activeDuration = 10f; - - /// - /// Time in seconds between eruptions - /// - [DefaultValue(19f)] public float inactiveDuration = 19f; - - /// - /// Color of the geyser. Alpha sets the particle density. - /// - public MColor tint; - - /// - /// Disable the individual particle systems of the geyser - /// - public bool disableBubbles, disableShaft, disableSpout; - - /// - /// Loudness of the geyser - /// - [DefaultValue(0.7f)] public float volume = 0.7f; - } - - [JsonObject] - public class TornadoInfo : GeneralPointPropInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum TornadoType - { - [EnumMember(Value = @"upwards")] Upwards = 0, - - [EnumMember(Value = @"downwards")] Downwards = 1, - - [EnumMember(Value = @"hurricane")] Hurricane = 2 - } - - [Obsolete("Downwards is deprecated. Use Type instead.")] public bool downwards; - - /// - /// Alternative to setting the position. Will choose a random place at this elevation. - /// - public float elevation; - - /// - /// The height of this tornado. - /// - [DefaultValue(30f)] public float height = 30f; - - /// - /// The colour of the tornado. - /// - public MColor tint; - - /// - /// What type of cyclone should this be? Upwards and downwards are both tornados and will push in that direction. - /// - [DefaultValue("upwards")] public TornadoType type = TornadoType.Upwards; - - /// - /// Angular distance from the starting position that it will wander, in terms of the angle around the x-axis. - /// - [DefaultValue(45f)] public float wanderDegreesX = 45f; - - /// - /// Angular distance from the starting position that it will wander, in terms of the angle around the z-axis. - /// - [DefaultValue(45f)] public float wanderDegreesZ = 45f; - - /// - /// The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around - /// 0.1. - /// - public float wanderRate; - - /// - /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. - /// - public float audioDistance; - - /// - /// Fluid type for sounds/effects when colliding with this tornado. - /// - [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud; - } - - [JsonObject] - public class VolcanoInfo : GeneralPointPropInfo - { - /// - /// The colour of the meteor's lava. - /// - public MColor lavaTint; - - /// - /// Maximum time between meteor launches. - /// - [DefaultValue(20f)] - public float maxInterval = 20f; - - /// - /// Maximum random speed at which meteors are launched. - /// - [DefaultValue(150f)] - public float maxLaunchSpeed = 150f; - - /// - /// Minimum time between meteor launches. - /// - [DefaultValue(5f)] - public float minInterval = 5f; - - /// - /// Minimum random speed at which meteors are launched. - /// - [DefaultValue(50f)] - public float minLaunchSpeed = 50f; - - /// - /// Scale of the meteors. - /// - public float scale = 1; - - /// - /// The colour of the meteor's stone. - /// - public MColor stoneTint; - } - - [JsonObject] - public class DialogueInfo : GeneralPointPropInfo - { - /// - /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue - /// triggers that you want to have happen only once. - /// - public string blockAfterPersistentCondition; - - /// - /// If a pathToAnimController is supplied, if you are within this distance the character will look at you. If it is set - /// to 0, they will only look at you when spoken to. - /// - public float lookAtRadius; - - /// - /// If this dialogue is meant for a character, this is the relative path from the planet to that character's - /// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController. - /// - /// If none of those components are present it will add a FacePlayerWhenTalking component. - /// - public string pathToAnimController; - - /// - /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a - /// remoteTrigger, you can set this to 0 to make the dialogue only trigger remotely. - /// - public float radius = 1f; - - /// - /// Distance from radius the prompt appears - /// - [DefaultValue(2f)] public float range = 2f; - - /// - /// Allows you to trigger dialogue from a distance when you walk into an area. - /// - public RemoteTriggerInfo remoteTrigger; - - [Obsolete("remoteTriggerPosition is deprecated. Use remoteTrigger.position instead")] public MVector3 remoteTriggerPosition; - [Obsolete("remoteTriggerRadius is deprecated. Use remoteTrigger.radius instead")] public float remoteTriggerRadius; - [Obsolete("remoteTriggerPrereqCondition is deprecated. Use remoteTrigger.prereqCondition instead")] public string remoteTriggerPrereqCondition; - - /// - /// Relative path to the xml file defining the dialogue. - /// - public string xmlFile; - - /// - /// What type of flashlight toggle to do when dialogue is interacted with - /// - [DefaultValue("none")] public FlashlightToggle flashlightToggle = FlashlightToggle.None; - - [JsonConverter(typeof(StringEnumConverter))] - public enum FlashlightToggle - { - [EnumMember(Value = @"none")] None = -1, - [EnumMember(Value = @"turnOff")] TurnOff = 0, - [EnumMember(Value = @"turnOffThenOn")] TurnOffThenOn = 1, - } - - [JsonObject] - public class RemoteTriggerInfo : GeneralPointPropInfo - { - /// - /// The radius of the remote trigger volume. - /// - public float radius; - /// - /// This condition must be met for the remote trigger volume to trigger. - /// - public string prereqCondition; - } - } - - [JsonObject] - public class EntryLocationInfo : GeneralPointPropInfo - { - /// - /// Whether this location is cloaked - /// - public bool cloaked; - - /// - /// ID of the entry this location relates to - /// - public string id; - } - - [JsonObject] - public class NomaiTextInfo : GeneralPointPropInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextType - { - [EnumMember(Value = @"wall")] Wall = 0, - - [EnumMember(Value = @"scroll")] Scroll = 1, - - [EnumMember(Value = @"computer")] Computer = 2, - - [EnumMember(Value = @"cairn")] Cairn = 3, - - [EnumMember(Value = @"recorder")] Recorder = 4, - - [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, - - [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, - - [EnumMember(Value = @"trailmarker")] Trailmarker = 7, - - [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextLocation - { - [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, - - [EnumMember(Value = @"a")] A = 1, - - [EnumMember(Value = @"b")] B = 2 - } - - /// - /// Additional information about each arc in the text - /// - public NomaiTextArcInfo[] arcInfo; - - /// - /// The normal vector for this object. Used for writing on walls and positioning computers. - /// - public MVector3 normal; - - /// - /// The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient - /// themselves to the surface of the planet automatically. - /// - public MVector3 rotation; - - /// - /// The random seed used to pick what the text arcs will look like. - /// - public int seed; // For randomizing arcs - - /// - /// The type of object this is. - /// - [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; - - /// - /// The location of this object. - /// - [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; - - /// - /// The relative path to the xml file for this object. - /// - public string xmlFile; - } - - [JsonObject] - public class NomaiTextArcInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextArcType - { - [EnumMember(Value = @"adult")] Adult = 0, - - [EnumMember(Value = @"child")] Child = 1, - - [EnumMember(Value = @"stranger")] Stranger = 2 - } - - /// - /// Whether to skip modifying this spiral's placement, and instead keep the automatically determined placement. - /// - public bool keepAutoPlacement; - - /// - /// Whether to flip the spiral from left-curling to right-curling or vice versa. - /// - public bool mirror; - - /// - /// The local position of this object on the wall. - /// - public MVector2 position; - - /// - /// The type of text to display. - /// - [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; - - /// - /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. - /// - [DefaultValue(-1)] public int variation = -1; - - /// - /// The z euler angle for this arc. - /// - [Range(0f, 360f)] public float zRotation; - } - - [JsonObject] - public class ProjectionInfo : GeneralPropInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum SlideShowType - { - [EnumMember(Value = @"slideReel")] SlideReel = 0, - - [EnumMember(Value = @"autoProjector")] AutoProjector = 1, - - [EnumMember(Value = @"visionTorchTarget")] VisionTorchTarget = 2, - - [EnumMember(Value = @"standingVisionTorch")] StandingVisionTorch = 3, - - } - - /// - /// The ship log facts revealed after finishing this slide reel. - /// - public string[] reveals; - - /// - /// The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows). - /// You should probably include facts from `reveals` here. - /// If you only specify a rumor fact, then it would only play in its ship log entry if this has revealed only - /// rumor facts because an entry with revealed explore facts doesn't display rumor facts. - /// - public string[] playWithShipLogFacts; - - /// - /// The list of slides for this object. - /// - public SlideInfo[] slides; - - /// - /// The type of object this is. - /// - [DefaultValue("slideReel")] public SlideShowType type = SlideShowType.SlideReel; - } - - [JsonObject] - public class SlideInfo - { - /// - /// Ambient light colour when viewing this slide. - /// - public MColor ambientLightColor; - - - // SlideAmbientLightModule - - /// - /// Ambient light intensity when viewing this slide. - /// - public float ambientLightIntensity; - - /// - /// Ambient light range when viewing this slide. - /// - public float ambientLightRange; - - // SlideBackdropAudioModule - - /// - /// The name of the AudioClip that will continuously play while watching these slides - /// - public string backdropAudio; - - /// - /// The time to fade into the backdrop audio - /// - public float backdropFadeTime; - - // SlideBeatAudioModule - - /// - /// The name of the AudioClip for a one-shot sound when opening the slide. - /// - public string beatAudio; - - /// - /// The time delay until the one-shot audio - /// - public float beatDelay; - - - // SlideBlackFrameModule - - /// - /// Before viewing this slide, there will be a black frame for this many seconds. - /// - public float blackFrameDuration; - - /// - /// The path to the image file for this slide. - /// - public string imagePath; - - - // SlidePlayTimeModule - - /// - /// Play-time duration for auto-projector slides. - /// - public float playTimeDuration; - - - // SlideShipLogEntryModule - - /// - /// Ship log fact revealed when viewing this slide - /// - public string reveal; - - /// - /// Spotlight intensity modifier when viewing this slide. - /// - public float spotIntensityMod; - } - - - - - [JsonConverter(typeof(StringEnumConverter))] - public enum QuantumGroupType - { - [EnumMember(Value = @"sockets")] Sockets = 0, - - [EnumMember(Value = @"states")] States = 1, - - FailedValidation = 10 - } - - [JsonObject] - public class QuantumGroupInfo - { - /// - /// What type of group this is: does it define a list of states a single quantum object could take or a list of sockets one or more quantum objects could share? - /// - public QuantumGroupType type; - - /// - /// A unique string used by props (that are marked as quantum) use to refer back to this group - /// - public string id; - - /// - /// Only required if type is `sockets`. This lists all the possible locations for any props assigned to this group. - /// - public QuantumSocketInfo[] sockets; - - /// - /// Optional. Only used if type is `states`. If this is true, then the first prop made part of this group will be used to construct a visibility box for an empty game object, which will be considered one of the states. - /// - public bool hasEmptyState; - - /// - /// Optional. Only used if type is `states`. If this is true, then the states will be presented in order, rather than in a random order - /// - public bool sequential; - - /// - /// Optional. Only used if type is `states` and `sequential` is true. If this is false, then after the last state has appeared, the object will no longer change state - /// - [DefaultValue(true)] public bool loop = true; - } - - [JsonObject] - public class QuantumSocketInfo : GeneralPropInfo - { - /// - /// The probability any props that are part of this group will occupy this socket - /// - [DefaultValue(1f)] public float probability = 1f; - } - - [JsonObject] - public class RemoteInfo - { - /// - /// The unique remote id - /// - public string id; - - /// - /// Icon that the will show on the stone, pedastal of the whiteboard, and pedastal of the platform. - /// - public string decalPath; - - /// - /// Whiteboard that the stones can put text onto - /// - public WhiteboardInfo whiteboard; - - /// - /// Camera platform that the stones can project to and from - /// - public PlatformInfo platform; - - /// - /// Projection stones - /// - public StoneInfo[] stones; - - [JsonObject] - public class WhiteboardInfo : GeneralPropInfo - { - /// - /// The text for each stone - /// - public SharedNomaiTextInfo[] nomaiText; - - /// - /// Disable the wall, leaving only the pedestal and text. - /// - public bool disableWall; - - [JsonObject] - public class SharedNomaiTextInfo - { - /// - /// The id of the stone this text will appear for - /// - public string id; - - /// - /// Additional information about each arc in the text - /// - public NomaiTextArcInfo[] arcInfo; - - /// - /// The random seed used to pick what the text arcs will look like. - /// - public int seed; // For randomizing arcs - - /// - /// The location of this object. - /// - [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; - - /// - /// The relative path to the xml file for this object. - /// - public string xmlFile; - - /// - /// An optional rename of this object - /// - public string rename; - } - } - - [JsonObject] - public class PlatformInfo : GeneralPropInfo - { - /// - /// A ship log fact to reveal when the platform is connected to. - /// - [DefaultValue("")] public string reveals = ""; - - /// - /// Disable the structure, leaving only the pedestal. - /// - public bool disableStructure; - - /// - /// Disable the pool that rises when you place a stone. - /// - public bool disablePool; - } - - [JsonObject] - public class StoneInfo : GeneralPropInfo - { + [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/RulesetModule.cs b/NewHorizons/External/Modules/RulesetModule.cs new file mode 100644 index 000000000..4b35e44f2 --- /dev/null +++ b/NewHorizons/External/Modules/RulesetModule.cs @@ -0,0 +1,90 @@ +using NewHorizons.External.Volumes; +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Modules +{ + [JsonObject] + public class RulesetModule + { + /// + /// Add anti travel music rulesets to this planet. + /// + public VolumeInfo[] antiTravelMusicRulesets; + /// + /// Add player impact rulesets to this planet. + /// + public PlayerImpactRulesetInfo[] playerImpactRulesets; + /// + /// Add probe rulesets to this planet. + /// + public ProbeRulesetInfo[] probeRulesets; + /// + /// Add thrust rulesets to this planet. + /// + public ThrustRulesetInfo[] thrustRulesets; + + [JsonObject] + public class PlayerImpactRulesetInfo : VolumeInfo + { + /// + /// Minimum player impact speed. Player will take the minimum amount of damage if they impact something at this speed. + /// + [DefaultValue(20f)] public float minImpactSpeed = 20f; + + /// + /// Maximum player impact speed. Players will die if they impact something at this speed. + /// + [DefaultValue(40f)] public float maxImpactSpeed = 40f; + } + + [JsonObject] + public class ProbeRulesetInfo : VolumeInfo + { + /// + /// Should this ruleset override the probe's speed? + /// + public bool overrideProbeSpeed; + + /// + /// The speed of the probe while in this ruleset volume. + /// + public float probeSpeed; + + /// + /// Should this ruleset override the range of probe's light? + /// + public bool overrideLanternRange; + + /// + /// The range of probe's light while in this ruleset volume. + /// + public float lanternRange; + + /// + /// Stop the probe from attaching to anything while in this ruleset volume. + /// + public bool ignoreAnchor; + } + + [JsonObject] + public class ThrustRulesetInfo : VolumeInfo + { + /// + /// Limit how fast you can fly with your ship while in this ruleset volume. + /// + [DefaultValue(float.PositiveInfinity)] public float thrustLimit = float.PositiveInfinity; + + /// + /// Nerf the jetpack booster. + /// + public bool nerfJetpackBooster; + + /// + /// How long the jetpack booster will be nerfed. + /// + [DefaultValue(0.5f)] public float nerfDuration = 0.5f; + } + } + } + diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index cfa66a16f..337258cbb 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using NewHorizons.External.Props; using NewHorizons.Utility; using Newtonsoft.Json; @@ -13,63 +14,5 @@ public class SignalModule /// List of signals to add (Why did xen do it like this) /// public SignalInfo[] signals; - - [JsonObject] - public class SignalInfo : PropModule.GeneralPointPropInfo - { - [Obsolete("audioClip is deprecated, please use audio instead")] - public string audioClip; - - [Obsolete("audioFilePath is deprecated, please use audio instead")] - public string audioFilePath; - - /// - /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. - /// - public string audio; - - /// - /// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected" - /// notification. - /// - [Range(0f, double.MaxValue)] public float detectionRadius; - - /// - /// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`, - /// `Statue`, `WarpCore`, `HideAndSeek`, and `Radio`. You can also put a custom value. - /// - public string frequency; - - /// - /// How close the player must get to the signal to identify it. This is when you learn its name. - /// - [DefaultValue(10f)] [Range(0f, double.MaxValue)] - public float identificationRadius = 10f; - - /// - /// Only set to `true` if you are putting this signal inside a cloaking field. - /// - public bool insideCloak; - - /// - /// The unique ID of the signal. - /// - public string name; - - /// - /// `false` if the player can hear the signal without equipping the signal-scope. - /// - [DefaultValue(true)] public bool onlyAudibleToScope = true; - - /// - /// A ship log fact to reveal when the signal is identified. - /// - [DefaultValue("")] public string reveals = ""; - - /// - /// Radius of the sphere giving off the signal. - /// - [DefaultValue(1f)] public float sourceRadius = 1f; - } } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index ea8067c14..5ab6bf71d 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -1,3 +1,4 @@ +using NewHorizons.External.Props; using NewHorizons.Utility; using Newtonsoft.Json; using System; @@ -24,7 +25,7 @@ public class SpawnModule [Obsolete("startWithSuit is deprecated. Use playerSpawn.startWithSuit instead")] public bool startWithSuit; [JsonObject] - public class PlayerSpawnPoint : PropModule.GeneralPropInfo { + public class PlayerSpawnPoint : GeneralPropInfo { /// /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) /// @@ -32,7 +33,7 @@ public class PlayerSpawnPoint : PropModule.GeneralPropInfo { } [JsonObject] - public class ShipSpawnPoint : PropModule.GeneralPropInfo { + public class ShipSpawnPoint : GeneralPropInfo { } } diff --git a/NewHorizons/External/Modules/VisorEffectModule.cs b/NewHorizons/External/Modules/VisorEffectModule.cs new file mode 100644 index 000000000..fa1fd6ceb --- /dev/null +++ b/NewHorizons/External/Modules/VisorEffectModule.cs @@ -0,0 +1,55 @@ +using NewHorizons.External.Volumes; +using Newtonsoft.Json; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace NewHorizons.External.Modules +{ + [JsonObject] + public class VisorEffectModule + { + /// + /// Add visor frost effect volumes to this planet. This is the ghost matter effect. + /// + public FrostEffectVolumeInfo[] frostEffectVolumes; + + /// + /// Add visor rain effect volumes to this planet. You can see this on Giant's Deep. + /// + public RainEffectVolumeInfo[] rainEffectVolumes; + + [JsonObject] + public class FrostEffectVolumeInfo : PriorityVolumeInfo + { + /// + /// The rate at which the frost effect will get stronger + /// + [DefaultValue(0.5f)] + public float frostRate = 0.5f; + + /// + /// The maximum strength of frost this volume can give + /// + [Range(0f, 1f)] + [DefaultValue(0.91f)] + public float maxFrost = 0.91f; + } + + [JsonObject] + public class RainEffectVolumeInfo : PriorityVolumeInfo + { + /// + /// The rate at which the rain droplet effect will happen + /// + [DefaultValue(0.1f)] + public float dropletRate = 10f; + + /// + /// The rate at which the rain streak effect will happen + /// + [DefaultValue(1f)] + public float streakRate = 1f; + } + } + } + diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 8b60df6ea..5118db0ca 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -1,3 +1,5 @@ +using NewHorizons.External.Props; +using NewHorizons.External.Volumes; using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -115,539 +117,5 @@ public class VolumesModule /// Enter this volume to be sent to the end credits scene /// public LoadCreditsVolumeInfo[] creditsVolume; - - [JsonObject] - public class VolumeInfo : PropModule.GeneralPointPropInfo - { - /// - /// The radius of this volume. - /// - [DefaultValue(1f)] - public float radius = 1f; - } - - [JsonObject] - public class ChangeStarSystemVolumeInfo : VolumeInfo - { - /// - /// The star system that entering this volume will send you to. - /// - [DefaultValue("SolarSystem")] - public string targetStarSystem; - } - - [JsonObject] - public class LoadCreditsVolumeInfo : VolumeInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum CreditsType - { - [EnumMember(Value = @"fast")] Fast = 0, - - [EnumMember(Value = @"final")] Final = 1, - - [EnumMember(Value = @"kazoo")] Kazoo = 2 - } - - [DefaultValue("fast")] - public CreditsType creditsType = CreditsType.Fast; - } - - [JsonObject] - public class PriorityVolumeInfo : VolumeInfo - { - /// - /// The layer of this volume. - /// - [DefaultValue(0)] - public int layer = 0; - - /// - /// The priority for this volume's effects to be applied. - /// Ex, a player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity. - /// - [DefaultValue(1)] - public int priority = 1; - } - - [JsonObject] - public class RevealVolumeInfo : VolumeInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum RevealVolumeType - { - [EnumMember(Value = @"enter")] Enter = 0, - - [EnumMember(Value = @"observe")] Observe = 1, - - [EnumMember(Value = @"snapshot")] Snapshot = 2 - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum EnterType - { - [EnumMember(Value = @"both")] Both = 0, - - [EnumMember(Value = @"player")] Player = 1, - - [EnumMember(Value = @"probe")] Probe = 2 - } - - /// - /// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only) - /// - [DefaultValue(180f)] - public float maxAngle = 180f; // Observe Only - - /// - /// The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only) - /// - [DefaultValue(-1f)] - public float maxDistance = -1f; // Snapshot & Observe Only - - /// - /// What needs to be done to the volume to unlock the facts - /// - [DefaultValue("enter")] public RevealVolumeType revealOn = RevealVolumeType.Enter; - - /// - /// What can enter the volume to unlock the facts (`enter` only) - /// - [DefaultValue("both")] public EnterType revealFor = EnterType.Both; - - /// - /// A list of facts to reveal - /// - public string[] reveals; - - /// - /// An achievement to unlock. Optional. - /// - public string achievementID; - } - - [JsonObject] - public class AudioVolumeInfo : PriorityVolumeInfo - { - /// - /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. - /// - public string audio; - - [DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM; - - /// - /// The audio track of this audio volume - /// - [DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment; - - /// - /// Whether to loop this audio while in this audio volume or just play it once - /// - [DefaultValue(true)] public bool loop = true; - - /// - /// The loudness of the audio - /// - [Range(0f, 1f)] - [DefaultValue(1f)] - public float volume = 1f; - - /// - /// How long it will take to fade this sound in and out when entering/exiting this volume. - /// - [DefaultValue(2f)] - public float fadeSeconds = 2f; - - /// - /// Play the sound instantly without any fading. - /// - public bool noFadeFromBeginning; - - /// - /// Randomize what time the audio starts at. - /// - public bool randomizePlayhead; - - /// - /// Pause the music when exiting the volume. - /// - public bool pauseOnFadeOut; - } - - [JsonObject] - public class NotificationVolumeInfo : VolumeInfo - { - /// - /// What the notification will show for. - /// - [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; - - /// - /// The notification that will play when you enter this volume. - /// - public NotificationInfo entryNotification; - - /// - /// The notification that will play when you exit this volume. - /// - public NotificationInfo exitNotification; - - - [JsonObject] - public class NotificationInfo - { - /// - /// The message that will be displayed. - /// - public string displayMessage; - - /// - /// The duration this notification will be displayed. - /// - [DefaultValue(5f)] public float duration = 5f; - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum NotificationTarget - { - [EnumMember(Value = @"all")] All = 0, - [EnumMember(Value = @"ship")] Ship = 1, - [EnumMember(Value = @"player")] Player = 2, - } - } - - [JsonObject] - public class HazardVolumeInfo : VolumeInfo - { - /// - /// The type of hazard for this volume. - /// - [DefaultValue("general")] public HazardType type = HazardType.GENERAL; - - /// - /// The amount of damage you will take per second while inside this volume. - /// - [DefaultValue(10f)] public float damagePerSecond = 10f; - - /// - /// The type of damage you will take when you first touch this volume. - /// - [DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact; - - /// - /// The amount of damage you will take when you first touch this volume. - /// - public float firstContactDamage; - - [JsonConverter(typeof(StringEnumConverter))] - public enum HazardType - { - [EnumMember(Value = @"none")] NONE = 0, - [EnumMember(Value = @"general")] GENERAL = 1, - [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2, - [EnumMember(Value = @"heat")] HEAT = 4, - [EnumMember(Value = @"fire")] FIRE = 8, - [EnumMember(Value = @"sandfall")] SANDFALL = 16, - [EnumMember(Value = @"electricity")] ELECTRICITY = 32, - [EnumMember(Value = @"rapids")] RAPIDS = 64, - [EnumMember(Value = @"riverHeat")] RIVERHEAT = 128, - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum InstantDamageType - { - [EnumMember(Value = @"impact")] Impact, - [EnumMember(Value = @"puncture")] Puncture, - [EnumMember(Value = @"electrical")] Electrical - } - } - - [JsonObject] - public class VanishVolumeInfo : VolumeInfo - { - /// - /// Whether the bodies will shrink when they enter this volume or just disappear instantly. - /// - [DefaultValue(true)] public bool shrinkBodies = true; - - /// - /// Whether this volume only affects the player and ship. - /// - public bool onlyAffectsPlayerAndShip; - } - - [JsonObject] - public class DestructionVolumeInfo : VanishVolumeInfo - { - /// - /// The type of death the player will have if they enter this volume. - /// - [DefaultValue("default")] public DeathType deathType = DeathType.Default; - - [JsonConverter(typeof(StringEnumConverter))] - public enum DeathType - { - [EnumMember(Value = @"default")] Default, - [EnumMember(Value = @"impact")] Impact, - [EnumMember(Value = @"asphyxiation")] Asphyxiation, - [EnumMember(Value = @"energy")] Energy, - [EnumMember(Value = @"supernova")] Supernova, - [EnumMember(Value = @"digestion")] Digestion, - [EnumMember(Value = @"bigBang")] BigBang, - [EnumMember(Value = @"crushed")] Crushed, - [EnumMember(Value = @"meditation")] Meditation, - [EnumMember(Value = @"timeLoop")] TimeLoop, - [EnumMember(Value = @"lava")] Lava, - [EnumMember(Value = @"blackHole")] BlackHole, - [EnumMember(Value = @"dream")] Dream, - [EnumMember(Value = @"dreamExplosion")] DreamExplosion, - [EnumMember(Value = @"crushedByElevator")] CrushedByElevator - } - } - - [JsonObject] - public class OxygenVolumeInfo : VolumeInfo - { - /// - /// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled". - /// - public bool treeVolume; - - /// - /// Whether to play the oxygen tank refill sound or just fill quietly. - /// - [DefaultValue(true)] public bool playRefillAudio = true; - } - - [JsonObject] - public class FluidVolumeInfo : PriorityVolumeInfo - { - /// - /// Density of the fluid. The higher the density, the harder it is to go through this fluid. - /// - [DefaultValue(1.2f)] public float density = 1.2f; - - /// - /// The type of fluid for this volume. - /// - public FluidType type; - - /// - /// Should the player and rafts align to this fluid. - /// - [DefaultValue(true)] public bool alignmentFluid = true; - - /// - /// Should the ship align to the fluid by rolling. - /// - public bool allowShipAutoroll; - - /// - /// Disable this fluid volume immediately? - /// - public bool disableOnStart; - - [JsonConverter(typeof(StringEnumConverter))] - public enum FluidType - { - [EnumMember(Value = @"none")] NONE = 0, - [EnumMember(Value = @"air")] AIR, - [EnumMember(Value = @"water")] WATER, - [EnumMember(Value = @"cloud")] CLOUD, - [EnumMember(Value = @"sand")] SAND, - [EnumMember(Value = @"plasma")] PLASMA, - [EnumMember(Value = @"fog")] FOG - } - } - - [JsonObject] - public class ProbeModule - { - /// - /// Add probe destruction volumes to this planet. These will delete your probe. - /// - public VolumeInfo[] destructionVolumes; - - /// - /// Add probe safety volumes to this planet. These will stop the probe destruction volumes from working. - /// - public VolumeInfo[] safetyVolumes; - } - - [JsonObject] - public class VisorEffectModule - { - /// - /// Add visor frost effect volumes to this planet. This is the ghost matter effect. - /// - public FrostEffectVolumeInfo[] frostEffectVolumes; - - /// - /// Add visor rain effect volumes to this planet. You can see this on Giant's Deep. - /// - public RainEffectVolumeInfo[] rainEffectVolumes; - - [JsonObject] - public class FrostEffectVolumeInfo : PriorityVolumeInfo - { - /// - /// The rate at which the frost effect will get stronger - /// - [DefaultValue(0.5f)] - public float frostRate = 0.5f; - - /// - /// The maximum strength of frost this volume can give - /// - [Range(0f, 1f)] - [DefaultValue(0.91f)] - public float maxFrost = 0.91f; - } - - [JsonObject] - public class RainEffectVolumeInfo : PriorityVolumeInfo - { - /// - /// The rate at which the rain droplet effect will happen - /// - [DefaultValue(0.1f)] - public float dropletRate = 10f; - - /// - /// The rate at which the rain streak effect will happen - /// - [DefaultValue(1f)] - public float streakRate = 1f; - } - } - - [JsonObject] - public class RulesetModule - { - /// - /// Add anti travel music rulesets to this planet. - /// - public VolumeInfo[] antiTravelMusicRulesets; - /// - /// Add player impact rulesets to this planet. - /// - public PlayerImpactRulesetInfo[] playerImpactRulesets; - /// - /// Add probe rulesets to this planet. - /// - public ProbeRulesetInfo[] probeRulesets; - /// - /// Add thrust rulesets to this planet. - /// - public ThrustRulesetInfo[] thrustRulesets; - - [JsonObject] - public class PlayerImpactRulesetInfo : VolumeInfo - { - /// - /// Minimum player impact speed. Player will take the minimum amount of damage if they impact something at this speed. - /// - [DefaultValue(20f)] public float minImpactSpeed = 20f; - - /// - /// Maximum player impact speed. Players will die if they impact something at this speed. - /// - [DefaultValue(40f)] public float maxImpactSpeed = 40f; - } - - [JsonObject] - public class ProbeRulesetInfo : VolumeInfo - { - /// - /// Should this ruleset override the probe's speed? - /// - public bool overrideProbeSpeed; - - /// - /// The speed of the probe while in this ruleset volume. - /// - public float probeSpeed; - - /// - /// Should this ruleset override the range of probe's light? - /// - public bool overrideLanternRange; - - /// - /// The range of probe's light while in this ruleset volume. - /// - public float lanternRange; - - /// - /// Stop the probe from attaching to anything while in this ruleset volume. - /// - public bool ignoreAnchor; - } - - [JsonObject] - public class ThrustRulesetInfo : VolumeInfo - { - /// - /// Limit how fast you can fly with your ship while in this ruleset volume. - /// - [DefaultValue(float.PositiveInfinity)] public float thrustLimit = float.PositiveInfinity; - - /// - /// Nerf the jetpack booster. - /// - public bool nerfJetpackBooster; - - /// - /// How long the jetpack booster will be nerfed. - /// - [DefaultValue(0.5f)] public float nerfDuration = 0.5f; - } - } - - [JsonObject] - public class SpeedTrapVolumeInfo : VolumeInfo - { - /// - /// The speed the volume will slow you down to when you enter it. - /// - [DefaultValue(10f)] - public float speedLimit = 10f; - - /// - /// How fast it will slow down the player to the speed limit. - /// - [DefaultValue(3f)] - public float acceleration = 3f; - } - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum ClipSelectionType - { - [EnumMember(Value = @"random")] RANDOM, - [EnumMember(Value = @"sequential")] SEQUENTIAL, - [EnumMember(Value = @"manual")] MANUAL - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum AudioMixerTrackName - { - [EnumMember(Value = @"undefined")] Undefined = 0, - [EnumMember(Value = @"menu")] Menu = 1, - [EnumMember(Value = @"music")] Music = 2, - [EnumMember(Value = @"environment")] Environment = 4, - [EnumMember(Value = @"environmentUnfiltered")] Environment_Unfiltered = 5, - [EnumMember(Value = @"endTimesSfx")] EndTimes_SFX = 8, - [EnumMember(Value = @"signal")] Signal = 16, - [EnumMember(Value = @"death")] Death = 32, - [EnumMember(Value = @"player")] Player = 64, - [EnumMember(Value = @"playerExternal")] Player_External = 65, - [EnumMember(Value = @"ship")] Ship = 128, - [EnumMember(Value = @"map")] Map = 256, - [EnumMember(Value = @"endTimesMusic")] EndTimes_Music = 512, - [EnumMember(Value = @"muffleWhileRafting")] MuffleWhileRafting = 1024, - [EnumMember(Value = @"muffleIndoors")] MuffleIndoors = 2048, - [EnumMember(Value = @"slideReelMusic")] SlideReelMusic = 4096, } } diff --git a/NewHorizons/External/Props/BrambleNodeInfo.cs b/NewHorizons/External/Props/BrambleNodeInfo.cs new file mode 100644 index 000000000..18d9f2984 --- /dev/null +++ b/NewHorizons/External/Props/BrambleNodeInfo.cs @@ -0,0 +1,73 @@ +using NewHorizons.Utility; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.External.Props +{ + + [JsonObject] + public class BrambleNodeInfo : GeneralPropInfo + { + /// + /// The physical scale of the node, as a multiplier of the original size. + /// Nodes are 150m across, seeds are 10m across. + /// + [DefaultValue(1f)] public float scale = 1f; + + /// + /// The name of the planet that hosts the dimension this node links to + /// + public string linksTo; + + /// + /// The name of this node. Only required if this node should serve as an exit. + /// + public string name; + + /// + /// Set this to true to make this node a seed instead of a node the player can enter + /// + [DefaultValue(false)] public bool isSeed = false; + + /// + /// The color of the fog inside the node. + /// Leave blank for the default yellowish white color: (255, 245, 217, 255) + /// + public MColor fogTint; + + /// + /// The color of the light from the node. Alpha controls brightness. + /// Leave blank for the default white color. + /// + public MColor lightTint; + + /// + /// Should this node have a point of light from afar? + /// By default, nodes will have a foglight, while seeds won't, and neither will if not in a dimension. + /// + public bool? hasFogLight; + + /// + /// An array of integers from 0-5. By default, all exits are allowed. To force this node to warp players out from only one hole set this value to [3], [5], or similar. Values of 0-5 only. + /// + public int[] possibleExits; + + /// + /// If your game hard crashes upon entering bramble, it's most likely because you have indirectly recursive dimensions, i.e. one leads to another that leads back to the first one. + /// Set this to true for one of the nodes in the recursion to fix this, at the cost of it no longer showing markers for the scout, ship, etc. + /// + [DefaultValue(false)] public bool preventRecursionCrash = false; + + #region Obsolete + + [Obsolete("farFogTint is deprecated, please use fogTint instead")] + public MColor farFogTint; + + #endregion Obsolete + } +} diff --git a/NewHorizons/External/Props/DetailInfo.cs b/NewHorizons/External/Props/DetailInfo.cs new file mode 100644 index 000000000..f68977b96 --- /dev/null +++ b/NewHorizons/External/Props/DetailInfo.cs @@ -0,0 +1,76 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class DetailInfo : GeneralPropInfo + { + + /// + /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? + /// + public bool alignToNormal; + + /// + /// Relative filepath to an asset-bundle to load the prefab defined in `path` from + /// + public string assetBundle; + + /// + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// + public string path; + + /// + /// A list of children to remove from this detail + /// + public string[] removeChildren; + + /// + /// Do we reset all the components on this object? Useful for certain props that have dialogue components attached to + /// them. + /// + public bool removeComponents; + + /// + /// Scale the prop + /// + [DefaultValue(1f)] public float scale = 1f; + + /// + /// Scale each axis of the prop. Overrides `scale`. + /// + public MVector3 stretch; + + /// + /// If this value is not null, this prop will be quantum. Assign this field to the id of the quantum group it should be a part of. The group it is assigned to determines what kind of quantum object it is + /// + public string quantumGroupID; + + /// + /// Should this detail stay loaded even if you're outside the sector (good for very large props) + /// + public bool keepLoaded; + + /// + /// Should this object dynamically move around? + /// This tries to make all mesh colliders convex, as well as adding a sphere collider in case the detail has no others. + /// + public bool hasPhysics; + + /// + /// The mass of the physics object. + /// Most pushable props use the default value, which matches the player mass. + /// + [DefaultValue(0.001f)] public float physicsMass = 0.001f; + + /// + /// The radius that the added sphere collider will use for physics collision. + /// If there's already good colliders on the detail, you can make this 0. + /// + [DefaultValue(1f)] public float physicsRadius = 1f; + } +} diff --git a/NewHorizons/External/Props/DialogueInfo.cs b/NewHorizons/External/Props/DialogueInfo.cs new file mode 100644 index 000000000..e3e7dc1f9 --- /dev/null +++ b/NewHorizons/External/Props/DialogueInfo.cs @@ -0,0 +1,85 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class DialogueInfo : GeneralPointPropInfo + { + /// + /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue + /// triggers that you want to have happen only once. + /// + public string blockAfterPersistentCondition; + + /// + /// If a pathToAnimController is supplied, if you are within this distance the character will look at you. If it is set + /// to 0, they will only look at you when spoken to. + /// + public float lookAtRadius; + + /// + /// If this dialogue is meant for a character, this is the relative path from the planet to that character's + /// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController. + /// + /// If none of those components are present it will add a FacePlayerWhenTalking component. + /// + public string pathToAnimController; + + /// + /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a + /// remoteTrigger, you can set this to 0 to make the dialogue only trigger remotely. + /// + public float radius = 1f; + + /// + /// Distance from radius the prompt appears + /// + [DefaultValue(2f)] public float range = 2f; + + /// + /// Allows you to trigger dialogue from a distance when you walk into an area. + /// + public RemoteTriggerInfo remoteTrigger; + + [Obsolete("remoteTriggerPosition is deprecated. Use remoteTrigger.position instead")] public MVector3 remoteTriggerPosition; + [Obsolete("remoteTriggerRadius is deprecated. Use remoteTrigger.radius instead")] public float remoteTriggerRadius; + [Obsolete("remoteTriggerPrereqCondition is deprecated. Use remoteTrigger.prereqCondition instead")] public string remoteTriggerPrereqCondition; + + /// + /// Relative path to the xml file defining the dialogue. + /// + public string xmlFile; + + /// + /// What type of flashlight toggle to do when dialogue is interacted with + /// + [DefaultValue("none")] public FlashlightToggle flashlightToggle = FlashlightToggle.None; + + [JsonConverter(typeof(StringEnumConverter))] + public enum FlashlightToggle + { + [EnumMember(Value = @"none")] None = -1, + [EnumMember(Value = @"turnOff")] TurnOff = 0, + [EnumMember(Value = @"turnOffThenOn")] TurnOffThenOn = 1, + } + + [JsonObject] + public class RemoteTriggerInfo : GeneralPointPropInfo + { + /// + /// The radius of the remote trigger volume. + /// + public float radius; + /// + /// This condition must be met for the remote trigger volume to trigger. + /// + public string prereqCondition; + } + } +} diff --git a/NewHorizons/External/Props/EntryLocationInfo.cs b/NewHorizons/External/Props/EntryLocationInfo.cs new file mode 100644 index 000000000..f0791b74f --- /dev/null +++ b/NewHorizons/External/Props/EntryLocationInfo.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class EntryLocationInfo : GeneralPointPropInfo + { + /// + /// Whether this location is cloaked + /// + public bool cloaked; + + /// + /// ID of the entry this location relates to + /// + public string id; + } +} diff --git a/NewHorizons/External/Props/GeneralPointPropInfo.cs b/NewHorizons/External/Props/GeneralPointPropInfo.cs new file mode 100644 index 000000000..ddb428e29 --- /dev/null +++ b/NewHorizons/External/Props/GeneralPointPropInfo.cs @@ -0,0 +1,29 @@ +using NewHorizons.Utility; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public abstract class GeneralPointPropInfo + { + /// + /// Position of the object + /// + public MVector3 position; + + /// + /// 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; + } +} diff --git a/NewHorizons/External/Props/GeneralPropInfo.cs b/NewHorizons/External/Props/GeneralPropInfo.cs new file mode 100644 index 000000000..7f3397117 --- /dev/null +++ b/NewHorizons/External/Props/GeneralPropInfo.cs @@ -0,0 +1,14 @@ +using NewHorizons.Utility; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public abstract class GeneralPropInfo : GeneralPointPropInfo + { + /// + /// Rotation of the object + /// + public MVector3 rotation; + } +} diff --git a/NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs b/NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs new file mode 100644 index 000000000..bd4356112 --- /dev/null +++ b/NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo + { + /// + /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. + /// + public string parentBody; + } +} diff --git a/NewHorizons/External/Props/GeyserInfo.cs b/NewHorizons/External/Props/GeyserInfo.cs new file mode 100644 index 000000000..eb64d207b --- /dev/null +++ b/NewHorizons/External/Props/GeyserInfo.cs @@ -0,0 +1,46 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class GeyserInfo : GeneralPointPropInfo + { + /// + /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. + /// + [DefaultValue(-97.5f)] public float offset = -97.5f; + + /// + /// Force of the geyser on objects + /// + [DefaultValue(55f)] public float force = 55f; + + /// + /// Time in seconds eruptions last for + /// + [DefaultValue(10f)] public float activeDuration = 10f; + + /// + /// Time in seconds between eruptions + /// + [DefaultValue(19f)] public float inactiveDuration = 19f; + + /// + /// Color of the geyser. Alpha sets the particle density. + /// + public MColor tint; + + /// + /// Disable the individual particle systems of the geyser + /// + public bool disableBubbles, disableShaft, disableSpout; + + /// + /// Loudness of the geyser + /// + [DefaultValue(0.7f)] public float volume = 0.7f; + } +} diff --git a/NewHorizons/External/Props/NomaiTextArcInfo.cs b/NewHorizons/External/Props/NomaiTextArcInfo.cs new file mode 100644 index 000000000..b11a38df2 --- /dev/null +++ b/NewHorizons/External/Props/NomaiTextArcInfo.cs @@ -0,0 +1,54 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class NomaiTextArcInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextArcType + { + [EnumMember(Value = @"adult")] Adult = 0, + + [EnumMember(Value = @"child")] Child = 1, + + [EnumMember(Value = @"stranger")] Stranger = 2 + } + + /// + /// Whether to skip modifying this spiral's placement, and instead keep the automatically determined placement. + /// + public bool keepAutoPlacement; + + /// + /// Whether to flip the spiral from left-curling to right-curling or vice versa. + /// + public bool mirror; + + /// + /// The local position of this object on the wall. + /// + public MVector2 position; + + /// + /// The type of text to display. + /// + [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; + + /// + /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. + /// + [DefaultValue(-1)] public int variation = -1; + + /// + /// The z euler angle for this arc. + /// + [Range(0f, 360f)] public float zRotation; + } +} diff --git a/NewHorizons/External/Props/NomaiTextInfo.cs b/NewHorizons/External/Props/NomaiTextInfo.cs new file mode 100644 index 000000000..9819edb35 --- /dev/null +++ b/NewHorizons/External/Props/NomaiTextInfo.cs @@ -0,0 +1,81 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class NomaiTextInfo : GeneralPointPropInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextType + { + [EnumMember(Value = @"wall")] Wall = 0, + + [EnumMember(Value = @"scroll")] Scroll = 1, + + [EnumMember(Value = @"computer")] Computer = 2, + + [EnumMember(Value = @"cairn")] Cairn = 3, + + [EnumMember(Value = @"recorder")] Recorder = 4, + + [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, + + [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, + + [EnumMember(Value = @"trailmarker")] Trailmarker = 7, + + [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextLocation + { + [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, + + [EnumMember(Value = @"a")] A = 1, + + [EnumMember(Value = @"b")] B = 2 + } + + /// + /// Additional information about each arc in the text + /// + public NomaiTextArcInfo[] arcInfo; + + /// + /// The normal vector for this object. Used for writing on walls and positioning computers. + /// + public MVector3 normal; + + /// + /// The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient + /// themselves to the surface of the planet automatically. + /// + public MVector3 rotation; + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; // For randomizing arcs + + /// + /// The type of object this is. + /// + [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; + + /// + /// The location of this object. + /// + [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; + + /// + /// The relative path to the xml file for this object. + /// + public string xmlFile; + } +} diff --git a/NewHorizons/External/Props/ProjectionInfo.cs b/NewHorizons/External/Props/ProjectionInfo.cs new file mode 100644 index 000000000..c05950eb3 --- /dev/null +++ b/NewHorizons/External/Props/ProjectionInfo.cs @@ -0,0 +1,47 @@ +using System.ComponentModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class ProjectionInfo : GeneralPropInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum SlideShowType + { + [EnumMember(Value = @"slideReel")] SlideReel = 0, + + [EnumMember(Value = @"autoProjector")] AutoProjector = 1, + + [EnumMember(Value = @"visionTorchTarget")] VisionTorchTarget = 2, + + [EnumMember(Value = @"standingVisionTorch")] StandingVisionTorch = 3, + + } + + /// + /// The ship log facts revealed after finishing this slide reel. + /// + public string[] reveals; + + /// + /// The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows). + /// You should probably include facts from `reveals` here. + /// If you only specify a rumor fact, then it would only play in its ship log entry if this has revealed only + /// rumor facts because an entry with revealed explore facts doesn't display rumor facts. + /// + public string[] playWithShipLogFacts; + + /// + /// The list of slides for this object. + /// + public SlideInfo[] slides; + + /// + /// The type of object this is. + /// + [DefaultValue("slideReel")] public SlideShowType type = SlideShowType.SlideReel; + } +} diff --git a/NewHorizons/External/Props/QuantumGroupInfo.cs b/NewHorizons/External/Props/QuantumGroupInfo.cs new file mode 100644 index 000000000..21e40449c --- /dev/null +++ b/NewHorizons/External/Props/QuantumGroupInfo.cs @@ -0,0 +1,51 @@ +using System.ComponentModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class QuantumGroupInfo + { + /// + /// What type of group this is: does it define a list of states a single quantum object could take or a list of sockets one or more quantum objects could share? + /// + public QuantumGroupType type; + + /// + /// A unique string used by props (that are marked as quantum) use to refer back to this group + /// + public string id; + + /// + /// Only required if type is `sockets`. This lists all the possible locations for any props assigned to this group. + /// + public QuantumSocketInfo[] sockets; + + /// + /// Optional. Only used if type is `states`. If this is true, then the first prop made part of this group will be used to construct a visibility box for an empty game object, which will be considered one of the states. + /// + public bool hasEmptyState; + + /// + /// Optional. Only used if type is `states`. If this is true, then the states will be presented in order, rather than in a random order + /// + public bool sequential; + + /// + /// Optional. Only used if type is `states` and `sequential` is true. If this is false, then after the last state has appeared, the object will no longer change state + /// + [DefaultValue(true)] public bool loop = true; + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum QuantumGroupType + { + [EnumMember(Value = @"sockets")] Sockets = 0, + + [EnumMember(Value = @"states")] States = 1, + + FailedValidation = 10 + } +} diff --git a/NewHorizons/External/Props/QuantumSocketInfo.cs b/NewHorizons/External/Props/QuantumSocketInfo.cs new file mode 100644 index 000000000..39e2431a1 --- /dev/null +++ b/NewHorizons/External/Props/QuantumSocketInfo.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class QuantumSocketInfo : GeneralPropInfo + { + /// + /// The probability any props that are part of this group will occupy this socket + /// + [DefaultValue(1f)] public float probability = 1f; + } +} diff --git a/NewHorizons/External/Props/RaftInfo.cs b/NewHorizons/External/Props/RaftInfo.cs new file mode 100644 index 000000000..811de16f7 --- /dev/null +++ b/NewHorizons/External/Props/RaftInfo.cs @@ -0,0 +1,14 @@ +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class RaftInfo : GeneralPointPropInfo + { + /// + /// Acceleration of the raft. Default acceleration is 5. + /// + [DefaultValue(5f)] public float acceleration = 5f; + } +} diff --git a/NewHorizons/External/Props/RemoteInfo.cs b/NewHorizons/External/Props/RemoteInfo.cs new file mode 100644 index 000000000..941087b42 --- /dev/null +++ b/NewHorizons/External/Props/RemoteInfo.cs @@ -0,0 +1,107 @@ +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class RemoteInfo + { + /// + /// The unique remote id + /// + public string id; + + /// + /// Icon that the will show on the stone, pedastal of the whiteboard, and pedastal of the platform. + /// + public string decalPath; + + /// + /// Whiteboard that the stones can put text onto + /// + public WhiteboardInfo whiteboard; + + /// + /// Camera platform that the stones can project to and from + /// + public PlatformInfo platform; + + /// + /// Projection stones + /// + public StoneInfo[] stones; + + [JsonObject] + public class WhiteboardInfo : GeneralPropInfo + { + /// + /// The text for each stone + /// + public SharedNomaiTextInfo[] nomaiText; + + /// + /// Disable the wall, leaving only the pedestal and text. + /// + public bool disableWall; + + [JsonObject] + public class SharedNomaiTextInfo + { + /// + /// The id of the stone this text will appear for + /// + public string id; + + /// + /// Additional information about each arc in the text + /// + public NomaiTextArcInfo[] arcInfo; + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; // For randomizing arcs + + /// + /// The location of this object. + /// + [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; + + /// + /// The relative path to the xml file for this object. + /// + public string xmlFile; + + /// + /// An optional rename of this object + /// + public string rename; + } + } + + [JsonObject] + public class PlatformInfo : GeneralPropInfo + { + /// + /// A ship log fact to reveal when the platform is connected to. + /// + [DefaultValue("")] public string reveals = ""; + + /// + /// Disable the structure, leaving only the pedestal. + /// + public bool disableStructure; + + /// + /// Disable the pool that rises when you place a stone. + /// + public bool disablePool; + } + + [JsonObject] + public class StoneInfo : GeneralPropInfo + { + + } + } +} diff --git a/NewHorizons/External/Props/ScatterInfo.cs b/NewHorizons/External/Props/ScatterInfo.cs new file mode 100644 index 000000000..5e48db01c --- /dev/null +++ b/NewHorizons/External/Props/ScatterInfo.cs @@ -0,0 +1,71 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class ScatterInfo + { + /// + /// Relative filepath to an asset-bundle + /// + public string assetBundle; + + /// + /// Number of props to scatter + /// + public int count; + + /// + /// Offset this prop once it is placed + /// + public MVector3 offset; + + /// + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// + public string path; + + /// + /// Rotate this prop once it is placed + /// + public MVector3 rotation; + + /// + /// Scale this prop once it is placed + /// + [DefaultValue(1f)] public float scale = 1f; + + /// + /// Scale each axis of the prop. Overrides `scale`. + /// + public MVector3 stretch; + + /// + /// The number used as entropy for scattering the props + /// + public int seed; + + /// + /// The lowest height that these object will be placed at (only relevant if there's a heightmap) + /// + public float? minHeight; + + /// + /// The highest height that these objects will be placed at (only relevant if there's a heightmap) + /// + public float? maxHeight; + + /// + /// Should we try to prevent overlap between the scattered details? True by default. If it's affecting load times turn it off. + /// + [DefaultValue(true)] public bool preventOverlap = true; + + /// + /// Should this detail stay loaded even if you're outside the sector (good for very large props) + /// + public bool keepLoaded; + } +} diff --git a/NewHorizons/External/Props/SignalInfo.cs b/NewHorizons/External/Props/SignalInfo.cs new file mode 100644 index 000000000..a9803029b --- /dev/null +++ b/NewHorizons/External/Props/SignalInfo.cs @@ -0,0 +1,71 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.External.Props +{ + + [JsonObject] + public class SignalInfo : GeneralPointPropInfo + { + [Obsolete("audioClip is deprecated, please use audio instead")] + public string audioClip; + + [Obsolete("audioFilePath is deprecated, please use audio instead")] + public string audioFilePath; + + /// + /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. + /// + public string audio; + + /// + /// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected" + /// notification. + /// + [Range(0f, double.MaxValue)] public float detectionRadius; + + /// + /// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`, + /// `Statue`, `WarpCore`, `HideAndSeek`, and `Radio`. You can also put a custom value. + /// + public string frequency; + + /// + /// How close the player must get to the signal to identify it. This is when you learn its name. + /// + [DefaultValue(10f)] + [Range(0f, double.MaxValue)] + public float identificationRadius = 10f; + + /// + /// Only set to `true` if you are putting this signal inside a cloaking field. + /// + public bool insideCloak; + + /// + /// The unique ID of the signal. + /// + public string name; + + /// + /// `false` if the player can hear the signal without equipping the signal-scope. + /// + [DefaultValue(true)] public bool onlyAudibleToScope = true; + + /// + /// A ship log fact to reveal when the signal is identified. + /// + [DefaultValue("")] public string reveals = ""; + + /// + /// Radius of the sphere giving off the signal. + /// + [DefaultValue(1f)] public float sourceRadius = 1f; + } +} diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Props/SingularityInfo.cs similarity index 92% rename from NewHorizons/External/Modules/VariableSize/SingularityModule.cs rename to NewHorizons/External/Props/SingularityInfo.cs index 58b35b9a4..6b6175884 100644 --- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs +++ b/NewHorizons/External/Props/SingularityInfo.cs @@ -6,10 +6,10 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace NewHorizons.External.Modules.VariableSize +namespace NewHorizons.External.Props { [JsonObject] - public class SingularityModule : PropModule.GeneralPropInfo + public class SingularityInfo : GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SingularityType @@ -39,7 +39,7 @@ public enum SingularityType /// Radius of the singularity. Note that this isn't the same as the event horizon, but includes the entire volume that /// has warped effects in it. /// - [Obsolete("size is deprecated, please use horizonRadius and distortRadius instead")] [Range(0f, double.MaxValue)] public float size; + [Obsolete("size is deprecated, please use horizonRadius and distortRadius instead")][Range(0f, double.MaxValue)] public float size; /// /// Radius of the event horizon (solid part) diff --git a/NewHorizons/External/Props/SlideInfo.cs b/NewHorizons/External/Props/SlideInfo.cs new file mode 100644 index 000000000..10c6fceb0 --- /dev/null +++ b/NewHorizons/External/Props/SlideInfo.cs @@ -0,0 +1,85 @@ +using NewHorizons.Utility; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class SlideInfo + { + /// + /// Ambient light colour when viewing this slide. + /// + public MColor ambientLightColor; + + + // SlideAmbientLightModule + + /// + /// Ambient light intensity when viewing this slide. + /// + public float ambientLightIntensity; + + /// + /// Ambient light range when viewing this slide. + /// + public float ambientLightRange; + + // SlideBackdropAudioModule + + /// + /// The name of the AudioClip that will continuously play while watching these slides + /// + public string backdropAudio; + + /// + /// The time to fade into the backdrop audio + /// + public float backdropFadeTime; + + // SlideBeatAudioModule + + /// + /// The name of the AudioClip for a one-shot sound when opening the slide. + /// + public string beatAudio; + + /// + /// The time delay until the one-shot audio + /// + public float beatDelay; + + + // SlideBlackFrameModule + + /// + /// Before viewing this slide, there will be a black frame for this many seconds. + /// + public float blackFrameDuration; + + /// + /// The path to the image file for this slide. + /// + public string imagePath; + + + // SlidePlayTimeModule + + /// + /// Play-time duration for auto-projector slides. + /// + public float playTimeDuration; + + + // SlideShipLogEntryModule + + /// + /// Ship log fact revealed when viewing this slide + /// + public string reveal; + + /// + /// Spotlight intensity modifier when viewing this slide. + /// + public float spotIntensityMod; + } +} diff --git a/NewHorizons/External/Props/TornadoInfo.cs b/NewHorizons/External/Props/TornadoInfo.cs new file mode 100644 index 000000000..dbf8affa7 --- /dev/null +++ b/NewHorizons/External/Props/TornadoInfo.cs @@ -0,0 +1,73 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; +using NewHorizons.External.Modules; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class TornadoInfo : GeneralPointPropInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum TornadoType + { + [EnumMember(Value = @"upwards")] Upwards = 0, + + [EnumMember(Value = @"downwards")] Downwards = 1, + + [EnumMember(Value = @"hurricane")] Hurricane = 2 + } + + [Obsolete("Downwards is deprecated. Use Type instead.")] public bool downwards; + + /// + /// Alternative to setting the position. Will choose a random place at this elevation. + /// + public float elevation; + + /// + /// The height of this tornado. + /// + [DefaultValue(30f)] public float height = 30f; + + /// + /// The colour of the tornado. + /// + public MColor tint; + + /// + /// What type of cyclone should this be? Upwards and downwards are both tornados and will push in that direction. + /// + [DefaultValue("upwards")] public TornadoType type = TornadoType.Upwards; + + /// + /// Angular distance from the starting position that it will wander, in terms of the angle around the x-axis. + /// + [DefaultValue(45f)] public float wanderDegreesX = 45f; + + /// + /// Angular distance from the starting position that it will wander, in terms of the angle around the z-axis. + /// + [DefaultValue(45f)] public float wanderDegreesZ = 45f; + + /// + /// The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around + /// 0.1. + /// + public float wanderRate; + + /// + /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. + /// + public float audioDistance; + + /// + /// Fluid type for sounds/effects when colliding with this tornado. + /// + [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud; + } +} diff --git a/NewHorizons/External/Props/VolcanoInfo.cs b/NewHorizons/External/Props/VolcanoInfo.cs new file mode 100644 index 000000000..9c891aa6c --- /dev/null +++ b/NewHorizons/External/Props/VolcanoInfo.cs @@ -0,0 +1,50 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using Newtonsoft.Json; + +namespace NewHorizons.External.Props +{ + [JsonObject] + public class VolcanoInfo : GeneralPointPropInfo + { + /// + /// The colour of the meteor's lava. + /// + public MColor lavaTint; + + /// + /// Maximum time between meteor launches. + /// + [DefaultValue(20f)] + public float maxInterval = 20f; + + /// + /// Maximum random speed at which meteors are launched. + /// + [DefaultValue(150f)] + public float maxLaunchSpeed = 150f; + + /// + /// Minimum time between meteor launches. + /// + [DefaultValue(5f)] + public float minInterval = 5f; + + /// + /// Minimum random speed at which meteors are launched. + /// + [DefaultValue(50f)] + public float minLaunchSpeed = 50f; + + /// + /// Scale of the meteors. + /// + public float scale = 1; + + /// + /// The colour of the meteor's stone. + /// + public MColor stoneTint; + } +} diff --git a/NewHorizons/External/Volumes/AudioVolumeInfo.cs b/NewHorizons/External/Volumes/AudioVolumeInfo.cs new file mode 100644 index 000000000..e5a90b882 --- /dev/null +++ b/NewHorizons/External/Volumes/AudioVolumeInfo.cs @@ -0,0 +1,88 @@ +using NewHorizons.External.Modules; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class AudioVolumeInfo : PriorityVolumeInfo + { + /// + /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. + /// + public string audio; + + [DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM; + + /// + /// The audio track of this audio volume + /// + [DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment; + + /// + /// Whether to loop this audio while in this audio volume or just play it once + /// + [DefaultValue(true)] public bool loop = true; + + /// + /// The loudness of the audio + /// + [Range(0f, 1f)] + [DefaultValue(1f)] + public float volume = 1f; + + /// + /// How long it will take to fade this sound in and out when entering/exiting this volume. + /// + [DefaultValue(2f)] + public float fadeSeconds = 2f; + + /// + /// Play the sound instantly without any fading. + /// + public bool noFadeFromBeginning; + + /// + /// Randomize what time the audio starts at. + /// + public bool randomizePlayhead; + + /// + /// Pause the music when exiting the volume. + /// + public bool pauseOnFadeOut; + + + [JsonConverter(typeof(StringEnumConverter))] + public enum ClipSelectionType + { + [EnumMember(Value = @"random")] RANDOM, + [EnumMember(Value = @"sequential")] SEQUENTIAL, + [EnumMember(Value = @"manual")] MANUAL + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum AudioMixerTrackName + { + [EnumMember(Value = @"undefined")] Undefined = 0, + [EnumMember(Value = @"menu")] Menu = 1, + [EnumMember(Value = @"music")] Music = 2, + [EnumMember(Value = @"environment")] Environment = 4, + [EnumMember(Value = @"environmentUnfiltered")] Environment_Unfiltered = 5, + [EnumMember(Value = @"endTimesSfx")] EndTimes_SFX = 8, + [EnumMember(Value = @"signal")] Signal = 16, + [EnumMember(Value = @"death")] Death = 32, + [EnumMember(Value = @"player")] Player = 64, + [EnumMember(Value = @"playerExternal")] Player_External = 65, + [EnumMember(Value = @"ship")] Ship = 128, + [EnumMember(Value = @"map")] Map = 256, + [EnumMember(Value = @"endTimesMusic")] EndTimes_Music = 512, + [EnumMember(Value = @"muffleWhileRafting")] MuffleWhileRafting = 1024, + [EnumMember(Value = @"muffleIndoors")] MuffleIndoors = 2048, + [EnumMember(Value = @"slideReelMusic")] SlideReelMusic = 4096, + } + } +} diff --git a/NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs b/NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs new file mode 100644 index 000000000..a68405400 --- /dev/null +++ b/NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class ChangeStarSystemVolumeInfo : VolumeInfo + { + /// + /// The star system that entering this volume will send you to. + /// + [DefaultValue("SolarSystem")] + public string targetStarSystem; + } +} + diff --git a/NewHorizons/External/Volumes/DestructionVolumeInfo.cs b/NewHorizons/External/Volumes/DestructionVolumeInfo.cs new file mode 100644 index 000000000..27359f0ff --- /dev/null +++ b/NewHorizons/External/Volumes/DestructionVolumeInfo.cs @@ -0,0 +1,37 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class DestructionVolumeInfo : VanishVolumeInfo + { + /// + /// The type of death the player will have if they enter this volume. + /// + [DefaultValue("default")] public DeathType deathType = DeathType.Default; + + [JsonConverter(typeof(StringEnumConverter))] + public enum DeathType + { + [EnumMember(Value = @"default")] Default, + [EnumMember(Value = @"impact")] Impact, + [EnumMember(Value = @"asphyxiation")] Asphyxiation, + [EnumMember(Value = @"energy")] Energy, + [EnumMember(Value = @"supernova")] Supernova, + [EnumMember(Value = @"digestion")] Digestion, + [EnumMember(Value = @"bigBang")] BigBang, + [EnumMember(Value = @"crushed")] Crushed, + [EnumMember(Value = @"meditation")] Meditation, + [EnumMember(Value = @"timeLoop")] TimeLoop, + [EnumMember(Value = @"lava")] Lava, + [EnumMember(Value = @"blackHole")] BlackHole, + [EnumMember(Value = @"dream")] Dream, + [EnumMember(Value = @"dreamExplosion")] DreamExplosion, + [EnumMember(Value = @"crushedByElevator")] CrushedByElevator + } + } +} + diff --git a/NewHorizons/External/Volumes/FluidVolumeInfo.cs b/NewHorizons/External/Volumes/FluidVolumeInfo.cs new file mode 100644 index 000000000..fe9315419 --- /dev/null +++ b/NewHorizons/External/Volumes/FluidVolumeInfo.cs @@ -0,0 +1,49 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class FluidVolumeInfo : PriorityVolumeInfo + { + /// + /// Density of the fluid. The higher the density, the harder it is to go through this fluid. + /// + [DefaultValue(1.2f)] public float density = 1.2f; + + /// + /// The type of fluid for this volume. + /// + public FluidType type; + + /// + /// Should the player and rafts align to this fluid. + /// + [DefaultValue(true)] public bool alignmentFluid = true; + + /// + /// Should the ship align to the fluid by rolling. + /// + public bool allowShipAutoroll; + + /// + /// Disable this fluid volume immediately? + /// + public bool disableOnStart; + + [JsonConverter(typeof(StringEnumConverter))] + public enum FluidType + { + [EnumMember(Value = @"none")] NONE = 0, + [EnumMember(Value = @"air")] AIR, + [EnumMember(Value = @"water")] WATER, + [EnumMember(Value = @"cloud")] CLOUD, + [EnumMember(Value = @"sand")] SAND, + [EnumMember(Value = @"plasma")] PLASMA, + [EnumMember(Value = @"fog")] FOG + } + } +} + diff --git a/NewHorizons/External/Volumes/HazardVolumeInfo.cs b/NewHorizons/External/Volumes/HazardVolumeInfo.cs new file mode 100644 index 000000000..8d81a50a7 --- /dev/null +++ b/NewHorizons/External/Volumes/HazardVolumeInfo.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class HazardVolumeInfo : VolumeInfo + { + /// + /// The type of hazard for this volume. + /// + [DefaultValue("general")] public HazardType type = HazardType.GENERAL; + + /// + /// The amount of damage you will take per second while inside this volume. + /// + [DefaultValue(10f)] public float damagePerSecond = 10f; + + /// + /// The type of damage you will take when you first touch this volume. + /// + [DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact; + + /// + /// The amount of damage you will take when you first touch this volume. + /// + public float firstContactDamage; + + [JsonConverter(typeof(StringEnumConverter))] + public enum HazardType + { + [EnumMember(Value = @"none")] NONE = 0, + [EnumMember(Value = @"general")] GENERAL = 1, + [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2, + [EnumMember(Value = @"heat")] HEAT = 4, + [EnumMember(Value = @"fire")] FIRE = 8, + [EnumMember(Value = @"sandfall")] SANDFALL = 16, + [EnumMember(Value = @"electricity")] ELECTRICITY = 32, + [EnumMember(Value = @"rapids")] RAPIDS = 64, + [EnumMember(Value = @"riverHeat")] RIVERHEAT = 128, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum InstantDamageType + { + [EnumMember(Value = @"impact")] Impact, + [EnumMember(Value = @"puncture")] Puncture, + [EnumMember(Value = @"electrical")] Electrical + } + } +} + diff --git a/NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs b/NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs new file mode 100644 index 000000000..b69c9f2dd --- /dev/null +++ b/NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class LoadCreditsVolumeInfo : VolumeInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum CreditsType + { + [EnumMember(Value = @"fast")] Fast = 0, + + [EnumMember(Value = @"final")] Final = 1, + + [EnumMember(Value = @"kazoo")] Kazoo = 2 + } + + [DefaultValue("fast")] + public CreditsType creditsType = CreditsType.Fast; + } +} + diff --git a/NewHorizons/External/Volumes/NotificationVolumeInfo.cs b/NewHorizons/External/Volumes/NotificationVolumeInfo.cs new file mode 100644 index 000000000..ac6439b7b --- /dev/null +++ b/NewHorizons/External/Volumes/NotificationVolumeInfo.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class NotificationVolumeInfo : VolumeInfo + { + /// + /// What the notification will show for. + /// + [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; + + /// + /// The notification that will play when you enter this volume. + /// + public NotificationInfo entryNotification; + + /// + /// The notification that will play when you exit this volume. + /// + public NotificationInfo exitNotification; + + + [JsonObject] + public class NotificationInfo + { + /// + /// The message that will be displayed. + /// + public string displayMessage; + + /// + /// The duration this notification will be displayed. + /// + [DefaultValue(5f)] public float duration = 5f; + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NotificationTarget + { + [EnumMember(Value = @"all")] All = 0, + [EnumMember(Value = @"ship")] Ship = 1, + [EnumMember(Value = @"player")] Player = 2, + } + } +} + diff --git a/NewHorizons/External/Volumes/OxygenVolumeInfo.cs b/NewHorizons/External/Volumes/OxygenVolumeInfo.cs new file mode 100644 index 000000000..abb087825 --- /dev/null +++ b/NewHorizons/External/Volumes/OxygenVolumeInfo.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class OxygenVolumeInfo : VolumeInfo + { + /// + /// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled". + /// + public bool treeVolume; + + /// + /// Whether to play the oxygen tank refill sound or just fill quietly. + /// + [DefaultValue(true)] public bool playRefillAudio = true; + } +} + diff --git a/NewHorizons/External/Volumes/PriorityVolumeInfo.cs b/NewHorizons/External/Volumes/PriorityVolumeInfo.cs new file mode 100644 index 000000000..b514e8173 --- /dev/null +++ b/NewHorizons/External/Volumes/PriorityVolumeInfo.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class PriorityVolumeInfo : VolumeInfo + { + /// + /// The layer of this volume. + /// + [DefaultValue(0)] + public int layer = 0; + + /// + /// The priority for this volume's effects to be applied. + /// Ex, a player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity. + /// + [DefaultValue(1)] + public int priority = 1; + } +} + diff --git a/NewHorizons/External/Volumes/RevealVolumeInfo.cs b/NewHorizons/External/Volumes/RevealVolumeInfo.cs new file mode 100644 index 000000000..f74be55ff --- /dev/null +++ b/NewHorizons/External/Volumes/RevealVolumeInfo.cs @@ -0,0 +1,64 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System.ComponentModel; +using System.Runtime.Serialization; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class RevealVolumeInfo : VolumeInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum RevealVolumeType + { + [EnumMember(Value = @"enter")] Enter = 0, + + [EnumMember(Value = @"observe")] Observe = 1, + + [EnumMember(Value = @"snapshot")] Snapshot = 2 + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum EnterType + { + [EnumMember(Value = @"both")] Both = 0, + + [EnumMember(Value = @"player")] Player = 1, + + [EnumMember(Value = @"probe")] Probe = 2 + } + + /// + /// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only) + /// + [DefaultValue(180f)] + public float maxAngle = 180f; // Observe Only + + /// + /// The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only) + /// + [DefaultValue(-1f)] + public float maxDistance = -1f; // Snapshot & Observe Only + + /// + /// What needs to be done to the volume to unlock the facts + /// + [DefaultValue("enter")] public RevealVolumeType revealOn = RevealVolumeType.Enter; + + /// + /// What can enter the volume to unlock the facts (`enter` only) + /// + [DefaultValue("both")] public EnterType revealFor = EnterType.Both; + + /// + /// A list of facts to reveal + /// + public string[] reveals; + + /// + /// An achievement to unlock. Optional. + /// + public string achievementID; + } +} + diff --git a/NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs b/NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs new file mode 100644 index 000000000..3e6416374 --- /dev/null +++ b/NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class SpeedTrapVolumeInfo : VolumeInfo + { + /// + /// The speed the volume will slow you down to when you enter it. + /// + [DefaultValue(10f)] + public float speedLimit = 10f; + + /// + /// How fast it will slow down the player to the speed limit. + /// + [DefaultValue(3f)] + public float acceleration = 3f; + } +} + diff --git a/NewHorizons/External/Volumes/VanishVolumeInfo.cs b/NewHorizons/External/Volumes/VanishVolumeInfo.cs new file mode 100644 index 000000000..6b592ce83 --- /dev/null +++ b/NewHorizons/External/Volumes/VanishVolumeInfo.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Volumes +{ + [JsonObject] + public class VanishVolumeInfo : VolumeInfo + { + /// + /// Whether the bodies will shrink when they enter this volume or just disappear instantly. + /// + [DefaultValue(true)] public bool shrinkBodies = true; + + /// + /// Whether this volume only affects the player and ship. + /// + public bool onlyAffectsPlayerAndShip; + } +} + diff --git a/NewHorizons/External/Volumes/VolumeInfo.cs b/NewHorizons/External/Volumes/VolumeInfo.cs new file mode 100644 index 000000000..645bf267c --- /dev/null +++ b/NewHorizons/External/Volumes/VolumeInfo.cs @@ -0,0 +1,121 @@ +using NewHorizons.External.Props; +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Volumes +{ + /*[JsonObject] + public class VolumesModule + { + /// + /// Add audio volumes to this planet. + /// + public AudioVolumeInfo[] audioVolumes; + + /// + /// Add destruction volumes to this planet. + /// + public DestructionVolumeInfo[] destructionVolumes; + + /// + /// Add fluid volumes to this planet. + /// + public FluidVolumeInfo[] fluidVolumes; + + /// + /// Add hazard volumes to this planet. + /// + public HazardVolumeInfo[] hazardVolumes; + + /// + /// Add interference volumes to this planet. + /// + public VolumeInfo[] interferenceVolumes; + + /// + /// Add insulating volumes to this planet. These will stop electricty hazard volumes from affecting you (just like the jellyfish). + /// + public VolumeInfo[] insulatingVolumes; + + /// + /// Add light source volumes to this planet. These will activate rafts and other light detectors. + /// + public VolumeInfo[] lightSourceVolumes; + + /// + /// Add map restriction volumes to this planet. + /// + public VolumeInfo[] mapRestrictionVolumes; + + /// + /// Add notification volumes to this planet. + /// + public NotificationVolumeInfo[] notificationVolumes; + + /// + /// Add oxygen volumes to this planet. + /// + public OxygenVolumeInfo[] oxygenVolumes; + + /// + /// Add probe-specific volumes to this planet. + /// + public ProbeModule probe; + + /// + /// Add reference frame blocker volumes to this planet. These will stop the player from seeing/targeting any reference frames. + /// + public VolumeInfo[] referenceFrameBlockerVolumes; + + /// + /// Add triggers that reveal parts of the ship log on this planet. + /// + public RevealVolumeInfo[] revealVolumes; + + /// + /// Add reverb volumes to this planet. Great for echoes in caves. + /// + public VolumeInfo[] reverbVolumes; + + /// + /// Add ruleset volumes to this planet. + /// + public RulesetModule rulesets; + + /// + /// Add speed trap volumes to this planet. Slows down the player when they enter this volume. + /// + public SpeedTrapVolumeInfo[] speedTrapVolumes; + + /// + /// Add visor effect volumes to this planet. + /// + public VisorEffectModule visorEffects; + + /// + /// Add zero-gravity volumes to this planet. + /// Good for surrounding planets which are using a static position to stop the player being pulled away. + /// + public PriorityVolumeInfo[] zeroGravityVolumes; + + /// + /// Entering this volume will load a new solar system. + /// + public ChangeStarSystemVolumeInfo[] solarSystemVolume; + + /// + /// Enter this volume to be sent to the end credits scene + /// + public LoadCreditsVolumeInfo[] creditsVolume;*/ + + [JsonObject] + public class VolumeInfo : GeneralPointPropInfo + { + /// + /// The radius of this volume. + /// + [DefaultValue(1f)] + public float radius = 1f; + } +} + diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index ce358343a..b276bf68e 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -12,6 +12,7 @@ using UnityEngine; using UnityEngine.Events; using Logger = NewHorizons.Utility.Logger; +using NewHorizons.External.Props; namespace NewHorizons { @@ -158,7 +159,7 @@ public object QuerySystem(Type outType, string jsonPath) float scale, bool alignWithNormal) { var prefab = SearchUtilities.Find(propToCopyPath); - var detailInfo = new PropModule.DetailInfo() { + var detailInfo = new DetailInfo() { position = position, rotation = eulerAngles, scale = scale, @@ -171,7 +172,7 @@ public object QuerySystem(Type outType, string jsonPath) float sourceRadius = 1f, float detectionRadius = 20f, float identificationRadius = 10f, bool insideCloak = false, bool onlyAudibleToScope = true, string reveals = "") { - var info = new SignalModule.SignalInfo() + var info = new SignalInfo() { audio = audio, detectionRadius = detectionRadius, @@ -192,7 +193,7 @@ public object QuerySystem(Type outType, string jsonPath) float range = 1f, string blockAfterPersistentCondition = null, float lookAtRadius = 1f, string pathToAnimController = null, float remoteTriggerRadius = 0f) { - var info = new PropModule.DialogueInfo() + var info = new DialogueInfo() { blockAfterPersistentCondition = blockAfterPersistentCondition, lookAtRadius = lookAtRadius, @@ -201,7 +202,7 @@ public object QuerySystem(Type outType, string jsonPath) radius = radius, range = range, xmlFile = xmlFile, - remoteTrigger = new PropModule.DialogueInfo.RemoteTriggerInfo() + remoteTrigger = new DialogueInfo.RemoteTriggerInfo() { position = null, radius = remoteTriggerRadius, diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index 04554fd14..affb71d79 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Configs; using NewHorizons.External.Modules; +using NewHorizons.External.Props; using NewHorizons.Handlers; using System.Collections.Generic; using System.Linq; @@ -22,7 +23,7 @@ private struct PropPlacementData public AstroObject body; public string system; public GameObject gameObject; - public PropModule.DetailInfo detailInfo; + public DetailInfo detailInfo; } // VASE @@ -149,7 +150,7 @@ public void PlaceObject(DebugRaycastData data) var sector = planetGO.GetComponentInChildren(); var prefab = SearchUtilities.Find(currentObject); - var detailInfo = new PropModule.DetailInfo() + var detailInfo = new DetailInfo() { position = data.pos, rotation = data.rot.eulerAngles, @@ -214,7 +215,7 @@ public void RegisterProp(AstroObject body, GameObject prop) RegisterProp_WithReturn(body, prop); } - private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject prop, string propPath = null, PropModule.DetailInfo detailInfo = null) + private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject prop, string propPath = null, DetailInfo detailInfo = null) { if (Main.Debug) { @@ -226,7 +227,7 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p Logger.LogVerbose($"Adding prop to {Main.Instance.CurrentStarSystem}::{body.name}"); - detailInfo = detailInfo == null ? new PropModule.DetailInfo() : detailInfo; + detailInfo = detailInfo == null ? new DetailInfo() : detailInfo; detailInfo.path = propPath == null ? currentObject : propPath; PropPlacementData data = new PropPlacementData @@ -241,14 +242,14 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p return data; } - public Dictionary GetPropsConfigByBody() + public Dictionary GetPropsConfigByBody() { var groupedProps = props .GroupBy(p => p.system + "." + p.body) .Select(grp => grp.ToList()) .ToList(); - Dictionary propConfigs = new Dictionary(); + Dictionary propConfigs = new Dictionary(); foreach (List bodyProps in groupedProps) { @@ -258,7 +259,7 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p Logger.LogVerbose("getting prop group for body " + body.name); //string bodyName = GetAstroObjectName(bodyProps[0].body); - PropModule.DetailInfo[] infoArray = new PropModule.DetailInfo[bodyProps.Count]; + DetailInfo[] infoArray = new DetailInfo[bodyProps.Count]; propConfigs[body] = infoArray; for (int i = 0; i < bodyProps.Count; i++) From c67b6bfc918184905749279c2dedd05fd172314b Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 16:43:29 +0000 Subject: [PATCH 027/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 9 ++------- NewHorizons/Schemas/star_system_schema.json | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index d25f9db34..948e932bb 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1065,7 +1065,7 @@ "type": "array", "description": "Add black/white-holes to this planet", "items": { - "$ref": "#/definitions/SingularityModule" + "$ref": "#/definitions/SingularityInfo" } }, "signals": { @@ -1825,11 +1825,6 @@ "type": "string", "description": "An optional rename of this object" }, - "isRelativeToGroup": { - "type": "boolean", - "description": "Whether the socket will be placed relative to the group it belongs to. Overrides `isRelativeToParent`", - "default": true - }, "probability": { "type": "number", "description": "The probability any props that are part of this group will occupy this socket", @@ -1980,7 +1975,7 @@ } } }, - "SingularityModule": { + "SingularityInfo": { "type": "object", "additionalProperties": false, "properties": { diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 12b9eaafd..e68cc2261 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -216,6 +216,11 @@ "rename": { "type": "string", "description": "An optional rename of this object" + }, + "hasPhysics": { + "type": "boolean", + "description": "Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.", + "default": true } } }, From b3d78369231e95b2e24977f668b2920e9f2654e4 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 11:50:55 -0500 Subject: [PATCH 028/119] Moved vessel hasPhysics field to a better location --- NewHorizons/External/Configs/StarSystemConfig.cs | 9 +++++---- NewHorizons/Handlers/VesselWarpHandler.cs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index b5a4dff82..a3e5d2980 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -191,6 +191,11 @@ public class VesselModule /// public string promptFact; + /// + /// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body. + /// + [DefaultValue(true)] public bool hasPhysics = true; + /// /// The location that the vessel will warp to. /// @@ -209,10 +214,6 @@ public class VesselModule [JsonObject] public class VesselInfo : GeneralSolarSystemPropInfo { - /// - /// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body. - /// - [DefaultValue(true)] public bool hasPhysics = true; } [JsonObject] diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index c18c27c61..f88dfb201 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -89,7 +89,7 @@ public static EyeSpawnPoint CreateVessel() VesselObject = vesselObject; var vesselAO = vesselObject.AddComponent(); - if (system.Config.Vessel?.vesselSpawn.hasPhysics ?? true) + if (system.Config.Vessel?.hasPhysics ?? true) { vesselAO._owRigidbody = vesselObject.GetComponent(); vesselObject.transform.parent = null; From 11e9cf8769dc8472b39cd032d316da24913d049d Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 16:53:33 +0000 Subject: [PATCH 029/119] Updated Schemas --- NewHorizons/Schemas/star_system_schema.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index e68cc2261..c31343262 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -143,6 +143,11 @@ "type": "string", "description": "A ship log fact which will make a prompt appear showing the coordinates when you're in the Vessel." }, + "hasPhysics": { + "type": "boolean", + "description": "Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.", + "default": true + }, "vesselSpawn": { "description": "The location that the vessel will warp to.", "$ref": "#/definitions/VesselInfo" @@ -216,11 +221,6 @@ "rename": { "type": "string", "description": "An optional rename of this object" - }, - "hasPhysics": { - "type": "boolean", - "description": "Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.", - "default": true } } }, From 6ecdc3d7a15d6df60ac22123b84b8eacad4fd18f Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 13:30:22 -0400 Subject: [PATCH 030/119] Rearrange and clean up patches --- .../CameraPatches/NomaiRemoteCameraPatches.cs | 4 +- .../NomaiRemoteCameraPlatformPatches.cs | 32 +++ .../{OWCameraPatch.cs => OWCameraPatches.cs} | 6 +- .../CameraPatches/ProbeCameraPatches.cs | 16 ++ .../Patches/CharacterDialogueTreePatches.cs | 26 -- .../CreditsEntryPatches.cs | 4 +- .../CreditsPatches.cs | 4 +- .../AlignToSurfaceFluidDetectorPatches.cs | 41 +++ .../PlayerFogWarpDetectorPatches.cs | 6 +- .../ProbeDestructionDetectorPatches.cs} | 24 +- .../CharacterDialogueTreePatches.cs | 41 +++ .../RemoteDialogueTriggerPatches.cs | 17 +- .../AutoSlideProjectorPatches.cs | 10 +- .../CloakFieldControllerPatches.cs} | 14 +- .../MindProjectorTriggerPatches.cs | 47 ++++ .../MindSlideProjectionPatches.cs | 35 +++ .../RaftControllerPatches.cs} | 54 +--- .../VisionTorchItemPatches.cs | 33 +++ .../Patches/EyeOfTheUniversePatches.cs | 53 ---- .../EyeVortexTriggerPatches.cs | 17 ++ .../EyeScenePatches/LoadManagerPatches.cs | 29 ++ .../SubmitActionLoadScenePatches.cs | 21 ++ NewHorizons/Patches/HUDPatches.cs | 124 --------- .../Patches/HUDPatches/HUDMarkerPatches.cs | 28 ++ .../HUDPatches/ProbeHUDMarkerPatches.cs | 44 +++ .../HUDPatches/ShipHUDMarkerPatches.cs | 43 +++ .../ShipLogEntryHUDMarkerPatches.cs | 26 ++ NewHorizons/Patches/LocatorPatches.cs | 10 +- .../MapPatches/CanvasMapMarkerPatches.cs | 19 ++ .../{ => MapPatches}/MapControllerPatches.cs | 18 +- .../ReferenceFramePatches.cs} | 25 +- .../ReferenceFrameTrackerPatches.cs | 15 ++ ...rPatches.cs => MeteorControllerPatches.cs} | 6 +- .../{ => PlayerPatches}/PlayerDataPatches.cs | 32 +-- .../PlayerSpawnerPatches.cs | 7 +- .../{ => PlayerPatches}/PlayerStatePatches.cs | 8 +- NewHorizons/Patches/ProbeLauncherPatches.cs | 14 - .../Patches/ProxyPatches/ProxyBodyPatches.cs | 15 ++ .../ProxyPlanetPatches.cs} | 14 +- .../SunProxyEffectControllerPatches.cs | 22 ++ NewHorizons/Patches/RemotePatches.cs | 153 ----------- ...ShapePatches.cs => ShapeManagerPatches.cs} | 6 +- NewHorizons/Patches/ShipLogPatches.cs | 254 ------------------ .../ShipLogAstroObjectPatches.cs | 52 ++++ .../ShipLogPatches/ShipLogFactPatches.cs | 24 ++ .../ShipLogPatches/ShipLogManagerPatches.cs | 135 ++++++++++ .../ShipLogPatches/ShipLogMapModePatches.cs | 47 ++++ .../ShipLogSandFunnelPatches.cs | 22 ++ .../ShipLogPatches/UIStyleManagerPatches.cs | 25 ++ .../{ => SignalPatches}/AudioSignalPatches.cs | 107 +++----- .../SignalscopePatches.cs} | 19 +- .../TravelerAudioManagerPatches.cs | 15 ++ NewHorizons/Patches/SingularityPatches.cs | 51 ---- NewHorizons/Patches/StreamingPatches.cs | 26 -- .../NomaiRemoteCameraStreamingPatches.cs | 47 ++++ .../StreamingManagerPatches.cs | 18 ++ .../StreamingPatches/UnityLoggerPatches.cs | 17 ++ NewHorizons/Patches/SunPatches.cs | 65 ----- .../SunPatches/SunControllerPatches.cs | 18 ++ .../SunPatches/SunLightParamUpdaterPatches.cs | 31 +++ .../SunSurfaceAudioControllerPatches.cs | 22 ++ NewHorizons/Patches/TimeLoopPatches.cs | 43 +-- .../ToolPatches/ProbeLauncherPatches.cs | 15 ++ .../ToolPatches/SurveyorProbePatches.cs | 18 ++ .../ToolModeSwapperPatches.cs | 20 +- NewHorizons/Patches/VisionTorchPatches.cs | 108 -------- .../VolumePatches/BlackHoleVolumePatches.cs | 15 ++ .../DestructionVolumePatches.cs | 2 +- .../VolumePatches/FluidVolumePatches.cs | 20 ++ .../FogWarpVolumePatches.cs} | 12 +- .../VolumePatches/VanishVolumePatches.cs | 15 ++ .../VolumePatches/WhiteHoleVolumePatches.cs | 28 ++ .../EyeCoordinatePromptTriggerPatches.cs | 2 +- .../NomaiCoordinateInterfacePatches.cs | 18 ++ .../ShipCockpitControllerPatches.cs} | 11 +- .../VesselWarpControllerPatches.cs} | 28 +- 76 files changed, 1288 insertions(+), 1225 deletions(-) create mode 100644 NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPlatformPatches.cs rename NewHorizons/Patches/CameraPatches/{OWCameraPatch.cs => OWCameraPatches.cs} (83%) create mode 100644 NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs delete mode 100644 NewHorizons/Patches/CharacterDialogueTreePatches.cs rename NewHorizons/Patches/{CreditsScene => CreditsScenePatches}/CreditsEntryPatches.cs (90%) rename NewHorizons/Patches/{CreditsScene => CreditsScenePatches}/CreditsPatches.cs (78%) create mode 100644 NewHorizons/Patches/DetectorPatches/AlignToSurfaceFluidDetectorPatches.cs rename NewHorizons/Patches/{ => DetectorPatches}/PlayerFogWarpDetectorPatches.cs (86%) rename NewHorizons/Patches/{AchievementPatches.cs => DetectorPatches/ProbeDestructionDetectorPatches.cs} (61%) create mode 100644 NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs rename NewHorizons/Patches/{ => DialoguePatches}/RemoteDialogueTriggerPatches.cs (72%) rename NewHorizons/Patches/{ => EchoesOfTheEyePatches}/AutoSlideProjectorPatches.cs (51%) rename NewHorizons/Patches/{CloakPatches.cs => EchoesOfTheEyePatches/CloakFieldControllerPatches.cs} (62%) create mode 100644 NewHorizons/Patches/EchoesOfTheEyePatches/MindProjectorTriggerPatches.cs create mode 100644 NewHorizons/Patches/EchoesOfTheEyePatches/MindSlideProjectionPatches.cs rename NewHorizons/Patches/{RaftPatches.cs => EchoesOfTheEyePatches/RaftControllerPatches.cs} (55%) create mode 100644 NewHorizons/Patches/EchoesOfTheEyePatches/VisionTorchItemPatches.cs delete mode 100644 NewHorizons/Patches/EyeOfTheUniversePatches.cs create mode 100644 NewHorizons/Patches/EyeScenePatches/EyeVortexTriggerPatches.cs create mode 100644 NewHorizons/Patches/EyeScenePatches/LoadManagerPatches.cs create mode 100644 NewHorizons/Patches/EyeScenePatches/SubmitActionLoadScenePatches.cs delete mode 100644 NewHorizons/Patches/HUDPatches.cs create mode 100644 NewHorizons/Patches/HUDPatches/HUDMarkerPatches.cs create mode 100644 NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs create mode 100644 NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs create mode 100644 NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs create mode 100644 NewHorizons/Patches/MapPatches/CanvasMapMarkerPatches.cs rename NewHorizons/Patches/{ => MapPatches}/MapControllerPatches.cs (66%) rename NewHorizons/Patches/{TranslationPatches.cs => MapPatches/ReferenceFramePatches.cs} (50%) create mode 100644 NewHorizons/Patches/MapPatches/ReferenceFrameTrackerPatches.cs rename NewHorizons/Patches/{MeteorPatches.cs => MeteorControllerPatches.cs} (65%) rename NewHorizons/Patches/{ => PlayerPatches}/PlayerDataPatches.cs (82%) rename NewHorizons/Patches/{ => PlayerPatches}/PlayerSpawnerPatches.cs (83%) rename NewHorizons/Patches/{ => PlayerPatches}/PlayerStatePatches.cs (81%) delete mode 100644 NewHorizons/Patches/ProbeLauncherPatches.cs create mode 100644 NewHorizons/Patches/ProxyPatches/ProxyBodyPatches.cs rename NewHorizons/Patches/{ProxyBodyPatches.cs => ProxyPatches/ProxyPlanetPatches.cs} (89%) create mode 100644 NewHorizons/Patches/ProxyPatches/SunProxyEffectControllerPatches.cs delete mode 100644 NewHorizons/Patches/RemotePatches.cs rename NewHorizons/Patches/{ShapePatches.cs => ShapeManagerPatches.cs} (85%) delete mode 100644 NewHorizons/Patches/ShipLogPatches.cs create mode 100644 NewHorizons/Patches/ShipLogPatches/ShipLogAstroObjectPatches.cs create mode 100644 NewHorizons/Patches/ShipLogPatches/ShipLogFactPatches.cs create mode 100644 NewHorizons/Patches/ShipLogPatches/ShipLogManagerPatches.cs create mode 100644 NewHorizons/Patches/ShipLogPatches/ShipLogMapModePatches.cs create mode 100644 NewHorizons/Patches/ShipLogPatches/ShipLogSandFunnelPatches.cs create mode 100644 NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs rename NewHorizons/Patches/{ => SignalPatches}/AudioSignalPatches.cs (66%) rename NewHorizons/Patches/{SignalScopePatches.cs => SignalPatches/SignalscopePatches.cs} (59%) create mode 100644 NewHorizons/Patches/SignalPatches/TravelerAudioManagerPatches.cs delete mode 100644 NewHorizons/Patches/SingularityPatches.cs delete mode 100644 NewHorizons/Patches/StreamingPatches.cs create mode 100644 NewHorizons/Patches/StreamingPatches/NomaiRemoteCameraStreamingPatches.cs create mode 100644 NewHorizons/Patches/StreamingPatches/StreamingManagerPatches.cs create mode 100644 NewHorizons/Patches/StreamingPatches/UnityLoggerPatches.cs delete mode 100644 NewHorizons/Patches/SunPatches.cs create mode 100644 NewHorizons/Patches/SunPatches/SunControllerPatches.cs create mode 100644 NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs create mode 100644 NewHorizons/Patches/SunPatches/SunSurfaceAudioControllerPatches.cs create mode 100644 NewHorizons/Patches/ToolPatches/ProbeLauncherPatches.cs create mode 100644 NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs rename NewHorizons/Patches/{ => ToolPatches}/ToolModeSwapperPatches.cs (73%) delete mode 100644 NewHorizons/Patches/VisionTorchPatches.cs create mode 100644 NewHorizons/Patches/VolumePatches/BlackHoleVolumePatches.cs rename NewHorizons/Patches/{ => VolumePatches}/DestructionVolumePatches.cs (95%) create mode 100644 NewHorizons/Patches/VolumePatches/FluidVolumePatches.cs rename NewHorizons/Patches/{BramblePatches.cs => VolumePatches/FogWarpVolumePatches.cs} (80%) create mode 100644 NewHorizons/Patches/VolumePatches/VanishVolumePatches.cs create mode 100644 NewHorizons/Patches/VolumePatches/WhiteHoleVolumePatches.cs rename NewHorizons/Patches/{ => WarpPatches}/EyeCoordinatePromptTriggerPatches.cs (96%) create mode 100644 NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs rename NewHorizons/Patches/{WarpDrivePatches.cs => WarpPatches/ShipCockpitControllerPatches.cs} (77%) rename NewHorizons/Patches/{NomaiCoordinatePatches.cs => WarpPatches/VesselWarpControllerPatches.cs} (69%) diff --git a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs index 29719c0e9..02e3a8be8 100644 --- a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs +++ b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs @@ -4,11 +4,11 @@ namespace NewHorizons.Patches.CameraPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(NomaiRemoteCamera))] public static class NomaiRemoteCameraPatches { [HarmonyPostfix] - [HarmonyPatch(typeof(NomaiRemoteCamera), nameof(NomaiRemoteCamera.Awake))] + [HarmonyPatch(nameof(NomaiRemoteCamera.Awake))] public static void NomaiRemoteCamera_Awake(NomaiRemoteCamera __instance) { // Ensures that if the player is visible from the remote camera they look normal diff --git a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPlatformPatches.cs b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPlatformPatches.cs new file mode 100644 index 000000000..a2c7a5327 --- /dev/null +++ b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPlatformPatches.cs @@ -0,0 +1,32 @@ +using HarmonyLib; +using NewHorizons.Handlers; + +namespace NewHorizons.Patches.CameraPatches +{ + [HarmonyPatch(typeof(NomaiRemoteCameraPlatform))] + public static class NomaiRemoteCameraPlatformPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(NomaiRemoteCameraPlatform.IDToPlanetString))] + public static bool NomaiRemoteCameraPlatform_IDToPlanetString(NomaiRemoteCameraPlatform.ID id, out string __result) + { + __result = id switch + { + NomaiRemoteCameraPlatform.ID.None => "None", + NomaiRemoteCameraPlatform.ID.SunStation => UITextLibrary.GetString(UITextType.LocationSS), + NomaiRemoteCameraPlatform.ID.HGT_TimeLoop => UITextLibrary.GetString(UITextType.LocationTT), + NomaiRemoteCameraPlatform.ID.TH_Mine => UITextLibrary.GetString(UITextType.LocationTH), + NomaiRemoteCameraPlatform.ID.THM_EyeLocator => UITextLibrary.GetString(UITextType.LocationTHMoon), + NomaiRemoteCameraPlatform.ID.BH_Observatory or NomaiRemoteCameraPlatform.ID.BH_GravityCannon or NomaiRemoteCameraPlatform.ID.BH_QuantumFragment or NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge or NomaiRemoteCameraPlatform.ID.BH_NorthPole => UITextLibrary.GetString(UITextType.LocationBH), + NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1 or NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2 or NomaiRemoteCameraPlatform.ID.GD_StatueIsland => UITextLibrary.GetString(UITextType.LocationGD), + NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule => UITextLibrary.GetString(UITextType.LocationOPC_Module3), + NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule => UITextLibrary.GetString(UITextType.LocationOPC_Module2), + NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule => UITextLibrary.GetString(UITextType.LocationOPC_Module1), + NomaiRemoteCameraPlatform.ID.VM_Interior => UITextLibrary.GetString(UITextType.LocationBHMoon), + NomaiRemoteCameraPlatform.ID.HGT_TLE => UITextLibrary.GetString(UITextType.LocationCT), + _ => RemoteHandler.GetPlatformIDName(id), + }; + return false; + } + } +} diff --git a/NewHorizons/Patches/CameraPatches/OWCameraPatch.cs b/NewHorizons/Patches/CameraPatches/OWCameraPatches.cs similarity index 83% rename from NewHorizons/Patches/CameraPatches/OWCameraPatch.cs rename to NewHorizons/Patches/CameraPatches/OWCameraPatches.cs index db9251c11..efa9aba6b 100644 --- a/NewHorizons/Patches/CameraPatches/OWCameraPatch.cs +++ b/NewHorizons/Patches/CameraPatches/OWCameraPatches.cs @@ -2,11 +2,11 @@ namespace NewHorizons.Patches.CameraPatches { - [HarmonyPatch] - public static class OWCameraPatch + [HarmonyPatch(typeof(OWCamera))] + public static class OWCameraPatches { [HarmonyPostfix] - [HarmonyPatch(typeof(OWCamera), nameof(OWCamera.Awake))] + [HarmonyPatch(nameof(OWCamera.Awake))] public static void OnOWCameraAwake(OWCamera __instance) { if (Main.SystemDict.TryGetValue(Main.Instance.CurrentStarSystem, out var system) && system?.Config?.farClipPlaneOverride != 0f) diff --git a/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs b/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs new file mode 100644 index 000000000..481c0f30f --- /dev/null +++ b/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs @@ -0,0 +1,16 @@ +using HarmonyLib; +using NewHorizons.Handlers; + +namespace NewHorizons.Patches.CameraPatches +{ + [HarmonyPatch(typeof(ProbeCamera))] + public static class ProbeCameraPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(ProbeCamera.HasInterference))] + public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result) + { + __result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe())); + } + } +} diff --git a/NewHorizons/Patches/CharacterDialogueTreePatches.cs b/NewHorizons/Patches/CharacterDialogueTreePatches.cs deleted file mode 100644 index 2d4a8831c..000000000 --- a/NewHorizons/Patches/CharacterDialogueTreePatches.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; - -namespace NewHorizons.Patches; - -[HarmonyPatch] -internal static class CharacterDialogueTreePatches -{ - [HarmonyPrefix] - [HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.Awake))] - private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance) - { - GlobalMessenger.AddListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.OnDestroy))] - private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance) - { - GlobalMessenger.RemoveListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint); - } - - private static void OnAttachPlayerToPoint(this CharacterDialogueTree characterDialogueTree, OWRigidbody rigidbody) - { - characterDialogueTree.EndConversation(); - } -} diff --git a/NewHorizons/Patches/CreditsScene/CreditsEntryPatches.cs b/NewHorizons/Patches/CreditsScenePatches/CreditsEntryPatches.cs similarity index 90% rename from NewHorizons/Patches/CreditsScene/CreditsEntryPatches.cs rename to NewHorizons/Patches/CreditsScenePatches/CreditsEntryPatches.cs index fe255ed61..a5e10707e 100644 --- a/NewHorizons/Patches/CreditsScene/CreditsEntryPatches.cs +++ b/NewHorizons/Patches/CreditsScenePatches/CreditsEntryPatches.cs @@ -4,11 +4,11 @@ namespace NewHorizons.Patches.CreditsScene { - [HarmonyPatch] + [HarmonyPatch(typeof(CreditsEntry))] public static class CreditsEntryPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(CreditsEntry), nameof(CreditsEntry.SetContents))] + [HarmonyPatch(nameof(CreditsEntry.SetContents))] public static bool CreditsEntry_SetContents(CreditsEntry __instance, string[] __0) { var columnTexts = __0; diff --git a/NewHorizons/Patches/CreditsScene/CreditsPatches.cs b/NewHorizons/Patches/CreditsScenePatches/CreditsPatches.cs similarity index 78% rename from NewHorizons/Patches/CreditsScene/CreditsPatches.cs rename to NewHorizons/Patches/CreditsScenePatches/CreditsPatches.cs index 724ef6960..787d2eada 100644 --- a/NewHorizons/Patches/CreditsScene/CreditsPatches.cs +++ b/NewHorizons/Patches/CreditsScenePatches/CreditsPatches.cs @@ -3,11 +3,11 @@ namespace NewHorizons.Patches.CreditsScene { - [HarmonyPatch] + [HarmonyPatch(typeof(Credits))] public static class CreditsPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(Credits), nameof(Credits.Start))] + [HarmonyPatch(nameof(Credits.Start))] public static void Credits_Start(Credits __instance) { CreditsHandler.AddCredits(__instance); diff --git a/NewHorizons/Patches/DetectorPatches/AlignToSurfaceFluidDetectorPatches.cs b/NewHorizons/Patches/DetectorPatches/AlignToSurfaceFluidDetectorPatches.cs new file mode 100644 index 000000000..7634cbd5b --- /dev/null +++ b/NewHorizons/Patches/DetectorPatches/AlignToSurfaceFluidDetectorPatches.cs @@ -0,0 +1,41 @@ +using HarmonyLib; +using UnityEngine; + +namespace NewHorizons.Patches.DetectorPatches +{ + [HarmonyPatch] + public static class AlignToSurfaceFluidDetectorPatches + { + [HarmonyReversePatch] + [HarmonyPatch(typeof(AsymmetricFluidDetector), nameof(AsymmetricFluidDetector.ManagedFixedUpdate))] + public static void AsymmetricFluidDetector_ManagedFixedUpdate(AsymmetricFluidDetector __instance) + { + // This is like doing base.FixedUpdate + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))] + public static bool AlignToSurfaceFluidDetector_ManagedFixedUpdate(AlignToSurfaceFluidDetector __instance) + { + if (__instance._alignmentFluid is not RadialFluidVolume) return true; + + // Mostly copy pasting from the AlignWithDirection class + AsymmetricFluidDetector_ManagedFixedUpdate(__instance); + + if (__instance._inAlignmentFluid) + { + // Both in world space + var currentDirection = __instance._owRigidbody.transform.up; + var alignmentDirection = (__instance.transform.position - __instance._alignmentFluid.transform.position).normalized; + var degreesToTarget = Vector3.Angle(currentDirection, alignmentDirection); + + var adjustedSlerpRate = Mathf.Clamp01(0.01f * degreesToTarget * Time.fixedDeltaTime); + + Vector3 a = OWPhysics.FromToAngularVelocity(currentDirection, alignmentDirection); + __instance._owRigidbody.AddAngularVelocityChange(a * adjustedSlerpRate); + } + + return false; + } + } +} diff --git a/NewHorizons/Patches/PlayerFogWarpDetectorPatches.cs b/NewHorizons/Patches/DetectorPatches/PlayerFogWarpDetectorPatches.cs similarity index 86% rename from NewHorizons/Patches/PlayerFogWarpDetectorPatches.cs rename to NewHorizons/Patches/DetectorPatches/PlayerFogWarpDetectorPatches.cs index 003484902..e9b894c17 100644 --- a/NewHorizons/Patches/PlayerFogWarpDetectorPatches.cs +++ b/NewHorizons/Patches/DetectorPatches/PlayerFogWarpDetectorPatches.cs @@ -1,15 +1,15 @@ using HarmonyLib; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.DetectorPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(PlayerFogWarpDetector))] public static class PlayerFogWarpDetectorPatches { // Morbius moment: they only let fog go away if there is a fog controller on the planet near you // However you can leave these volumes with fog on your screen, or have fog applied by a bramble node on a fogless planet [HarmonyPostfix] - [HarmonyPatch(typeof(PlayerFogWarpDetector), nameof(PlayerFogWarpDetector.LateUpdate))] + [HarmonyPatch(nameof(PlayerFogWarpDetector.LateUpdate))] public static void PlayerFogWarpDetector_LateUpdate(PlayerFogWarpDetector __instance) { if (PlanetaryFogController.GetActiveFogSphere() == null) diff --git a/NewHorizons/Patches/AchievementPatches.cs b/NewHorizons/Patches/DetectorPatches/ProbeDestructionDetectorPatches.cs similarity index 61% rename from NewHorizons/Patches/AchievementPatches.cs rename to NewHorizons/Patches/DetectorPatches/ProbeDestructionDetectorPatches.cs index 1c75e7d85..b73be6699 100644 --- a/NewHorizons/Patches/AchievementPatches.cs +++ b/NewHorizons/Patches/DetectorPatches/ProbeDestructionDetectorPatches.cs @@ -1,17 +1,15 @@ using HarmonyLib; -using NewHorizons.Components; -using NewHorizons.OtherMods.AchievementsPlus; using NewHorizons.OtherMods.AchievementsPlus.NH; -using System.Linq; +using NewHorizons.OtherMods.AchievementsPlus; using UnityEngine; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.DetectorPatches { - [HarmonyPatch] - public static class AchievementPatches + [HarmonyPatch(typeof(ProbeDestructionDetector))] + internal static class ProbeDestructionDetectorPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(ProbeDestructionDetector), nameof(ProbeDestructionDetector.FixedUpdate))] + [HarmonyPatch(nameof(ProbeDestructionDetector.FixedUpdate))] public static bool ProbeDestructionDetector_FixedUpdate(ProbeDestructionDetector __instance) { if (__instance._activeVolumes.Count > 0 && __instance._safetyVolumes.Count == 0) @@ -32,17 +30,5 @@ public static bool ProbeDestructionDetector_FixedUpdate(ProbeDestructionDetector __instance.enabled = false; return false; } - - [HarmonyPostfix] - [HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.StartConversation))] - public static void CharacterDialogueTree_StartConversation(CharacterDialogueTree __instance) - { - if (!AchievementHandler.Enabled) return; - - if (__instance is NHCharacterDialogueTree) - { - TalkToFiveCharactersAchievement.OnTalkedToCharacter(__instance._characterName); - } - } } } diff --git a/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs b/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs new file mode 100644 index 000000000..32cab4ad2 --- /dev/null +++ b/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs @@ -0,0 +1,41 @@ +using HarmonyLib; +using NewHorizons.Components; +using NewHorizons.OtherMods.AchievementsPlus.NH; +using NewHorizons.OtherMods.AchievementsPlus; + +namespace NewHorizons.Patches.DialoguePatches; + +[HarmonyPatch(typeof(CharacterDialogueTree))] +public static class CharacterDialogueTreePatches +{ + [HarmonyPrefix] + [HarmonyPatch(nameof(CharacterDialogueTree.Awake))] + private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance) + { + GlobalMessenger.AddListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint); + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(CharacterDialogueTree.OnDestroy))] + private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance) + { + GlobalMessenger.RemoveListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint); + } + + private static void OnAttachPlayerToPoint(this CharacterDialogueTree characterDialogueTree, OWRigidbody rigidbody) + { + characterDialogueTree.EndConversation(); + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(CharacterDialogueTree.StartConversation))] + public static void CharacterDialogueTree_StartConversation(CharacterDialogueTree __instance) + { + if (!AchievementHandler.Enabled) return; + + if (__instance is NHCharacterDialogueTree) + { + TalkToFiveCharactersAchievement.OnTalkedToCharacter(__instance._characterName); + } + } +} diff --git a/NewHorizons/Patches/RemoteDialogueTriggerPatches.cs b/NewHorizons/Patches/DialoguePatches/RemoteDialogueTriggerPatches.cs similarity index 72% rename from NewHorizons/Patches/RemoteDialogueTriggerPatches.cs rename to NewHorizons/Patches/DialoguePatches/RemoteDialogueTriggerPatches.cs index f6002b05f..330e578e5 100644 --- a/NewHorizons/Patches/RemoteDialogueTriggerPatches.cs +++ b/NewHorizons/Patches/DialoguePatches/RemoteDialogueTriggerPatches.cs @@ -1,19 +1,18 @@ using HarmonyLib; -using NewHorizons.Utility; -using System; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.DialoguePatches { - /// - /// Should fix a bug where disabled a CharacterDialogueTree makes its related RemoteDialogueTriggers softlock your game - /// - [HarmonyPatch] + [HarmonyPatch(typeof(RemoteDialogueTrigger))] public static class RemoteDialogueTriggerPatches { private static bool _wasLastDialogueInactive = false; + /// + /// Should fix a bug where disabled a CharacterDialogueTree makes its related RemoteDialogueTriggers softlock your game + /// + [HarmonyPostfix] - [HarmonyPatch(typeof(RemoteDialogueTrigger), nameof(RemoteDialogueTrigger.OnTriggerEnter))] + [HarmonyPatch(nameof(RemoteDialogueTrigger.OnTriggerEnter))] public static void RemoteDialogueTrigger_OnTriggerEnter(RemoteDialogueTrigger __instance) { if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue?.gameObject != null) @@ -27,7 +26,7 @@ public static void RemoteDialogueTrigger_OnTriggerEnter(RemoteDialogueTrigger __ } [HarmonyPrefix] - [HarmonyPatch(typeof(RemoteDialogueTrigger), nameof(RemoteDialogueTrigger.OnEndConversation))] + [HarmonyPatch(nameof(RemoteDialogueTrigger.OnEndConversation))] public static void RemoteDialogueTrigger_OnEndConversation(RemoteDialogueTrigger __instance) { if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue != null) diff --git a/NewHorizons/Patches/AutoSlideProjectorPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/AutoSlideProjectorPatches.cs similarity index 51% rename from NewHorizons/Patches/AutoSlideProjectorPatches.cs rename to NewHorizons/Patches/EchoesOfTheEyePatches/AutoSlideProjectorPatches.cs index 9c5d5e2dd..accd6ee62 100644 --- a/NewHorizons/Patches/AutoSlideProjectorPatches.cs +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/AutoSlideProjectorPatches.cs @@ -1,12 +1,12 @@ using HarmonyLib; -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public class AutoSlideProjectorPatches +namespace NewHorizons.Patches.EchoesOfTheEyePatches +{ + [HarmonyPatch(typeof(AutoSlideProjector))] + public static class AutoSlideProjectorPatches { [HarmonyPostfix] - [HarmonyPatch(typeof(AutoSlideProjector), nameof(AutoSlideProjector.Play))] + [HarmonyPatch(nameof(AutoSlideProjector.Play))] public static void AutoSlideProjector_Play(AutoSlideProjector __instance) { __instance._slideCollectionItem.enabled = true; diff --git a/NewHorizons/Patches/CloakPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs similarity index 62% rename from NewHorizons/Patches/CloakPatches.cs rename to NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs index 2129a198d..cdb8736cd 100644 --- a/NewHorizons/Patches/CloakPatches.cs +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs @@ -1,33 +1,33 @@ using HarmonyLib; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.EchoesOfTheEyePatches { - [HarmonyPatch] - public static class CloakPatches + [HarmonyPatch(typeof(CloakFieldController))] + public static class CloakFieldControllerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.FixedUpdate))] + [HarmonyPatch(nameof(CloakFieldController.FixedUpdate))] public static bool CloakFieldController_FixedUpdate(CloakFieldController __instance) { return __instance != null && __instance._cloakSphereShape != null; } [HarmonyPostfix] - [HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)] + [HarmonyPatch(nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)] public static void CloakFieldController_isPlayerInsideCloak(ref bool __result) { __result = __result || Components.CloakSectorController.isPlayerInside; } [HarmonyPostfix] - [HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)] + [HarmonyPatch(nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)] public static void CloakFieldController_isProbeInsideCloak(ref bool __result) { __result = __result || Components.CloakSectorController.isProbeInside; } [HarmonyPostfix] - [HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)] + [HarmonyPatch(nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)] public static void CloakFieldController_isShipInsideCloak(ref bool __result) { __result = __result || Components.CloakSectorController.isShipInside; diff --git a/NewHorizons/Patches/EchoesOfTheEyePatches/MindProjectorTriggerPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/MindProjectorTriggerPatches.cs new file mode 100644 index 000000000..eefb309b4 --- /dev/null +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/MindProjectorTriggerPatches.cs @@ -0,0 +1,47 @@ +using HarmonyLib; +using NewHorizons.Builder.Props; +using UnityEngine; + +namespace NewHorizons.Patches.EchoesOfTheEyePatches +{ + [HarmonyPatch(typeof(MindProjectorTrigger))] + public static class MindProjectorTriggerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(MindProjectorTrigger.OnTriggerVolumeEntry))] + public static bool MindProjectorTrigger_OnTriggerVolumeEntry(MindProjectorTrigger __instance, GameObject hitObj) + { + var t = hitObj.GetComponent(); + if (t != null) //(hitObj.CompareTag("PrisonerDetector")) + { + __instance._mindProjector.OnProjectionStart += t.onSlidesStart; + __instance._mindProjector.OnProjectionComplete += t.onSlidesComplete; + __instance._mindProjector.SetMindSlideCollection(t.slideCollection); + + __instance.OnBeamStartHitPrisoner.Invoke(); + __instance._mindProjector.Play(reset: true); + __instance._mindProjector.OnProjectionStart += __instance.OnProjectionStart; + __instance._mindProjector.OnProjectionComplete += __instance.OnProjectionComplete; + + Locator.GetPlayerTransform().GetComponent().LockOn(hitObj.transform, Vector3.zero); + __instance._playerLockedOn = true; + return false; + } + + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(MindProjectorTrigger.OnTriggerVolumeExit))] + private static bool MindProjectorTrigger_OnTriggerVolumeExit(MindProjectorTrigger __instance, GameObject hitObj) + { + var t = hitObj.GetComponent(); + if (t != null) //(hitObj.CompareTag("PrisonerDetector")) + { + __instance._mindProjector.OnProjectionStart -= t.onSlidesStart; + __instance._mindProjector.OnProjectionComplete -= t.onSlidesComplete; + } + return true; + } + } +} diff --git a/NewHorizons/Patches/EchoesOfTheEyePatches/MindSlideProjectionPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/MindSlideProjectionPatches.cs new file mode 100644 index 000000000..b40493ab9 --- /dev/null +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/MindSlideProjectionPatches.cs @@ -0,0 +1,35 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.EchoesOfTheEyePatches +{ + [HarmonyPatch(typeof(MindSlideProjector))] + public static class MindSlideProjectionPatches + { + [HarmonyPrefix] + [HarmonyPatch(typeof(MindSlideProjector), nameof(MindSlideProjector.SetMindSlideCollection))] + private static bool MindSlideProjector_SetMindSlideCollection(MindSlideProjector __instance, MindSlideCollection mindSlideCollection) + { + if (mindSlideCollection == null) return false; + + if (__instance._mindSlideCollection == mindSlideCollection) return false; + + // Original method didn't check if old _slideCollectionItem was null. + if (__instance._slideCollectionItem != null) + { + __instance._slideCollectionItem.onSlideTextureUpdated -= __instance.OnSlideTextureUpdated; + __instance._slideCollectionItem.onPlayBeatAudio -= __instance.OnPlayBeatAudio; + } + + __instance._mindSlideCollection = mindSlideCollection; + __instance._defaultSlideDuration = mindSlideCollection.defaultSlideDuration; + + __instance._slideCollectionItem = mindSlideCollection.slideCollectionContainer; + __instance._slideCollectionItem.onSlideTextureUpdated += __instance.OnSlideTextureUpdated; + __instance._slideCollectionItem.onPlayBeatAudio += __instance.OnPlayBeatAudio; + __instance._slideCollectionItem.Initialize(); + __instance._slideCollectionItem.enabled = false; + + return false; + } + } +} diff --git a/NewHorizons/Patches/RaftPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/RaftControllerPatches.cs similarity index 55% rename from NewHorizons/Patches/RaftPatches.cs rename to NewHorizons/Patches/EchoesOfTheEyePatches/RaftControllerPatches.cs index 196885c0d..a0b40a998 100644 --- a/NewHorizons/Patches/RaftPatches.cs +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/RaftControllerPatches.cs @@ -1,12 +1,13 @@ using HarmonyLib; using UnityEngine; -namespace NewHorizons.Patches + +namespace NewHorizons.Patches.EchoesOfTheEyePatches { - [HarmonyPatch] - public static class RaftPatches + [HarmonyPatch(typeof(RaftController))] + public static class RaftControllerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(RaftController), nameof(RaftController.FixedUpdate))] + [HarmonyPatch(nameof(RaftController.FixedUpdate))] public static bool RaftController_FixedUpdate(RaftController __instance) { // If it has a river fluid its a normal one and we don't do anything @@ -18,7 +19,7 @@ public static bool RaftController_FixedUpdate(RaftController __instance) return false; } bool playerInEffectsRange = __instance._playerInEffectsRange; - __instance._playerInEffectsRange = ((Locator.GetPlayerBody().GetPosition() - __instance._raftBody.GetPosition()).sqrMagnitude < 2500f); + __instance._playerInEffectsRange = (Locator.GetPlayerBody().GetPosition() - __instance._raftBody.GetPosition()).sqrMagnitude < 2500f; if (playerInEffectsRange && !__instance._playerInEffectsRange) { __instance._effectsController.StopAllEffects(); @@ -71,48 +72,5 @@ public static bool RaftController_FixedUpdate(RaftController __instance) return false; } - - [HarmonyReversePatch] - [HarmonyPatch(typeof(AsymmetricFluidDetector), nameof(AsymmetricFluidDetector.ManagedFixedUpdate))] - public static void AsymmetricFluidDetector_ManagedFixedUpdate(AsymmetricFluidDetector __instance) - { - // This is like doing base.FixedUpdate - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(AlignToSurfaceFluidDetector), nameof(AlignToSurfaceFluidDetector.ManagedFixedUpdate))] - public static bool AlignToSurfaceFluidDetector_ManagedFixedUpdate(AlignToSurfaceFluidDetector __instance) - { - if (__instance._alignmentFluid is not RadialFluidVolume) return true; - - // Mostly copy pasting from the AlignWithDirection class - AsymmetricFluidDetector_ManagedFixedUpdate(__instance); - - if (__instance._inAlignmentFluid) - { - // Both in world space - var currentDirection = __instance._owRigidbody.transform.up; - var alignmentDirection = (__instance.transform.position - __instance._alignmentFluid.transform.position).normalized; - var degreesToTarget = Vector3.Angle(currentDirection, alignmentDirection); - - var adjustedSlerpRate = Mathf.Clamp01(0.01f * degreesToTarget * Time.fixedDeltaTime); - - Vector3 a = OWPhysics.FromToAngularVelocity(currentDirection, alignmentDirection); - __instance._owRigidbody.AddAngularVelocityChange(a * adjustedSlerpRate); - } - - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(FluidVolume), nameof(FluidVolume.GetDepthAtPosition))] - public static bool FluidVolume_GetDepthAtPosition(FluidVolume __instance, ref float __result, Vector3 worldPosition) - { - if (__instance is not RadialFluidVolume radialFluidVolume) return true; - - Vector3 vector = radialFluidVolume.transform.InverseTransformPoint(worldPosition); - __result = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z + vector.y * vector.y) - radialFluidVolume._radius; - return false; - } } } diff --git a/NewHorizons/Patches/EchoesOfTheEyePatches/VisionTorchItemPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/VisionTorchItemPatches.cs new file mode 100644 index 000000000..8565c244f --- /dev/null +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/VisionTorchItemPatches.cs @@ -0,0 +1,33 @@ +using HarmonyLib; +using UnityEngine; + +namespace NewHorizons.Patches.EchoesOfTheEyePatches +{ + [HarmonyPatch] + public static class VisionTorchItemPatches + { + // This is some dark magic + // this creates a method called base_DropItem that basically just calls OWItem.PickUpItem whenever it (VisionTorchItemPatches.base_PickUpItem) is called + [HarmonyReversePatch] + [HarmonyPatch(typeof(OWItem), nameof(OWItem.DropItem))] + private static void base_DropItem(OWItem instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget) { } + + + // Make the vision torch droppable. In the base game you can only drop it if you're in the dream world. + [HarmonyPrefix] + [HarmonyPatch(typeof(VisionTorchItem), nameof(VisionTorchItem.DropItem))] + public static bool VisionTorchItem_DropItem(VisionTorchItem __instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget) + { + if (!Locator.GetDreamWorldController().IsInDream()) + { + base_DropItem(__instance, position, normal, parent, sector, customDropTarget); + } + + if (__instance._wasProjecting) __instance._mindProjectorTrigger.SetProjectorActive(false); + + __instance.gameObject.GetComponent().enabled = true; + + return true; + } + } +} diff --git a/NewHorizons/Patches/EyeOfTheUniversePatches.cs b/NewHorizons/Patches/EyeOfTheUniversePatches.cs deleted file mode 100644 index df4ba1e74..000000000 --- a/NewHorizons/Patches/EyeOfTheUniversePatches.cs +++ /dev/null @@ -1,53 +0,0 @@ -using HarmonyLib; -using UnityEngine; -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class EyeOfTheUniversePatches - { - // Funny eye of the universe stuff - - private static void OnLoadScene(OWScene scene) - { - if (scene == OWScene.SolarSystem && !Main.Instance.IsWarpingBackToEye) - { - PlayerData.SaveEyeCompletion(); - - // Switch to default just in case another mod warps back. - if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") Main.Instance._currentStarSystem = Main.Instance.DefaultStarSystem; - } - // Switch to eye just in case another mod warps there. - else if (scene == OWScene.EyeOfTheUniverse) Main.Instance._currentStarSystem = "EyeOfTheUniverse"; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(LoadManager), nameof(LoadManager.LoadSceneImmediate))] - public static void LoadManager_LoadSceneImmediate(OWScene scene) => OnLoadScene(scene); - - [HarmonyPrefix] - [HarmonyPatch(typeof(LoadManager), nameof(LoadManager.StartAsyncSceneLoad))] - public static void LoadManager_StartAsyncSceneLoad(OWScene scene) => OnLoadScene(scene); - - [HarmonyPrefix] - [HarmonyPatch(typeof(SubmitActionLoadScene), nameof(SubmitActionLoadScene.ConfirmSubmit))] - public static void SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance) - { - // Title screen can warp you to eye and cause problems. - if (__instance._sceneToLoad == SubmitActionLoadScene.LoadableScenes.EYE) - { - Utility.Logger.LogWarning("Warping to solar system and then back to eye"); - Main.Instance.IsWarpingBackToEye = true; - __instance._sceneToLoad = SubmitActionLoadScene.LoadableScenes.GAME; - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(EyeVortexTrigger), nameof(EyeVortexTrigger.OnEnterVortex))] - public static void EyeVortexTrigger_OnEnterVortex(EyeVortexTrigger __instance, GameObject hitObj) - { - if (!hitObj.CompareTag("PlayerDetector")) return; - __instance._tunnelObject.SetActive(true); - } - - } -} diff --git a/NewHorizons/Patches/EyeScenePatches/EyeVortexTriggerPatches.cs b/NewHorizons/Patches/EyeScenePatches/EyeVortexTriggerPatches.cs new file mode 100644 index 000000000..d99e33f04 --- /dev/null +++ b/NewHorizons/Patches/EyeScenePatches/EyeVortexTriggerPatches.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using UnityEngine; + +namespace NewHorizons.Patches.EyeScenePatches +{ + [HarmonyPatch(typeof(EyeVortexTrigger))] + public static class EyeVortexTriggerPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(EyeVortexTrigger.OnEnterVortex))] + public static void EyeVortexTrigger_OnEnterVortex(EyeVortexTrigger __instance, GameObject hitObj) + { + if (!hitObj.CompareTag("PlayerDetector")) return; + __instance._tunnelObject.SetActive(true); + } + } +} diff --git a/NewHorizons/Patches/EyeScenePatches/LoadManagerPatches.cs b/NewHorizons/Patches/EyeScenePatches/LoadManagerPatches.cs new file mode 100644 index 000000000..2bf53abfa --- /dev/null +++ b/NewHorizons/Patches/EyeScenePatches/LoadManagerPatches.cs @@ -0,0 +1,29 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.EyeScenePatches +{ + [HarmonyPatch(typeof(LoadManager))] + public static class LoadManagerPatches + { + private static void OnLoadScene(OWScene scene) + { + if (scene == OWScene.SolarSystem && !Main.Instance.IsWarpingBackToEye) + { + PlayerData.SaveEyeCompletion(); + + // Switch to default just in case another mod warps back. + if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") Main.Instance._currentStarSystem = Main.Instance.DefaultStarSystem; + } + // Switch to eye just in case another mod warps there. + else if (scene == OWScene.EyeOfTheUniverse) Main.Instance._currentStarSystem = "EyeOfTheUniverse"; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(LoadManager.LoadSceneImmediate))] + public static void LoadManager_LoadSceneImmediate(OWScene scene) => OnLoadScene(scene); + + [HarmonyPrefix] + [HarmonyPatch(nameof(LoadManager.StartAsyncSceneLoad))] + public static void LoadManager_StartAsyncSceneLoad(OWScene scene) => OnLoadScene(scene); + } +} diff --git a/NewHorizons/Patches/EyeScenePatches/SubmitActionLoadScenePatches.cs b/NewHorizons/Patches/EyeScenePatches/SubmitActionLoadScenePatches.cs new file mode 100644 index 000000000..33bdb2362 --- /dev/null +++ b/NewHorizons/Patches/EyeScenePatches/SubmitActionLoadScenePatches.cs @@ -0,0 +1,21 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.EyeScenePatches +{ + [HarmonyPatch(typeof(SubmitActionLoadScene))] + public static class SubmitActionLoadScenePatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(SubmitActionLoadScene.ConfirmSubmit))] + public static void SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance) + { + // Title screen can warp you to eye and cause problems. + if (__instance._sceneToLoad == SubmitActionLoadScene.LoadableScenes.EYE) + { + Utility.Logger.LogWarning("Warping to solar system and then back to eye"); + Main.Instance.IsWarpingBackToEye = true; + __instance._sceneToLoad = SubmitActionLoadScene.LoadableScenes.GAME; + } + } + } +} diff --git a/NewHorizons/Patches/HUDPatches.cs b/NewHorizons/Patches/HUDPatches.cs deleted file mode 100644 index bb9a1c4fc..000000000 --- a/NewHorizons/Patches/HUDPatches.cs +++ /dev/null @@ -1,124 +0,0 @@ -using HarmonyLib; -using NewHorizons.Handlers; - -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class HUDPatches - { - [HarmonyPostfix] - [HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))] - public static void HUDMarker_Awake(HUDMarker __instance) - { - GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); - GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); - GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField); - GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField); - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.OnDestroy))] - public static void HUDMarker_OnDestroy(HUDMarker __instance) - { - GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); - GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); - GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField); - GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField); - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.Awake))] - public static void ProbeHUDMarker_Awake(ProbeHUDMarker __instance) - { - GlobalMessenger.AddListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility); - GlobalMessenger.AddListener("ProbeExitCloakField", __instance.RefreshOwnVisibility); - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.OnDestroy))] - public static void ProbeHUDMarker_OnDestroy(ProbeHUDMarker __instance) - { - GlobalMessenger.RemoveListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility); - GlobalMessenger.RemoveListener("ProbeExitCloakField", __instance.RefreshOwnVisibility); - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.Awake))] - public static void ShipHUDMarker_Awake(ShipHUDMarker __instance) - { - GlobalMessenger.AddListener("ShipEnterCloakField", __instance.RefreshOwnVisibility); - GlobalMessenger.AddListener("ShipExitCloakField", __instance.RefreshOwnVisibility); - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.OnDestroy))] - public static void ShipHUDMarker_OnDestroy(ShipHUDMarker __instance) - { - GlobalMessenger.RemoveListener("ShipEnterCloakField", __instance.RefreshOwnVisibility); - GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.RefreshOwnVisibility))] - public static bool ProbeHUDMarker_RefreshOwnVisibility(ProbeHUDMarker __instance) - { - bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye(); - bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside()); - bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside; - bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak; - bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside; - bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe(); - bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate; - - __instance._isVisible = isActive && !insideEYE && !insideQM && !__instance._translatorEquipped && !__instance._inConversation && __instance._launched && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideRW && insideIP && insideCloak && sameInterference; - - if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible); - - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.RefreshOwnVisibility))] - public static bool ShipHUDMarker_RefreshOwnVisibility(ShipHUDMarker __instance) - { - bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye(); - bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside()); - bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside; - bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak; - bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside; - bool sameInterference = InterferenceHandler.IsPlayerSameAsShip(); - - __instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference; - - if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible); - - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogEntryHUDMarker), nameof(ShipLogEntryHUDMarker.RefreshOwnVisibility))] - public static bool ShipLogEntryHUDMarker_RefreshOwnVisibility(ShipLogEntryHUDMarker __instance) - { - bool hasEntryLocation = ShipLogEntryHUDMarker.s_entryLocation != null; - bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye(); - bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside(); - bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD"; - bool insideIP = (hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField()) || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak); - bool insideCloak = (hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField()) || !Components.CloakSectorController.isPlayerInside; - - __instance._isVisible = (!insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak); - - if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible); - - return false; - } - - - [HarmonyPostfix] - [HarmonyPatch(typeof(ProbeCamera), nameof(ProbeCamera.HasInterference))] - public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result) - { - __result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe())); - } - } -} diff --git a/NewHorizons/Patches/HUDPatches/HUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/HUDMarkerPatches.cs new file mode 100644 index 000000000..f82459ac6 --- /dev/null +++ b/NewHorizons/Patches/HUDPatches/HUDMarkerPatches.cs @@ -0,0 +1,28 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.HUDPatches +{ + [HarmonyPatch(typeof(HUDMarker))] + public static class HUDMarkerPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(HUDMarker.Awake))] + public static void HUDMarker_Awake(HUDMarker __instance) + { + GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); + GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); + GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField); + GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField); + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(HUDMarker.OnDestroy))] + public static void HUDMarker_OnDestroy(HUDMarker __instance) + { + GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); + GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility); + GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField); + GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField); + } + } +} diff --git a/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs new file mode 100644 index 000000000..dc464f3c8 --- /dev/null +++ b/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs @@ -0,0 +1,44 @@ +using HarmonyLib; +using NewHorizons.Handlers; + +namespace NewHorizons.Patches.HUDPatches +{ + [HarmonyPatch(typeof(ProbeHUDMarker))] + public static class ProbeHUDMarkerPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(ProbeHUDMarker.Awake))] + public static void ProbeHUDMarker_Awake(ProbeHUDMarker __instance) + { + GlobalMessenger.AddListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility); + GlobalMessenger.AddListener("ProbeExitCloakField", __instance.RefreshOwnVisibility); + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ProbeHUDMarker.OnDestroy))] + public static void ProbeHUDMarker_OnDestroy(ProbeHUDMarker __instance) + { + GlobalMessenger.RemoveListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility); + GlobalMessenger.RemoveListener("ProbeExitCloakField", __instance.RefreshOwnVisibility); + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(ProbeHUDMarker.RefreshOwnVisibility))] + public static bool ProbeHUDMarker_RefreshOwnVisibility(ProbeHUDMarker __instance) + { + bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye(); + bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside()); + bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside; + bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak; + bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside; + bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe(); + bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate; + + __instance._isVisible = isActive && !insideEYE && !insideQM && !__instance._translatorEquipped && !__instance._inConversation && __instance._launched && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideRW && insideIP && insideCloak && sameInterference; + + if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible); + + return false; + } + } +} diff --git a/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs new file mode 100644 index 000000000..c44f46dc6 --- /dev/null +++ b/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs @@ -0,0 +1,43 @@ +using HarmonyLib; +using NewHorizons.Handlers; + +namespace NewHorizons.Patches.HUDPatches +{ + [HarmonyPatch(typeof(ShipHUDMarker))] + public static class ShipHUDMarkerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipHUDMarker.RefreshOwnVisibility))] + public static bool ShipHUDMarker_RefreshOwnVisibility(ShipHUDMarker __instance) + { + bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye(); + bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside()); + bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside; + bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak; + bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside; + bool sameInterference = InterferenceHandler.IsPlayerSameAsShip(); + + __instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference; + + if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible); + + return false; + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ShipHUDMarker.OnDestroy))] + public static void ShipHUDMarker_OnDestroy(ShipHUDMarker __instance) + { + GlobalMessenger.RemoveListener("ShipEnterCloakField", __instance.RefreshOwnVisibility); + GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility); + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ShipHUDMarker.Awake))] + public static void ShipHUDMarker_Awake(ShipHUDMarker __instance) + { + GlobalMessenger.AddListener("ShipEnterCloakField", __instance.RefreshOwnVisibility); + GlobalMessenger.AddListener("ShipExitCloakField", __instance.RefreshOwnVisibility); + } + } +} diff --git a/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs new file mode 100644 index 000000000..75800339d --- /dev/null +++ b/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs @@ -0,0 +1,26 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.HUDPatches +{ + [HarmonyPatch(typeof(ShipLogEntryHUDMarker))] + public static class ShipLogEntryHUDMarkerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogEntryHUDMarker.RefreshOwnVisibility))] + public static bool ShipLogEntryHUDMarker_RefreshOwnVisibility(ShipLogEntryHUDMarker __instance) + { + bool hasEntryLocation = ShipLogEntryHUDMarker.s_entryLocation != null; + bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye(); + bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside(); + bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD"; + bool insideIP = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak); + bool insideCloak = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !Components.CloakSectorController.isPlayerInside; + + __instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak; + + if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible); + + return false; + } + } +} diff --git a/NewHorizons/Patches/LocatorPatches.cs b/NewHorizons/Patches/LocatorPatches.cs index a9a901e08..b1d32bd8c 100644 --- a/NewHorizons/Patches/LocatorPatches.cs +++ b/NewHorizons/Patches/LocatorPatches.cs @@ -2,7 +2,7 @@ namespace NewHorizons.Patches { - [HarmonyPatch] + [HarmonyPatch(typeof(Locator))] public static class LocatorPatches { public static AstroObject _attlerock; @@ -13,7 +13,7 @@ public static class LocatorPatches public static AstroObject _sunStation; [HarmonyPrefix] - [HarmonyPatch(typeof(Locator), nameof(Locator.RegisterCloakFieldController))] + [HarmonyPatch(nameof(Locator.RegisterCloakFieldController))] public static bool Locator_RegisterCloakFieldController() { return Locator._cloakFieldController == null; @@ -22,7 +22,7 @@ public static bool Locator_RegisterCloakFieldController() // Locator Fixes // Vanilla doesn't register these AstroObjects for some reason. So here is a fix. [HarmonyPrefix] - [HarmonyPatch(typeof(Locator), nameof(Locator.GetAstroObject))] + [HarmonyPatch(nameof(Locator.GetAstroObject))] public static bool Locator_GetAstroObject(AstroObject.Name astroObjectName, ref AstroObject __result) { switch (astroObjectName) @@ -52,7 +52,7 @@ public static bool Locator_GetAstroObject(AstroObject.Name astroObjectName, ref } [HarmonyPrefix] - [HarmonyPatch(typeof(Locator), nameof(Locator.RegisterAstroObject))] + [HarmonyPatch(nameof(Locator.RegisterAstroObject))] public static bool Locator_RegisterAstroObject(AstroObject astroObject) { if (astroObject.GetAstroObjectName() == AstroObject.Name.None) return false; @@ -98,7 +98,7 @@ public static bool Locator_RegisterAstroObject(AstroObject astroObject) } [HarmonyPostfix] - [HarmonyPatch(typeof(Locator), nameof(Locator.ClearReferences))] + [HarmonyPatch(nameof(Locator.ClearReferences))] public static void Locator_ClearReferences() { _attlerock = null; diff --git a/NewHorizons/Patches/MapPatches/CanvasMapMarkerPatches.cs b/NewHorizons/Patches/MapPatches/CanvasMapMarkerPatches.cs new file mode 100644 index 000000000..8339d26eb --- /dev/null +++ b/NewHorizons/Patches/MapPatches/CanvasMapMarkerPatches.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using NewHorizons.Handlers; +using System; +using UnityEngine; + +namespace NewHorizons.Patches.MapPatches +{ + [HarmonyPatch(typeof(CanvasMapMarker))] + public static class CanvasMapMarkerPatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(CanvasMapMarker.Init), new Type[] { typeof(Canvas), typeof(Transform), typeof(string) })] + [HarmonyPatch(nameof(CanvasMapMarker.SetLabel))] + public static void CanvasMapMarker_LocalizeLabel(CanvasMapMarker __instance) + { + __instance._label = TranslationHandler.GetTranslation(__instance._label, TranslationHandler.TextType.UI); + } + } +} diff --git a/NewHorizons/Patches/MapControllerPatches.cs b/NewHorizons/Patches/MapPatches/MapControllerPatches.cs similarity index 66% rename from NewHorizons/Patches/MapControllerPatches.cs rename to NewHorizons/Patches/MapPatches/MapControllerPatches.cs index 3c13673e1..653069181 100644 --- a/NewHorizons/Patches/MapControllerPatches.cs +++ b/NewHorizons/Patches/MapPatches/MapControllerPatches.cs @@ -2,13 +2,13 @@ using UnityEngine; using UnityEngine.SceneManagement; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.MapPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(MapController))] public static class MapControllerPatches { [HarmonyPostfix] - [HarmonyPatch(typeof(MapController), nameof(MapController.Awake))] + [HarmonyPatch(nameof(MapController.Awake))] public static void MapController_Awake(MapController __instance) { __instance._maxPanDistance = Mathf.Max(__instance._maxPanDistance, Main.FurthestOrbit * 1.5f); @@ -19,14 +19,15 @@ public static void MapController_Awake(MapController __instance) } [HarmonyPostfix] - [HarmonyPatch(typeof(MapController), nameof(MapController.OnTargetReferenceFrame))] + [HarmonyPatch(nameof(MapController.OnTargetReferenceFrame))] public static void MapController_OnTargetReferenceFrame(MapController __instance, ReferenceFrame __0) { + // Locked onto map satellite just means it will move vertically up from the plane of the solar system __instance._isLockedOntoMapSatellite = true; } [HarmonyPrefix] - [HarmonyPatch(typeof(MapController), nameof(MapController.MapInoperable))] + [HarmonyPatch(nameof(MapController.MapInoperable))] public static bool MapController_MapInoperable(MapController __instance, ref bool __result) { if (SceneManager.GetActiveScene().name != "SolarSystem") return true; @@ -44,12 +45,5 @@ public static bool MapController_MapInoperable(MapController __instance, ref boo return true; } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ReferenceFrameTracker), nameof(ReferenceFrameTracker.UntargetReferenceFrame), new System.Type[] { typeof(bool) })] - public static bool ReferenceFrameTracker_UntargetReferenceFrame(ReferenceFrameTracker __instance, bool playAudio) - { - return __instance != null && __instance._hasTarget && __instance._currentReferenceFrame != null; - } } } diff --git a/NewHorizons/Patches/TranslationPatches.cs b/NewHorizons/Patches/MapPatches/ReferenceFramePatches.cs similarity index 50% rename from NewHorizons/Patches/TranslationPatches.cs rename to NewHorizons/Patches/MapPatches/ReferenceFramePatches.cs index c6ea4fc5c..a9efb8b1d 100644 --- a/NewHorizons/Patches/TranslationPatches.cs +++ b/NewHorizons/Patches/MapPatches/ReferenceFramePatches.cs @@ -1,15 +1,14 @@ using HarmonyLib; using NewHorizons.Components.Orbital; using NewHorizons.Handlers; -using System; -using UnityEngine; -namespace NewHorizons.Patches + +namespace NewHorizons.Patches.MapPatches { - [HarmonyPatch] - public static class TranslationPatches + [HarmonyPatch(typeof(ReferenceFrame))] + public static class ReferenceFramePatches { [HarmonyPrefix] - [HarmonyPatch(typeof(ReferenceFrame), nameof(ReferenceFrame.GetHUDDisplayName))] + [HarmonyPatch(nameof(ReferenceFrame.GetHUDDisplayName))] public static bool ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, ref string __result) { var ao = __instance.GetAstroObject(); @@ -35,19 +34,5 @@ public static bool ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, r return false; } - - [HarmonyPostfix] - [HarmonyPatch(typeof(CanvasMapMarker), nameof(CanvasMapMarker.Init), new Type[] { typeof(Canvas), typeof(Transform), typeof(string) })] - public static void CanvasMapMarker_Init(CanvasMapMarker __instance) - { - __instance._label = TranslationHandler.GetTranslation(__instance._label, TranslationHandler.TextType.UI); - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(CanvasMapMarker), nameof(CanvasMapMarker.SetLabel))] - public static void CanvasMapMarker_SetLabel(CanvasMapMarker __instance) - { - __instance._label = TranslationHandler.GetTranslation(__instance._label, TranslationHandler.TextType.UI); - } } } diff --git a/NewHorizons/Patches/MapPatches/ReferenceFrameTrackerPatches.cs b/NewHorizons/Patches/MapPatches/ReferenceFrameTrackerPatches.cs new file mode 100644 index 000000000..8184ef787 --- /dev/null +++ b/NewHorizons/Patches/MapPatches/ReferenceFrameTrackerPatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.MapPatches +{ + [HarmonyPatch(typeof(ReferenceFrameTracker))] + public static class ReferenceFrameTrackerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ReferenceFrameTracker.UntargetReferenceFrame), new System.Type[] { typeof(bool) })] + public static bool ReferenceFrameTracker_UntargetReferenceFrame(ReferenceFrameTracker __instance, bool playAudio) + { + return __instance != null && __instance._hasTarget && __instance._currentReferenceFrame != null; + } + } +} diff --git a/NewHorizons/Patches/MeteorPatches.cs b/NewHorizons/Patches/MeteorControllerPatches.cs similarity index 65% rename from NewHorizons/Patches/MeteorPatches.cs rename to NewHorizons/Patches/MeteorControllerPatches.cs index 31eb73fa9..ba1603ebf 100644 --- a/NewHorizons/Patches/MeteorPatches.cs +++ b/NewHorizons/Patches/MeteorControllerPatches.cs @@ -2,11 +2,11 @@ namespace NewHorizons.Patches { - [HarmonyPatch] - public static class MeteorPatches + [HarmonyPatch(typeof(MeteorController))] + public static class MeteorControllerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(MeteorController), nameof(MeteorController.Suspend), new System.Type[0])] + [HarmonyPatch(nameof(MeteorController.Suspend), new System.Type[0])] public static void MeteorController_Suspend(MeteorController __instance) { // Meteors launch inactive because of prefab. So let's fix that. diff --git a/NewHorizons/Patches/PlayerDataPatches.cs b/NewHorizons/Patches/PlayerPatches/PlayerDataPatches.cs similarity index 82% rename from NewHorizons/Patches/PlayerDataPatches.cs rename to NewHorizons/Patches/PlayerPatches/PlayerDataPatches.cs index 7c4b3fc6f..38f3f1e70 100644 --- a/NewHorizons/Patches/PlayerDataPatches.cs +++ b/NewHorizons/Patches/PlayerPatches/PlayerDataPatches.cs @@ -1,20 +1,20 @@ using HarmonyLib; -using NewHorizons.OtherMods.AchievementsPlus; -using NewHorizons.OtherMods.AchievementsPlus.NH; using NewHorizons.Builder.Props; using NewHorizons.External; using NewHorizons.Handlers; +using NewHorizons.OtherMods.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus.NH; +using NewHorizons.Utility; using System.Collections.Generic; using System.Linq; -using NewHorizons.Utility; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.PlayerPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(PlayerData))] public static class PlayerDataPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.KnowsFrequency))] + [HarmonyPatch(nameof(PlayerData.KnowsFrequency))] public static bool OnPlayerDataKnowsFrequency(SignalFrequency __0, ref bool __result) { var freqString = SignalBuilder.GetCustomFrequencyName(__0); @@ -28,7 +28,7 @@ public static bool OnPlayerDataKnowsFrequency(SignalFrequency __0, ref bool __re } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.LearnFrequency))] + [HarmonyPatch(nameof(PlayerData.LearnFrequency))] public static bool OnPlayerDataLearnFrequency(SignalFrequency __0) { var freqString = SignalBuilder.GetCustomFrequencyName(__0); @@ -42,7 +42,7 @@ public static bool OnPlayerDataLearnFrequency(SignalFrequency __0) } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.KnowsSignal))] + [HarmonyPatch(nameof(PlayerData.KnowsSignal))] public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result) { var customSignalName = SignalBuilder.GetCustomSignalName(__0); @@ -55,13 +55,13 @@ public static bool OnPlayerDataKnowsSignal(SignalName __0, ref bool __result) } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.LearnSignal))] + [HarmonyPatch(nameof(PlayerData.LearnSignal))] public static bool OnPlayerDataLearnSignal(SignalName __0) { var customSignalName = SignalBuilder.GetCustomSignalName(__0); if (customSignalName != null) { - if (!NewHorizonsData.KnowsSignal(customSignalName)) + if (!NewHorizonsData.KnowsSignal(customSignalName)) { NewHorizonsData.LearnSignal(customSignalName); } @@ -74,7 +74,7 @@ public static bool OnPlayerDataLearnSignal(SignalName __0) } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.KnowsMultipleFrequencies))] + [HarmonyPatch(nameof(PlayerData.KnowsMultipleFrequencies))] public static bool OnPlayerDataKnowsMultipleFrequencies(ref bool __result) { if (NewHorizonsData.KnowsMultipleFrequencies()) @@ -86,7 +86,7 @@ public static bool OnPlayerDataKnowsMultipleFrequencies(ref bool __result) } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.AddNewlyRevealedFactID))] + [HarmonyPatch(nameof(PlayerData.AddNewlyRevealedFactID))] public static bool OnPlayerDataAddNewlyRevealedFactID(string __0) { if (ShipLogHandler.IsModdedFact(__0)) @@ -101,7 +101,7 @@ public static bool OnPlayerDataAddNewlyRevealedFactID(string __0) } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.GetNewlyRevealedFactIDs))] + [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))] public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List __result) { var newHorizonsNewlyRevealedFactIDs = NewHorizonsData.GetNewlyRevealedFactIDs(); @@ -118,7 +118,7 @@ public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List __result } [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.ClearNewlyRevealedFactIDs))] + [HarmonyPatch(nameof(PlayerData.ClearNewlyRevealedFactIDs))] public static bool OnPlayerDataClearNewlyRevealedFactIDs() { PlayerData._currentGameSave.newlyRevealedFactIDs.Clear(); @@ -127,14 +127,14 @@ public static bool OnPlayerDataClearNewlyRevealedFactIDs() } [HarmonyPostfix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.ResetGame))] + [HarmonyPatch(nameof(PlayerData.ResetGame))] public static void OnPlayerDataResetGame() { NewHorizonsData.Reset(); } [HarmonyPostfix] - [HarmonyPatch(typeof(PlayerData), nameof(PlayerData.GetNewlyRevealedFactIDs))] + [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))] public static void PlayerData_GetNewlyRevealedFactIDs(ref List __result) { ShipLogManager manager = Locator.GetShipLogManager(); diff --git a/NewHorizons/Patches/PlayerSpawnerPatches.cs b/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs similarity index 83% rename from NewHorizons/Patches/PlayerSpawnerPatches.cs rename to NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs index 3eef005c0..80f814fbb 100644 --- a/NewHorizons/Patches/PlayerSpawnerPatches.cs +++ b/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs @@ -1,12 +1,13 @@ using HarmonyLib; using Logger = NewHorizons.Utility.Logger; -namespace NewHorizons.Patches + +namespace NewHorizons.Patches.PlayerPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(PlayerSpawner))] public static class PlayerSpawnerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))] + [HarmonyPatch(nameof(PlayerSpawner.SpawnPlayer))] public static bool PlayerSpawner_SpawnPlayer(PlayerSpawner __instance) { if (Main.Instance.IsWarpingFromVessel || Main.Instance.DidWarpFromVessel) diff --git a/NewHorizons/Patches/PlayerStatePatches.cs b/NewHorizons/Patches/PlayerPatches/PlayerStatePatches.cs similarity index 81% rename from NewHorizons/Patches/PlayerStatePatches.cs rename to NewHorizons/Patches/PlayerPatches/PlayerStatePatches.cs index 0fe139187..adc39008d 100644 --- a/NewHorizons/Patches/PlayerStatePatches.cs +++ b/NewHorizons/Patches/PlayerPatches/PlayerStatePatches.cs @@ -1,12 +1,12 @@ -using HarmonyLib; +using HarmonyLib; using UnityEngine; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.PlayerPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(PlayerState))] public static class PlayerStatePatches { [HarmonyPrefix] - [HarmonyPatch(typeof(PlayerState), nameof(PlayerState.CheckShipOutsideSolarSystem))] + [HarmonyPatch(nameof(PlayerState.CheckShipOutsideSolarSystem))] public static bool PlayerState_CheckShipOutsideSolarSystem(PlayerState __instance, ref bool __result) { if (PlayerState._inBrambleDimension) return false; diff --git a/NewHorizons/Patches/ProbeLauncherPatches.cs b/NewHorizons/Patches/ProbeLauncherPatches.cs deleted file mode 100644 index 0f1ef17ec..000000000 --- a/NewHorizons/Patches/ProbeLauncherPatches.cs +++ /dev/null @@ -1,14 +0,0 @@ -using HarmonyLib; -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class ProbeLauncherPatches - { - [HarmonyPrefix] - [HarmonyPatch(typeof(ProbeLauncher), nameof(ProbeLauncher.UpdateOrbitalLaunchValues))] - public static bool ProbeLauncher_UpdateOrbitalLaunchValues(ProbeLauncher __instance) - { - return (Locator.GetPlayerRulesetDetector()?.GetPlanetoidRuleset()?.GetGravityVolume() != null); - } - } -} diff --git a/NewHorizons/Patches/ProxyPatches/ProxyBodyPatches.cs b/NewHorizons/Patches/ProxyPatches/ProxyBodyPatches.cs new file mode 100644 index 000000000..5ff71810d --- /dev/null +++ b/NewHorizons/Patches/ProxyPatches/ProxyBodyPatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.ProxyPatches +{ + [HarmonyPatch(typeof(ProxyBody))] + public static class ProxyBodyPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ProxyBody.IsObjectInSupernova))] + public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance) + { + return Locator.GetSunController() != null; + } + } +} diff --git a/NewHorizons/Patches/ProxyBodyPatches.cs b/NewHorizons/Patches/ProxyPatches/ProxyPlanetPatches.cs similarity index 89% rename from NewHorizons/Patches/ProxyBodyPatches.cs rename to NewHorizons/Patches/ProxyPatches/ProxyPlanetPatches.cs index 8040d8052..b59bdfcf0 100644 --- a/NewHorizons/Patches/ProxyBodyPatches.cs +++ b/NewHorizons/Patches/ProxyPatches/ProxyPlanetPatches.cs @@ -1,23 +1,15 @@ using HarmonyLib; -using NewHorizons.Components; -using NewHorizons.Handlers; using NewHorizons.Utility; using System; using System.Runtime.CompilerServices; using UnityEngine; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.ProxyPatches { [HarmonyPatch] - public static class ProxyBodyPatches + public static class ProxyPlanetPatches { - [HarmonyPrefix] - [HarmonyPatch(typeof(ProxyBody), nameof(ProxyBody.IsObjectInSupernova))] - public static bool ProxyBody_IsObjectInSupernova(ProxyBody __instance) - { - return Locator.GetSunController() != null; - } - + // To call the base method [HarmonyReversePatch] [HarmonyPatch(typeof(ProxyPlanet), nameof(ProxyPlanet.Initialize))] [MethodImpl(MethodImplOptions.NoInlining)] diff --git a/NewHorizons/Patches/ProxyPatches/SunProxyEffectControllerPatches.cs b/NewHorizons/Patches/ProxyPatches/SunProxyEffectControllerPatches.cs new file mode 100644 index 000000000..24e22d07e --- /dev/null +++ b/NewHorizons/Patches/ProxyPatches/SunProxyEffectControllerPatches.cs @@ -0,0 +1,22 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.ProxyPatches +{ + [HarmonyPatch(typeof(SunProxyEffectController))] + public static class SunProxyEffectControllerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(SunProxyEffectController.UpdateScales))] + public static bool SunProxyEffectController_UpdateScales(SunProxyEffectController __instance) + { + return __instance != null && __instance._surface != null && __instance._fog != null && __instance._fogMaterial != null && __instance._solarFlareEmitter != null && __instance._atmosphere != null; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(SunProxyEffectController.UpdateAtmosphereRadii))] + public static bool SunProxyEffectController_UpdateAtmosphereRadii(SunProxyEffectController __instance) + { + return __instance != null && __instance.transform != null && __instance.transform.parent != null && __instance._atmosphereMaterial != null; + } + } +} diff --git a/NewHorizons/Patches/RemotePatches.cs b/NewHorizons/Patches/RemotePatches.cs deleted file mode 100644 index 40c6a5c25..000000000 --- a/NewHorizons/Patches/RemotePatches.cs +++ /dev/null @@ -1,153 +0,0 @@ -using HarmonyLib; -using NewHorizons.Components; -using NewHorizons.Handlers; -using UnityEngine; - -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public class RemotePatches - { - [HarmonyPrefix] - [HarmonyPatch(typeof(NomaiRemoteCameraPlatform), nameof(NomaiRemoteCameraPlatform.IDToPlanetString))] - public static bool NomaiRemoteCameraPlatform_IDToPlanetString(NomaiRemoteCameraPlatform.ID id, out string __result) - { - switch (id) - { - case NomaiRemoteCameraPlatform.ID.None: - __result = "None"; - break; - case NomaiRemoteCameraPlatform.ID.SunStation: - __result = UITextLibrary.GetString(UITextType.LocationSS); - break; - case NomaiRemoteCameraPlatform.ID.HGT_TimeLoop: - __result = UITextLibrary.GetString(UITextType.LocationTT); - break; - case NomaiRemoteCameraPlatform.ID.TH_Mine: - __result = UITextLibrary.GetString(UITextType.LocationTH); - break; - case NomaiRemoteCameraPlatform.ID.THM_EyeLocator: - __result = UITextLibrary.GetString(UITextType.LocationTHMoon); - break; - case NomaiRemoteCameraPlatform.ID.BH_Observatory: - case NomaiRemoteCameraPlatform.ID.BH_GravityCannon: - case NomaiRemoteCameraPlatform.ID.BH_QuantumFragment: - case NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge: - case NomaiRemoteCameraPlatform.ID.BH_NorthPole: - __result = UITextLibrary.GetString(UITextType.LocationBH); - break; - case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1: - case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2: - case NomaiRemoteCameraPlatform.ID.GD_StatueIsland: - __result = UITextLibrary.GetString(UITextType.LocationGD); - break; - case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule: - __result = UITextLibrary.GetString(UITextType.LocationOPC_Module3); - break; - case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule: - __result = UITextLibrary.GetString(UITextType.LocationOPC_Module2); - break; - case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule: - __result = UITextLibrary.GetString(UITextType.LocationOPC_Module1); - break; - case NomaiRemoteCameraPlatform.ID.VM_Interior: - __result = UITextLibrary.GetString(UITextType.LocationBHMoon); - break; - case NomaiRemoteCameraPlatform.ID.HGT_TLE: - __result = UITextLibrary.GetString(UITextType.LocationCT); - break; - default: - __result = RemoteHandler.GetPlatformIDName(id); - break; - } - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(NomaiRemoteCameraStreaming), nameof(NomaiRemoteCameraStreaming.NomaiRemoteCameraPlatformIDToSceneName))] - public static bool NomaiRemoteCameraStreaming_NomaiRemoteCameraPlatformIDToSceneName(NomaiRemoteCameraPlatform.ID id, out string __result) - { - switch (id) - { - case NomaiRemoteCameraPlatform.ID.SunStation: - __result = "SolarSystem"; - break; - case NomaiRemoteCameraPlatform.ID.HGT_TimeLoop: - case NomaiRemoteCameraPlatform.ID.HGT_TLE: - __result = "HourglassTwins"; - break; - case NomaiRemoteCameraPlatform.ID.TH_Mine: - case NomaiRemoteCameraPlatform.ID.THM_EyeLocator: - __result = "TimberHearth"; - break; - case NomaiRemoteCameraPlatform.ID.BH_Observatory: - case NomaiRemoteCameraPlatform.ID.BH_GravityCannon: - case NomaiRemoteCameraPlatform.ID.BH_QuantumFragment: - case NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge: - case NomaiRemoteCameraPlatform.ID.BH_NorthPole: - case NomaiRemoteCameraPlatform.ID.VM_Interior: - __result = "BrittleHollow"; - break; - case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1: - case NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2: - case NomaiRemoteCameraPlatform.ID.GD_StatueIsland: - case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule: - case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule: - case NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule: - __result = "GiantsDeep"; - break; - case NomaiRemoteCameraPlatform.ID.None: - __result = ""; - break; - default: - var key = RemoteHandler.GetPlatformIDKey(id); - var _ = key.IndexOf("_"); - switch ((_ == -1) ? key : key.Substring(0, _)) - { - case "SS": - __result = "SolarSystem"; - break; - case "HGT": - case "CT": - case "TT": - __result = "HourglassTwins"; - break; - case "CO": - __result = "Comet"; - break; - case "QM": - __result = "QuantumMoon"; - break; - case "GD": - __result = "GiantsDeep"; - break; - case "BH": - case "VM": - __result = "BrittleHollow"; - break; - case "TH": - case "THM": - __result = "TimberHearth"; - break; - case "DB": - __result = "DarkBramble"; - break; - case "WH": - __result = "WhiteHole"; - break; - case "RW": - __result = "RingWorld"; - break; - case "DW": - __result = "DreamWorld"; - break; - default: - __result = key; - break; - } - break; - } - return false; - } - } -} diff --git a/NewHorizons/Patches/ShapePatches.cs b/NewHorizons/Patches/ShapeManagerPatches.cs similarity index 85% rename from NewHorizons/Patches/ShapePatches.cs rename to NewHorizons/Patches/ShapeManagerPatches.cs index cf4d19d0a..ea6a61905 100644 --- a/NewHorizons/Patches/ShapePatches.cs +++ b/NewHorizons/Patches/ShapeManagerPatches.cs @@ -3,11 +3,11 @@ namespace NewHorizons.Patches { - [HarmonyPatch] - public class ShapePatches + [HarmonyPatch(typeof(ShapeManager))] + public class ShapeManagerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(ShapeManager), nameof(ShapeManager.Initialize))] + [HarmonyPatch(nameof(ShapeManager.Initialize))] public static bool ShapeManager_Initialize() { ShapeManager._exists = true; diff --git a/NewHorizons/Patches/ShipLogPatches.cs b/NewHorizons/Patches/ShipLogPatches.cs deleted file mode 100644 index 8fe329c1a..000000000 --- a/NewHorizons/Patches/ShipLogPatches.cs +++ /dev/null @@ -1,254 +0,0 @@ -using HarmonyLib; -using NewHorizons.OtherMods.AchievementsPlus; -using NewHorizons.Builder.ShipLog; -using NewHorizons.Handlers; -using NewHorizons.Utility; -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using Logger = NewHorizons.Utility.Logger; -using Object = UnityEngine.Object; -using NewHorizons.Components.ShipLog; - -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class ShipLogPatches - { - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.Awake))] - public static void ShipLogManager_Awake_Prefix(ShipLogManager __instance) - { - if (Main.Instance.IsWarpingBackToEye) return; - - RumorModeBuilder.Init(); - ShipLogHandler.Init(); - - var currentStarSystem = Main.Instance.CurrentStarSystem; - - if (!Main.SystemDict.ContainsKey(currentStarSystem) || !Main.BodyDict.ContainsKey(currentStarSystem)) - { - currentStarSystem = Main.Instance.DefaultStarSystem; - } - - Logger.Log($"Beginning Ship Log Generation For: {currentStarSystem}"); - - if (currentStarSystem != "SolarSystem") - { - __instance._shipLogXmlAssets = new TextAsset[] { }; - foreach (ShipLogEntryLocation logEntryLocation in GameObject.FindObjectsOfType()) - { - logEntryLocation._initialized = true; - } - } - - var curiosities = Main.SystemDict[currentStarSystem].Config.curiosities; - if (curiosities != null) - { - RumorModeBuilder.AddCuriosityColors(curiosities); - } - - foreach (NewHorizonsBody body in Main.BodyDict[currentStarSystem]) - { - if (body.Config.ShipLog?.xmlFile != null) - { - RumorModeBuilder.AddBodyToShipLog(__instance, body); - } - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.Awake))] - public static void ShipLogManager_Awake_Postfix(ShipLogManager __instance) - { - if (Main.Instance.IsWarpingBackToEye) return; - - ShipLogHandler.CheckForModdedFacts(__instance); - RumorModeBuilder.GenerateEntryData(__instance); - for (var i = 0; i < __instance._entryList.Count; i++) - { - ShipLogEntry logEntry = __instance._entryList[i]; - RumorModeBuilder.UpdateEntryCuriosity(ref logEntry); - } - - Logger.Log($"Ship Log Generation Complete For: {Main.Instance.CurrentStarSystem}"); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.IsFactRevealed))] - public static bool ShipLogManager_IsFactRevealed(ShipLogManager __instance, ref bool __result, string __0) - { - if (__instance._factDict != null && __instance._factDict.ContainsKey(__0)) - { - __result = __instance._factDict[__0].IsRevealed(); - } - else - { - __result = false; - } - - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.CheckForCompletionAchievement))] - public static bool ShipLogManager_CheckForCompletionAchievement(ShipLogManager __instance) - { - foreach (KeyValuePair keyValuePair in __instance._factDict) - { - if (!ShipLogHandler.IsModdedFact(keyValuePair.Key) && !keyValuePair.Value.IsRumor() && !keyValuePair.Value.IsRevealed() && !keyValuePair.Key.Equals("TH_VILLAGE_X3") && !keyValuePair.Key.Equals("GD_GABBRO_ISLAND_X1") && __instance.GetEntry(keyValuePair.Value.GetEntryID()).GetCuriosityName() != CuriosityName.InvisiblePlanet) - { - return false; - } - } - Achievements.Earn(Achievements.Type.STUDIOUS); - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.Start))] - public static bool ShipLogManager_Start(ShipLogManager __instance) - { - var initialReveal = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.initialReveal ?? Array.Empty(); - foreach (string fact in initialReveal) - { - __instance.RevealFact(fact, false, false); - } - - if (Main.Instance.CurrentStarSystem == "SolarSystem") - { - return true; - } - else - { - EntryLocationBuilder.InitializeLocations(); - return false; - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(UIStyleManager), nameof(UIStyleManager.GetCuriosityColor))] - public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result) - { - if ((int)__0 < 7) - { - return true; - } - else - { - __result = RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight); - return false; - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.Initialize))] - public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance) - { - GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH); - GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun"); - ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer); - if (navMatrix == null || navMatrix.Length <= 1) - { - Logger.LogWarning("Skipping Map Mode Generation."); - } - else - { - __instance._astroObjects = navMatrix; - __instance._startingAstroObjectID = navMatrix[1][0].GetID(); - if (Main.Instance.CurrentStarSystem != "SolarSystem") - { - List delete = panRoot.GetAllChildren().Where(g => g.name.Contains("_ShipLog") == false).ToList(); - foreach (GameObject gameObject in delete) - { - Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name)); - } - if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null) - { - __instance._sandFunnel = __instance.gameObject.AddComponent(); - } - } - } - - Logger.Log("Map Mode Construction Complete"); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogAstroObject), nameof(ShipLogAstroObject.GetName))] - public static bool ShipLogAstroObject_GetName(ShipLogAstroObject __instance, ref string __result) - { - if (ShipLogHandler.IsVanillaAstroID(__instance.GetID())) - { - return true; - } - else - { - __result = MapModeBuilder.GetAstroBodyShipLogName(__instance.GetID()); - return false; - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ShipLogAstroObject), nameof(ShipLogAstroObject.UpdateState))] - public static void ShipLogAstroObject_UpdateState(ShipLogAstroObject __instance) - { - Transform detailsParent = __instance.transform.Find("Details"); - if (detailsParent != null) - { - foreach (GameObject child in detailsParent.gameObject.GetAllChildren()) - { - if (child.TryGetComponent(typeof(ShipLogDetail), out Component detail)) - { - (detail as ShipLogDetail)?.UpdateState(__instance._state); - } - } - } - - Transform lineObject = __instance.transform.Find("Line_ShipLog"); - if (lineObject != null) - { - ShipLogDetail lineDetail = lineObject.gameObject.GetComponent(); - lineDetail.UpdateState(__instance._state); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogSandFunnel), nameof(ShipLogSandFunnel.UpdateState))] - public static bool ShipLogSandFunnel_UpdateState() - { - return Main.Instance.CurrentStarSystem == "SolarSystem"; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogSandFunnel), nameof(ShipLogSandFunnel.Awake))] - public static bool ShipLogSandFunnel_Awake() - { - return Main.Instance.CurrentStarSystem == "SolarSystem"; - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ShipLogManager), nameof(ShipLogManager.RevealFact))] - public static void ShipLogManager_RevealFact(string __0) - { - StarChartHandler.OnRevealFact(__0); - - AchievementHandler.OnRevealFact(); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ShipLogFact), nameof(ShipLogFact.GetText))] - public static bool ShipLogFact_GetText(ShipLogFact __instance, ref string __result) - { - if (ShipLogHandler.IsModdedFact(__instance.GetID())) - { - __result = TranslationHandler.GetTranslation(__instance._text, TranslationHandler.TextType.SHIPLOG); - return false; - } - else - { - return true; - } - } - } -} \ No newline at end of file diff --git a/NewHorizons/Patches/ShipLogPatches/ShipLogAstroObjectPatches.cs b/NewHorizons/Patches/ShipLogPatches/ShipLogAstroObjectPatches.cs new file mode 100644 index 000000000..ba3c0e337 --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/ShipLogAstroObjectPatches.cs @@ -0,0 +1,52 @@ +using HarmonyLib; +using NewHorizons.Builder.ShipLog; +using NewHorizons.Components.ShipLog; +using NewHorizons.Handlers; +using NewHorizons.Utility; +using UnityEngine; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(ShipLogAstroObject))] + public static class ShipLogAstroObjectPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogAstroObject.GetName))] + public static bool ShipLogAstroObject_GetName(ShipLogAstroObject __instance, ref string __result) + { + if (ShipLogHandler.IsVanillaAstroID(__instance.GetID())) + { + return true; + } + else + { + __result = MapModeBuilder.GetAstroBodyShipLogName(__instance.GetID()); + return false; + } + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ShipLogAstroObject.UpdateState))] + public static void ShipLogAstroObject_UpdateState(ShipLogAstroObject __instance) + { + Transform detailsParent = __instance.transform.Find("Details"); + if (detailsParent != null) + { + foreach (GameObject child in detailsParent.gameObject.GetAllChildren()) + { + if (child.TryGetComponent(typeof(ShipLogDetail), out Component detail)) + { + (detail as ShipLogDetail)?.UpdateState(__instance._state); + } + } + } + + Transform lineObject = __instance.transform.Find("Line_ShipLog"); + if (lineObject != null) + { + ShipLogDetail lineDetail = lineObject.gameObject.GetComponent(); + lineDetail.UpdateState(__instance._state); + } + } + } +} diff --git a/NewHorizons/Patches/ShipLogPatches/ShipLogFactPatches.cs b/NewHorizons/Patches/ShipLogPatches/ShipLogFactPatches.cs new file mode 100644 index 000000000..39f7647cd --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/ShipLogFactPatches.cs @@ -0,0 +1,24 @@ +using HarmonyLib; +using NewHorizons.Handlers; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(ShipLogFact))] + public static class ShipLogFactPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogFact.GetText))] + public static bool ShipLogFact_GetText(ShipLogFact __instance, ref string __result) + { + if (ShipLogHandler.IsModdedFact(__instance.GetID())) + { + __result = TranslationHandler.GetTranslation(__instance._text, TranslationHandler.TextType.SHIPLOG); + return false; + } + else + { + return true; + } + } + } +} diff --git a/NewHorizons/Patches/ShipLogPatches/ShipLogManagerPatches.cs b/NewHorizons/Patches/ShipLogPatches/ShipLogManagerPatches.cs new file mode 100644 index 000000000..8276ccc70 --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/ShipLogManagerPatches.cs @@ -0,0 +1,135 @@ +using HarmonyLib; +using NewHorizons.Builder.ShipLog; +using NewHorizons.Handlers; +using NewHorizons.OtherMods.AchievementsPlus; +using NewHorizons.Utility; +using System.Collections.Generic; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(ShipLogManager))] + public static class ShipLogManagerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogManager.Awake))] + public static void ShipLogManager_Awake_Prefix(ShipLogManager __instance) + { + if (Main.Instance.IsWarpingBackToEye) return; + + RumorModeBuilder.Init(); + ShipLogHandler.Init(); + + var currentStarSystem = Main.Instance.CurrentStarSystem; + + if (!Main.SystemDict.ContainsKey(currentStarSystem) || !Main.BodyDict.ContainsKey(currentStarSystem)) + { + currentStarSystem = Main.Instance.DefaultStarSystem; + } + + Logger.Log($"Beginning Ship Log Generation For: {currentStarSystem}"); + + if (currentStarSystem != "SolarSystem") + { + __instance._shipLogXmlAssets = new TextAsset[] { }; + foreach (ShipLogEntryLocation logEntryLocation in Object.FindObjectsOfType()) + { + logEntryLocation._initialized = true; + } + } + + var curiosities = Main.SystemDict[currentStarSystem].Config.curiosities; + if (curiosities != null) + { + RumorModeBuilder.AddCuriosityColors(curiosities); + } + + foreach (NewHorizonsBody body in Main.BodyDict[currentStarSystem]) + { + if (body.Config.ShipLog?.xmlFile != null) + { + RumorModeBuilder.AddBodyToShipLog(__instance, body); + } + } + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ShipLogManager.Awake))] + public static void ShipLogManager_Awake_Postfix(ShipLogManager __instance) + { + if (Main.Instance.IsWarpingBackToEye) return; + + ShipLogHandler.CheckForModdedFacts(__instance); + RumorModeBuilder.GenerateEntryData(__instance); + for (var i = 0; i < __instance._entryList.Count; i++) + { + ShipLogEntry logEntry = __instance._entryList[i]; + RumorModeBuilder.UpdateEntryCuriosity(ref logEntry); + } + + Logger.Log($"Ship Log Generation Complete For: {Main.Instance.CurrentStarSystem}"); + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogManager.IsFactRevealed))] + public static bool ShipLogManager_IsFactRevealed(ShipLogManager __instance, ref bool __result, string __0) + { + if (__instance._factDict != null && __instance._factDict.ContainsKey(__0)) + { + __result = __instance._factDict[__0].IsRevealed(); + } + else + { + __result = false; + } + + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogManager.CheckForCompletionAchievement))] + public static bool ShipLogManager_CheckForCompletionAchievement(ShipLogManager __instance) + { + foreach (KeyValuePair keyValuePair in __instance._factDict) + { + if (!ShipLogHandler.IsModdedFact(keyValuePair.Key) && !keyValuePair.Value.IsRumor() && !keyValuePair.Value.IsRevealed() && !keyValuePair.Key.Equals("TH_VILLAGE_X3") && !keyValuePair.Key.Equals("GD_GABBRO_ISLAND_X1") && __instance.GetEntry(keyValuePair.Value.GetEntryID()).GetCuriosityName() != CuriosityName.InvisiblePlanet) + { + return false; + } + } + Achievements.Earn(Achievements.Type.STUDIOUS); + return false; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogManager.Start))] + public static bool ShipLogManager_Start(ShipLogManager __instance) + { + var initialReveal = Main.SystemDict[Main.Instance.CurrentStarSystem].Config.initialReveal ?? System.Array.Empty(); + foreach (string fact in initialReveal) + { + __instance.RevealFact(fact, false, false); + } + + if (Main.Instance.CurrentStarSystem == "SolarSystem") + { + return true; + } + else + { + EntryLocationBuilder.InitializeLocations(); + return false; + } + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ShipLogManager.RevealFact))] + public static void ShipLogManager_RevealFact(string __0) + { + StarChartHandler.OnRevealFact(__0); + + AchievementHandler.OnRevealFact(); + } + } +} \ No newline at end of file diff --git a/NewHorizons/Patches/ShipLogPatches/ShipLogMapModePatches.cs b/NewHorizons/Patches/ShipLogPatches/ShipLogMapModePatches.cs new file mode 100644 index 000000000..b946c3c67 --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/ShipLogMapModePatches.cs @@ -0,0 +1,47 @@ +using HarmonyLib; +using NewHorizons.Builder.ShipLog; +using NewHorizons.Handlers; +using NewHorizons.Utility; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(ShipLogMapMode))] + public static class ShipLogMapModePatches + { + [HarmonyPostfix] + [HarmonyPatch(nameof(ShipLogMapMode.Initialize))] + public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance) + { + GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH); + GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun"); + ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer); + if (navMatrix == null || navMatrix.Length <= 1) + { + Logger.LogWarning("Skipping Map Mode Generation."); + } + else + { + __instance._astroObjects = navMatrix; + __instance._startingAstroObjectID = navMatrix[1][0].GetID(); + if (Main.Instance.CurrentStarSystem != "SolarSystem") + { + List delete = panRoot.GetAllChildren().Where(g => g.name.Contains("_ShipLog") == false).ToList(); + foreach (GameObject gameObject in delete) + { + Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name)); + } + if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null) + { + __instance._sandFunnel = __instance.gameObject.AddComponent(); + } + } + } + + Logger.Log("Map Mode Construction Complete"); + } + } +} diff --git a/NewHorizons/Patches/ShipLogPatches/ShipLogSandFunnelPatches.cs b/NewHorizons/Patches/ShipLogPatches/ShipLogSandFunnelPatches.cs new file mode 100644 index 000000000..1f56a1523 --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/ShipLogSandFunnelPatches.cs @@ -0,0 +1,22 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(ShipLogSandFunnel))] + public static class ShipLogSandFunnelPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogSandFunnel.UpdateState))] + public static bool ShipLogSandFunnel_UpdateState() + { + return Main.Instance.CurrentStarSystem == "SolarSystem"; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(ShipLogSandFunnel.Awake))] + public static bool ShipLogSandFunnel_Awake() + { + return Main.Instance.CurrentStarSystem == "SolarSystem"; + } + } +} diff --git a/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs b/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs new file mode 100644 index 000000000..be44f0364 --- /dev/null +++ b/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using NewHorizons.Builder.ShipLog; +using UnityEngine; + +namespace NewHorizons.Patches.ShipLogPatches +{ + [HarmonyPatch(typeof(UIStyleManager))] + public static class UIStyleManagerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(UIStyleManager.GetCuriosityColor))] + public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result) + { + if ((int)__0 < 7) + { + return true; + } + else + { + __result = RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight); + return false; + } + } + } +} diff --git a/NewHorizons/Patches/AudioSignalPatches.cs b/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs similarity index 66% rename from NewHorizons/Patches/AudioSignalPatches.cs rename to NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs index 9811bc77a..5470d5f2f 100644 --- a/NewHorizons/Patches/AudioSignalPatches.cs +++ b/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs @@ -5,13 +5,13 @@ using System; using UnityEngine; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.SignalPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(AudioSignal))] public static class AudioSignalPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.SignalNameToString))] + [HarmonyPatch(nameof(AudioSignal.SignalNameToString))] public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __result) { var customSignalName = SignalBuilder.GetCustomSignalName(__0); @@ -24,83 +24,45 @@ public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __r } [HarmonyPrefix] - [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.FrequencyToIndex))] + [HarmonyPatch(nameof(AudioSignal.FrequencyToIndex))] public static bool AudioSignal_FrequencyToIndex(SignalFrequency __0, ref int __result) { - switch (__0) + __result = __0 switch { - case (SignalFrequency.Default): - __result = 0; - break; - case (SignalFrequency.Traveler): - __result = 1; - break; - case (SignalFrequency.Quantum): - __result = 2; - break; - case (SignalFrequency.EscapePod): - __result = 3; - break; - case (SignalFrequency.WarpCore): - __result = 4; - break; - case (SignalFrequency.HideAndSeek): - __result = 5; - break; - case (SignalFrequency.Radio): - __result = 6; - break; - case (SignalFrequency.Statue): - __result = 7; - break; - default: - // Frequencies are in powers of 2 - __result = (int)(Mathf.Log((float)__0) / Mathf.Log(2f)); - break; - } - + SignalFrequency.Default => 0, + SignalFrequency.Traveler => 1, + SignalFrequency.Quantum => 2, + SignalFrequency.EscapePod => 3, + SignalFrequency.WarpCore => 4, + SignalFrequency.HideAndSeek => 5, + SignalFrequency.Radio => 6, + SignalFrequency.Statue => 7, + _ => (int)(Mathf.Log((float)__0) / Mathf.Log(2f)),// Frequencies are in powers of 2 + }; return false; } [HarmonyPrefix] - [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.IndexToFrequency))] + [HarmonyPatch(nameof(AudioSignal.IndexToFrequency))] public static bool AudioSignal_IndexToFrequency(int __0, ref SignalFrequency __result) { - switch (__0) + __result = __0 switch { - case 0: - __result = SignalFrequency.Default; - break; - case 1: - __result = SignalFrequency.Traveler; - break; - case 2: - __result = SignalFrequency.Quantum; - break; - case 3: - __result = SignalFrequency.EscapePod; - break; - case 4: - __result = SignalFrequency.WarpCore; - break; - case 5: - __result = SignalFrequency.HideAndSeek; - break; - case 6: - __result = SignalFrequency.Radio; - break; - case 7: - __result = SignalFrequency.Statue; - break; - default: - __result = (SignalFrequency)(Math.Pow(2, __0)); - break; - } + 0 => SignalFrequency.Default, + 1 => SignalFrequency.Traveler, + 2 => SignalFrequency.Quantum, + 3 => SignalFrequency.EscapePod, + 4 => SignalFrequency.WarpCore, + 5 => SignalFrequency.HideAndSeek, + 6 => SignalFrequency.Radio, + 7 => SignalFrequency.Statue, + _ => (SignalFrequency)Math.Pow(2, __0), + }; return false; } [HarmonyPrefix] - [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.FrequencyToString))] + [HarmonyPatch(nameof(AudioSignal.FrequencyToString))] public static bool AudioSignal_FrequencyToString(SignalFrequency __0, ref string __result) { var customName = SignalBuilder.GetCustomFrequencyName(__0); @@ -114,13 +76,13 @@ public static bool AudioSignal_FrequencyToString(SignalFrequency __0, ref string } [HarmonyPrefix] - [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.UpdateSignalStrength))] + [HarmonyPatch(nameof(AudioSignal.UpdateSignalStrength))] public static bool AudioSignal_UpdateSignalStrength(AudioSignal __instance, Signalscope scope, float distToClosestScopeObstruction) { if (!SignalBuilder.Initialized) return true; - var isCloaked = SignalBuilder.IsCloaked(__instance._name); - var isOnQuantumMoon = SignalBuilder.IsOnQuantumMoon(__instance._name); + var isCloaked = __instance._name.IsCloaked(); + var isOnQuantumMoon = __instance._name.IsOnQuantumMoon(); if (!isCloaked && !isOnQuantumMoon) return true; @@ -213,12 +175,5 @@ public static bool AudioSignal_UpdateSignalStrength(AudioSignal __instance, Sign return false; } - - [HarmonyPrefix] - [HarmonyPatch(typeof(TravelerAudioManager), nameof(TravelerAudioManager.Update))] - public static void TravelerAudioManager_Update(TravelerAudioManager __instance) - { - __instance._signals.RemoveAll(signal => signal == null || signal.gameObject == null || signal._owAudioSource == null || signal._owAudioSource._audioSource == null); - } } } diff --git a/NewHorizons/Patches/SignalScopePatches.cs b/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs similarity index 59% rename from NewHorizons/Patches/SignalScopePatches.cs rename to NewHorizons/Patches/SignalPatches/SignalscopePatches.cs index 6f1cdb2d2..b6e241a46 100644 --- a/NewHorizons/Patches/SignalScopePatches.cs +++ b/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs @@ -1,33 +1,34 @@ -using HarmonyLib; +using HarmonyLib; using NewHorizons.Builder.Props; -namespace NewHorizons.Patches + +namespace NewHorizons.Patches.SignalPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(Signalscope))] public static class SignalScopePatches { [HarmonyPrefix] - [HarmonyPatch(typeof(Signalscope), nameof(Signalscope.Awake))] - public static bool Signalscope_Awake(Signalscope __instance) + [HarmonyPatch(nameof(Signalscope.Awake))] + public static void Signalscope_Awake(Signalscope __instance) { __instance._strongestSignals = new AudioSignal[8]; - return true; } [HarmonyPrefix] - [HarmonyPatch(typeof(Signalscope), nameof(Signalscope.SwitchFrequencyFilter))] + [HarmonyPatch(nameof(Signalscope.SwitchFrequencyFilter))] public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int __0) { var increment = __0; var count = SignalBuilder.NumberOfFrequencies; __instance._frequencyFilterIndex += increment; - __instance._frequencyFilterIndex = ((__instance._frequencyFilterIndex >= count) ? 0 : __instance._frequencyFilterIndex); - __instance._frequencyFilterIndex = ((__instance._frequencyFilterIndex < 0) ? count - 1 : __instance._frequencyFilterIndex); + __instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 0 : __instance._frequencyFilterIndex; + __instance._frequencyFilterIndex = __instance._frequencyFilterIndex < 0 ? count - 1 : __instance._frequencyFilterIndex; SignalFrequency signalFrequency = AudioSignal.IndexToFrequency(__instance._frequencyFilterIndex); if (!PlayerData.KnowsFrequency(signalFrequency) && (!__instance._isUnknownFreqNearby || __instance._unknownFrequency != signalFrequency)) { __instance.SwitchFrequencyFilter(increment); } + return false; } } diff --git a/NewHorizons/Patches/SignalPatches/TravelerAudioManagerPatches.cs b/NewHorizons/Patches/SignalPatches/TravelerAudioManagerPatches.cs new file mode 100644 index 000000000..af33b3f5f --- /dev/null +++ b/NewHorizons/Patches/SignalPatches/TravelerAudioManagerPatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.SignalPatches +{ + [HarmonyPatch(typeof(TravelerAudioManager))] + public static class TravelerAudioManagerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(TravelerAudioManager.Update))] + public static void TravelerAudioManager_Update(TravelerAudioManager __instance) + { + __instance._signals.RemoveAll(signal => signal == null || signal.gameObject == null || signal._owAudioSource == null || signal._owAudioSource._audioSource == null); + } + } +} diff --git a/NewHorizons/Patches/SingularityPatches.cs b/NewHorizons/Patches/SingularityPatches.cs deleted file mode 100644 index e172c9e1c..000000000 --- a/NewHorizons/Patches/SingularityPatches.cs +++ /dev/null @@ -1,51 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class SingularityPatches - { - // For our custom black holes that don't link to anything - [HarmonyPrefix] - [HarmonyPatch(typeof(BlackHoleVolume), nameof(BlackHoleVolume.Start))] - public static bool BlackHoleVolume_Start(BlackHoleVolume __instance) - { - return __instance._whiteHole == null; - } - - // To fix custom white holes - [HarmonyPrefix] - [HarmonyPatch(typeof(WhiteHoleVolume), nameof(WhiteHoleVolume.Awake))] - public static bool WhiteHoleVolume_Awake(WhiteHoleVolume __instance) - { - __instance._growQueue = new List(8); - __instance._growQueueLocationData = new List(8); - __instance._ejectedBodyList = new List(64); - try - { - __instance._whiteHoleBody = __instance.gameObject.GetAttachedOWRigidbody(false); - __instance._whiteHoleProxyShadowSuperGroup = __instance._whiteHoleBody.GetComponentInChildren(); - __instance._fluidVolume = __instance.gameObject.GetRequiredComponent(); - } - catch (Exception) { } - return false; - } - - // This is to stop the game throwing too many errors if the probe is destroyed by a blackhole - [HarmonyPrefix] - [HarmonyPatch(typeof(SurveyorProbe), nameof(SurveyorProbe.IsLaunched))] - public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, ref bool __result) - { - try - { - __result = __instance.gameObject.activeSelf; - } - catch (Exception) - { - __result = true; - } - return false; - } - } -} diff --git a/NewHorizons/Patches/StreamingPatches.cs b/NewHorizons/Patches/StreamingPatches.cs deleted file mode 100644 index 85acd0abe..000000000 --- a/NewHorizons/Patches/StreamingPatches.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using NewHorizons.Handlers; -using OWML.Logging; - -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class StreamingPatches - { - [HarmonyPrefix] - [HarmonyPatch(typeof(StreamingManager), nameof(StreamingManager.UnloadStreamingAssets))] - public static bool StreamingManager_UnloadStreamingAssets(string assetBundleName) - { - // Only let it unload stuff that isn't being used - return !StreamingHandler.IsBundleInUse(assetBundleName); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(UnityLogger), "OnLogMessageReceived")] - public static bool UnityLogger_OnLogMessageReceived(string message) - { - // Filter out goofy error that doesn't actually break anything - return !message.EndsWith(") is out of bounds (size=0)"); - } - } -} diff --git a/NewHorizons/Patches/StreamingPatches/NomaiRemoteCameraStreamingPatches.cs b/NewHorizons/Patches/StreamingPatches/NomaiRemoteCameraStreamingPatches.cs new file mode 100644 index 000000000..e520a99fc --- /dev/null +++ b/NewHorizons/Patches/StreamingPatches/NomaiRemoteCameraStreamingPatches.cs @@ -0,0 +1,47 @@ +using HarmonyLib; +using NewHorizons.Handlers; + +namespace NewHorizons.Patches.StreamingPatches +{ + [HarmonyPatch(typeof(NomaiRemoteCameraStreaming))] + public class NomaiRemoteCameraStreamingPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(NomaiRemoteCameraStreaming.NomaiRemoteCameraPlatformIDToSceneName))] + public static bool NomaiRemoteCameraStreaming_NomaiRemoteCameraPlatformIDToSceneName(NomaiRemoteCameraPlatform.ID id, out string __result) + { + __result = id switch + { + NomaiRemoteCameraPlatform.ID.SunStation => "SolarSystem", + NomaiRemoteCameraPlatform.ID.HGT_TimeLoop or NomaiRemoteCameraPlatform.ID.HGT_TLE => "HourglassTwins", + NomaiRemoteCameraPlatform.ID.TH_Mine or NomaiRemoteCameraPlatform.ID.THM_EyeLocator => "TimberHearth", + NomaiRemoteCameraPlatform.ID.BH_Observatory or NomaiRemoteCameraPlatform.ID.BH_GravityCannon or NomaiRemoteCameraPlatform.ID.BH_QuantumFragment or NomaiRemoteCameraPlatform.ID.BH_BlackHoleForge or NomaiRemoteCameraPlatform.ID.BH_NorthPole or NomaiRemoteCameraPlatform.ID.VM_Interior => "BrittleHollow", + NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland1 or NomaiRemoteCameraPlatform.ID.GD_ConstructionYardIsland2 or NomaiRemoteCameraPlatform.ID.GD_StatueIsland or NomaiRemoteCameraPlatform.ID.GD_ProbeCannonSunkenModule or NomaiRemoteCameraPlatform.ID.GD_ProbeCannonDamagedModule or NomaiRemoteCameraPlatform.ID.GD_ProbeCannonIntactModule => "GiantsDeep", + NomaiRemoteCameraPlatform.ID.None => "", + _ => PlatformKeyToSceneName(id), + }; + return false; + } + + private static string PlatformKeyToSceneName(NomaiRemoteCameraPlatform.ID id) + { + var key = RemoteHandler.GetPlatformIDKey(id); + var _ = key.IndexOf("_"); + return (_ == -1 ? key : key.Substring(0, _)) switch + { + "SS" => "SolarSystem", + "HGT" or "CT" or "TT" => "HourglassTwins", + "CO" => "Comet", + "QM" => "QuantumMoon", + "GD" => "GiantsDeep", + "BH" or "VM" => "BrittleHollow", + "TH" or "THM" => "TimberHearth", + "DB" => "DarkBramble", + "WH" => "WhiteHole", + "RW" => "RingWorld", + "DW" => "DreamWorld", + _ => key, + }; + } + } +} diff --git a/NewHorizons/Patches/StreamingPatches/StreamingManagerPatches.cs b/NewHorizons/Patches/StreamingPatches/StreamingManagerPatches.cs new file mode 100644 index 000000000..db34067cf --- /dev/null +++ b/NewHorizons/Patches/StreamingPatches/StreamingManagerPatches.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using NewHorizons.Handlers; +using OWML.Logging; + +namespace NewHorizons.Patches.StreamingPatches +{ + [HarmonyPatch(typeof(StreamingManager))] + public static class StreamingManagerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(StreamingManager.UnloadStreamingAssets))] + public static bool StreamingManager_UnloadStreamingAssets(string assetBundleName) + { + // Only let it unload stuff that isn't being used + return !StreamingHandler.IsBundleInUse(assetBundleName); + } + } +} diff --git a/NewHorizons/Patches/StreamingPatches/UnityLoggerPatches.cs b/NewHorizons/Patches/StreamingPatches/UnityLoggerPatches.cs new file mode 100644 index 000000000..ac772441b --- /dev/null +++ b/NewHorizons/Patches/StreamingPatches/UnityLoggerPatches.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using OWML.Logging; + +namespace NewHorizons.Patches.StreamingPatches +{ + [HarmonyPatch(typeof(UnityLogger))] + public static class UnityLoggerPatches + { + [HarmonyPrefix] + [HarmonyPatch("OnLogMessageReceived")] + public static bool UnityLogger_OnLogMessageReceived(string message) + { + // Filter out goofy error that doesn't actually break anything + return !message.EndsWith(") is out of bounds (size=0)"); + } + } +} diff --git a/NewHorizons/Patches/SunPatches.cs b/NewHorizons/Patches/SunPatches.cs deleted file mode 100644 index 447028bd7..000000000 --- a/NewHorizons/Patches/SunPatches.cs +++ /dev/null @@ -1,65 +0,0 @@ -using HarmonyLib; -using UnityEngine; -namespace NewHorizons.Patches -{ - [HarmonyPatch] - public static class SunPatches - { - [HarmonyPrefix] - [HarmonyPatch(typeof(SunLightParamUpdater), nameof(SunLightParamUpdater.LateUpdate))] - public static bool SunLightParamUpdater_LateUpdate(SunLightParamUpdater __instance) - { - if (__instance.sunLight) - { - Vector3 position = __instance.transform.position; - float w = 2000f; - if (__instance._sunController != null) - { - w = (__instance._sunController.HasSupernovaStarted() ? __instance._sunController.GetSupernovaRadius() : __instance._sunController.GetSurfaceRadius()); - } - float range = __instance.sunLight.range; - Color color = (__instance._sunLightController != null) ? __instance._sunLightController.sunColor : __instance.sunLight.color; - float w2 = (__instance._sunLightController != null) ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity; - Shader.SetGlobalVector(__instance._propID_SunPosition, new Vector4(position.x, position.y, position.z, w)); - Shader.SetGlobalVector(__instance._propID_OWSunPositionRange, new Vector4(position.x, position.y, position.z, 1f / (range * range))); - Shader.SetGlobalVector(__instance._propID_OWSunColorIntensity, new Vector4(color.r, color.g, color.b, w2)); - } - - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(SunSurfaceAudioController), nameof(SunSurfaceAudioController.Update))] - public static bool SunSurfaceAudioController_Update(SunSurfaceAudioController __instance) - { - if (__instance._sunController != null) return true; - - var surfaceRadius = __instance.transform.parent.parent.localScale.magnitude; - float value = Mathf.Max(0f, Vector3.Distance(Locator.GetPlayerCamera().transform.position, __instance.transform.position) - surfaceRadius); - float num = Mathf.InverseLerp(1600f, 100f, value); - __instance._audioSource.SetLocalVolume(num * num * __instance._fade); - return false; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateScales))] - public static bool SunProxyEffectController_UpdateScales(SunProxyEffectController __instance) - { - return __instance != null && __instance._surface != null && __instance._fog != null && __instance._fogMaterial != null && __instance._solarFlareEmitter != null && __instance._atmosphere != null; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateAtmosphereRadii))] - public static bool SunProxyEffectController_UpdateAtmosphereRadii(SunProxyEffectController __instance) - { - return __instance != null && __instance.transform != null && __instance.transform.parent != null && __instance._atmosphereMaterial != null; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(VanishVolume), nameof(VanishVolume.Shrink))] - public static bool VanishVolume_Shrink(VanishVolume __instance, OWRigidbody bodyToShrink) - { - return __instance != null && __instance.transform != null && __instance._shrinkingBodies != null && __instance._shrinkingBodyLocationData != null && bodyToShrink != null; - } - } -} diff --git a/NewHorizons/Patches/SunPatches/SunControllerPatches.cs b/NewHorizons/Patches/SunPatches/SunControllerPatches.cs new file mode 100644 index 000000000..222b87f01 --- /dev/null +++ b/NewHorizons/Patches/SunPatches/SunControllerPatches.cs @@ -0,0 +1,18 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.SunPatches +{ + [HarmonyPatch(typeof(SunController))] + public static class SunControllerPatches + { + /// + /// Disables sun logic if no time loop + /// + [HarmonyPrefix] + [HarmonyPatch(nameof(SunController.Update))] + [HarmonyPatch(nameof(SunController.UpdateScale))] + [HarmonyPatch(nameof(SunController.OnTriggerSupernova))] + public static bool SunController_DisableWithoutTimeLoop(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled; + + } +} diff --git a/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs b/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs new file mode 100644 index 000000000..45d68e3e9 --- /dev/null +++ b/NewHorizons/Patches/SunPatches/SunLightParamUpdaterPatches.cs @@ -0,0 +1,31 @@ +using HarmonyLib; +using UnityEngine; +namespace NewHorizons.Patches.SunPatches +{ + [HarmonyPatch(typeof(SunLightParamUpdater))] + public static class SunLightParamUpdaterPatches + { + [HarmonyPrefix] + [HarmonyPatch(typeof(SunLightParamUpdater), nameof(SunLightParamUpdater.LateUpdate))] + public static bool SunLightParamUpdater_LateUpdate(SunLightParamUpdater __instance) + { + if (__instance.sunLight) + { + Vector3 position = __instance.transform.position; + float w = 2000f; + if (__instance._sunController != null) + { + w = __instance._sunController.HasSupernovaStarted() ? __instance._sunController.GetSupernovaRadius() : __instance._sunController.GetSurfaceRadius(); + } + float range = __instance.sunLight.range; + Color color = __instance._sunLightController != null ? __instance._sunLightController.sunColor : __instance.sunLight.color; + float w2 = __instance._sunLightController != null ? __instance._sunLightController.sunIntensity : __instance.sunLight.intensity; + Shader.SetGlobalVector(__instance._propID_SunPosition, new Vector4(position.x, position.y, position.z, w)); + Shader.SetGlobalVector(__instance._propID_OWSunPositionRange, new Vector4(position.x, position.y, position.z, 1f / (range * range))); + Shader.SetGlobalVector(__instance._propID_OWSunColorIntensity, new Vector4(color.r, color.g, color.b, w2)); + } + + return false; + } + } +} diff --git a/NewHorizons/Patches/SunPatches/SunSurfaceAudioControllerPatches.cs b/NewHorizons/Patches/SunPatches/SunSurfaceAudioControllerPatches.cs new file mode 100644 index 000000000..d4040f3ff --- /dev/null +++ b/NewHorizons/Patches/SunPatches/SunSurfaceAudioControllerPatches.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using UnityEngine; + +namespace NewHorizons.Patches.SunPatches +{ + [HarmonyPatch(typeof(SunSurfaceAudioController))] + public static class SunSurfaceAudioControllerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(SunSurfaceAudioController.Update))] + public static bool SunSurfaceAudioController_Update(SunSurfaceAudioController __instance) + { + if (__instance._sunController != null) return true; + + var surfaceRadius = __instance.transform.parent.parent.localScale.magnitude; + float value = Mathf.Max(0f, Vector3.Distance(Locator.GetPlayerCamera().transform.position, __instance.transform.position) - surfaceRadius); + float num = Mathf.InverseLerp(1600f, 100f, value); + __instance._audioSource.SetLocalVolume(num * num * __instance._fade); + return false; + } + } +} diff --git a/NewHorizons/Patches/TimeLoopPatches.cs b/NewHorizons/Patches/TimeLoopPatches.cs index d627d2b40..5628fa155 100644 --- a/NewHorizons/Patches/TimeLoopPatches.cs +++ b/NewHorizons/Patches/TimeLoopPatches.cs @@ -6,52 +6,13 @@ namespace NewHorizons.Patches public static class TimeLoopPatches { /// - /// Disables starfield updates + /// Disable certain behaviours without timeloop /// [HarmonyPrefix] [HarmonyPatch(typeof(StarfieldController), nameof(StarfieldController.Update))] - public static bool StarfieldController_Update() => Main.Instance.TimeLoopEnabled; - - /// - /// Disables interloper destruction - /// - [HarmonyPrefix] [HarmonyPatch(typeof(TempCometCollisionFix), nameof(TempCometCollisionFix.Update))] - public static bool TempCometCollisionFix_Update() => Main.Instance.TimeLoopEnabled; - - /// - /// Disables sun logic - /// - [HarmonyPrefix] - [HarmonyPatch(typeof(SunController), nameof(SunController.Update))] - public static bool SunController_Update(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled; - - /// - /// Disables sun expansion - /// - [HarmonyPrefix] - [HarmonyPatch(typeof(SunController), nameof(SunController.UpdateScale))] - public static bool SunController_UpdateScale(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled; - - /// - /// Disables sun collapse SFX - /// - [HarmonyPrefix] - [HarmonyPatch(typeof(SunController), nameof(SunController.OnTriggerSupernova))] - public static bool SunController_OnTriggerSupernova(SunController __instance) => Main.Instance.TimeLoopEnabled && __instance.isActiveAndEnabled; - - /// - /// Disables end times music - /// - [HarmonyPrefix] [HarmonyPatch(typeof(GlobalMusicController), nameof(GlobalMusicController.UpdateEndTimesMusic))] - public static bool GlobalMusicController_UpdateEndTimesMusic() => Main.Instance.TimeLoopEnabled; - - /// - /// Disables supernova trigger - /// - [HarmonyPrefix] [HarmonyPatch(typeof(TimeLoop), nameof(TimeLoop.Update))] - public static bool TimeLoop_Update() => Main.Instance.TimeLoopEnabled; + public static bool DisableWithoutTimeLoop() => Main.Instance.TimeLoopEnabled; } } diff --git a/NewHorizons/Patches/ToolPatches/ProbeLauncherPatches.cs b/NewHorizons/Patches/ToolPatches/ProbeLauncherPatches.cs new file mode 100644 index 000000000..a2e38c286 --- /dev/null +++ b/NewHorizons/Patches/ToolPatches/ProbeLauncherPatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.ToolPatches +{ + [HarmonyPatch(typeof(ProbeLauncher))] + public static class ProbeLauncherPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(ProbeLauncher.UpdateOrbitalLaunchValues))] + public static bool ProbeLauncher_UpdateOrbitalLaunchValues(ProbeLauncher __instance) + { + return Locator.GetPlayerRulesetDetector()?.GetPlanetoidRuleset()?.GetGravityVolume() != null; + } + } +} diff --git a/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs b/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs new file mode 100644 index 000000000..08cd5d15c --- /dev/null +++ b/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using System; + +namespace NewHorizons.Patches.ToolPatches +{ + [HarmonyPatch(typeof(SurveyorProbe))] + public static class SurveyorProbePatches + { + // This is to stop the game throwing too many errors if the probe is destroyed by a blackhole + [HarmonyPrefix] + [HarmonyPatch(nameof(SurveyorProbe.IsLaunched))] + public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, ref bool __result) + { + __result = __instance?.gameObject?.activeSelf ?? false; + return false; + } + } +} diff --git a/NewHorizons/Patches/ToolModeSwapperPatches.cs b/NewHorizons/Patches/ToolPatches/ToolModeSwapperPatches.cs similarity index 73% rename from NewHorizons/Patches/ToolModeSwapperPatches.cs rename to NewHorizons/Patches/ToolPatches/ToolModeSwapperPatches.cs index ec5e4a935..63986a2a4 100644 --- a/NewHorizons/Patches/ToolModeSwapperPatches.cs +++ b/NewHorizons/Patches/ToolPatches/ToolModeSwapperPatches.cs @@ -1,16 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using HarmonyLib; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.ToolPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(ToolModeSwapper))] public static class ToolModeSwapperPatches { - // Patches ToolModeSwapper.EquipToolMode(ToolMode mode) to deny swaps if you're holding a vision torch. // This is critical for preventing swapping to the scout launcher (causes memory slides to fail) but it // just doesn't look right when you switch to other stuff (eg the signalscope), so I'm disabling swapping tools entirely @@ -19,15 +13,15 @@ public static class ToolModeSwapperPatches // to include a check for "is holding vision torch", but I'm not copy/pasting an entire function, no sir // if (((_currentToolMode == ToolMode.None || _currentToolMode == ToolMode.Item) && Locator.GetPlayerSuit().IsWearingSuit(includeTrainingSuit: false)) || ((_currentToolMode == ToolMode.None || _currentToolMode == ToolMode.SignalScope) && OWInput.IsInputMode(InputMode.ShipCockpit))) [HarmonyPrefix] - [HarmonyPatch(typeof(ToolModeSwapper), nameof(ToolModeSwapper.EquipToolMode))] + [HarmonyPatch(nameof(ToolModeSwapper.EquipToolMode))] public static bool ToolModeSwapper_EquipToolMode(ToolModeSwapper __instance, ToolMode mode) { var isHoldingVisionTorch = __instance.GetItemCarryTool()?.GetHeldItemType() == ItemType.VisionTorch; - var swappingToRestrictedTool = - mode == ToolMode.Probe || - mode == ToolMode.SignalScope || + var swappingToRestrictedTool = + mode == ToolMode.Probe || + mode == ToolMode.SignalScope || mode == ToolMode.Translator; - var isInShip = UnityEngine.GameObject.FindObjectOfType()?._playerAtFlightConsole ?? false; + var isInShip = UnityEngine.Object.FindObjectOfType()?._playerAtFlightConsole ?? false; if (!isInShip && isHoldingVisionTorch && swappingToRestrictedTool) return false; diff --git a/NewHorizons/Patches/VisionTorchPatches.cs b/NewHorizons/Patches/VisionTorchPatches.cs deleted file mode 100644 index 9a0b7b56f..000000000 --- a/NewHorizons/Patches/VisionTorchPatches.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using NewHorizons.Builder.Props; -using UnityEngine; - -namespace NewHorizons.Patches -{ - - [HarmonyPatch] - public static class MindProjectorTriggerPatches - { - [HarmonyPrefix] - [HarmonyPatch(typeof(MindProjectorTrigger), nameof(MindProjectorTrigger.OnTriggerVolumeEntry))] - public static bool MindProjectorTrigger_OnTriggerVolumeEntry(MindProjectorTrigger __instance, GameObject hitObj) - { - var t = hitObj.GetComponent(); - if (t != null) //(hitObj.CompareTag("PrisonerDetector")) - { - __instance._mindProjector.OnProjectionStart += t.onSlidesStart; - __instance._mindProjector.OnProjectionComplete += t.onSlidesComplete; - __instance._mindProjector.SetMindSlideCollection(t.slideCollection); - - __instance.OnBeamStartHitPrisoner.Invoke(); - __instance._mindProjector.Play(reset: true); - __instance._mindProjector.OnProjectionStart += __instance.OnProjectionStart; - __instance._mindProjector.OnProjectionComplete += __instance.OnProjectionComplete; - - Locator.GetPlayerTransform().GetComponent().LockOn(hitObj.transform, Vector3.zero); - __instance._playerLockedOn = true; - return false; - } - - return true; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(MindProjectorTrigger), nameof(MindProjectorTrigger.OnTriggerVolumeExit))] - private static bool MindProjectorTrigger_OnTriggerVolumeExit(MindProjectorTrigger __instance, GameObject hitObj) - { - var t = hitObj.GetComponent(); - if (t != null) //(hitObj.CompareTag("PrisonerDetector")) - { - __instance._mindProjector.OnProjectionStart -= t.onSlidesStart; - __instance._mindProjector.OnProjectionComplete -= t.onSlidesComplete; - } - return true; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(MindSlideProjector), nameof(MindSlideProjector.SetMindSlideCollection))] - private static bool MindSlideProjector_SetMindSlideCollection(MindSlideProjector __instance, MindSlideCollection mindSlideCollection) - { - if (mindSlideCollection == null) return false; - - if (__instance._mindSlideCollection == mindSlideCollection) return false; - - // Original method didn't check if old _slideCollectionItem was null. - if (__instance._slideCollectionItem != null) - { - __instance._slideCollectionItem.onSlideTextureUpdated -= __instance.OnSlideTextureUpdated; - __instance._slideCollectionItem.onPlayBeatAudio -= __instance.OnPlayBeatAudio; - } - - __instance._mindSlideCollection = mindSlideCollection; - __instance._defaultSlideDuration = mindSlideCollection.defaultSlideDuration; - - __instance._slideCollectionItem = mindSlideCollection.slideCollectionContainer; - __instance._slideCollectionItem.onSlideTextureUpdated += __instance.OnSlideTextureUpdated; - __instance._slideCollectionItem.onPlayBeatAudio += __instance.OnPlayBeatAudio; - __instance._slideCollectionItem.Initialize(); - __instance._slideCollectionItem.enabled = false; - - return false; - } - } - - [HarmonyPatch] - public static class VisionTorchItemPatches - { - // This is some dark magic - // this creates a method called base_DropItem that basically just calls OWItem.PickUpItem whenever it (VisionTorchItemPatches.base_PickUpItem) is called - [HarmonyReversePatch] - [HarmonyPatch(typeof(OWItem), nameof(OWItem.DropItem))] - private static void base_DropItem(OWItem instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget) { } - - - // Make the vision torch droppable. In the base game you can only drop it if you're in the dream world. - [HarmonyPrefix] - [HarmonyPatch(typeof(VisionTorchItem), nameof(VisionTorchItem.DropItem))] - public static bool VisionTorchItem_DropItem(VisionTorchItem __instance, Vector3 position, Vector3 normal, Transform parent, Sector sector, IItemDropTarget customDropTarget) - { - if (!Locator.GetDreamWorldController().IsInDream()) - { - base_DropItem(__instance, position, normal, parent, sector, customDropTarget); - } - - if (__instance._wasProjecting) __instance._mindProjectorTrigger.SetProjectorActive(false); - - __instance.gameObject.GetComponent().enabled = true; - - return true; - } - } -} diff --git a/NewHorizons/Patches/VolumePatches/BlackHoleVolumePatches.cs b/NewHorizons/Patches/VolumePatches/BlackHoleVolumePatches.cs new file mode 100644 index 000000000..65cd95b7f --- /dev/null +++ b/NewHorizons/Patches/VolumePatches/BlackHoleVolumePatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.VolumePatches +{ + [HarmonyPatch(typeof(BlackHoleVolume))] + public static class BlackHoleVolumePatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(BlackHoleVolume.Start))] + public static bool BlackHoleVolume_Start(BlackHoleVolume __instance) + { + return __instance._whiteHole == null; + } + } +} diff --git a/NewHorizons/Patches/DestructionVolumePatches.cs b/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs similarity index 95% rename from NewHorizons/Patches/DestructionVolumePatches.cs rename to NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs index e29e3d024..45564b50b 100644 --- a/NewHorizons/Patches/DestructionVolumePatches.cs +++ b/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.VolumePatches { [HarmonyPatch] public static class DestructionVolumePatches diff --git a/NewHorizons/Patches/VolumePatches/FluidVolumePatches.cs b/NewHorizons/Patches/VolumePatches/FluidVolumePatches.cs new file mode 100644 index 000000000..a85acc0f3 --- /dev/null +++ b/NewHorizons/Patches/VolumePatches/FluidVolumePatches.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using UnityEngine; + +namespace NewHorizons.Patches.VolumePatches +{ + [HarmonyPatch(typeof(FluidVolume))] + public static class FluidVolumePatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(FluidVolume.GetDepthAtPosition))] + public static bool FluidVolume_GetDepthAtPosition(FluidVolume __instance, ref float __result, Vector3 worldPosition) + { + if (__instance is not RadialFluidVolume radialFluidVolume) return true; + + Vector3 vector = radialFluidVolume.transform.InverseTransformPoint(worldPosition); + __result = Mathf.Sqrt(vector.x * vector.x + vector.z * vector.z + vector.y * vector.y) - radialFluidVolume._radius; + return false; + } + } +} diff --git a/NewHorizons/Patches/BramblePatches.cs b/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs similarity index 80% rename from NewHorizons/Patches/BramblePatches.cs rename to NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs index fcec7f303..21283d6e9 100644 --- a/NewHorizons/Patches/BramblePatches.cs +++ b/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs @@ -1,17 +1,11 @@ using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.VolumePatches { [HarmonyPatch] - public static class BramblePatches + public static class FogWarpVolumePatches { - [HarmonyPrefix] [HarmonyPatch(typeof(SphericalFogWarpVolume), nameof(SphericalFogWarpVolume.IsProbeOnly))] public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, ref bool __result) @@ -22,7 +16,7 @@ public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __i [HarmonyPrefix] [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.GetFogThickness))] - public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result) + public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result) { if (__instance is InnerFogWarpVolume sph) __result = sph._exitRadius; else __result = 50; // 50f is hardcoded as the return value in the base game diff --git a/NewHorizons/Patches/VolumePatches/VanishVolumePatches.cs b/NewHorizons/Patches/VolumePatches/VanishVolumePatches.cs new file mode 100644 index 000000000..9b1b8ab21 --- /dev/null +++ b/NewHorizons/Patches/VolumePatches/VanishVolumePatches.cs @@ -0,0 +1,15 @@ +using HarmonyLib; + +namespace NewHorizons.Patches.VolumePatches +{ + [HarmonyPatch(typeof(VanishVolume))] + public static class VanishVolumePatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(VanishVolume.Shrink))] + public static bool VanishVolume_Shrink(VanishVolume __instance, OWRigidbody bodyToShrink) + { + return __instance != null && __instance.transform != null && __instance._shrinkingBodies != null && __instance._shrinkingBodyLocationData != null && bodyToShrink != null; + } + } +} diff --git a/NewHorizons/Patches/VolumePatches/WhiteHoleVolumePatches.cs b/NewHorizons/Patches/VolumePatches/WhiteHoleVolumePatches.cs new file mode 100644 index 000000000..0abf582f3 --- /dev/null +++ b/NewHorizons/Patches/VolumePatches/WhiteHoleVolumePatches.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; + +namespace NewHorizons.Patches.VolumePatches +{ + [HarmonyPatch(typeof(WhiteHoleVolume))] + public static class WhiteHoleVolumePatches + { + // To fix custom white holes + [HarmonyPrefix] + [HarmonyPatch(nameof(WhiteHoleVolume.Awake))] + public static bool WhiteHoleVolume_Awake(WhiteHoleVolume __instance) + { + __instance._growQueue = new List(8); + __instance._growQueueLocationData = new List(8); + __instance._ejectedBodyList = new List(64); + try + { + __instance._whiteHoleBody = __instance.gameObject.GetAttachedOWRigidbody(false); + __instance._whiteHoleProxyShadowSuperGroup = __instance._whiteHoleBody.GetComponentInChildren(); + __instance._fluidVolume = __instance.gameObject.GetRequiredComponent(); + } + catch (Exception) { } + return false; + } + } +} diff --git a/NewHorizons/Patches/EyeCoordinatePromptTriggerPatches.cs b/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs similarity index 96% rename from NewHorizons/Patches/EyeCoordinatePromptTriggerPatches.cs rename to NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs index ed827a6f7..9afd44e93 100644 --- a/NewHorizons/Patches/EyeCoordinatePromptTriggerPatches.cs +++ b/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs @@ -2,7 +2,7 @@ using NewHorizons.Handlers; using UnityEngine; -namespace NewHorizons.Patches +namespace NewHorizons.Patches.WarpPatches { [HarmonyPatch] public static class EyeCoordinatePromptTriggerPatches diff --git a/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs b/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs new file mode 100644 index 000000000..f34b97855 --- /dev/null +++ b/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using NewHorizons.Utility; + +namespace NewHorizons.Patches.WarpPatches +{ + [HarmonyPatch(typeof(NomaiCoordinateInterface))] + public static class NomaiCoordinateInterfacePatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(NomaiCoordinateInterface.SetPillarRaised), new System.Type[] { typeof(bool) })] + public static bool NomaiCoordinateInterface_SetPillarRaised(NomaiCoordinateInterface __instance, bool raised) + { + if (raised) + return !(!__instance._powered || __instance.CheckEyeCoordinates() && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || __instance.CheckAllCoordinates(out string targetSystem) && Main.Instance.CurrentStarSystem != targetSystem); + return true; + } + } +} diff --git a/NewHorizons/Patches/WarpDrivePatches.cs b/NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs similarity index 77% rename from NewHorizons/Patches/WarpDrivePatches.cs rename to NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs index 4520fa977..b17b02486 100644 --- a/NewHorizons/Patches/WarpDrivePatches.cs +++ b/NewHorizons/Patches/WarpPatches/ShipCockpitControllerPatches.cs @@ -1,14 +1,13 @@ using HarmonyLib; using NewHorizons.Handlers; -using NewHorizons.Utility; -using UnityEngine; -namespace NewHorizons.Patches + +namespace NewHorizons.Patches.WarpPatches { - [HarmonyPatch] - public static class WarpDrivePatches + [HarmonyPatch(typeof(ShipCockpitController))] + public static class ShipCockpitControllerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(ShipCockpitController), nameof(ShipCockpitController.Update))] + [HarmonyPatch(nameof(ShipCockpitController.Update))] public static bool ShipCockpitController_Update(ShipCockpitController __instance) { if (!Main.HasWarpDrive) return true; diff --git a/NewHorizons/Patches/NomaiCoordinatePatches.cs b/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs similarity index 69% rename from NewHorizons/Patches/NomaiCoordinatePatches.cs rename to NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs index 5191ceca8..1a6df7435 100644 --- a/NewHorizons/Patches/NomaiCoordinatePatches.cs +++ b/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs @@ -1,22 +1,13 @@ using HarmonyLib; using NewHorizons.Utility; -using UnityEngine; -namespace NewHorizons.Patches + +namespace NewHorizons.Patches.WarpPatches { - [HarmonyPatch] - public static class NomaiCoordinatePatches + [HarmonyPatch(typeof(VesselWarpController))] + public static class VesselWarpControllerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(NomaiCoordinateInterface), nameof(NomaiCoordinateInterface.SetPillarRaised), new System.Type[] { typeof(bool) })] - public static bool NomaiCoordinateInterface_SetPillarRaised(NomaiCoordinateInterface __instance, bool raised) - { - if (raised) - return !(!__instance._powered || (__instance.CheckEyeCoordinates() && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") || (__instance.CheckAllCoordinates(out string targetSystem) && Main.Instance.CurrentStarSystem != targetSystem)); - return true; - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(VesselWarpController), nameof(VesselWarpController.WarpVessel))] + [HarmonyPatch(nameof(VesselWarpController.WarpVessel))] public static bool VesselWarpController_WarpVessel(VesselWarpController __instance, bool debugWarp) { if (!Main.Instance.IsWarpingFromVessel && TimeLoop.GetLoopCount() < 2) @@ -29,11 +20,12 @@ public static bool VesselWarpController_WarpVessel(VesselWarpController __instan PlayerData.SaveWarpedToTheEye(TimeLoopUtilities.GetVanillaSecondsRemaining()); LoadManager.EnableAsyncLoadTransition(); + return false; } [HarmonyPrefix] - [HarmonyPatch(typeof(VesselWarpController), nameof(VesselWarpController.CheckSystemActivation))] + [HarmonyPatch(nameof(VesselWarpController.CheckSystemActivation))] public static void VesselWarpController_CheckSystemActivation(VesselWarpController __instance) { if (Locator.GetEyeStateManager() == null && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") @@ -46,19 +38,19 @@ public static void VesselWarpController_CheckSystemActivation(VesselWarpControll } [HarmonyPrefix] - [HarmonyPatch(typeof(VesselWarpController), nameof(VesselWarpController.OnSlotActivated))] + [HarmonyPatch(nameof(VesselWarpController.OnSlotActivated))] public static bool VesselWarpController_OnSlotActivated(VesselWarpController __instance, NomaiInterfaceSlot slot) { bool canWarpToEye = __instance._coordinateInterface.CheckEyeCoordinates(); bool canWarpToStarSystem = __instance._coordinateInterface.CheckAllCoordinates(out string targetSystem); - if (slot == __instance._warpVesselSlot && __instance._hasPower && ((canWarpToEye && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") || (canWarpToStarSystem && targetSystem != Main.Instance.CurrentStarSystem)) && __instance._blackHole.GetState() == SingularityController.State.Collapsed) + if (slot == __instance._warpVesselSlot && __instance._hasPower && (canWarpToEye && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || canWarpToStarSystem && targetSystem != Main.Instance.CurrentStarSystem) && __instance._blackHole.GetState() == SingularityController.State.Collapsed) { __instance._blackHole.Create(); RumbleManager.StartVesselWarp(); __instance._openingBlackHole = true; __instance.enabled = true; Locator.GetPauseCommandListener().AddPauseCommandLock(); - if (canWarpToEye || (canWarpToStarSystem && targetSystem == "EyeOfTheUniverse")) + if (canWarpToEye || canWarpToStarSystem && targetSystem == "EyeOfTheUniverse") { Main.Instance._currentStarSystem = "EyeOfTheUniverse"; LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, false, LoadManager.FadeType.ToWhite); From 77fc15f18ed5aa7b066a17271fe37cadfa0537f2 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 12:35:15 -0500 Subject: [PATCH 031/119] Revert "Moved prop info and volume info classes to their own files" This reverts commit 550c96d1678a0969edaa40c7266d9459ccd4c2f8. --- .../Builder/Body/BrambleDimensionBuilder.cs | 3 +- NewHorizons/Builder/Body/ProxyBuilder.cs | 4 +- .../Builder/Body/SingularityBuilder.cs | 8 +- .../Builder/Props/BrambleNodeBuilder.cs | 1 - NewHorizons/Builder/Props/DetailBuilder.cs | 11 +- NewHorizons/Builder/Props/DialogueBuilder.cs | 15 +- .../Builder/Props/GeneralPropBuilder.cs | 11 +- NewHorizons/Builder/Props/GeyserBuilder.cs | 3 +- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 55 +- .../Builder/Props/ProjectionBuilder.cs | 25 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 15 +- NewHorizons/Builder/Props/RaftBuilder.cs | 3 +- NewHorizons/Builder/Props/RemoteBuilder.cs | 17 +- NewHorizons/Builder/Props/ScatterBuilder.cs | 5 +- NewHorizons/Builder/Props/SignalBuilder.cs | 3 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 13 +- .../TranslatorText/TranslatorTextBuilder.cs | 55 +- NewHorizons/Builder/Props/VolcanoBuilder.cs | 5 +- .../Builder/ShipLog/EntryLocationBuilder.cs | 3 +- NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 6 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 29 +- .../Builder/Volumes/AudioVolumeBuilder.cs | 3 +- .../Volumes/ChangeStarSystemVolumeBuilder.cs | 3 +- .../Builder/Volumes/CreditsVolumeBuilder.cs | 3 +- .../Volumes/DestructionVolumeBuilder.cs | 3 +- .../Builder/Volumes/FluidVolumeBuilder.cs | 3 +- .../Builder/Volumes/HazardVolumeBuilder.cs | 11 +- .../Volumes/NotificationVolumeBuilder.cs | 3 +- .../Builder/Volumes/OxygenVolumeBuilder.cs | 3 +- .../Builder/Volumes/PriorityVolumeBuilder.cs | 3 +- .../Rulesets/PlayerImpactRulesetBuilder.cs | 2 +- .../Volumes/Rulesets/ProbeRulesetBuilder.cs | 2 +- .../Volumes/Rulesets/ThrustRulesetBuilder.cs | 2 +- .../Builder/Volumes/SpeedTrapVolumeBuilder.cs | 3 +- .../Builder/Volumes/VanishVolumeBuilder.cs | 3 +- .../VisorFrostEffectVolumeBuilder.cs | 2 +- .../VisorRainEffectVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 3 +- .../Builder/Volumes/ZeroGVolumeBuilder.cs | 3 +- .../Components/Volumes/LoadCreditsVolume.cs | 9 +- .../Components/Volumes/NotificationVolume.cs | 3 +- NewHorizons/External/Configs/PlanetConfig.cs | 42 +- .../External/Configs/StarSystemConfig.cs | 5 +- NewHorizons/External/Modules/BrambleModule.cs | 62 +- NewHorizons/External/Modules/ProbeModule.cs | 20 - NewHorizons/External/Modules/PropModule.cs | 828 +++++++++++++++++- NewHorizons/External/Modules/RulesetModule.cs | 90 -- NewHorizons/External/Modules/SignalModule.cs | 59 +- NewHorizons/External/Modules/SpawnModule.cs | 5 +- .../VariableSize/SingularityModule.cs} | 6 +- .../External/Modules/VisorEffectModule.cs | 55 -- NewHorizons/External/Modules/VolumesModule.cs | 536 +++++++++++- NewHorizons/External/Props/BrambleNodeInfo.cs | 73 -- NewHorizons/External/Props/DetailInfo.cs | 76 -- NewHorizons/External/Props/DialogueInfo.cs | 85 -- .../External/Props/EntryLocationInfo.cs | 18 - .../External/Props/GeneralPointPropInfo.cs | 29 - NewHorizons/External/Props/GeneralPropInfo.cs | 14 - .../Props/GeneralSolarSystemPropInfo.cs | 13 - NewHorizons/External/Props/GeyserInfo.cs | 46 - .../External/Props/NomaiTextArcInfo.cs | 54 -- NewHorizons/External/Props/NomaiTextInfo.cs | 81 -- NewHorizons/External/Props/ProjectionInfo.cs | 47 - .../External/Props/QuantumGroupInfo.cs | 51 -- .../External/Props/QuantumSocketInfo.cs | 14 - NewHorizons/External/Props/RaftInfo.cs | 14 - NewHorizons/External/Props/RemoteInfo.cs | 107 --- NewHorizons/External/Props/ScatterInfo.cs | 71 -- NewHorizons/External/Props/SignalInfo.cs | 71 -- NewHorizons/External/Props/SlideInfo.cs | 85 -- NewHorizons/External/Props/TornadoInfo.cs | 73 -- NewHorizons/External/Props/VolcanoInfo.cs | 50 -- .../External/Volumes/AudioVolumeInfo.cs | 88 -- .../Volumes/ChangeStarSystemVolumeInfo.cs | 16 - .../External/Volumes/DestructionVolumeInfo.cs | 37 - .../External/Volumes/FluidVolumeInfo.cs | 49 -- .../External/Volumes/HazardVolumeInfo.cs | 54 -- .../External/Volumes/LoadCreditsVolumeInfo.cs | 25 - .../Volumes/NotificationVolumeInfo.cs | 50 -- .../External/Volumes/OxygenVolumeInfo.cs | 20 - .../External/Volumes/PriorityVolumeInfo.cs | 23 - .../External/Volumes/RevealVolumeInfo.cs | 64 -- .../External/Volumes/SpeedTrapVolumeInfo.cs | 22 - .../External/Volumes/VanishVolumeInfo.cs | 20 - NewHorizons/External/Volumes/VolumeInfo.cs | 121 --- NewHorizons/NewHorizonsApi.cs | 9 +- .../Utility/DebugUtilities/DebugPropPlacer.cs | 15 +- 87 files changed, 1676 insertions(+), 2076 deletions(-) delete mode 100644 NewHorizons/External/Modules/ProbeModule.cs delete mode 100644 NewHorizons/External/Modules/RulesetModule.cs rename NewHorizons/External/{Props/SingularityInfo.cs => Modules/VariableSize/SingularityModule.cs} (92%) delete mode 100644 NewHorizons/External/Modules/VisorEffectModule.cs delete mode 100644 NewHorizons/External/Props/BrambleNodeInfo.cs delete mode 100644 NewHorizons/External/Props/DetailInfo.cs delete mode 100644 NewHorizons/External/Props/DialogueInfo.cs delete mode 100644 NewHorizons/External/Props/EntryLocationInfo.cs delete mode 100644 NewHorizons/External/Props/GeneralPointPropInfo.cs delete mode 100644 NewHorizons/External/Props/GeneralPropInfo.cs delete mode 100644 NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs delete mode 100644 NewHorizons/External/Props/GeyserInfo.cs delete mode 100644 NewHorizons/External/Props/NomaiTextArcInfo.cs delete mode 100644 NewHorizons/External/Props/NomaiTextInfo.cs delete mode 100644 NewHorizons/External/Props/ProjectionInfo.cs delete mode 100644 NewHorizons/External/Props/QuantumGroupInfo.cs delete mode 100644 NewHorizons/External/Props/QuantumSocketInfo.cs delete mode 100644 NewHorizons/External/Props/RaftInfo.cs delete mode 100644 NewHorizons/External/Props/RemoteInfo.cs delete mode 100644 NewHorizons/External/Props/ScatterInfo.cs delete mode 100644 NewHorizons/External/Props/SignalInfo.cs delete mode 100644 NewHorizons/External/Props/SlideInfo.cs delete mode 100644 NewHorizons/External/Props/TornadoInfo.cs delete mode 100644 NewHorizons/External/Props/VolcanoInfo.cs delete mode 100644 NewHorizons/External/Volumes/AudioVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/DestructionVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/FluidVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/HazardVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/NotificationVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/OxygenVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/PriorityVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/RevealVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/VanishVolumeInfo.cs delete mode 100644 NewHorizons/External/Volumes/VolumeInfo.cs diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 4501dce38..02f32731e 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -10,7 +10,6 @@ using UnityEngine; using Logger = NewHorizons.Utility.Logger; using static NewHorizons.Main; -using NewHorizons.External.Props; namespace NewHorizons.Builder.Body { @@ -104,7 +103,7 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject default: geometryPrefab = _hubGeometry; break; } - var detailInfo = new DetailInfo(); + var detailInfo = new PropModule.DetailInfo(); var geometry = DetailBuilder.Make(go, sector, geometryPrefab, detailInfo); var exitWarps = _exitWarps.InstantiateInactive(); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 6b085afff..f2a76bced 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -2,7 +2,7 @@ using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.Components.SizeControllers; -using NewHorizons.External.Props; +using NewHorizons.External.Modules.VariableSize; using NewHorizons.Handlers; using NewHorizons.Utility; using System; @@ -187,7 +187,7 @@ private static bool SharedMake(GameObject planetGO, GameObject proxy, NHProxy pr { foreach (var singularity in body.Config.Props.singularities) { - var polarity = singularity.type == SingularityInfo.SingularityType.BlackHole; + var polarity = singularity.type == SingularityModule.SingularityType.BlackHole; SingularityBuilder.MakeSingularityProxy(proxy, singularity.position, polarity, singularity.horizonRadius, singularity.distortRadius, singularity.curve, singularity.renderQueueOverride); if (realSize < singularity.distortRadius) realSize = singularity.distortRadius; } diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 0c2e4df2b..97c530103 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; using System; +using NewHorizons.External.Modules.VariableSize; using UnityEngine; using Logger = NewHorizons.Utility.Logger; using System.Collections.Generic; @@ -10,7 +11,6 @@ using Color = UnityEngine.Color; using NewHorizons.Components.Volumes; using NewHorizons.Builder.Props; -using NewHorizons.External.Props; namespace NewHorizons.Builder.Body { @@ -70,7 +70,7 @@ internal static void InitPrefabs() if (_whiteHoleVolume == null) _whiteHoleVolume = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVolume").InstantiateInactive().Rename("WhiteHoleVolume").DontDestroyOnLoad(); } - public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityInfo singularity) + public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityModule singularity) { InitPrefabs(); @@ -81,7 +81,7 @@ public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetCo var distortRadius = singularity.distortRadius != 0f ? singularity.distortRadius : horizonRadius * 2.5f; var pairedSingularity = singularity.pairedSingularity; - bool polarity = singularity.type == SingularityInfo.SingularityType.BlackHole; + bool polarity = singularity.type == SingularityModule.SingularityType.BlackHole; bool isWormHole = singularity?.targetStarSystem != null; bool hasHazardVolume = !isWormHole && (pairedSingularity == null); @@ -140,7 +140,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam // polarity true = black, false = white - var info = new SingularityInfo + var info = new SingularityModule { position = position, rotation = rotation, diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 8996604eb..4a836fb4b 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -1,7 +1,6 @@ using NewHorizons.Builder.Body; using NewHorizons.Components; using NewHorizons.External.Configs; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 00d7888aa..88aa7db54 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -1,7 +1,6 @@ using NewHorizons.Builder.General; using NewHorizons.Components; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -16,7 +15,7 @@ namespace NewHorizons.Builder.Props { public static class DetailBuilder { - private static readonly Dictionary _detailInfoToCorrespondingSpawnedGameObject = new(); + private static readonly Dictionary _detailInfoToCorrespondingSpawnedGameObject = new(); private static readonly Dictionary<(Sector, string), (GameObject prefab, bool isItem)> _fixedPrefabCache = new(); static DetailBuilder() @@ -34,7 +33,7 @@ private static void SceneManager_sceneUnloaded(Scene scene) _detailInfoToCorrespondingSpawnedGameObject.Clear(); } - public static GameObject GetSpawnedGameObjectByDetailInfo(DetailInfo detail) + public static GameObject GetSpawnedGameObjectByDetailInfo(PropModule.DetailInfo detail) { if (!_detailInfoToCorrespondingSpawnedGameObject.ContainsKey(detail)) { @@ -49,7 +48,7 @@ public static GameObject GetSpawnedGameObjectByDetailInfo(DetailInfo detail) /// /// Create a detail using an asset bundle or a path in the scene hierarchy of the item to copy. /// - public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, DetailInfo detail) + public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, PropModule.DetailInfo detail) { if (detail.assetBundle != null) { @@ -65,7 +64,7 @@ public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, D /// /// Create a detail using a path in the scene hierarchy of the item to copy. /// - public static GameObject Make(GameObject planetGO, Sector sector, DetailInfo info) + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.DetailInfo info) { var prefab = SearchUtilities.Find(info.path); if (prefab == null) @@ -80,7 +79,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, DetailInfo inf /// /// Create a detail using a prefab. /// - public static GameObject Make(GameObject go, Sector sector, GameObject prefab, DetailInfo detail) + public static GameObject Make(GameObject go, Sector sector, GameObject prefab, PropModule.DetailInfo detail) { if (prefab == null) return null; diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index 028cbc9d9..f81d8ac29 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -7,14 +7,13 @@ using NewHorizons.Utility; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components; -using NewHorizons.External.Props; namespace NewHorizons.Builder.Props { public static class DialogueBuilder { // Returns the character dialogue tree and remote dialogue trigger, if applicable. - public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, Sector sector, DialogueInfo info, IModBehaviour mod) + public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, Sector sector, PropModule.DialogueInfo info, IModBehaviour mod) { // In stock I think they disable dialogue stuff with conditions // Here we just don't make it at all @@ -39,7 +38,7 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, return (dialogue, remoteTrigger); } - private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, DialogueInfo info, CharacterDialogueTree dialogue) + private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue) { var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", sector?.transform ?? planetGO.transform, info.remoteTrigger, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); @@ -70,7 +69,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet return remoteDialogueTrigger; } - private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, DialogueInfo info, IModHelper mod) + private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, IModHelper mod) { var conversationZone = GeneralPropBuilder.MakeNew("ConversationZone", sector?.transform ?? planetGO.transform, info, defaultParentPath: info.pathToAnimController); @@ -106,15 +105,15 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S switch (info.flashlightToggle) { - case DialogueInfo.FlashlightToggle.TurnOff: + case PropModule.DialogueInfo.FlashlightToggle.TurnOff: dialogueTree._turnOffFlashlight = true; dialogueTree._turnOnFlashlight = false; break; - case DialogueInfo.FlashlightToggle.TurnOffThenOn: + case PropModule.DialogueInfo.FlashlightToggle.TurnOffThenOn: dialogueTree._turnOffFlashlight = true; dialogueTree._turnOnFlashlight = true; break; - case DialogueInfo.FlashlightToggle.None: + case PropModule.DialogueInfo.FlashlightToggle.None: default: dialogueTree._turnOffFlashlight = false; dialogueTree._turnOnFlashlight = false; @@ -126,7 +125,7 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S return dialogueTree; } - private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree dialogue, DialogueInfo info) + private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree dialogue, PropModule.DialogueInfo info) { var character = go.transform.Find(info.pathToAnimController); diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 5b8228423..691f10831 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using System; using System.Collections.Generic; @@ -13,11 +12,11 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromExisting(GameObject go, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { if (info == null) return go; - if (info is GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) + if (info is PropModule.GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) { var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody); if (targetPlanet != null) @@ -53,7 +52,7 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, Gener var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); var rot = Quaternion.identity; - if (info is GeneralPropInfo rotInfo) + if (info is PropModule.GeneralPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; } @@ -80,14 +79,14 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, Gener return go; } - public static GameObject MakeNew(string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeNew(string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = new GameObject(defaultName); go.SetActive(false); return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index eb1f1c99d..2b4819fd0 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -15,7 +14,7 @@ internal static void InitPrefab() if (_geyserPrefab == null) _geyserPrefab = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village").InstantiateInactive().Rename("Prefab_TH_Geyser").DontDestroyOnLoad(); } - public static void Make(GameObject planetGO, Sector sector, GeyserInfo info) + public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info) { InitPrefab(); diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 571e58ac3..5e630fec9 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -33,16 +32,16 @@ public static class NomaiTextBuilder private static GameObject _preCrashRecorderPrefab; private static GameObject _trailmarkerPrefab; - private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(NomaiTextArcInfo arc) + private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); + public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(PropModule.NomaiTextArcInfo arc) { if (!arcInfoToCorrespondingSpawnedGameObject.ContainsKey(arc)) return null; return arcInfoToCorrespondingSpawnedGameObject[arc]; } - private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextInfo(NomaiTextInfo convo) + public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) { Logger.LogVerbose("Retrieving wall text obj for " + convo); if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; @@ -143,7 +142,7 @@ internal static void InitPrefabs() } } - public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo info, IModBehaviour mod) + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, IModBehaviour mod) { InitPrefabs(); @@ -151,7 +150,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo switch (info.type) { - case NomaiTextInfo.NomaiTextType.Wall: + case PropModule.NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject; @@ -216,7 +215,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return nomaiWallTextObj; } - case NomaiTextInfo.NomaiTextType.Scroll: + case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { var customScroll = _scrollPrefab.InstantiateInactive(); @@ -305,7 +304,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return customScroll; } - case NomaiTextInfo.NomaiTextType.Computer: + case PropModule.NomaiTextInfo.NomaiTextType.Computer: { var computerObject = _computerPrefab.InstantiateInactive(); @@ -358,9 +357,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return computerObject; } - case NomaiTextInfo.NomaiTextType.PreCrashComputer: + case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: { - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = info.position, parentPath = info.parentPath, @@ -408,10 +407,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return computerObject; } - case NomaiTextInfo.NomaiTextType.Cairn: - case NomaiTextInfo.NomaiTextType.CairnVariant: + case PropModule.NomaiTextInfo.NomaiTextType.Cairn: + case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: { - var cairnObject = (info.type == NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); + var cairnObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); if (!string.IsNullOrEmpty(info.rename)) { @@ -483,11 +482,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return cairnObject; } - case NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case NomaiTextInfo.NomaiTextType.Recorder: + case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: + case PropModule.NomaiTextInfo.NomaiTextType.Recorder: { - var prefab = (info.type == NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); - var detailInfo = new DetailInfo { + var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var detailInfo = new PropModule.DetailInfo { parentPath = info.parentPath, rotation = info.rotation, position = info.position, @@ -518,7 +517,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case NomaiTextInfo.NomaiTextType.Trailmarker: + case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: { var trailmarkerObject = _trailmarkerPrefab.InstantiateInactive(); @@ -590,7 +589,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTextInfo info, string xmlPath) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath) { GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); nomaiWallTextObj.SetActive(false); @@ -619,7 +618,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTex nomaiWallText.SetTextAsset(text); // #433 fuzzy stranger text - if (info.arcInfo != null && info.arcInfo.Any(x => x.type == NomaiTextArcInfo.NomaiTextArcType.Stranger)) + if (info.arcInfo != null && info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger)) { StreamingHandler.SetUpStreaming(AstroObject.Name.RingWorld, sector); } @@ -627,7 +626,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTex return nomaiWallText; } - internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info) + internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info) { var dict = MakeNomaiTextDict(xml); @@ -636,7 +635,7 @@ internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObje RefreshArcs(nomaiWallText, conversationZone, info); } - internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info) + internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info) { var dict = nomaiWallText._dictNomaiTextData; Random.InitState(info.seed); @@ -667,26 +666,26 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers } } - internal static GameObject MakeArc(NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID) + internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID) { GameObject arc; - var type = arcInfo != null ? arcInfo.type : NomaiTextArcInfo.NomaiTextArcType.Adult; + var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; var variation = arcInfo != null ? arcInfo.variation : -1; switch (type) { - case NomaiTextArcInfo.NomaiTextArcType.Child: + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: variation = variation < 0 ? Random.Range(0, _childArcPrefabs.Count()) : (variation % _childArcPrefabs.Count()); arc = _childArcPrefabs[variation].InstantiateInactive(); break; - case NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): variation = variation < 0 ? Random.Range(0, _ghostArcPrefabs.Count()) : (variation % _ghostArcPrefabs.Count()); arc = _ghostArcPrefabs[variation].InstantiateInactive(); break; - case NomaiTextArcInfo.NomaiTextArcType.Adult: + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: default: variation = variation < 0 ? Random.Range(0, _arcPrefabs.Count()) diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 737387294..d7fd2668c 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -66,20 +65,20 @@ internal static void InitPrefabs() } } - public static void Make(GameObject go, Sector sector, ProjectionInfo info, IModBehaviour mod) + public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { switch (info.type) { - case ProjectionInfo.SlideShowType.AutoProjector: + case PropModule.ProjectionInfo.SlideShowType.AutoProjector: MakeAutoProjector(go, sector, info, mod); break; - case ProjectionInfo.SlideShowType.SlideReel: + case PropModule.ProjectionInfo.SlideShowType.SlideReel: MakeSlideReel(go, sector, info, mod); break; - case ProjectionInfo.SlideShowType.VisionTorchTarget: + case PropModule.ProjectionInfo.SlideShowType.VisionTorchTarget: MakeMindSlidesTarget(go, sector, info, mod); break; - case ProjectionInfo.SlideShowType.StandingVisionTorch: + case PropModule.ProjectionInfo.SlideShowType.StandingVisionTorch: MakeStandingVisionTorch(go, sector, info, mod); break; default: @@ -88,7 +87,7 @@ public static void Make(GameObject go, Sector sector, ProjectionInfo info, IModB } } - private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) + private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); @@ -161,7 +160,7 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Proj return slideReelObj; } - public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) + public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); @@ -196,14 +195,14 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P } // Makes a target for a vision torch to scan - public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) + public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); if (_visionTorchDetectorPrefab == null) return null; // spawn a trigger for the vision torch - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = info.position, rotation = info.rotation, @@ -242,14 +241,14 @@ public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector return g; } - public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod) + public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod) { InitPrefabs(); if (_standingVisionTorchPrefab == null) return null; // Spawn the torch itself - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = info.position, rotation = info.rotation, @@ -345,7 +344,7 @@ private static ImageUtilities.AsyncImageLoader AddAsyncLoader(GameObject gameObj return imageLoader; } - private static void AddModules(SlideInfo slideInfo, ref Slide slide, IModBehaviour mod) + private static void AddModules(PropModule.SlideInfo slideInfo, ref Slide slide, IModBehaviour mod) { var modules = new List(); if (!String.IsNullOrEmpty(slideInfo.beatAudio)) diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 8db6f2fd6..0697c5a0a 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -2,7 +2,6 @@ using NewHorizons.Components.Quantum; using NewHorizons.External.Configs; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using OWML.Common; using System; @@ -29,17 +28,17 @@ namespace NewHorizons.Builder.Props public static class QuantumBuilder { - public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { switch(quantumGroup.type) { - case QuantumGroupType.Sockets: MakeSocketGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; - case QuantumGroupType.States: MakeStateGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; - // case QuantumGroupType.Shuffle: MakeShuffleGroup(go, sector, config, mod, quantumGroup, propsInGroup); return; + case PropModule.QuantumGroupType.Sockets: MakeSocketGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; + case PropModule.QuantumGroupType.States: MakeStateGroup (go, sector, config, mod, quantumGroup, propsInGroup); return; + // case PropModule.QuantumGroupType.Shuffle: MakeShuffleGroup(go, sector, config, mod, quantumGroup, propsInGroup); return; } } - public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id); groupRoot.transform.parent = sector?.transform ?? go.transform; @@ -73,7 +72,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co } } - public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { var groupRoot = new GameObject("Quantum States - " + quantumGroup.id); groupRoot.transform.parent = sector?.transform ?? go.transform; @@ -120,7 +119,7 @@ public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig con groupRoot.SetActive(true); } - public static void MakeShuffleGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) + public static void MakeShuffleGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup) { //var averagePosition = propsInGroup.Aggregate(Vector3.zero, (avg, prop) => avg + prop.transform.position) / propsInGroup.Count(); GameObject shuffleParent = new GameObject("Quantum Shuffle - " + quantumGroup.id); diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index 587ab4647..663fa27e1 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -2,7 +2,6 @@ using NewHorizons.Components.Achievement; using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using UnityEngine; @@ -47,7 +46,7 @@ internal static void InitPrefab() } } - public static GameObject Make(GameObject planetGO, Sector sector, RaftInfo info, OWRigidbody planetBody) + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.RaftInfo info, OWRigidbody planetBody) { InitPrefab(); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index e0c3801b6..75e273748 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using OWML.Common; @@ -117,7 +116,7 @@ internal static void InitPrefabs() } } - public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizonsBody nhBody) + public static void Make(GameObject go, Sector sector, PropModule.RemoteInfo info, NewHorizonsBody nhBody) { InitPrefabs(); @@ -168,9 +167,9 @@ public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizo } } - public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteInfo.WhiteboardInfo info, NewHorizonsBody nhBody) + public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.WhiteboardInfo info, NewHorizonsBody nhBody) { - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = info.position, rotation = info.rotation, @@ -195,7 +194,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer { var textInfo = info.nomaiText[i]; component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id); - var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new NomaiTextInfo + var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.NomaiTextInfo { arcInfo = textInfo.arcInfo, location = textInfo.location, @@ -204,7 +203,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer rename = textInfo.rename, rotation = Vector3.zero, seed = textInfo.seed, - type = NomaiTextInfo.NomaiTextType.Wall, + type = PropModule.NomaiTextInfo.NomaiTextType.Wall, xmlFile = textInfo.xmlFile }, nhBody).GetComponent(); wallText._showTextOnStart = false; @@ -216,9 +215,9 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer whiteboard.SetActive(true); } - public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteInfo.PlatformInfo info, IModBehaviour mod) + public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.PlatformInfo info, IModBehaviour mod) { - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = info.position, rotation = info.rotation, @@ -250,7 +249,7 @@ public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraP platform.SetActive(true); } - public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteInfo.StoneInfo info, IModBehaviour mod) + public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.StoneInfo info, IModBehaviour mod) { var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), sector?.transform ?? go.transform, info); diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index be162319e..f6583c4d2 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using OWML.Common; using System; @@ -18,7 +17,7 @@ public static void Make(GameObject go, Sector sector, PlanetConfig config, IModB MakeScatter(go, config.Props.scatter, config.Base.surfaceSize, sector, mod, config); } - private static void MakeScatter(GameObject go, ScatterInfo[] scatterInfo, float radius, Sector sector, IModBehaviour mod, PlanetConfig config) + private static void MakeScatter(GameObject go, PropModule.ScatterInfo[] scatterInfo, float radius, Sector sector, IModBehaviour mod, PlanetConfig config) { var heightMap = config.HeightMap; @@ -70,7 +69,7 @@ private static void MakeScatter(GameObject go, ScatterInfo[] scatterInfo, float else prefab = SearchUtilities.Find(propInfo.path); // Run all the make detail stuff on it early and just copy it over and over instead - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { scale = propInfo.scale, stretch = propInfo.stretch, diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index f51bfce0d..1665c33cc 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using OWML.Common; using OWML.Utils; @@ -108,7 +107,7 @@ public static string GetCustomSignalName(SignalName signalName) return name; } - public static GameObject Make(GameObject planetGO, Sector sector, SignalInfo info, IModBehaviour mod) + public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) { var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", sector?.transform ?? planetGO.transform, info); signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 5a6fae48c..1aad9a6e8 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Components; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using NewHorizons.Utility; using System; @@ -74,7 +73,7 @@ internal static void InitPrefabs() if (_soundPrefab == null) _soundPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive().Rename("AudioRail_Prefab").DontDestroyOnLoad(); } - public static void Make(GameObject planetGO, Sector sector, TornadoInfo info, bool hasClouds) + public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, bool hasClouds) { InitPrefabs(); @@ -93,11 +92,11 @@ public static void Make(GameObject planetGO, Sector sector, TornadoInfo info, bo return; } - if (info.type == TornadoInfo.TornadoType.Hurricane) MakeHurricane(planetGO, sector, info, position, hasClouds); - else MakeTornado(planetGO, sector, info, position, info.type == TornadoInfo.TornadoType.Downwards); + if (info.type == PropModule.TornadoInfo.TornadoType.Hurricane) MakeHurricane(planetGO, sector, info, position, hasClouds); + else MakeTornado(planetGO, sector, info, position, info.type == PropModule.TornadoInfo.TornadoType.Downwards); } - private static void MakeTornado(GameObject planetGO, Sector sector, TornadoInfo info, Vector3 position, bool downwards) + private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", sector?.transform ?? planetGO.transform, info, true, defaultPosition: position); @@ -173,7 +172,7 @@ private static void MakeTornado(GameObject planetGO, Sector sector, TornadoInfo tornadoGO.SetActive(true); } - private static void MakeHurricane(GameObject planetGO, Sector sector, TornadoInfo info, Vector3 position, bool hasClouds) + private static void MakeHurricane(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool hasClouds) { var hurricaneGO = _hurricanePrefab.InstantiateInactive(); hurricaneGO.name = "Hurricane"; @@ -261,7 +260,7 @@ private static void ApplyTint(GameObject go, Color colour, bool hurricane, bool } } - private static void ApplyWanderer(GameObject go, GameObject planetGO, TornadoInfo info) + private static void ApplyWanderer(GameObject go, GameObject planetGO, PropModule.TornadoInfo info) { var wanderer = go.AddComponent(); wanderer.wanderRate = info.wanderRate; diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 9dff7d380..1d4a29fcc 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -13,7 +13,6 @@ using OWML.Utils; using Newtonsoft.Json; using System; -using NewHorizons.External.Props; namespace NewHorizons.Builder.Props { @@ -31,16 +30,16 @@ public static class TranslatorTextBuilder private static GameObject _preCrashRecorderPrefab; private static GameObject _trailmarkerPrefab; - private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(NomaiTextArcInfo arc) + private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); + public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(PropModule.NomaiTextArcInfo arc) { if (!arcInfoToCorrespondingSpawnedGameObject.ContainsKey(arc)) return null; return arcInfoToCorrespondingSpawnedGameObject[arc]; } - private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextInfo(NomaiTextInfo convo) + public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) { Logger.LogVerbose("Retrieving wall text obj for " + convo); if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; @@ -121,7 +120,7 @@ internal static void InitPrefabs() } } - public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo info, NewHorizonsBody nhBody) + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) { InitPrefabs(); @@ -129,7 +128,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo switch (info.type) { - case NomaiTextInfo.NomaiTextType.Wall: + case PropModule.NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; @@ -160,7 +159,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return nomaiWallTextObj; } - case NomaiTextInfo.NomaiTextType.Scroll: + case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, sector?.transform ?? planetGO.transform, info); @@ -212,7 +211,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return customScroll; } - case NomaiTextInfo.NomaiTextType.Computer: + case PropModule.NomaiTextInfo.NomaiTextType.Computer: { var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, sector?.transform ?? planetGO.transform, info, true, info.normal); @@ -233,9 +232,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return computerObject; } - case NomaiTextInfo.NomaiTextType.PreCrashComputer: + case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: { - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = info.position, parentPath = info.parentPath, @@ -283,10 +282,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return computerObject; } - case NomaiTextInfo.NomaiTextType.Cairn: - case NomaiTextInfo.NomaiTextType.CairnVariant: + case PropModule.NomaiTextInfo.NomaiTextType.Cairn: + case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: { - var cairnPrefab = info.type == NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; + var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); // Idk do we have to set it active before finding things? @@ -318,11 +317,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo return cairnObject; } - case NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case NomaiTextInfo.NomaiTextType.Recorder: + case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: + case PropModule.NomaiTextInfo.NomaiTextType.Recorder: { - var prefab = (info.type == NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); - var detailInfo = new DetailInfo { + var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var detailInfo = new PropModule.DetailInfo { parentPath = info.parentPath, rotation = info.rotation, position = info.position, @@ -348,7 +347,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case NomaiTextInfo.NomaiTextType.Trailmarker: + case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: { var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); @@ -379,7 +378,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, NomaiTextInfo } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) { GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", sector?.transform ?? go.transform, info); @@ -407,7 +406,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTex nomaiWallText.SetTextAsset(text); // #433 fuzzy stranger text - if (info.arcInfo != null && info.arcInfo.Any(x => x.type == NomaiTextArcInfo.NomaiTextArcType.Stranger)) + if (info.arcInfo != null && info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger)) { StreamingHandler.SetUpStreaming(AstroObject.Name.RingWorld, sector); } @@ -415,7 +414,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, NomaiTex return nomaiWallText; } - internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info, NewHorizonsBody nhBody) + internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) { var dict = MakeNomaiTextDict(xml); @@ -435,7 +434,7 @@ private struct ArcCacheData public bool mirrored; } - internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey) + internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey) { var dict = nomaiWallText._dictNomaiTextData; Random.InitState(info.seed == 0 ? info.xmlFile.GetHashCode() : info.seed); @@ -537,27 +536,27 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers } } - internal static GameObject MakeArc(NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID, GameObject prebuiltArc = null) + internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID, GameObject prebuiltArc = null) { GameObject arc; - var type = arcInfo != null ? arcInfo.type : NomaiTextArcInfo.NomaiTextArcType.Adult; + var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; NomaiTextArcBuilder.SpiralProfile profile; Material mat; Mesh overrideMesh = null; Color? overrideColor = null; switch (type) { - case NomaiTextArcInfo.NomaiTextArcType.Child: + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: profile = NomaiTextArcBuilder.childSpiralProfile; mat = _childArcMaterial; break; - case NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcMaterial != null: + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcMaterial != null: profile = NomaiTextArcBuilder.strangerSpiralProfile; mat = _ghostArcMaterial; overrideMesh = MeshUtilities.RectangleMeshFromCorners(new Vector3[]{ new Vector3(-0.9f, 0.0f, 0.0f), new Vector3(0.9f, 0.0f, 0.0f), new Vector3(-0.9f, 2.0f, 0.0f), new Vector3(0.9f, 2.0f, 0.0f) }); overrideColor = new Color(0.0158f, 1.0f, 0.5601f, 1f); break; - case NomaiTextArcInfo.NomaiTextArcType.Adult: + case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: default: profile = NomaiTextArcBuilder.adultSpiralProfile; mat = _adultArcMaterial; diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index 770ef4882..ced0ad9c2 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -42,7 +41,7 @@ internal static void InitPrefab() } } - public static void Make(GameObject planetGO, Sector sector, VolcanoInfo info) + public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info) { InitPrefab(); @@ -73,7 +72,7 @@ public static void Make(GameObject planetGO, Sector sector, VolcanoInfo info) }); } - private static void FixMeteor(MeteorController meteor, VolcanoInfo info) + private static void FixMeteor(MeteorController meteor, PropModule.VolcanoInfo info) { meteor.transform.localScale = Vector3.one * info.scale; diff --git a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs index 29181df07..7f6d591f2 100644 --- a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs +++ b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using OWML.Common; using System.Collections.Generic; using UnityEngine; @@ -11,7 +10,7 @@ namespace NewHorizons.Builder.ShipLog public static class EntryLocationBuilder { private static readonly List _locationsToInitialize = new List(); - public static void Make(GameObject go, Sector sector, EntryLocationInfo info, IModBehaviour mod) + public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod) { GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", sector?.transform ?? go.transform, info); diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index 5731a6ac1..0eaf91aab 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -4,11 +4,11 @@ using System; using System.Collections.Generic; using System.Linq; +using NewHorizons.External.Modules.VariableSize; using UnityEngine; using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components.ShipLog; -using NewHorizons.External.Props; namespace NewHorizons.Builder.ShipLog { @@ -552,9 +552,9 @@ private static Color GetDominantPlanetColor(NewHorizonsBody body) switch (body.Config?.Props?.singularities?.FirstOrDefault()?.type) { - case SingularityInfo.SingularityType.BlackHole: + case SingularityModule.SingularityType.BlackHole: return Color.black; - case SingularityInfo.SingularityType.WhiteHole: + case SingularityModule.SingularityType.WhiteHole: return Color.white; } } diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 66ab38370..349c3649a 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -1,7 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.Components.Achievement; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using OWML.Common; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -9,18 +8,18 @@ namespace NewHorizons.Builder.ShipLog { public static class RevealBuilder { - public static void Make(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) + public static void Make(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", sector?.transform ?? go.transform, info); switch (info.revealOn) { - case RevealVolumeInfo.RevealVolumeType.Enter: + case VolumesModule.RevealVolumeInfo.RevealVolumeType.Enter: MakeTrigger(newRevealGO, sector, info, mod); break; - case RevealVolumeInfo.RevealVolumeType.Observe: + case VolumesModule.RevealVolumeInfo.RevealVolumeType.Observe: MakeObservable(newRevealGO, sector, info, mod); break; - case RevealVolumeInfo.RevealVolumeType.Snapshot: + case VolumesModule.RevealVolumeInfo.RevealVolumeType.Snapshot: MakeSnapshot(newRevealGO, sector, info, mod); break; default: @@ -30,7 +29,7 @@ public static void Make(GameObject go, Sector sector, RevealVolumeInfo info, IMo newRevealGO.SetActive(true); } - private static SphereShape MakeShape(GameObject go, RevealVolumeInfo info, Shape.CollisionMode collisionMode) + private static SphereShape MakeShape(GameObject go, VolumesModule.RevealVolumeInfo info, Shape.CollisionMode collisionMode) { SphereShape newShape = go.AddComponent(); newShape.radius = info.radius; @@ -38,7 +37,7 @@ private static SphereShape MakeShape(GameObject go, RevealVolumeInfo info, Shape return newShape; } - private static void MakeTrigger(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) + private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { var shape = MakeShape(go, info, Shape.CollisionMode.Volume); @@ -51,15 +50,15 @@ private static void MakeTrigger(GameObject go, Sector sector, RevealVolumeInfo i factRevealVolume._factIDs = info.reveals; switch (info.revealFor) { - case RevealVolumeInfo.EnterType.Player: + case VolumesModule.RevealVolumeInfo.EnterType.Player: factRevealVolume._player = true; factRevealVolume._probe = false; break; - case RevealVolumeInfo.EnterType.Probe: + case VolumesModule.RevealVolumeInfo.EnterType.Probe: factRevealVolume._player = false; factRevealVolume._probe = true; break; - case RevealVolumeInfo.EnterType.Both: + case VolumesModule.RevealVolumeInfo.EnterType.Both: default: // if you want both player and probe to able to trigger the thing you have to set both player and probe to false. setting both to true will make nothing trigger it factRevealVolume._player = false; @@ -74,15 +73,15 @@ private static void MakeTrigger(GameObject go, Sector sector, RevealVolumeInfo i achievementVolume.achievementID = info.achievementID; switch (info.revealFor) { - case RevealVolumeInfo.EnterType.Player: + case VolumesModule.RevealVolumeInfo.EnterType.Player: achievementVolume.player = true; achievementVolume.probe = false; break; - case RevealVolumeInfo.EnterType.Probe: + case VolumesModule.RevealVolumeInfo.EnterType.Probe: achievementVolume.player = false; achievementVolume.probe = true; break; - case RevealVolumeInfo.EnterType.Both: + case VolumesModule.RevealVolumeInfo.EnterType.Both: default: achievementVolume.player = true; achievementVolume.probe = true; @@ -91,7 +90,7 @@ private static void MakeTrigger(GameObject go, Sector sector, RevealVolumeInfo i } } - private static void MakeObservable(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) + private static void MakeObservable(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { go.layer = LayerMask.NameToLayer("Interactible"); @@ -122,7 +121,7 @@ private static void MakeObservable(GameObject go, Sector sector, RevealVolumeInf } } - private static void MakeSnapshot(GameObject go, Sector sector, RevealVolumeInfo info, IModBehaviour mod) + private static void MakeSnapshot(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { var shape = MakeShape(go, info, Shape.CollisionMode.Manual); diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 8303d3fa4..34269fe67 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using NewHorizons.Utility; using OWML.Common; using OWML.Utils; @@ -16,7 +15,7 @@ namespace NewHorizons.Builder.Volumes { public static class AudioVolumeBuilder { - public static AudioVolume Make(GameObject planetGO, Sector sector, AudioVolumeInfo info, IModBehaviour mod) + public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule.AudioVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("AudioVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs b/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs index c66742fcd..2d97bbd36 100644 --- a/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/ChangeStarSystemVolumeBuilder.cs @@ -1,13 +1,12 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { internal static class ChangeStarSystemVolumeBuilder { - public static WarpVolume Make(GameObject planetGO, Sector sector, ChangeStarSystemVolumeInfo info) + public static WarpVolume Make(GameObject planetGO, Sector sector, VolumesModule.ChangeStarSystemVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs index 1fa4f985a..c34745c1b 100644 --- a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs @@ -1,13 +1,12 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { internal static class CreditsVolumeBuilder { - public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, LoadCreditsVolumeInfo info) + public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, VolumesModule.LoadCreditsVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs b/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs index 9305af6f7..b657cce0f 100644 --- a/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/DestructionVolumeBuilder.cs @@ -1,5 +1,4 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using OWML.Utils; using UnityEngine; @@ -7,7 +6,7 @@ namespace NewHorizons.Builder.Volumes { public static class DestructionVolumeBuilder { - public static DestructionVolume Make(GameObject planetGO, Sector sector, DestructionVolumeInfo info) + public static DestructionVolume Make(GameObject planetGO, Sector sector, VolumesModule.DestructionVolumeInfo info) { var volume = VanishVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs b/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs index 83ea1fa97..623a561ad 100644 --- a/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/FluidVolumeBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using OWML.Utils; using UnityEngine; @@ -8,7 +7,7 @@ namespace NewHorizons.Builder.Volumes { public static class FluidVolumeBuilder { - public static FluidVolume Make(GameObject planetGO, Sector sector, FluidVolumeInfo info) + public static FluidVolume Make(GameObject planetGO, Sector sector, VolumesModule.FluidVolumeInfo info) { var type = EnumUtils.Parse(info.type.ToString(), FluidVolume.Type.NONE); FluidVolume volume = null; diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index 2485613af..bb82013ce 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using OWML.Common; using OWML.Utils; using System; @@ -13,7 +12,7 @@ namespace NewHorizons.Builder.Volumes { public static class HazardVolumeBuilder { - public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, HazardVolumeInfo info, IModBehaviour mod) + public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("HazardVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); @@ -25,15 +24,15 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owTriggerVolume._shape = shape; HazardVolume hazardVolume = null; - if (info.type == HazardVolumeInfo.HazardType.RIVERHEAT) + if (info.type == VolumesModule.HazardVolumeInfo.HazardType.RIVERHEAT) { hazardVolume = go.AddComponent(); } - else if (info.type == HazardVolumeInfo.HazardType.HEAT) + else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.HEAT) { hazardVolume = go.AddComponent(); } - else if (info.type == HazardVolumeInfo.HazardType.DARKMATTER) + else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.DARKMATTER) { hazardVolume = go.AddComponent(); var visorFrostEffectVolume = go.AddComponent(); @@ -61,7 +60,7 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody submerge._fluidDetector = detector; } } - else if (info.type == HazardVolumeInfo.HazardType.ELECTRICITY) + else if (info.type == VolumesModule.HazardVolumeInfo.HazardType.ELECTRICITY) { var electricityVolume = go.AddComponent(); electricityVolume._shockAudioPool = new OWAudioSource[0]; diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index 7cf56bccc..574aa6daa 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using NewHorizons.Utility; using OWML.Common; using System; @@ -16,7 +15,7 @@ namespace NewHorizons.Builder.Volumes { public static class NotificationVolumeBuilder { - public static NHNotificationVolume Make(GameObject planetGO, Sector sector, NotificationVolumeInfo info, IModBehaviour mod) + public static NHNotificationVolume Make(GameObject planetGO, Sector sector, VolumesModule.NotificationVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("NotificationVolume", sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs b/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs index bcf1f4064..0722fbaf5 100644 --- a/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/OxygenVolumeBuilder.cs @@ -1,12 +1,11 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class OxygenVolumeBuilder { - public static OxygenVolume Make(GameObject planetGO, Sector sector, OxygenVolumeInfo info) + public static OxygenVolume Make(GameObject planetGO, Sector sector, VolumesModule.OxygenVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs b/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs index b38c966eb..994b1c91f 100644 --- a/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/PriorityVolumeBuilder.cs @@ -1,12 +1,11 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class PriorityVolumeBuilder { - public static TVolume Make(GameObject planetGO, Sector sector, PriorityVolumeInfo info) where TVolume : PriorityVolume + public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.PriorityVolumeInfo info) where TVolume : PriorityVolume { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs index db1c8e3aa..9ef330de7 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class PlayerImpactRulesetBuilder { - public static PlayerImpactRuleset Make(GameObject planetGO, Sector sector, RulesetModule.PlayerImpactRulesetInfo info) + public static PlayerImpactRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.PlayerImpactRulesetInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs index 1b17d62fa..b8293d944 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class ProbeRulesetBuilder { - public static ProbeRuleset Make(GameObject planetGO, Sector sector, RulesetModule.ProbeRulesetInfo info) + public static ProbeRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.ProbeRulesetInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs index 9543fad9a..8541f516b 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class ThrustRulesetBuilder { - public static ThrustRuleset Make(GameObject planetGO, Sector sector, RulesetModule.ThrustRulesetInfo info) + public static ThrustRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.ThrustRulesetInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs b/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs index d9ae1893a..3e264604e 100644 --- a/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/SpeedTrapVolumeBuilder.cs @@ -1,12 +1,11 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class SpeedTrapVolumeBuilder { - public static SpeedTrapVolume Make(GameObject planetGO, Sector sector, SpeedTrapVolumeInfo info) + public static SpeedTrapVolume Make(GameObject planetGO, Sector sector, VolumesModule.SpeedTrapVolumeInfo info) { var volume = VolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index 8cda0d15e..23628b122 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -1,7 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -9,7 +8,7 @@ namespace NewHorizons.Builder.Volumes { public static class VanishVolumeBuilder { - public static TVolume Make(GameObject planetGO, Sector sector, VanishVolumeInfo info) where TVolume : VanishVolume + public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VanishVolumeInfo info) where TVolume : VanishVolume { var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs index c38e0a807..139e09f90 100644 --- a/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class VisorFrostEffectVolumeBuilder { - public static VisorFrostEffectVolume Make(GameObject planetGO, Sector sector, VisorEffectModule.FrostEffectVolumeInfo info) + public static VisorFrostEffectVolume Make(GameObject planetGO, Sector sector, VolumesModule.VisorEffectModule.FrostEffectVolumeInfo info) { var volume = PriorityVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs index cf7d66e91..bf268c8ec 100644 --- a/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs @@ -5,7 +5,7 @@ namespace NewHorizons.Builder.Volumes { public static class VisorRainEffectVolumeBuilder { - public static VisorRainEffectVolume Make(GameObject planetGO, Sector sector, VisorEffectModule.RainEffectVolumeInfo info) + public static VisorRainEffectVolume Make(GameObject planetGO, Sector sector, VolumesModule.VisorEffectModule.RainEffectVolumeInfo info) { var volume = PriorityVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index ca273c99c..8d29c9a95 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -1,7 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.Components; using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -9,7 +8,7 @@ namespace NewHorizons.Builder.Volumes { public static class VolumeBuilder { - public static TVolume Make(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. + public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. { var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); diff --git a/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs b/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs index da50d8c97..931d16086 100644 --- a/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/ZeroGVolumeBuilder.cs @@ -1,12 +1,11 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Builder.Volumes { public static class ZeroGVolumeBuilder { - public static ZeroGVolume Make(GameObject planetGO, Sector sector, PriorityVolumeInfo info) + public static ZeroGVolume Make(GameObject planetGO, Sector sector, VolumesModule.PriorityVolumeInfo info) { var volume = PriorityVolumeBuilder.Make(planetGO, sector, info); diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index f852917fb..119908406 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -1,12 +1,11 @@ using NewHorizons.External.Modules; -using NewHorizons.External.Volumes; using UnityEngine; namespace NewHorizons.Components.Volumes { internal class LoadCreditsVolume : BaseVolume { - public LoadCreditsVolumeInfo.CreditsType creditsType = LoadCreditsVolumeInfo.CreditsType.Fast; + public VolumesModule.LoadCreditsVolumeInfo.CreditsType creditsType = VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast; public override void OnTriggerVolumeEntry(GameObject hitObj) { @@ -14,13 +13,13 @@ public override void OnTriggerVolumeEntry(GameObject hitObj) { switch(creditsType) { - case LoadCreditsVolumeInfo.CreditsType.Fast: + case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); break; - case LoadCreditsVolumeInfo.CreditsType.Final: + case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final: LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack); break; - case LoadCreditsVolumeInfo.CreditsType.Kazoo: + case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo: TimelineObliterationController.s_hasRealityEnded = true; LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); break; diff --git a/NewHorizons/Components/Volumes/NotificationVolume.cs b/NewHorizons/Components/Volumes/NotificationVolume.cs index 9aa4f3f8f..70543449f 100644 --- a/NewHorizons/Components/Volumes/NotificationVolume.cs +++ b/NewHorizons/Components/Volumes/NotificationVolume.cs @@ -1,4 +1,3 @@ -using NewHorizons.External.Volumes; using NewHorizons.Handlers; using OWML.Utils; using System; @@ -17,7 +16,7 @@ public class NotificationVolume : BaseVolume public void SetPinned(bool pin) => _pin = pin; - public void SetTarget(NotificationVolumeInfo.NotificationTarget target) => SetTarget(EnumUtils.Parse(target.ToString(), NotificationTarget.All)); + public void SetTarget(External.Modules.VolumesModule.NotificationVolumeInfo.NotificationTarget target) => SetTarget(EnumUtils.Parse(target.ToString(), NotificationTarget.All)); public void SetTarget(NotificationTarget target) => _target = target; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 6de974db7..3330a4ada 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -1,8 +1,6 @@ using Epic.OnlineServices.Presence; using NewHorizons.External.Modules; using NewHorizons.External.Modules.VariableSize; -using NewHorizons.External.Props; -using NewHorizons.External.Volumes; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -66,7 +64,7 @@ public class PlanetConfig public string[] childrenToDestroy; [Obsolete("Singularity is deprecated, please use Props->singularities")] - public SingularityInfo Singularity; + public SingularityModule Singularity; [Obsolete("Signal is deprecated, please use Props->signals")] public SignalModule Signal; @@ -215,21 +213,21 @@ public void Validate() // if detail.quantumGroupID != null, there exists a quantum group with that id if (Props?.quantumGroups != null && Props?.details != null) { - Dictionary existingGroups = new Dictionary(); + Dictionary existingGroups = new Dictionary(); foreach (var quantumGroup in Props.quantumGroups) { - if (existingGroups.ContainsKey(quantumGroup.id)) { Logger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = QuantumGroupType.FailedValidation; } + if (existingGroups.ContainsKey(quantumGroup.id)) { Logger.LogWarning($"Duplicate quantumGroup id found: {quantumGroup.id}"); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } existingGroups[quantumGroup.id] = quantumGroup; - if (quantumGroup.type == QuantumGroupType.Sockets) + if (quantumGroup.type == PropModule.QuantumGroupType.Sockets) { - if (quantumGroup.sockets?.Length == 0) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = QuantumGroupType.FailedValidation; } + if (quantumGroup.sockets?.Length == 0) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" but has no defined sockets."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } else { foreach (var socket in quantumGroup.sockets) { if (socket.rotation == null) socket.rotation = UnityEngine.Vector3.zero; - if (socket.position == null) { Logger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = QuantumGroupType.FailedValidation; } + if (socket.position == null) { Logger.LogError($"quantumGroup {quantumGroup.id} has a socket without a position."); quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } } } } @@ -245,10 +243,10 @@ public void Validate() foreach (var quantumGroup in Props.quantumGroups) { - if (quantumGroup.type == QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length) + if (quantumGroup.type == PropModule.QuantumGroupType.Sockets && existingGroupsPropCounts.GetValueOrDefault(quantumGroup.id) >= quantumGroup.sockets?.Length) { Logger.LogError($"quantumGroup {quantumGroup.id} is of type \"sockets\" and has more props than sockets."); - quantumGroup.type = QuantumGroupType.FailedValidation; + quantumGroup.type = PropModule.QuantumGroupType.FailedValidation; } } } @@ -276,9 +274,9 @@ public void Migrate() }; if (Base.blackHoleSize != 0) - Singularity = new SingularityInfo + Singularity = new SingularityModule { - type = SingularityInfo.SingularityType.BlackHole, + type = SingularityModule.SingularityType.BlackHole, size = Base.blackHoleSize }; @@ -331,19 +329,19 @@ public void Migrate() if (Props?.tornados != null) foreach (var tornado in Props.tornados) if (tornado.downwards) - tornado.type = TornadoInfo.TornadoType.Downwards; + tornado.type = PropModule.TornadoInfo.TornadoType.Downwards; if (Props?.audioVolumes != null) { if (Volumes == null) Volumes = new VolumesModule(); - if (Volumes.audioVolumes == null) Volumes.audioVolumes = new AudioVolumeInfo[0]; + if (Volumes.audioVolumes == null) Volumes.audioVolumes = new VolumesModule.AudioVolumeInfo[0]; Volumes.audioVolumes = Volumes.audioVolumes.Concat(Props.audioVolumes).ToArray(); } if (Props?.reveal != null) { if (Volumes == null) Volumes = new VolumesModule(); - if (Volumes.revealVolumes == null) Volumes.revealVolumes = new RevealVolumeInfo[0]; + if (Volumes.revealVolumes == null) Volumes.revealVolumes = new VolumesModule.RevealVolumeInfo[0]; Volumes.revealVolumes = Volumes.revealVolumes.Concat(Props.reveal).ToArray(); } @@ -377,7 +375,7 @@ public void Migrate() if (Singularity != null) { if (Props == null) Props = new PropModule(); - if (Props.singularities == null) Props.singularities = new SingularityInfo[0]; + if (Props.singularities == null) Props.singularities = new SingularityModule[0]; Props.singularities = Props.singularities.Append(Singularity).ToArray(); } @@ -391,10 +389,10 @@ public void Migrate() singularity.horizonRadius = singularity.size * 0.4f; switch (singularity.type) { - case SingularityInfo.SingularityType.BlackHole: + case SingularityModule.SingularityType.BlackHole: singularity.distortRadius = singularity.size * 0.95f; break; - case SingularityInfo.SingularityType.WhiteHole: + case SingularityModule.SingularityType.WhiteHole: singularity.distortRadius = singularity.size * 2.8f; break; } @@ -406,7 +404,7 @@ public void Migrate() if (Signal?.signals != null) { if (Props == null) Props = new PropModule(); - if (Props.signals == null) Props.signals = new SignalInfo[0]; + if (Props.signals == null) Props.signals = new SignalModule.SignalInfo[0]; Props.signals = Props.signals.Concat(Signal.signals).ToArray(); } @@ -452,9 +450,9 @@ public void Migrate() if (Base.zeroGravityRadius != 0f) { Volumes ??= new VolumesModule(); - Volumes.zeroGravityVolumes ??= new PriorityVolumeInfo[0]; + Volumes.zeroGravityVolumes ??= new VolumesModule.PriorityVolumeInfo[0]; - Volumes.zeroGravityVolumes = Volumes.zeroGravityVolumes.Append(new PriorityVolumeInfo() + Volumes.zeroGravityVolumes = Volumes.zeroGravityVolumes.Append(new VolumesModule.PriorityVolumeInfo() { priority = 1, rename = "ZeroGVolume", @@ -495,7 +493,7 @@ public void Migrate() { if (dialogue.remoteTrigger == null && (dialogue.remoteTriggerPosition != null || dialogue.remoteTriggerRadius != 0)) { - dialogue.remoteTrigger = new DialogueInfo.RemoteTriggerInfo + dialogue.remoteTrigger = new PropModule.DialogueInfo.RemoteTriggerInfo { position = dialogue.remoteTriggerPosition, radius = dialogue.remoteTriggerRadius, diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index a3e5d2980..12a97277c 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Utility; using Newtonsoft.Json; using static NewHorizons.External.Modules.ShipLogModule; @@ -212,12 +211,12 @@ public class VesselModule [Obsolete("warpExitRotation is deprecated, use vesselSpawn.rotation instead")] public MVector3 warpExitRotation; [JsonObject] - public class VesselInfo : GeneralSolarSystemPropInfo + public class VesselInfo : PropModule.GeneralSolarSystemPropInfo { } [JsonObject] - public class WarpExitInfo : GeneralSolarSystemPropInfo + public class WarpExitInfo : PropModule.GeneralSolarSystemPropInfo { /// /// If set, keeps the warp exit attached to the vessel. Overrides `parentPath`. diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 64207cbcd..7fec298be 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using NewHorizons.External.Props; namespace NewHorizons.External.Modules { @@ -77,5 +76,66 @@ public class BrambleDimensionInfo public int[] allowedEntrances; } + + [JsonObject] + public class BrambleNodeInfo : PropModule.GeneralPropInfo + { + /// + /// The physical scale of the node, as a multiplier of the original size. + /// Nodes are 150m across, seeds are 10m across. + /// + [DefaultValue(1f)] public float scale = 1f; + + /// + /// The name of the planet that hosts the dimension this node links to + /// + public string linksTo; + + /// + /// The name of this node. Only required if this node should serve as an exit. + /// + public string name; + + /// + /// Set this to true to make this node a seed instead of a node the player can enter + /// + [DefaultValue(false)] public bool isSeed = false; + + /// + /// The color of the fog inside the node. + /// Leave blank for the default yellowish white color: (255, 245, 217, 255) + /// + public MColor fogTint; + + /// + /// The color of the light from the node. Alpha controls brightness. + /// Leave blank for the default white color. + /// + public MColor lightTint; + + /// + /// Should this node have a point of light from afar? + /// By default, nodes will have a foglight, while seeds won't, and neither will if not in a dimension. + /// + public bool? hasFogLight; + + /// + /// An array of integers from 0-5. By default, all exits are allowed. To force this node to warp players out from only one hole set this value to [3], [5], or similar. Values of 0-5 only. + /// + public int[] possibleExits; + + /// + /// If your game hard crashes upon entering bramble, it's most likely because you have indirectly recursive dimensions, i.e. one leads to another that leads back to the first one. + /// Set this to true for one of the nodes in the recursion to fix this, at the cost of it no longer showing markers for the scout, ship, etc. + /// + [DefaultValue(false)] public bool preventRecursionCrash = false; + + #region Obsolete + + [Obsolete("farFogTint is deprecated, please use fogTint instead")] + public MColor farFogTint; + + #endregion Obsolete + } } } diff --git a/NewHorizons/External/Modules/ProbeModule.cs b/NewHorizons/External/Modules/ProbeModule.cs deleted file mode 100644 index 79384968a..000000000 --- a/NewHorizons/External/Modules/ProbeModule.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NewHorizons.External.Volumes; -using Newtonsoft.Json; - -namespace NewHorizons.External.Modules -{ - [JsonObject] - public class ProbeModule - { - /// - /// Add probe destruction volumes to this planet. These will delete your probe. - /// - public VolumeInfo[] destructionVolumes; - - /// - /// Add probe safety volumes to this planet. These will stop the probe destruction volumes from working. - /// - public VolumeInfo[] safetyVolumes; - } - } - diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 301c88f7a..9c21b454a 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -1,7 +1,12 @@ + +using NewHorizons.Utility; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using System; -using NewHorizons.External.Props; -using NewHorizons.External.Volumes; +using NewHorizons.External.Modules.VariableSize; namespace NewHorizons.External.Modules { @@ -77,20 +82,831 @@ public class PropModule /// /// Add black/white-holes to this planet /// - public SingularityInfo[] singularities; + public SingularityModule[] singularities; /// /// Add signalscope signals to this planet /// - public SignalInfo[] signals; + public SignalModule.SignalInfo[] signals; /// /// Add projection pools/platforms, whiteboards, and stones to this planet /// public RemoteInfo[] remotes; - [Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public RevealVolumeInfo[] reveal; + [Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public VolumesModule.RevealVolumeInfo[] reveal; + + [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes; + + [JsonObject] + public abstract class GeneralPointPropInfo + { + /// + /// Position of the object + /// + public MVector3 position; + + /// + /// 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; + } + + [JsonObject] + public abstract class GeneralPropInfo : GeneralPointPropInfo + { + /// + /// Rotation of the object + /// + public MVector3 rotation; + } + + [JsonObject] + public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo + { + /// + /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. + /// + public string parentBody; + } + + [JsonObject] + public class ScatterInfo + { + /// + /// Relative filepath to an asset-bundle + /// + public string assetBundle; + + /// + /// Number of props to scatter + /// + public int count; + + /// + /// Offset this prop once it is placed + /// + public MVector3 offset; + + /// + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// + public string path; + + /// + /// Rotate this prop once it is placed + /// + public MVector3 rotation; + + /// + /// Scale this prop once it is placed + /// + [DefaultValue(1f)] public float scale = 1f; + + /// + /// Scale each axis of the prop. Overrides `scale`. + /// + public MVector3 stretch; + + /// + /// The number used as entropy for scattering the props + /// + public int seed; + + /// + /// The lowest height that these object will be placed at (only relevant if there's a heightmap) + /// + public float? minHeight; + + /// + /// The highest height that these objects will be placed at (only relevant if there's a heightmap) + /// + public float? maxHeight; + + /// + /// Should we try to prevent overlap between the scattered details? True by default. If it's affecting load times turn it off. + /// + [DefaultValue(true)] public bool preventOverlap = true; + + /// + /// Should this detail stay loaded even if you're outside the sector (good for very large props) + /// + public bool keepLoaded; + } + + [JsonObject] + public class DetailInfo : GeneralPropInfo + { + + /// + /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? + /// + public bool alignToNormal; + + /// + /// Relative filepath to an asset-bundle to load the prefab defined in `path` from + /// + public string assetBundle; + + /// + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// + public string path; + + /// + /// A list of children to remove from this detail + /// + public string[] removeChildren; + + /// + /// Do we reset all the components on this object? Useful for certain props that have dialogue components attached to + /// them. + /// + public bool removeComponents; + + /// + /// Scale the prop + /// + [DefaultValue(1f)] public float scale = 1f; + + /// + /// Scale each axis of the prop. Overrides `scale`. + /// + public MVector3 stretch; + + /// + /// If this value is not null, this prop will be quantum. Assign this field to the id of the quantum group it should be a part of. The group it is assigned to determines what kind of quantum object it is + /// + public string quantumGroupID; + + /// + /// Should this detail stay loaded even if you're outside the sector (good for very large props) + /// + public bool keepLoaded; + + /// + /// Should this object dynamically move around? + /// This tries to make all mesh colliders convex, as well as adding a sphere collider in case the detail has no others. + /// + public bool hasPhysics; + + /// + /// The mass of the physics object. + /// Most pushable props use the default value, which matches the player mass. + /// + [DefaultValue(0.001f)] public float physicsMass = 0.001f; + + /// + /// The radius that the added sphere collider will use for physics collision. + /// If there's already good colliders on the detail, you can make this 0. + /// + [DefaultValue(1f)] public float physicsRadius = 1f; + } + + [JsonObject] + public class RaftInfo : GeneralPointPropInfo + { + /// + /// Acceleration of the raft. Default acceleration is 5. + /// + [DefaultValue(5f)] public float acceleration = 5f; + } + + [JsonObject] + public class GeyserInfo : GeneralPointPropInfo + { + /// + /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. + /// + [DefaultValue(-97.5f)] public float offset = -97.5f; + + /// + /// Force of the geyser on objects + /// + [DefaultValue(55f)] public float force = 55f; + + /// + /// Time in seconds eruptions last for + /// + [DefaultValue(10f)] public float activeDuration = 10f; + + /// + /// Time in seconds between eruptions + /// + [DefaultValue(19f)] public float inactiveDuration = 19f; + + /// + /// Color of the geyser. Alpha sets the particle density. + /// + public MColor tint; + + /// + /// Disable the individual particle systems of the geyser + /// + public bool disableBubbles, disableShaft, disableSpout; + + /// + /// Loudness of the geyser + /// + [DefaultValue(0.7f)] public float volume = 0.7f; + } + + [JsonObject] + public class TornadoInfo : GeneralPointPropInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum TornadoType + { + [EnumMember(Value = @"upwards")] Upwards = 0, + + [EnumMember(Value = @"downwards")] Downwards = 1, + + [EnumMember(Value = @"hurricane")] Hurricane = 2 + } + + [Obsolete("Downwards is deprecated. Use Type instead.")] public bool downwards; + + /// + /// Alternative to setting the position. Will choose a random place at this elevation. + /// + public float elevation; + + /// + /// The height of this tornado. + /// + [DefaultValue(30f)] public float height = 30f; + + /// + /// The colour of the tornado. + /// + public MColor tint; + + /// + /// What type of cyclone should this be? Upwards and downwards are both tornados and will push in that direction. + /// + [DefaultValue("upwards")] public TornadoType type = TornadoType.Upwards; + + /// + /// Angular distance from the starting position that it will wander, in terms of the angle around the x-axis. + /// + [DefaultValue(45f)] public float wanderDegreesX = 45f; + + /// + /// Angular distance from the starting position that it will wander, in terms of the angle around the z-axis. + /// + [DefaultValue(45f)] public float wanderDegreesZ = 45f; + + /// + /// The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around + /// 0.1. + /// + public float wanderRate; + + /// + /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. + /// + public float audioDistance; + + /// + /// Fluid type for sounds/effects when colliding with this tornado. + /// + [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud; + } + + [JsonObject] + public class VolcanoInfo : GeneralPointPropInfo + { + /// + /// The colour of the meteor's lava. + /// + public MColor lavaTint; + + /// + /// Maximum time between meteor launches. + /// + [DefaultValue(20f)] + public float maxInterval = 20f; + + /// + /// Maximum random speed at which meteors are launched. + /// + [DefaultValue(150f)] + public float maxLaunchSpeed = 150f; + + /// + /// Minimum time between meteor launches. + /// + [DefaultValue(5f)] + public float minInterval = 5f; + + /// + /// Minimum random speed at which meteors are launched. + /// + [DefaultValue(50f)] + public float minLaunchSpeed = 50f; + + /// + /// Scale of the meteors. + /// + public float scale = 1; + + /// + /// The colour of the meteor's stone. + /// + public MColor stoneTint; + } + + [JsonObject] + public class DialogueInfo : GeneralPointPropInfo + { + /// + /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue + /// triggers that you want to have happen only once. + /// + public string blockAfterPersistentCondition; + + /// + /// If a pathToAnimController is supplied, if you are within this distance the character will look at you. If it is set + /// to 0, they will only look at you when spoken to. + /// + public float lookAtRadius; + + /// + /// If this dialogue is meant for a character, this is the relative path from the planet to that character's + /// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController. + /// + /// If none of those components are present it will add a FacePlayerWhenTalking component. + /// + public string pathToAnimController; + + /// + /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a + /// remoteTrigger, you can set this to 0 to make the dialogue only trigger remotely. + /// + public float radius = 1f; + + /// + /// Distance from radius the prompt appears + /// + [DefaultValue(2f)] public float range = 2f; + + /// + /// Allows you to trigger dialogue from a distance when you walk into an area. + /// + public RemoteTriggerInfo remoteTrigger; + + [Obsolete("remoteTriggerPosition is deprecated. Use remoteTrigger.position instead")] public MVector3 remoteTriggerPosition; + [Obsolete("remoteTriggerRadius is deprecated. Use remoteTrigger.radius instead")] public float remoteTriggerRadius; + [Obsolete("remoteTriggerPrereqCondition is deprecated. Use remoteTrigger.prereqCondition instead")] public string remoteTriggerPrereqCondition; + + /// + /// Relative path to the xml file defining the dialogue. + /// + public string xmlFile; + + /// + /// What type of flashlight toggle to do when dialogue is interacted with + /// + [DefaultValue("none")] public FlashlightToggle flashlightToggle = FlashlightToggle.None; + + [JsonConverter(typeof(StringEnumConverter))] + public enum FlashlightToggle + { + [EnumMember(Value = @"none")] None = -1, + [EnumMember(Value = @"turnOff")] TurnOff = 0, + [EnumMember(Value = @"turnOffThenOn")] TurnOffThenOn = 1, + } + + [JsonObject] + public class RemoteTriggerInfo : GeneralPointPropInfo + { + /// + /// The radius of the remote trigger volume. + /// + public float radius; + /// + /// This condition must be met for the remote trigger volume to trigger. + /// + public string prereqCondition; + } + } + + [JsonObject] + public class EntryLocationInfo : GeneralPointPropInfo + { + /// + /// Whether this location is cloaked + /// + public bool cloaked; + + /// + /// ID of the entry this location relates to + /// + public string id; + } + + [JsonObject] + public class NomaiTextInfo : GeneralPointPropInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextType + { + [EnumMember(Value = @"wall")] Wall = 0, + + [EnumMember(Value = @"scroll")] Scroll = 1, + + [EnumMember(Value = @"computer")] Computer = 2, + + [EnumMember(Value = @"cairn")] Cairn = 3, + + [EnumMember(Value = @"recorder")] Recorder = 4, + + [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, + + [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, + + [EnumMember(Value = @"trailmarker")] Trailmarker = 7, + + [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextLocation + { + [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, + + [EnumMember(Value = @"a")] A = 1, + + [EnumMember(Value = @"b")] B = 2 + } + + /// + /// Additional information about each arc in the text + /// + public NomaiTextArcInfo[] arcInfo; + + /// + /// The normal vector for this object. Used for writing on walls and positioning computers. + /// + public MVector3 normal; + + /// + /// The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient + /// themselves to the surface of the planet automatically. + /// + public MVector3 rotation; + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; // For randomizing arcs + + /// + /// The type of object this is. + /// + [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; + + /// + /// The location of this object. + /// + [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; + + /// + /// The relative path to the xml file for this object. + /// + public string xmlFile; + } + + [JsonObject] + public class NomaiTextArcInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextArcType + { + [EnumMember(Value = @"adult")] Adult = 0, + + [EnumMember(Value = @"child")] Child = 1, + + [EnumMember(Value = @"stranger")] Stranger = 2 + } + + /// + /// Whether to skip modifying this spiral's placement, and instead keep the automatically determined placement. + /// + public bool keepAutoPlacement; + + /// + /// Whether to flip the spiral from left-curling to right-curling or vice versa. + /// + public bool mirror; + + /// + /// The local position of this object on the wall. + /// + public MVector2 position; + + /// + /// The type of text to display. + /// + [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; + + /// + /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. + /// + [DefaultValue(-1)] public int variation = -1; + + /// + /// The z euler angle for this arc. + /// + [Range(0f, 360f)] public float zRotation; + } + + [JsonObject] + public class ProjectionInfo : GeneralPropInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum SlideShowType + { + [EnumMember(Value = @"slideReel")] SlideReel = 0, + + [EnumMember(Value = @"autoProjector")] AutoProjector = 1, + + [EnumMember(Value = @"visionTorchTarget")] VisionTorchTarget = 2, + + [EnumMember(Value = @"standingVisionTorch")] StandingVisionTorch = 3, + + } + + /// + /// The ship log facts revealed after finishing this slide reel. + /// + public string[] reveals; + + /// + /// The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows). + /// You should probably include facts from `reveals` here. + /// If you only specify a rumor fact, then it would only play in its ship log entry if this has revealed only + /// rumor facts because an entry with revealed explore facts doesn't display rumor facts. + /// + public string[] playWithShipLogFacts; + + /// + /// The list of slides for this object. + /// + public SlideInfo[] slides; + + /// + /// The type of object this is. + /// + [DefaultValue("slideReel")] public SlideShowType type = SlideShowType.SlideReel; + } + + [JsonObject] + public class SlideInfo + { + /// + /// Ambient light colour when viewing this slide. + /// + public MColor ambientLightColor; + + + // SlideAmbientLightModule + + /// + /// Ambient light intensity when viewing this slide. + /// + public float ambientLightIntensity; + + /// + /// Ambient light range when viewing this slide. + /// + public float ambientLightRange; + + // SlideBackdropAudioModule + + /// + /// The name of the AudioClip that will continuously play while watching these slides + /// + public string backdropAudio; + + /// + /// The time to fade into the backdrop audio + /// + public float backdropFadeTime; + + // SlideBeatAudioModule + + /// + /// The name of the AudioClip for a one-shot sound when opening the slide. + /// + public string beatAudio; + + /// + /// The time delay until the one-shot audio + /// + public float beatDelay; + + + // SlideBlackFrameModule + + /// + /// Before viewing this slide, there will be a black frame for this many seconds. + /// + public float blackFrameDuration; + + /// + /// The path to the image file for this slide. + /// + public string imagePath; + + + // SlidePlayTimeModule + + /// + /// Play-time duration for auto-projector slides. + /// + public float playTimeDuration; + + + // SlideShipLogEntryModule + + /// + /// Ship log fact revealed when viewing this slide + /// + public string reveal; + + /// + /// Spotlight intensity modifier when viewing this slide. + /// + public float spotIntensityMod; + } + + + + + [JsonConverter(typeof(StringEnumConverter))] + public enum QuantumGroupType + { + [EnumMember(Value = @"sockets")] Sockets = 0, + + [EnumMember(Value = @"states")] States = 1, + + FailedValidation = 10 + } + + [JsonObject] + public class QuantumGroupInfo + { + /// + /// What type of group this is: does it define a list of states a single quantum object could take or a list of sockets one or more quantum objects could share? + /// + public QuantumGroupType type; + + /// + /// A unique string used by props (that are marked as quantum) use to refer back to this group + /// + public string id; + + /// + /// Only required if type is `sockets`. This lists all the possible locations for any props assigned to this group. + /// + public QuantumSocketInfo[] sockets; + + /// + /// Optional. Only used if type is `states`. If this is true, then the first prop made part of this group will be used to construct a visibility box for an empty game object, which will be considered one of the states. + /// + public bool hasEmptyState; + + /// + /// Optional. Only used if type is `states`. If this is true, then the states will be presented in order, rather than in a random order + /// + public bool sequential; + + /// + /// Optional. Only used if type is `states` and `sequential` is true. If this is false, then after the last state has appeared, the object will no longer change state + /// + [DefaultValue(true)] public bool loop = true; + } + + [JsonObject] + public class QuantumSocketInfo : GeneralPropInfo + { + /// + /// The probability any props that are part of this group will occupy this socket + /// + [DefaultValue(1f)] public float probability = 1f; + } + + [JsonObject] + public class RemoteInfo + { + /// + /// The unique remote id + /// + public string id; + + /// + /// Icon that the will show on the stone, pedastal of the whiteboard, and pedastal of the platform. + /// + public string decalPath; + + /// + /// Whiteboard that the stones can put text onto + /// + public WhiteboardInfo whiteboard; + + /// + /// Camera platform that the stones can project to and from + /// + public PlatformInfo platform; + + /// + /// Projection stones + /// + public StoneInfo[] stones; + + [JsonObject] + public class WhiteboardInfo : GeneralPropInfo + { + /// + /// The text for each stone + /// + public SharedNomaiTextInfo[] nomaiText; + + /// + /// Disable the wall, leaving only the pedestal and text. + /// + public bool disableWall; + + [JsonObject] + public class SharedNomaiTextInfo + { + /// + /// The id of the stone this text will appear for + /// + public string id; + + /// + /// Additional information about each arc in the text + /// + public NomaiTextArcInfo[] arcInfo; + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; // For randomizing arcs + + /// + /// The location of this object. + /// + [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; + + /// + /// The relative path to the xml file for this object. + /// + public string xmlFile; + + /// + /// An optional rename of this object + /// + public string rename; + } + } + + [JsonObject] + public class PlatformInfo : GeneralPropInfo + { + /// + /// A ship log fact to reveal when the platform is connected to. + /// + [DefaultValue("")] public string reveals = ""; + + /// + /// Disable the structure, leaving only the pedestal. + /// + public bool disableStructure; + + /// + /// Disable the pool that rises when you place a stone. + /// + public bool disablePool; + } + + [JsonObject] + public class StoneInfo : GeneralPropInfo + { - [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public AudioVolumeInfo[] audioVolumes; + } + } } } diff --git a/NewHorizons/External/Modules/RulesetModule.cs b/NewHorizons/External/Modules/RulesetModule.cs deleted file mode 100644 index 4b35e44f2..000000000 --- a/NewHorizons/External/Modules/RulesetModule.cs +++ /dev/null @@ -1,90 +0,0 @@ -using NewHorizons.External.Volumes; -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Modules -{ - [JsonObject] - public class RulesetModule - { - /// - /// Add anti travel music rulesets to this planet. - /// - public VolumeInfo[] antiTravelMusicRulesets; - /// - /// Add player impact rulesets to this planet. - /// - public PlayerImpactRulesetInfo[] playerImpactRulesets; - /// - /// Add probe rulesets to this planet. - /// - public ProbeRulesetInfo[] probeRulesets; - /// - /// Add thrust rulesets to this planet. - /// - public ThrustRulesetInfo[] thrustRulesets; - - [JsonObject] - public class PlayerImpactRulesetInfo : VolumeInfo - { - /// - /// Minimum player impact speed. Player will take the minimum amount of damage if they impact something at this speed. - /// - [DefaultValue(20f)] public float minImpactSpeed = 20f; - - /// - /// Maximum player impact speed. Players will die if they impact something at this speed. - /// - [DefaultValue(40f)] public float maxImpactSpeed = 40f; - } - - [JsonObject] - public class ProbeRulesetInfo : VolumeInfo - { - /// - /// Should this ruleset override the probe's speed? - /// - public bool overrideProbeSpeed; - - /// - /// The speed of the probe while in this ruleset volume. - /// - public float probeSpeed; - - /// - /// Should this ruleset override the range of probe's light? - /// - public bool overrideLanternRange; - - /// - /// The range of probe's light while in this ruleset volume. - /// - public float lanternRange; - - /// - /// Stop the probe from attaching to anything while in this ruleset volume. - /// - public bool ignoreAnchor; - } - - [JsonObject] - public class ThrustRulesetInfo : VolumeInfo - { - /// - /// Limit how fast you can fly with your ship while in this ruleset volume. - /// - [DefaultValue(float.PositiveInfinity)] public float thrustLimit = float.PositiveInfinity; - - /// - /// Nerf the jetpack booster. - /// - public bool nerfJetpackBooster; - - /// - /// How long the jetpack booster will be nerfed. - /// - [DefaultValue(0.5f)] public float nerfDuration = 0.5f; - } - } - } - diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index 337258cbb..cfa66a16f 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -1,7 +1,6 @@ using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using NewHorizons.External.Props; using NewHorizons.Utility; using Newtonsoft.Json; @@ -14,5 +13,63 @@ public class SignalModule /// List of signals to add (Why did xen do it like this) /// public SignalInfo[] signals; + + [JsonObject] + public class SignalInfo : PropModule.GeneralPointPropInfo + { + [Obsolete("audioClip is deprecated, please use audio instead")] + public string audioClip; + + [Obsolete("audioFilePath is deprecated, please use audio instead")] + public string audioFilePath; + + /// + /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. + /// + public string audio; + + /// + /// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected" + /// notification. + /// + [Range(0f, double.MaxValue)] public float detectionRadius; + + /// + /// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`, + /// `Statue`, `WarpCore`, `HideAndSeek`, and `Radio`. You can also put a custom value. + /// + public string frequency; + + /// + /// How close the player must get to the signal to identify it. This is when you learn its name. + /// + [DefaultValue(10f)] [Range(0f, double.MaxValue)] + public float identificationRadius = 10f; + + /// + /// Only set to `true` if you are putting this signal inside a cloaking field. + /// + public bool insideCloak; + + /// + /// The unique ID of the signal. + /// + public string name; + + /// + /// `false` if the player can hear the signal without equipping the signal-scope. + /// + [DefaultValue(true)] public bool onlyAudibleToScope = true; + + /// + /// A ship log fact to reveal when the signal is identified. + /// + [DefaultValue("")] public string reveals = ""; + + /// + /// Radius of the sphere giving off the signal. + /// + [DefaultValue(1f)] public float sourceRadius = 1f; + } } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index 5ab6bf71d..ea8067c14 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -1,4 +1,3 @@ -using NewHorizons.External.Props; using NewHorizons.Utility; using Newtonsoft.Json; using System; @@ -25,7 +24,7 @@ public class SpawnModule [Obsolete("startWithSuit is deprecated. Use playerSpawn.startWithSuit instead")] public bool startWithSuit; [JsonObject] - public class PlayerSpawnPoint : GeneralPropInfo { + public class PlayerSpawnPoint : PropModule.GeneralPropInfo { /// /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) /// @@ -33,7 +32,7 @@ public class PlayerSpawnPoint : GeneralPropInfo { } [JsonObject] - public class ShipSpawnPoint : GeneralPropInfo { + public class ShipSpawnPoint : PropModule.GeneralPropInfo { } } diff --git a/NewHorizons/External/Props/SingularityInfo.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs similarity index 92% rename from NewHorizons/External/Props/SingularityInfo.cs rename to NewHorizons/External/Modules/VariableSize/SingularityModule.cs index 6b6175884..58b35b9a4 100644 --- a/NewHorizons/External/Props/SingularityInfo.cs +++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs @@ -6,10 +6,10 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace NewHorizons.External.Props +namespace NewHorizons.External.Modules.VariableSize { [JsonObject] - public class SingularityInfo : GeneralPropInfo + public class SingularityModule : PropModule.GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SingularityType @@ -39,7 +39,7 @@ public enum SingularityType /// Radius of the singularity. Note that this isn't the same as the event horizon, but includes the entire volume that /// has warped effects in it. /// - [Obsolete("size is deprecated, please use horizonRadius and distortRadius instead")][Range(0f, double.MaxValue)] public float size; + [Obsolete("size is deprecated, please use horizonRadius and distortRadius instead")] [Range(0f, double.MaxValue)] public float size; /// /// Radius of the event horizon (solid part) diff --git a/NewHorizons/External/Modules/VisorEffectModule.cs b/NewHorizons/External/Modules/VisorEffectModule.cs deleted file mode 100644 index fa1fd6ceb..000000000 --- a/NewHorizons/External/Modules/VisorEffectModule.cs +++ /dev/null @@ -1,55 +0,0 @@ -using NewHorizons.External.Volumes; -using Newtonsoft.Json; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; - -namespace NewHorizons.External.Modules -{ - [JsonObject] - public class VisorEffectModule - { - /// - /// Add visor frost effect volumes to this planet. This is the ghost matter effect. - /// - public FrostEffectVolumeInfo[] frostEffectVolumes; - - /// - /// Add visor rain effect volumes to this planet. You can see this on Giant's Deep. - /// - public RainEffectVolumeInfo[] rainEffectVolumes; - - [JsonObject] - public class FrostEffectVolumeInfo : PriorityVolumeInfo - { - /// - /// The rate at which the frost effect will get stronger - /// - [DefaultValue(0.5f)] - public float frostRate = 0.5f; - - /// - /// The maximum strength of frost this volume can give - /// - [Range(0f, 1f)] - [DefaultValue(0.91f)] - public float maxFrost = 0.91f; - } - - [JsonObject] - public class RainEffectVolumeInfo : PriorityVolumeInfo - { - /// - /// The rate at which the rain droplet effect will happen - /// - [DefaultValue(0.1f)] - public float dropletRate = 10f; - - /// - /// The rate at which the rain streak effect will happen - /// - [DefaultValue(1f)] - public float streakRate = 1f; - } - } - } - diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 5118db0ca..8b60df6ea 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -1,5 +1,3 @@ -using NewHorizons.External.Props; -using NewHorizons.External.Volumes; using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -117,5 +115,539 @@ public class VolumesModule /// Enter this volume to be sent to the end credits scene /// public LoadCreditsVolumeInfo[] creditsVolume; + + [JsonObject] + public class VolumeInfo : PropModule.GeneralPointPropInfo + { + /// + /// The radius of this volume. + /// + [DefaultValue(1f)] + public float radius = 1f; + } + + [JsonObject] + public class ChangeStarSystemVolumeInfo : VolumeInfo + { + /// + /// The star system that entering this volume will send you to. + /// + [DefaultValue("SolarSystem")] + public string targetStarSystem; + } + + [JsonObject] + public class LoadCreditsVolumeInfo : VolumeInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum CreditsType + { + [EnumMember(Value = @"fast")] Fast = 0, + + [EnumMember(Value = @"final")] Final = 1, + + [EnumMember(Value = @"kazoo")] Kazoo = 2 + } + + [DefaultValue("fast")] + public CreditsType creditsType = CreditsType.Fast; + } + + [JsonObject] + public class PriorityVolumeInfo : VolumeInfo + { + /// + /// The layer of this volume. + /// + [DefaultValue(0)] + public int layer = 0; + + /// + /// The priority for this volume's effects to be applied. + /// Ex, a player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity. + /// + [DefaultValue(1)] + public int priority = 1; + } + + [JsonObject] + public class RevealVolumeInfo : VolumeInfo + { + [JsonConverter(typeof(StringEnumConverter))] + public enum RevealVolumeType + { + [EnumMember(Value = @"enter")] Enter = 0, + + [EnumMember(Value = @"observe")] Observe = 1, + + [EnumMember(Value = @"snapshot")] Snapshot = 2 + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum EnterType + { + [EnumMember(Value = @"both")] Both = 0, + + [EnumMember(Value = @"player")] Player = 1, + + [EnumMember(Value = @"probe")] Probe = 2 + } + + /// + /// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only) + /// + [DefaultValue(180f)] + public float maxAngle = 180f; // Observe Only + + /// + /// The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only) + /// + [DefaultValue(-1f)] + public float maxDistance = -1f; // Snapshot & Observe Only + + /// + /// What needs to be done to the volume to unlock the facts + /// + [DefaultValue("enter")] public RevealVolumeType revealOn = RevealVolumeType.Enter; + + /// + /// What can enter the volume to unlock the facts (`enter` only) + /// + [DefaultValue("both")] public EnterType revealFor = EnterType.Both; + + /// + /// A list of facts to reveal + /// + public string[] reveals; + + /// + /// An achievement to unlock. Optional. + /// + public string achievementID; + } + + [JsonObject] + public class AudioVolumeInfo : PriorityVolumeInfo + { + /// + /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. + /// + public string audio; + + [DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM; + + /// + /// The audio track of this audio volume + /// + [DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment; + + /// + /// Whether to loop this audio while in this audio volume or just play it once + /// + [DefaultValue(true)] public bool loop = true; + + /// + /// The loudness of the audio + /// + [Range(0f, 1f)] + [DefaultValue(1f)] + public float volume = 1f; + + /// + /// How long it will take to fade this sound in and out when entering/exiting this volume. + /// + [DefaultValue(2f)] + public float fadeSeconds = 2f; + + /// + /// Play the sound instantly without any fading. + /// + public bool noFadeFromBeginning; + + /// + /// Randomize what time the audio starts at. + /// + public bool randomizePlayhead; + + /// + /// Pause the music when exiting the volume. + /// + public bool pauseOnFadeOut; + } + + [JsonObject] + public class NotificationVolumeInfo : VolumeInfo + { + /// + /// What the notification will show for. + /// + [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; + + /// + /// The notification that will play when you enter this volume. + /// + public NotificationInfo entryNotification; + + /// + /// The notification that will play when you exit this volume. + /// + public NotificationInfo exitNotification; + + + [JsonObject] + public class NotificationInfo + { + /// + /// The message that will be displayed. + /// + public string displayMessage; + + /// + /// The duration this notification will be displayed. + /// + [DefaultValue(5f)] public float duration = 5f; + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NotificationTarget + { + [EnumMember(Value = @"all")] All = 0, + [EnumMember(Value = @"ship")] Ship = 1, + [EnumMember(Value = @"player")] Player = 2, + } + } + + [JsonObject] + public class HazardVolumeInfo : VolumeInfo + { + /// + /// The type of hazard for this volume. + /// + [DefaultValue("general")] public HazardType type = HazardType.GENERAL; + + /// + /// The amount of damage you will take per second while inside this volume. + /// + [DefaultValue(10f)] public float damagePerSecond = 10f; + + /// + /// The type of damage you will take when you first touch this volume. + /// + [DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact; + + /// + /// The amount of damage you will take when you first touch this volume. + /// + public float firstContactDamage; + + [JsonConverter(typeof(StringEnumConverter))] + public enum HazardType + { + [EnumMember(Value = @"none")] NONE = 0, + [EnumMember(Value = @"general")] GENERAL = 1, + [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2, + [EnumMember(Value = @"heat")] HEAT = 4, + [EnumMember(Value = @"fire")] FIRE = 8, + [EnumMember(Value = @"sandfall")] SANDFALL = 16, + [EnumMember(Value = @"electricity")] ELECTRICITY = 32, + [EnumMember(Value = @"rapids")] RAPIDS = 64, + [EnumMember(Value = @"riverHeat")] RIVERHEAT = 128, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum InstantDamageType + { + [EnumMember(Value = @"impact")] Impact, + [EnumMember(Value = @"puncture")] Puncture, + [EnumMember(Value = @"electrical")] Electrical + } + } + + [JsonObject] + public class VanishVolumeInfo : VolumeInfo + { + /// + /// Whether the bodies will shrink when they enter this volume or just disappear instantly. + /// + [DefaultValue(true)] public bool shrinkBodies = true; + + /// + /// Whether this volume only affects the player and ship. + /// + public bool onlyAffectsPlayerAndShip; + } + + [JsonObject] + public class DestructionVolumeInfo : VanishVolumeInfo + { + /// + /// The type of death the player will have if they enter this volume. + /// + [DefaultValue("default")] public DeathType deathType = DeathType.Default; + + [JsonConverter(typeof(StringEnumConverter))] + public enum DeathType + { + [EnumMember(Value = @"default")] Default, + [EnumMember(Value = @"impact")] Impact, + [EnumMember(Value = @"asphyxiation")] Asphyxiation, + [EnumMember(Value = @"energy")] Energy, + [EnumMember(Value = @"supernova")] Supernova, + [EnumMember(Value = @"digestion")] Digestion, + [EnumMember(Value = @"bigBang")] BigBang, + [EnumMember(Value = @"crushed")] Crushed, + [EnumMember(Value = @"meditation")] Meditation, + [EnumMember(Value = @"timeLoop")] TimeLoop, + [EnumMember(Value = @"lava")] Lava, + [EnumMember(Value = @"blackHole")] BlackHole, + [EnumMember(Value = @"dream")] Dream, + [EnumMember(Value = @"dreamExplosion")] DreamExplosion, + [EnumMember(Value = @"crushedByElevator")] CrushedByElevator + } + } + + [JsonObject] + public class OxygenVolumeInfo : VolumeInfo + { + /// + /// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled". + /// + public bool treeVolume; + + /// + /// Whether to play the oxygen tank refill sound or just fill quietly. + /// + [DefaultValue(true)] public bool playRefillAudio = true; + } + + [JsonObject] + public class FluidVolumeInfo : PriorityVolumeInfo + { + /// + /// Density of the fluid. The higher the density, the harder it is to go through this fluid. + /// + [DefaultValue(1.2f)] public float density = 1.2f; + + /// + /// The type of fluid for this volume. + /// + public FluidType type; + + /// + /// Should the player and rafts align to this fluid. + /// + [DefaultValue(true)] public bool alignmentFluid = true; + + /// + /// Should the ship align to the fluid by rolling. + /// + public bool allowShipAutoroll; + + /// + /// Disable this fluid volume immediately? + /// + public bool disableOnStart; + + [JsonConverter(typeof(StringEnumConverter))] + public enum FluidType + { + [EnumMember(Value = @"none")] NONE = 0, + [EnumMember(Value = @"air")] AIR, + [EnumMember(Value = @"water")] WATER, + [EnumMember(Value = @"cloud")] CLOUD, + [EnumMember(Value = @"sand")] SAND, + [EnumMember(Value = @"plasma")] PLASMA, + [EnumMember(Value = @"fog")] FOG + } + } + + [JsonObject] + public class ProbeModule + { + /// + /// Add probe destruction volumes to this planet. These will delete your probe. + /// + public VolumeInfo[] destructionVolumes; + + /// + /// Add probe safety volumes to this planet. These will stop the probe destruction volumes from working. + /// + public VolumeInfo[] safetyVolumes; + } + + [JsonObject] + public class VisorEffectModule + { + /// + /// Add visor frost effect volumes to this planet. This is the ghost matter effect. + /// + public FrostEffectVolumeInfo[] frostEffectVolumes; + + /// + /// Add visor rain effect volumes to this planet. You can see this on Giant's Deep. + /// + public RainEffectVolumeInfo[] rainEffectVolumes; + + [JsonObject] + public class FrostEffectVolumeInfo : PriorityVolumeInfo + { + /// + /// The rate at which the frost effect will get stronger + /// + [DefaultValue(0.5f)] + public float frostRate = 0.5f; + + /// + /// The maximum strength of frost this volume can give + /// + [Range(0f, 1f)] + [DefaultValue(0.91f)] + public float maxFrost = 0.91f; + } + + [JsonObject] + public class RainEffectVolumeInfo : PriorityVolumeInfo + { + /// + /// The rate at which the rain droplet effect will happen + /// + [DefaultValue(0.1f)] + public float dropletRate = 10f; + + /// + /// The rate at which the rain streak effect will happen + /// + [DefaultValue(1f)] + public float streakRate = 1f; + } + } + + [JsonObject] + public class RulesetModule + { + /// + /// Add anti travel music rulesets to this planet. + /// + public VolumeInfo[] antiTravelMusicRulesets; + /// + /// Add player impact rulesets to this planet. + /// + public PlayerImpactRulesetInfo[] playerImpactRulesets; + /// + /// Add probe rulesets to this planet. + /// + public ProbeRulesetInfo[] probeRulesets; + /// + /// Add thrust rulesets to this planet. + /// + public ThrustRulesetInfo[] thrustRulesets; + + [JsonObject] + public class PlayerImpactRulesetInfo : VolumeInfo + { + /// + /// Minimum player impact speed. Player will take the minimum amount of damage if they impact something at this speed. + /// + [DefaultValue(20f)] public float minImpactSpeed = 20f; + + /// + /// Maximum player impact speed. Players will die if they impact something at this speed. + /// + [DefaultValue(40f)] public float maxImpactSpeed = 40f; + } + + [JsonObject] + public class ProbeRulesetInfo : VolumeInfo + { + /// + /// Should this ruleset override the probe's speed? + /// + public bool overrideProbeSpeed; + + /// + /// The speed of the probe while in this ruleset volume. + /// + public float probeSpeed; + + /// + /// Should this ruleset override the range of probe's light? + /// + public bool overrideLanternRange; + + /// + /// The range of probe's light while in this ruleset volume. + /// + public float lanternRange; + + /// + /// Stop the probe from attaching to anything while in this ruleset volume. + /// + public bool ignoreAnchor; + } + + [JsonObject] + public class ThrustRulesetInfo : VolumeInfo + { + /// + /// Limit how fast you can fly with your ship while in this ruleset volume. + /// + [DefaultValue(float.PositiveInfinity)] public float thrustLimit = float.PositiveInfinity; + + /// + /// Nerf the jetpack booster. + /// + public bool nerfJetpackBooster; + + /// + /// How long the jetpack booster will be nerfed. + /// + [DefaultValue(0.5f)] public float nerfDuration = 0.5f; + } + } + + [JsonObject] + public class SpeedTrapVolumeInfo : VolumeInfo + { + /// + /// The speed the volume will slow you down to when you enter it. + /// + [DefaultValue(10f)] + public float speedLimit = 10f; + + /// + /// How fast it will slow down the player to the speed limit. + /// + [DefaultValue(3f)] + public float acceleration = 3f; + } + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum ClipSelectionType + { + [EnumMember(Value = @"random")] RANDOM, + [EnumMember(Value = @"sequential")] SEQUENTIAL, + [EnumMember(Value = @"manual")] MANUAL + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum AudioMixerTrackName + { + [EnumMember(Value = @"undefined")] Undefined = 0, + [EnumMember(Value = @"menu")] Menu = 1, + [EnumMember(Value = @"music")] Music = 2, + [EnumMember(Value = @"environment")] Environment = 4, + [EnumMember(Value = @"environmentUnfiltered")] Environment_Unfiltered = 5, + [EnumMember(Value = @"endTimesSfx")] EndTimes_SFX = 8, + [EnumMember(Value = @"signal")] Signal = 16, + [EnumMember(Value = @"death")] Death = 32, + [EnumMember(Value = @"player")] Player = 64, + [EnumMember(Value = @"playerExternal")] Player_External = 65, + [EnumMember(Value = @"ship")] Ship = 128, + [EnumMember(Value = @"map")] Map = 256, + [EnumMember(Value = @"endTimesMusic")] EndTimes_Music = 512, + [EnumMember(Value = @"muffleWhileRafting")] MuffleWhileRafting = 1024, + [EnumMember(Value = @"muffleIndoors")] MuffleIndoors = 2048, + [EnumMember(Value = @"slideReelMusic")] SlideReelMusic = 4096, } } diff --git a/NewHorizons/External/Props/BrambleNodeInfo.cs b/NewHorizons/External/Props/BrambleNodeInfo.cs deleted file mode 100644 index 18d9f2984..000000000 --- a/NewHorizons/External/Props/BrambleNodeInfo.cs +++ /dev/null @@ -1,73 +0,0 @@ -using NewHorizons.Utility; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NewHorizons.External.Props -{ - - [JsonObject] - public class BrambleNodeInfo : GeneralPropInfo - { - /// - /// The physical scale of the node, as a multiplier of the original size. - /// Nodes are 150m across, seeds are 10m across. - /// - [DefaultValue(1f)] public float scale = 1f; - - /// - /// The name of the planet that hosts the dimension this node links to - /// - public string linksTo; - - /// - /// The name of this node. Only required if this node should serve as an exit. - /// - public string name; - - /// - /// Set this to true to make this node a seed instead of a node the player can enter - /// - [DefaultValue(false)] public bool isSeed = false; - - /// - /// The color of the fog inside the node. - /// Leave blank for the default yellowish white color: (255, 245, 217, 255) - /// - public MColor fogTint; - - /// - /// The color of the light from the node. Alpha controls brightness. - /// Leave blank for the default white color. - /// - public MColor lightTint; - - /// - /// Should this node have a point of light from afar? - /// By default, nodes will have a foglight, while seeds won't, and neither will if not in a dimension. - /// - public bool? hasFogLight; - - /// - /// An array of integers from 0-5. By default, all exits are allowed. To force this node to warp players out from only one hole set this value to [3], [5], or similar. Values of 0-5 only. - /// - public int[] possibleExits; - - /// - /// If your game hard crashes upon entering bramble, it's most likely because you have indirectly recursive dimensions, i.e. one leads to another that leads back to the first one. - /// Set this to true for one of the nodes in the recursion to fix this, at the cost of it no longer showing markers for the scout, ship, etc. - /// - [DefaultValue(false)] public bool preventRecursionCrash = false; - - #region Obsolete - - [Obsolete("farFogTint is deprecated, please use fogTint instead")] - public MColor farFogTint; - - #endregion Obsolete - } -} diff --git a/NewHorizons/External/Props/DetailInfo.cs b/NewHorizons/External/Props/DetailInfo.cs deleted file mode 100644 index f68977b96..000000000 --- a/NewHorizons/External/Props/DetailInfo.cs +++ /dev/null @@ -1,76 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class DetailInfo : GeneralPropInfo - { - - /// - /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? - /// - public bool alignToNormal; - - /// - /// Relative filepath to an asset-bundle to load the prefab defined in `path` from - /// - public string assetBundle; - - /// - /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle - /// - public string path; - - /// - /// A list of children to remove from this detail - /// - public string[] removeChildren; - - /// - /// Do we reset all the components on this object? Useful for certain props that have dialogue components attached to - /// them. - /// - public bool removeComponents; - - /// - /// Scale the prop - /// - [DefaultValue(1f)] public float scale = 1f; - - /// - /// Scale each axis of the prop. Overrides `scale`. - /// - public MVector3 stretch; - - /// - /// If this value is not null, this prop will be quantum. Assign this field to the id of the quantum group it should be a part of. The group it is assigned to determines what kind of quantum object it is - /// - public string quantumGroupID; - - /// - /// Should this detail stay loaded even if you're outside the sector (good for very large props) - /// - public bool keepLoaded; - - /// - /// Should this object dynamically move around? - /// This tries to make all mesh colliders convex, as well as adding a sphere collider in case the detail has no others. - /// - public bool hasPhysics; - - /// - /// The mass of the physics object. - /// Most pushable props use the default value, which matches the player mass. - /// - [DefaultValue(0.001f)] public float physicsMass = 0.001f; - - /// - /// The radius that the added sphere collider will use for physics collision. - /// If there's already good colliders on the detail, you can make this 0. - /// - [DefaultValue(1f)] public float physicsRadius = 1f; - } -} diff --git a/NewHorizons/External/Props/DialogueInfo.cs b/NewHorizons/External/Props/DialogueInfo.cs deleted file mode 100644 index e3e7dc1f9..000000000 --- a/NewHorizons/External/Props/DialogueInfo.cs +++ /dev/null @@ -1,85 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class DialogueInfo : GeneralPointPropInfo - { - /// - /// Prevents the dialogue from being created after a specific persistent condition is set. Useful for remote dialogue - /// triggers that you want to have happen only once. - /// - public string blockAfterPersistentCondition; - - /// - /// If a pathToAnimController is supplied, if you are within this distance the character will look at you. If it is set - /// to 0, they will only look at you when spoken to. - /// - public float lookAtRadius; - - /// - /// If this dialogue is meant for a character, this is the relative path from the planet to that character's - /// CharacterAnimController, TravelerController, TravelerEyeController (eye of the universe), FacePlayerWhenTalking, or SolanumAnimController. - /// - /// If none of those components are present it will add a FacePlayerWhenTalking component. - /// - public string pathToAnimController; - - /// - /// Radius of the spherical collision volume where you get the "talk to" prompt when looking at. If you use a - /// remoteTrigger, you can set this to 0 to make the dialogue only trigger remotely. - /// - public float radius = 1f; - - /// - /// Distance from radius the prompt appears - /// - [DefaultValue(2f)] public float range = 2f; - - /// - /// Allows you to trigger dialogue from a distance when you walk into an area. - /// - public RemoteTriggerInfo remoteTrigger; - - [Obsolete("remoteTriggerPosition is deprecated. Use remoteTrigger.position instead")] public MVector3 remoteTriggerPosition; - [Obsolete("remoteTriggerRadius is deprecated. Use remoteTrigger.radius instead")] public float remoteTriggerRadius; - [Obsolete("remoteTriggerPrereqCondition is deprecated. Use remoteTrigger.prereqCondition instead")] public string remoteTriggerPrereqCondition; - - /// - /// Relative path to the xml file defining the dialogue. - /// - public string xmlFile; - - /// - /// What type of flashlight toggle to do when dialogue is interacted with - /// - [DefaultValue("none")] public FlashlightToggle flashlightToggle = FlashlightToggle.None; - - [JsonConverter(typeof(StringEnumConverter))] - public enum FlashlightToggle - { - [EnumMember(Value = @"none")] None = -1, - [EnumMember(Value = @"turnOff")] TurnOff = 0, - [EnumMember(Value = @"turnOffThenOn")] TurnOffThenOn = 1, - } - - [JsonObject] - public class RemoteTriggerInfo : GeneralPointPropInfo - { - /// - /// The radius of the remote trigger volume. - /// - public float radius; - /// - /// This condition must be met for the remote trigger volume to trigger. - /// - public string prereqCondition; - } - } -} diff --git a/NewHorizons/External/Props/EntryLocationInfo.cs b/NewHorizons/External/Props/EntryLocationInfo.cs deleted file mode 100644 index f0791b74f..000000000 --- a/NewHorizons/External/Props/EntryLocationInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class EntryLocationInfo : GeneralPointPropInfo - { - /// - /// Whether this location is cloaked - /// - public bool cloaked; - - /// - /// ID of the entry this location relates to - /// - public string id; - } -} diff --git a/NewHorizons/External/Props/GeneralPointPropInfo.cs b/NewHorizons/External/Props/GeneralPointPropInfo.cs deleted file mode 100644 index ddb428e29..000000000 --- a/NewHorizons/External/Props/GeneralPointPropInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using NewHorizons.Utility; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public abstract class GeneralPointPropInfo - { - /// - /// Position of the object - /// - public MVector3 position; - - /// - /// 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; - } -} diff --git a/NewHorizons/External/Props/GeneralPropInfo.cs b/NewHorizons/External/Props/GeneralPropInfo.cs deleted file mode 100644 index 7f3397117..000000000 --- a/NewHorizons/External/Props/GeneralPropInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using NewHorizons.Utility; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public abstract class GeneralPropInfo : GeneralPointPropInfo - { - /// - /// Rotation of the object - /// - public MVector3 rotation; - } -} diff --git a/NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs b/NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs deleted file mode 100644 index bd4356112..000000000 --- a/NewHorizons/External/Props/GeneralSolarSystemPropInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo - { - /// - /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. - /// - public string parentBody; - } -} diff --git a/NewHorizons/External/Props/GeyserInfo.cs b/NewHorizons/External/Props/GeyserInfo.cs deleted file mode 100644 index eb64d207b..000000000 --- a/NewHorizons/External/Props/GeyserInfo.cs +++ /dev/null @@ -1,46 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class GeyserInfo : GeneralPointPropInfo - { - /// - /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. - /// - [DefaultValue(-97.5f)] public float offset = -97.5f; - - /// - /// Force of the geyser on objects - /// - [DefaultValue(55f)] public float force = 55f; - - /// - /// Time in seconds eruptions last for - /// - [DefaultValue(10f)] public float activeDuration = 10f; - - /// - /// Time in seconds between eruptions - /// - [DefaultValue(19f)] public float inactiveDuration = 19f; - - /// - /// Color of the geyser. Alpha sets the particle density. - /// - public MColor tint; - - /// - /// Disable the individual particle systems of the geyser - /// - public bool disableBubbles, disableShaft, disableSpout; - - /// - /// Loudness of the geyser - /// - [DefaultValue(0.7f)] public float volume = 0.7f; - } -} diff --git a/NewHorizons/External/Props/NomaiTextArcInfo.cs b/NewHorizons/External/Props/NomaiTextArcInfo.cs deleted file mode 100644 index b11a38df2..000000000 --- a/NewHorizons/External/Props/NomaiTextArcInfo.cs +++ /dev/null @@ -1,54 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class NomaiTextArcInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextArcType - { - [EnumMember(Value = @"adult")] Adult = 0, - - [EnumMember(Value = @"child")] Child = 1, - - [EnumMember(Value = @"stranger")] Stranger = 2 - } - - /// - /// Whether to skip modifying this spiral's placement, and instead keep the automatically determined placement. - /// - public bool keepAutoPlacement; - - /// - /// Whether to flip the spiral from left-curling to right-curling or vice versa. - /// - public bool mirror; - - /// - /// The local position of this object on the wall. - /// - public MVector2 position; - - /// - /// The type of text to display. - /// - [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; - - /// - /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. - /// - [DefaultValue(-1)] public int variation = -1; - - /// - /// The z euler angle for this arc. - /// - [Range(0f, 360f)] public float zRotation; - } -} diff --git a/NewHorizons/External/Props/NomaiTextInfo.cs b/NewHorizons/External/Props/NomaiTextInfo.cs deleted file mode 100644 index 9819edb35..000000000 --- a/NewHorizons/External/Props/NomaiTextInfo.cs +++ /dev/null @@ -1,81 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class NomaiTextInfo : GeneralPointPropInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextType - { - [EnumMember(Value = @"wall")] Wall = 0, - - [EnumMember(Value = @"scroll")] Scroll = 1, - - [EnumMember(Value = @"computer")] Computer = 2, - - [EnumMember(Value = @"cairn")] Cairn = 3, - - [EnumMember(Value = @"recorder")] Recorder = 4, - - [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, - - [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, - - [EnumMember(Value = @"trailmarker")] Trailmarker = 7, - - [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextLocation - { - [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, - - [EnumMember(Value = @"a")] A = 1, - - [EnumMember(Value = @"b")] B = 2 - } - - /// - /// Additional information about each arc in the text - /// - public NomaiTextArcInfo[] arcInfo; - - /// - /// The normal vector for this object. Used for writing on walls and positioning computers. - /// - public MVector3 normal; - - /// - /// The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient - /// themselves to the surface of the planet automatically. - /// - public MVector3 rotation; - - /// - /// The random seed used to pick what the text arcs will look like. - /// - public int seed; // For randomizing arcs - - /// - /// The type of object this is. - /// - [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; - - /// - /// The location of this object. - /// - [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; - - /// - /// The relative path to the xml file for this object. - /// - public string xmlFile; - } -} diff --git a/NewHorizons/External/Props/ProjectionInfo.cs b/NewHorizons/External/Props/ProjectionInfo.cs deleted file mode 100644 index c05950eb3..000000000 --- a/NewHorizons/External/Props/ProjectionInfo.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.ComponentModel; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class ProjectionInfo : GeneralPropInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum SlideShowType - { - [EnumMember(Value = @"slideReel")] SlideReel = 0, - - [EnumMember(Value = @"autoProjector")] AutoProjector = 1, - - [EnumMember(Value = @"visionTorchTarget")] VisionTorchTarget = 2, - - [EnumMember(Value = @"standingVisionTorch")] StandingVisionTorch = 3, - - } - - /// - /// The ship log facts revealed after finishing this slide reel. - /// - public string[] reveals; - - /// - /// The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows). - /// You should probably include facts from `reveals` here. - /// If you only specify a rumor fact, then it would only play in its ship log entry if this has revealed only - /// rumor facts because an entry with revealed explore facts doesn't display rumor facts. - /// - public string[] playWithShipLogFacts; - - /// - /// The list of slides for this object. - /// - public SlideInfo[] slides; - - /// - /// The type of object this is. - /// - [DefaultValue("slideReel")] public SlideShowType type = SlideShowType.SlideReel; - } -} diff --git a/NewHorizons/External/Props/QuantumGroupInfo.cs b/NewHorizons/External/Props/QuantumGroupInfo.cs deleted file mode 100644 index 21e40449c..000000000 --- a/NewHorizons/External/Props/QuantumGroupInfo.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.ComponentModel; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class QuantumGroupInfo - { - /// - /// What type of group this is: does it define a list of states a single quantum object could take or a list of sockets one or more quantum objects could share? - /// - public QuantumGroupType type; - - /// - /// A unique string used by props (that are marked as quantum) use to refer back to this group - /// - public string id; - - /// - /// Only required if type is `sockets`. This lists all the possible locations for any props assigned to this group. - /// - public QuantumSocketInfo[] sockets; - - /// - /// Optional. Only used if type is `states`. If this is true, then the first prop made part of this group will be used to construct a visibility box for an empty game object, which will be considered one of the states. - /// - public bool hasEmptyState; - - /// - /// Optional. Only used if type is `states`. If this is true, then the states will be presented in order, rather than in a random order - /// - public bool sequential; - - /// - /// Optional. Only used if type is `states` and `sequential` is true. If this is false, then after the last state has appeared, the object will no longer change state - /// - [DefaultValue(true)] public bool loop = true; - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum QuantumGroupType - { - [EnumMember(Value = @"sockets")] Sockets = 0, - - [EnumMember(Value = @"states")] States = 1, - - FailedValidation = 10 - } -} diff --git a/NewHorizons/External/Props/QuantumSocketInfo.cs b/NewHorizons/External/Props/QuantumSocketInfo.cs deleted file mode 100644 index 39e2431a1..000000000 --- a/NewHorizons/External/Props/QuantumSocketInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class QuantumSocketInfo : GeneralPropInfo - { - /// - /// The probability any props that are part of this group will occupy this socket - /// - [DefaultValue(1f)] public float probability = 1f; - } -} diff --git a/NewHorizons/External/Props/RaftInfo.cs b/NewHorizons/External/Props/RaftInfo.cs deleted file mode 100644 index 811de16f7..000000000 --- a/NewHorizons/External/Props/RaftInfo.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class RaftInfo : GeneralPointPropInfo - { - /// - /// Acceleration of the raft. Default acceleration is 5. - /// - [DefaultValue(5f)] public float acceleration = 5f; - } -} diff --git a/NewHorizons/External/Props/RemoteInfo.cs b/NewHorizons/External/Props/RemoteInfo.cs deleted file mode 100644 index 941087b42..000000000 --- a/NewHorizons/External/Props/RemoteInfo.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class RemoteInfo - { - /// - /// The unique remote id - /// - public string id; - - /// - /// Icon that the will show on the stone, pedastal of the whiteboard, and pedastal of the platform. - /// - public string decalPath; - - /// - /// Whiteboard that the stones can put text onto - /// - public WhiteboardInfo whiteboard; - - /// - /// Camera platform that the stones can project to and from - /// - public PlatformInfo platform; - - /// - /// Projection stones - /// - public StoneInfo[] stones; - - [JsonObject] - public class WhiteboardInfo : GeneralPropInfo - { - /// - /// The text for each stone - /// - public SharedNomaiTextInfo[] nomaiText; - - /// - /// Disable the wall, leaving only the pedestal and text. - /// - public bool disableWall; - - [JsonObject] - public class SharedNomaiTextInfo - { - /// - /// The id of the stone this text will appear for - /// - public string id; - - /// - /// Additional information about each arc in the text - /// - public NomaiTextArcInfo[] arcInfo; - - /// - /// The random seed used to pick what the text arcs will look like. - /// - public int seed; // For randomizing arcs - - /// - /// The location of this object. - /// - [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; - - /// - /// The relative path to the xml file for this object. - /// - public string xmlFile; - - /// - /// An optional rename of this object - /// - public string rename; - } - } - - [JsonObject] - public class PlatformInfo : GeneralPropInfo - { - /// - /// A ship log fact to reveal when the platform is connected to. - /// - [DefaultValue("")] public string reveals = ""; - - /// - /// Disable the structure, leaving only the pedestal. - /// - public bool disableStructure; - - /// - /// Disable the pool that rises when you place a stone. - /// - public bool disablePool; - } - - [JsonObject] - public class StoneInfo : GeneralPropInfo - { - - } - } -} diff --git a/NewHorizons/External/Props/ScatterInfo.cs b/NewHorizons/External/Props/ScatterInfo.cs deleted file mode 100644 index 5e48db01c..000000000 --- a/NewHorizons/External/Props/ScatterInfo.cs +++ /dev/null @@ -1,71 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class ScatterInfo - { - /// - /// Relative filepath to an asset-bundle - /// - public string assetBundle; - - /// - /// Number of props to scatter - /// - public int count; - - /// - /// Offset this prop once it is placed - /// - public MVector3 offset; - - /// - /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle - /// - public string path; - - /// - /// Rotate this prop once it is placed - /// - public MVector3 rotation; - - /// - /// Scale this prop once it is placed - /// - [DefaultValue(1f)] public float scale = 1f; - - /// - /// Scale each axis of the prop. Overrides `scale`. - /// - public MVector3 stretch; - - /// - /// The number used as entropy for scattering the props - /// - public int seed; - - /// - /// The lowest height that these object will be placed at (only relevant if there's a heightmap) - /// - public float? minHeight; - - /// - /// The highest height that these objects will be placed at (only relevant if there's a heightmap) - /// - public float? maxHeight; - - /// - /// Should we try to prevent overlap between the scattered details? True by default. If it's affecting load times turn it off. - /// - [DefaultValue(true)] public bool preventOverlap = true; - - /// - /// Should this detail stay loaded even if you're outside the sector (good for very large props) - /// - public bool keepLoaded; - } -} diff --git a/NewHorizons/External/Props/SignalInfo.cs b/NewHorizons/External/Props/SignalInfo.cs deleted file mode 100644 index a9803029b..000000000 --- a/NewHorizons/External/Props/SignalInfo.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NewHorizons.External.Props -{ - - [JsonObject] - public class SignalInfo : GeneralPointPropInfo - { - [Obsolete("audioClip is deprecated, please use audio instead")] - public string audioClip; - - [Obsolete("audioFilePath is deprecated, please use audio instead")] - public string audioFilePath; - - /// - /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. - /// - public string audio; - - /// - /// How close the player must get to the signal to detect it. This is when you get the "Unknown Signal Detected" - /// notification. - /// - [Range(0f, double.MaxValue)] public float detectionRadius; - - /// - /// The frequency ID of the signal. The built-in game values are `Default`, `Traveler`, `Quantum`, `EscapePod`, - /// `Statue`, `WarpCore`, `HideAndSeek`, and `Radio`. You can also put a custom value. - /// - public string frequency; - - /// - /// How close the player must get to the signal to identify it. This is when you learn its name. - /// - [DefaultValue(10f)] - [Range(0f, double.MaxValue)] - public float identificationRadius = 10f; - - /// - /// Only set to `true` if you are putting this signal inside a cloaking field. - /// - public bool insideCloak; - - /// - /// The unique ID of the signal. - /// - public string name; - - /// - /// `false` if the player can hear the signal without equipping the signal-scope. - /// - [DefaultValue(true)] public bool onlyAudibleToScope = true; - - /// - /// A ship log fact to reveal when the signal is identified. - /// - [DefaultValue("")] public string reveals = ""; - - /// - /// Radius of the sphere giving off the signal. - /// - [DefaultValue(1f)] public float sourceRadius = 1f; - } -} diff --git a/NewHorizons/External/Props/SlideInfo.cs b/NewHorizons/External/Props/SlideInfo.cs deleted file mode 100644 index 10c6fceb0..000000000 --- a/NewHorizons/External/Props/SlideInfo.cs +++ /dev/null @@ -1,85 +0,0 @@ -using NewHorizons.Utility; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class SlideInfo - { - /// - /// Ambient light colour when viewing this slide. - /// - public MColor ambientLightColor; - - - // SlideAmbientLightModule - - /// - /// Ambient light intensity when viewing this slide. - /// - public float ambientLightIntensity; - - /// - /// Ambient light range when viewing this slide. - /// - public float ambientLightRange; - - // SlideBackdropAudioModule - - /// - /// The name of the AudioClip that will continuously play while watching these slides - /// - public string backdropAudio; - - /// - /// The time to fade into the backdrop audio - /// - public float backdropFadeTime; - - // SlideBeatAudioModule - - /// - /// The name of the AudioClip for a one-shot sound when opening the slide. - /// - public string beatAudio; - - /// - /// The time delay until the one-shot audio - /// - public float beatDelay; - - - // SlideBlackFrameModule - - /// - /// Before viewing this slide, there will be a black frame for this many seconds. - /// - public float blackFrameDuration; - - /// - /// The path to the image file for this slide. - /// - public string imagePath; - - - // SlidePlayTimeModule - - /// - /// Play-time duration for auto-projector slides. - /// - public float playTimeDuration; - - - // SlideShipLogEntryModule - - /// - /// Ship log fact revealed when viewing this slide - /// - public string reveal; - - /// - /// Spotlight intensity modifier when viewing this slide. - /// - public float spotIntensityMod; - } -} diff --git a/NewHorizons/External/Props/TornadoInfo.cs b/NewHorizons/External/Props/TornadoInfo.cs deleted file mode 100644 index dbf8affa7..000000000 --- a/NewHorizons/External/Props/TornadoInfo.cs +++ /dev/null @@ -1,73 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System; -using NewHorizons.External.Modules; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class TornadoInfo : GeneralPointPropInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum TornadoType - { - [EnumMember(Value = @"upwards")] Upwards = 0, - - [EnumMember(Value = @"downwards")] Downwards = 1, - - [EnumMember(Value = @"hurricane")] Hurricane = 2 - } - - [Obsolete("Downwards is deprecated. Use Type instead.")] public bool downwards; - - /// - /// Alternative to setting the position. Will choose a random place at this elevation. - /// - public float elevation; - - /// - /// The height of this tornado. - /// - [DefaultValue(30f)] public float height = 30f; - - /// - /// The colour of the tornado. - /// - public MColor tint; - - /// - /// What type of cyclone should this be? Upwards and downwards are both tornados and will push in that direction. - /// - [DefaultValue("upwards")] public TornadoType type = TornadoType.Upwards; - - /// - /// Angular distance from the starting position that it will wander, in terms of the angle around the x-axis. - /// - [DefaultValue(45f)] public float wanderDegreesX = 45f; - - /// - /// Angular distance from the starting position that it will wander, in terms of the angle around the z-axis. - /// - [DefaultValue(45f)] public float wanderDegreesZ = 45f; - - /// - /// The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around - /// 0.1. - /// - public float wanderRate; - - /// - /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. - /// - public float audioDistance; - - /// - /// Fluid type for sounds/effects when colliding with this tornado. - /// - [DefaultValue("cloud")] public FluidType fluidType = FluidType.Cloud; - } -} diff --git a/NewHorizons/External/Props/VolcanoInfo.cs b/NewHorizons/External/Props/VolcanoInfo.cs deleted file mode 100644 index 9c891aa6c..000000000 --- a/NewHorizons/External/Props/VolcanoInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ - -using NewHorizons.Utility; -using System.ComponentModel; -using Newtonsoft.Json; - -namespace NewHorizons.External.Props -{ - [JsonObject] - public class VolcanoInfo : GeneralPointPropInfo - { - /// - /// The colour of the meteor's lava. - /// - public MColor lavaTint; - - /// - /// Maximum time between meteor launches. - /// - [DefaultValue(20f)] - public float maxInterval = 20f; - - /// - /// Maximum random speed at which meteors are launched. - /// - [DefaultValue(150f)] - public float maxLaunchSpeed = 150f; - - /// - /// Minimum time between meteor launches. - /// - [DefaultValue(5f)] - public float minInterval = 5f; - - /// - /// Minimum random speed at which meteors are launched. - /// - [DefaultValue(50f)] - public float minLaunchSpeed = 50f; - - /// - /// Scale of the meteors. - /// - public float scale = 1; - - /// - /// The colour of the meteor's stone. - /// - public MColor stoneTint; - } -} diff --git a/NewHorizons/External/Volumes/AudioVolumeInfo.cs b/NewHorizons/External/Volumes/AudioVolumeInfo.cs deleted file mode 100644 index e5a90b882..000000000 --- a/NewHorizons/External/Volumes/AudioVolumeInfo.cs +++ /dev/null @@ -1,88 +0,0 @@ -using NewHorizons.External.Modules; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class AudioVolumeInfo : PriorityVolumeInfo - { - /// - /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. - /// - public string audio; - - [DefaultValue("random")] public ClipSelectionType clipSelection = ClipSelectionType.RANDOM; - - /// - /// The audio track of this audio volume - /// - [DefaultValue("environment")] public AudioMixerTrackName track = AudioMixerTrackName.Environment; - - /// - /// Whether to loop this audio while in this audio volume or just play it once - /// - [DefaultValue(true)] public bool loop = true; - - /// - /// The loudness of the audio - /// - [Range(0f, 1f)] - [DefaultValue(1f)] - public float volume = 1f; - - /// - /// How long it will take to fade this sound in and out when entering/exiting this volume. - /// - [DefaultValue(2f)] - public float fadeSeconds = 2f; - - /// - /// Play the sound instantly without any fading. - /// - public bool noFadeFromBeginning; - - /// - /// Randomize what time the audio starts at. - /// - public bool randomizePlayhead; - - /// - /// Pause the music when exiting the volume. - /// - public bool pauseOnFadeOut; - - - [JsonConverter(typeof(StringEnumConverter))] - public enum ClipSelectionType - { - [EnumMember(Value = @"random")] RANDOM, - [EnumMember(Value = @"sequential")] SEQUENTIAL, - [EnumMember(Value = @"manual")] MANUAL - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum AudioMixerTrackName - { - [EnumMember(Value = @"undefined")] Undefined = 0, - [EnumMember(Value = @"menu")] Menu = 1, - [EnumMember(Value = @"music")] Music = 2, - [EnumMember(Value = @"environment")] Environment = 4, - [EnumMember(Value = @"environmentUnfiltered")] Environment_Unfiltered = 5, - [EnumMember(Value = @"endTimesSfx")] EndTimes_SFX = 8, - [EnumMember(Value = @"signal")] Signal = 16, - [EnumMember(Value = @"death")] Death = 32, - [EnumMember(Value = @"player")] Player = 64, - [EnumMember(Value = @"playerExternal")] Player_External = 65, - [EnumMember(Value = @"ship")] Ship = 128, - [EnumMember(Value = @"map")] Map = 256, - [EnumMember(Value = @"endTimesMusic")] EndTimes_Music = 512, - [EnumMember(Value = @"muffleWhileRafting")] MuffleWhileRafting = 1024, - [EnumMember(Value = @"muffleIndoors")] MuffleIndoors = 2048, - [EnumMember(Value = @"slideReelMusic")] SlideReelMusic = 4096, - } - } -} diff --git a/NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs b/NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs deleted file mode 100644 index a68405400..000000000 --- a/NewHorizons/External/Volumes/ChangeStarSystemVolumeInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class ChangeStarSystemVolumeInfo : VolumeInfo - { - /// - /// The star system that entering this volume will send you to. - /// - [DefaultValue("SolarSystem")] - public string targetStarSystem; - } -} - diff --git a/NewHorizons/External/Volumes/DestructionVolumeInfo.cs b/NewHorizons/External/Volumes/DestructionVolumeInfo.cs deleted file mode 100644 index 27359f0ff..000000000 --- a/NewHorizons/External/Volumes/DestructionVolumeInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class DestructionVolumeInfo : VanishVolumeInfo - { - /// - /// The type of death the player will have if they enter this volume. - /// - [DefaultValue("default")] public DeathType deathType = DeathType.Default; - - [JsonConverter(typeof(StringEnumConverter))] - public enum DeathType - { - [EnumMember(Value = @"default")] Default, - [EnumMember(Value = @"impact")] Impact, - [EnumMember(Value = @"asphyxiation")] Asphyxiation, - [EnumMember(Value = @"energy")] Energy, - [EnumMember(Value = @"supernova")] Supernova, - [EnumMember(Value = @"digestion")] Digestion, - [EnumMember(Value = @"bigBang")] BigBang, - [EnumMember(Value = @"crushed")] Crushed, - [EnumMember(Value = @"meditation")] Meditation, - [EnumMember(Value = @"timeLoop")] TimeLoop, - [EnumMember(Value = @"lava")] Lava, - [EnumMember(Value = @"blackHole")] BlackHole, - [EnumMember(Value = @"dream")] Dream, - [EnumMember(Value = @"dreamExplosion")] DreamExplosion, - [EnumMember(Value = @"crushedByElevator")] CrushedByElevator - } - } -} - diff --git a/NewHorizons/External/Volumes/FluidVolumeInfo.cs b/NewHorizons/External/Volumes/FluidVolumeInfo.cs deleted file mode 100644 index fe9315419..000000000 --- a/NewHorizons/External/Volumes/FluidVolumeInfo.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class FluidVolumeInfo : PriorityVolumeInfo - { - /// - /// Density of the fluid. The higher the density, the harder it is to go through this fluid. - /// - [DefaultValue(1.2f)] public float density = 1.2f; - - /// - /// The type of fluid for this volume. - /// - public FluidType type; - - /// - /// Should the player and rafts align to this fluid. - /// - [DefaultValue(true)] public bool alignmentFluid = true; - - /// - /// Should the ship align to the fluid by rolling. - /// - public bool allowShipAutoroll; - - /// - /// Disable this fluid volume immediately? - /// - public bool disableOnStart; - - [JsonConverter(typeof(StringEnumConverter))] - public enum FluidType - { - [EnumMember(Value = @"none")] NONE = 0, - [EnumMember(Value = @"air")] AIR, - [EnumMember(Value = @"water")] WATER, - [EnumMember(Value = @"cloud")] CLOUD, - [EnumMember(Value = @"sand")] SAND, - [EnumMember(Value = @"plasma")] PLASMA, - [EnumMember(Value = @"fog")] FOG - } - } -} - diff --git a/NewHorizons/External/Volumes/HazardVolumeInfo.cs b/NewHorizons/External/Volumes/HazardVolumeInfo.cs deleted file mode 100644 index 8d81a50a7..000000000 --- a/NewHorizons/External/Volumes/HazardVolumeInfo.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class HazardVolumeInfo : VolumeInfo - { - /// - /// The type of hazard for this volume. - /// - [DefaultValue("general")] public HazardType type = HazardType.GENERAL; - - /// - /// The amount of damage you will take per second while inside this volume. - /// - [DefaultValue(10f)] public float damagePerSecond = 10f; - - /// - /// The type of damage you will take when you first touch this volume. - /// - [DefaultValue("impact")] public InstantDamageType firstContactDamageType = InstantDamageType.Impact; - - /// - /// The amount of damage you will take when you first touch this volume. - /// - public float firstContactDamage; - - [JsonConverter(typeof(StringEnumConverter))] - public enum HazardType - { - [EnumMember(Value = @"none")] NONE = 0, - [EnumMember(Value = @"general")] GENERAL = 1, - [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2, - [EnumMember(Value = @"heat")] HEAT = 4, - [EnumMember(Value = @"fire")] FIRE = 8, - [EnumMember(Value = @"sandfall")] SANDFALL = 16, - [EnumMember(Value = @"electricity")] ELECTRICITY = 32, - [EnumMember(Value = @"rapids")] RAPIDS = 64, - [EnumMember(Value = @"riverHeat")] RIVERHEAT = 128, - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum InstantDamageType - { - [EnumMember(Value = @"impact")] Impact, - [EnumMember(Value = @"puncture")] Puncture, - [EnumMember(Value = @"electrical")] Electrical - } - } -} - diff --git a/NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs b/NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs deleted file mode 100644 index b69c9f2dd..000000000 --- a/NewHorizons/External/Volumes/LoadCreditsVolumeInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class LoadCreditsVolumeInfo : VolumeInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum CreditsType - { - [EnumMember(Value = @"fast")] Fast = 0, - - [EnumMember(Value = @"final")] Final = 1, - - [EnumMember(Value = @"kazoo")] Kazoo = 2 - } - - [DefaultValue("fast")] - public CreditsType creditsType = CreditsType.Fast; - } -} - diff --git a/NewHorizons/External/Volumes/NotificationVolumeInfo.cs b/NewHorizons/External/Volumes/NotificationVolumeInfo.cs deleted file mode 100644 index ac6439b7b..000000000 --- a/NewHorizons/External/Volumes/NotificationVolumeInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class NotificationVolumeInfo : VolumeInfo - { - /// - /// What the notification will show for. - /// - [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; - - /// - /// The notification that will play when you enter this volume. - /// - public NotificationInfo entryNotification; - - /// - /// The notification that will play when you exit this volume. - /// - public NotificationInfo exitNotification; - - - [JsonObject] - public class NotificationInfo - { - /// - /// The message that will be displayed. - /// - public string displayMessage; - - /// - /// The duration this notification will be displayed. - /// - [DefaultValue(5f)] public float duration = 5f; - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum NotificationTarget - { - [EnumMember(Value = @"all")] All = 0, - [EnumMember(Value = @"ship")] Ship = 1, - [EnumMember(Value = @"player")] Player = 2, - } - } -} - diff --git a/NewHorizons/External/Volumes/OxygenVolumeInfo.cs b/NewHorizons/External/Volumes/OxygenVolumeInfo.cs deleted file mode 100644 index abb087825..000000000 --- a/NewHorizons/External/Volumes/OxygenVolumeInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class OxygenVolumeInfo : VolumeInfo - { - /// - /// Does this volume contain trees? This will change the notification from "Oxygen tank refilled" to "Trees detected, oxygen tank refilled". - /// - public bool treeVolume; - - /// - /// Whether to play the oxygen tank refill sound or just fill quietly. - /// - [DefaultValue(true)] public bool playRefillAudio = true; - } -} - diff --git a/NewHorizons/External/Volumes/PriorityVolumeInfo.cs b/NewHorizons/External/Volumes/PriorityVolumeInfo.cs deleted file mode 100644 index b514e8173..000000000 --- a/NewHorizons/External/Volumes/PriorityVolumeInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class PriorityVolumeInfo : VolumeInfo - { - /// - /// The layer of this volume. - /// - [DefaultValue(0)] - public int layer = 0; - - /// - /// The priority for this volume's effects to be applied. - /// Ex, a player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity. - /// - [DefaultValue(1)] - public int priority = 1; - } -} - diff --git a/NewHorizons/External/Volumes/RevealVolumeInfo.cs b/NewHorizons/External/Volumes/RevealVolumeInfo.cs deleted file mode 100644 index f74be55ff..000000000 --- a/NewHorizons/External/Volumes/RevealVolumeInfo.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.ComponentModel; -using System.Runtime.Serialization; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class RevealVolumeInfo : VolumeInfo - { - [JsonConverter(typeof(StringEnumConverter))] - public enum RevealVolumeType - { - [EnumMember(Value = @"enter")] Enter = 0, - - [EnumMember(Value = @"observe")] Observe = 1, - - [EnumMember(Value = @"snapshot")] Snapshot = 2 - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum EnterType - { - [EnumMember(Value = @"both")] Both = 0, - - [EnumMember(Value = @"player")] Player = 1, - - [EnumMember(Value = @"probe")] Probe = 2 - } - - /// - /// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only) - /// - [DefaultValue(180f)] - public float maxAngle = 180f; // Observe Only - - /// - /// The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only) - /// - [DefaultValue(-1f)] - public float maxDistance = -1f; // Snapshot & Observe Only - - /// - /// What needs to be done to the volume to unlock the facts - /// - [DefaultValue("enter")] public RevealVolumeType revealOn = RevealVolumeType.Enter; - - /// - /// What can enter the volume to unlock the facts (`enter` only) - /// - [DefaultValue("both")] public EnterType revealFor = EnterType.Both; - - /// - /// A list of facts to reveal - /// - public string[] reveals; - - /// - /// An achievement to unlock. Optional. - /// - public string achievementID; - } -} - diff --git a/NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs b/NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs deleted file mode 100644 index 3e6416374..000000000 --- a/NewHorizons/External/Volumes/SpeedTrapVolumeInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class SpeedTrapVolumeInfo : VolumeInfo - { - /// - /// The speed the volume will slow you down to when you enter it. - /// - [DefaultValue(10f)] - public float speedLimit = 10f; - - /// - /// How fast it will slow down the player to the speed limit. - /// - [DefaultValue(3f)] - public float acceleration = 3f; - } -} - diff --git a/NewHorizons/External/Volumes/VanishVolumeInfo.cs b/NewHorizons/External/Volumes/VanishVolumeInfo.cs deleted file mode 100644 index 6b592ce83..000000000 --- a/NewHorizons/External/Volumes/VanishVolumeInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Volumes -{ - [JsonObject] - public class VanishVolumeInfo : VolumeInfo - { - /// - /// Whether the bodies will shrink when they enter this volume or just disappear instantly. - /// - [DefaultValue(true)] public bool shrinkBodies = true; - - /// - /// Whether this volume only affects the player and ship. - /// - public bool onlyAffectsPlayerAndShip; - } -} - diff --git a/NewHorizons/External/Volumes/VolumeInfo.cs b/NewHorizons/External/Volumes/VolumeInfo.cs deleted file mode 100644 index 645bf267c..000000000 --- a/NewHorizons/External/Volumes/VolumeInfo.cs +++ /dev/null @@ -1,121 +0,0 @@ -using NewHorizons.External.Props; -using Newtonsoft.Json; -using System.ComponentModel; - -namespace NewHorizons.External.Volumes -{ - /*[JsonObject] - public class VolumesModule - { - /// - /// Add audio volumes to this planet. - /// - public AudioVolumeInfo[] audioVolumes; - - /// - /// Add destruction volumes to this planet. - /// - public DestructionVolumeInfo[] destructionVolumes; - - /// - /// Add fluid volumes to this planet. - /// - public FluidVolumeInfo[] fluidVolumes; - - /// - /// Add hazard volumes to this planet. - /// - public HazardVolumeInfo[] hazardVolumes; - - /// - /// Add interference volumes to this planet. - /// - public VolumeInfo[] interferenceVolumes; - - /// - /// Add insulating volumes to this planet. These will stop electricty hazard volumes from affecting you (just like the jellyfish). - /// - public VolumeInfo[] insulatingVolumes; - - /// - /// Add light source volumes to this planet. These will activate rafts and other light detectors. - /// - public VolumeInfo[] lightSourceVolumes; - - /// - /// Add map restriction volumes to this planet. - /// - public VolumeInfo[] mapRestrictionVolumes; - - /// - /// Add notification volumes to this planet. - /// - public NotificationVolumeInfo[] notificationVolumes; - - /// - /// Add oxygen volumes to this planet. - /// - public OxygenVolumeInfo[] oxygenVolumes; - - /// - /// Add probe-specific volumes to this planet. - /// - public ProbeModule probe; - - /// - /// Add reference frame blocker volumes to this planet. These will stop the player from seeing/targeting any reference frames. - /// - public VolumeInfo[] referenceFrameBlockerVolumes; - - /// - /// Add triggers that reveal parts of the ship log on this planet. - /// - public RevealVolumeInfo[] revealVolumes; - - /// - /// Add reverb volumes to this planet. Great for echoes in caves. - /// - public VolumeInfo[] reverbVolumes; - - /// - /// Add ruleset volumes to this planet. - /// - public RulesetModule rulesets; - - /// - /// Add speed trap volumes to this planet. Slows down the player when they enter this volume. - /// - public SpeedTrapVolumeInfo[] speedTrapVolumes; - - /// - /// Add visor effect volumes to this planet. - /// - public VisorEffectModule visorEffects; - - /// - /// Add zero-gravity volumes to this planet. - /// Good for surrounding planets which are using a static position to stop the player being pulled away. - /// - public PriorityVolumeInfo[] zeroGravityVolumes; - - /// - /// Entering this volume will load a new solar system. - /// - public ChangeStarSystemVolumeInfo[] solarSystemVolume; - - /// - /// Enter this volume to be sent to the end credits scene - /// - public LoadCreditsVolumeInfo[] creditsVolume;*/ - - [JsonObject] - public class VolumeInfo : GeneralPointPropInfo - { - /// - /// The radius of this volume. - /// - [DefaultValue(1f)] - public float radius = 1f; - } -} - diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index b276bf68e..ce358343a 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -12,7 +12,6 @@ using UnityEngine; using UnityEngine.Events; using Logger = NewHorizons.Utility.Logger; -using NewHorizons.External.Props; namespace NewHorizons { @@ -159,7 +158,7 @@ public object QuerySystem(Type outType, string jsonPath) float scale, bool alignWithNormal) { var prefab = SearchUtilities.Find(propToCopyPath); - var detailInfo = new DetailInfo() { + var detailInfo = new PropModule.DetailInfo() { position = position, rotation = eulerAngles, scale = scale, @@ -172,7 +171,7 @@ public object QuerySystem(Type outType, string jsonPath) float sourceRadius = 1f, float detectionRadius = 20f, float identificationRadius = 10f, bool insideCloak = false, bool onlyAudibleToScope = true, string reveals = "") { - var info = new SignalInfo() + var info = new SignalModule.SignalInfo() { audio = audio, detectionRadius = detectionRadius, @@ -193,7 +192,7 @@ public object QuerySystem(Type outType, string jsonPath) float range = 1f, string blockAfterPersistentCondition = null, float lookAtRadius = 1f, string pathToAnimController = null, float remoteTriggerRadius = 0f) { - var info = new DialogueInfo() + var info = new PropModule.DialogueInfo() { blockAfterPersistentCondition = blockAfterPersistentCondition, lookAtRadius = lookAtRadius, @@ -202,7 +201,7 @@ public object QuerySystem(Type outType, string jsonPath) radius = radius, range = range, xmlFile = xmlFile, - remoteTrigger = new DialogueInfo.RemoteTriggerInfo() + remoteTrigger = new PropModule.DialogueInfo.RemoteTriggerInfo() { position = null, radius = remoteTriggerRadius, diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index affb71d79..04554fd14 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -1,7 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Configs; using NewHorizons.External.Modules; -using NewHorizons.External.Props; using NewHorizons.Handlers; using System.Collections.Generic; using System.Linq; @@ -23,7 +22,7 @@ private struct PropPlacementData public AstroObject body; public string system; public GameObject gameObject; - public DetailInfo detailInfo; + public PropModule.DetailInfo detailInfo; } // VASE @@ -150,7 +149,7 @@ public void PlaceObject(DebugRaycastData data) var sector = planetGO.GetComponentInChildren(); var prefab = SearchUtilities.Find(currentObject); - var detailInfo = new DetailInfo() + var detailInfo = new PropModule.DetailInfo() { position = data.pos, rotation = data.rot.eulerAngles, @@ -215,7 +214,7 @@ public void RegisterProp(AstroObject body, GameObject prop) RegisterProp_WithReturn(body, prop); } - private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject prop, string propPath = null, DetailInfo detailInfo = null) + private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject prop, string propPath = null, PropModule.DetailInfo detailInfo = null) { if (Main.Debug) { @@ -227,7 +226,7 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p Logger.LogVerbose($"Adding prop to {Main.Instance.CurrentStarSystem}::{body.name}"); - detailInfo = detailInfo == null ? new DetailInfo() : detailInfo; + detailInfo = detailInfo == null ? new PropModule.DetailInfo() : detailInfo; detailInfo.path = propPath == null ? currentObject : propPath; PropPlacementData data = new PropPlacementData @@ -242,14 +241,14 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p return data; } - public Dictionary GetPropsConfigByBody() + public Dictionary GetPropsConfigByBody() { var groupedProps = props .GroupBy(p => p.system + "." + p.body) .Select(grp => grp.ToList()) .ToList(); - Dictionary propConfigs = new Dictionary(); + Dictionary propConfigs = new Dictionary(); foreach (List bodyProps in groupedProps) { @@ -259,7 +258,7 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p Logger.LogVerbose("getting prop group for body " + body.name); //string bodyName = GetAstroObjectName(bodyProps[0].body); - DetailInfo[] infoArray = new DetailInfo[bodyProps.Count]; + PropModule.DetailInfo[] infoArray = new PropModule.DetailInfo[bodyProps.Count]; propConfigs[body] = infoArray; for (int i = 0; i < bodyProps.Count; i++) From ce848aeff5a36bbe9573c8559fda5b6c5eba0fbb Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 17:38:08 +0000 Subject: [PATCH 032/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 948e932bb..655fa695a 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1065,7 +1065,7 @@ "type": "array", "description": "Add black/white-holes to this planet", "items": { - "$ref": "#/definitions/SingularityInfo" + "$ref": "#/definitions/SingularityModule" } }, "signals": { @@ -1975,7 +1975,7 @@ } } }, - "SingularityInfo": { + "SingularityModule": { "type": "object", "additionalProperties": false, "properties": { From 7ac2bb0b8a66477e8c2264b66016a7f6747182ff Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 12:44:19 -0500 Subject: [PATCH 033/119] Add missing null checks in planet migration --- NewHorizons/External/Configs/PlanetConfig.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 3330a4ada..d7bc96b15 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -468,7 +468,7 @@ public void Migrate() } // Spawn points reorganized to use GenericPropInfo - if (Spawn.playerSpawn == null && Spawn.playerSpawnPoint != null) + if (Spawn != null && Spawn.playerSpawn == null && Spawn.playerSpawnPoint != null) { Spawn.playerSpawn = new SpawnModule.PlayerSpawnPoint() { @@ -477,7 +477,7 @@ public void Migrate() startWithSuit = Spawn.startWithSuit, }; } - if (Spawn.shipSpawn == null && Spawn.shipSpawnPoint != null) + if (Spawn != null && Spawn.shipSpawn == null && Spawn.shipSpawnPoint != null) { Spawn.shipSpawn = new SpawnModule.ShipSpawnPoint() { @@ -487,7 +487,7 @@ public void Migrate() } // Remote dialogue trigger reorganized to use GenericPropInfo - if (Props.dialogue != null) + if (Props != null && Props.dialogue != null) { foreach (var dialogue in Props.dialogue) { From 8f1954b40a50f6d6968645141ffd863b4872157e Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 13:49:50 -0400 Subject: [PATCH 034/119] #536 Check if physics object should be suspended on load --- NewHorizons/Components/AddPhysics.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Components/AddPhysics.cs b/NewHorizons/Components/AddPhysics.cs index 14785f9f9..976f6a287 100644 --- a/NewHorizons/Components/AddPhysics.cs +++ b/NewHorizons/Components/AddPhysics.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using UnityEngine; namespace NewHorizons.Components; @@ -66,6 +66,10 @@ private IEnumerator Start() owRigidbody.SetMass(Mass); owRigidbody.SetVelocity(parentBody.GetPointVelocity(transform.position)); + // #536 - Physics objects in bramble dimensions not disabled on load + // Should have it double check if it is meant to be suspended or not + owRigidbody.OnSectorOccupantsUpdated(); + Destroy(this); } From dbf01e354b2d90244baf79d8c27b09499ea7b556 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 11:17:38 -0700 Subject: [PATCH 035/119] check null sector, update comment --- NewHorizons/Components/AddPhysics.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Components/AddPhysics.cs b/NewHorizons/Components/AddPhysics.cs index 976f6a287..77f092472 100644 --- a/NewHorizons/Components/AddPhysics.cs +++ b/NewHorizons/Components/AddPhysics.cs @@ -67,8 +67,11 @@ private IEnumerator Start() owRigidbody.SetVelocity(parentBody.GetPointVelocity(transform.position)); // #536 - Physics objects in bramble dimensions not disabled on load - // Should have it double check if it is meant to be suspended or not - owRigidbody.OnSectorOccupantsUpdated(); + // sectors wait 3 frames and then call OnSectorOccupantsUpdated + // however we wait .1 real seconds which is longer + // so we have to manually call this + if (owRigidbody._simulateInSector != null) + owRigidbody.OnSectorOccupantsUpdated(); Destroy(this); } From 36a31f3b807f327625687eceebde6a0a44af7f4f Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 11:30:32 -0700 Subject: [PATCH 036/119] get bramble node fix from the other pr --- NewHorizons/Builder/Body/BrambleDimensionBuilder.cs | 8 ++++---- NewHorizons/Components/BrambleSectorController.cs | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 02f32731e..adc3cf0c3 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -245,13 +245,13 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject cloak._sectors = new Sector[] { sector }; cloak.GetComponent().enabled = true; + // Cull stuff + var cullController = go.AddComponent(); + cullController.SetSector(sector); + // Do next update so other nodes can be built first Delay.FireOnNextUpdate(() => { - // Cull stuff - var cullController = go.AddComponent(); - cullController.SetSector(sector); - // Prevent recursion from causing hard crash foreach (var senderWarp in outerFogWarpVolume._senderWarps.ToList()) { diff --git a/NewHorizons/Components/BrambleSectorController.cs b/NewHorizons/Components/BrambleSectorController.cs index 9d0762eb4..99a7d62cf 100644 --- a/NewHorizons/Components/BrambleSectorController.cs +++ b/NewHorizons/Components/BrambleSectorController.cs @@ -77,6 +77,8 @@ private void EnableRenderers() { light.enabled = true; } + + _renderersShown = true; } private void DisableRenderers() @@ -100,6 +102,8 @@ private void DisableRenderers() { light.enabled = false; } + + _renderersShown = false; } } } From e25cf1e00c6a544ac4489aac23036565411ecf09 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 14:51:13 -0400 Subject: [PATCH 037/119] Fixes #514 Setting scale value to 0 should disable it --- NewHorizons/Builder/Body/FunnelBuilder.cs | 2 +- .../{ => SizeControllers}/FunnelController.cs | 13 ++-- .../SingularitySizeController.cs | 66 +++++++++++++++++-- .../SizeControllers/SizeController.cs | 52 ++++++++++++++- 4 files changed, 117 insertions(+), 16 deletions(-) rename NewHorizons/Components/{ => SizeControllers}/FunnelController.cs (71%) diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index aeeea8819..d4c53360e 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -1,10 +1,10 @@ using System.Runtime.Serialization; -using NewHorizons.Components; using NewHorizons.Utility; using UnityEngine; using Logger = NewHorizons.Utility.Logger; using NewHorizons.External.Modules.VariableSize; using NewHorizons.Components.Orbital; +using NewHorizons.Components.SizeControllers; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Components/FunnelController.cs b/NewHorizons/Components/SizeControllers/FunnelController.cs similarity index 71% rename from NewHorizons/Components/FunnelController.cs rename to NewHorizons/Components/SizeControllers/FunnelController.cs index c0d39468f..a4867408e 100644 --- a/NewHorizons/Components/FunnelController.cs +++ b/NewHorizons/Components/SizeControllers/FunnelController.cs @@ -1,18 +1,19 @@ -using UnityEngine; -namespace NewHorizons.Components +using UnityEngine; +namespace NewHorizons.Components.SizeControllers { - public class FunnelController : MonoBehaviour + public class FunnelController : SizeController { - public AnimationCurve scaleCurve; public Transform target; public Transform anchor; - private void Update() + public override void FixedUpdate() { // Temporary solution that i will never get rid of transform.position = anchor.position; - float num = scaleCurve?.Evaluate(TimeLoop.GetMinutesElapsed()) ?? 1f; + UpdateScale(); + + float num = CurrentScale; var dist = (transform.position - target.position).magnitude; transform.localScale = new Vector3(num, num, dist / 500f); diff --git a/NewHorizons/Components/SizeControllers/SingularitySizeController.cs b/NewHorizons/Components/SizeControllers/SingularitySizeController.cs index 4633324ad..52cb7d3e3 100644 --- a/NewHorizons/Components/SizeControllers/SingularitySizeController.cs +++ b/NewHorizons/Components/SizeControllers/SingularitySizeController.cs @@ -1,9 +1,5 @@ using NewHorizons.Builder.Body; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Components.SizeControllers @@ -18,7 +14,7 @@ public class SingularitySizeController : SizeController public WhiteHoleFluidVolume fluidVolume; public WhiteHoleVolume volume; - protected new void FixedUpdate() + public override void FixedUpdate() { base.FixedUpdate(); @@ -56,5 +52,63 @@ protected new void FixedUpdate() volume._radius = CurrentScale * innerScale; } } + + protected override void Vanish() + { + if (audioSource != null) + { + audioSource.gameObject.SetActive(false); + audioSource.Stop(); + } + + if (oneShotAudioSource != null) + { + oneShotAudioSource.gameObject.SetActive(false); + } + + if (sphereCollider != null) + { + sphereCollider.gameObject.SetActive(false); + } + + if (fluidVolume != null) + { + fluidVolume.gameObject.SetActive(false); + } + + if (volume != null) + { + volume.gameObject.SetActive(false); + } + } + + protected override void Appear() + { + if (audioSource != null) + { + audioSource.gameObject.SetActive(true); + Delay.FireOnNextUpdate(audioSource.Play); + } + + if (oneShotAudioSource != null) + { + oneShotAudioSource.gameObject.SetActive(true); + } + + if (sphereCollider != null) + { + sphereCollider.gameObject.SetActive(true); + } + + if (fluidVolume != null) + { + fluidVolume.gameObject.SetActive(true); + } + + if (volume != null) + { + volume.gameObject.SetActive(true); + } + } } } diff --git a/NewHorizons/Components/SizeControllers/SizeController.cs b/NewHorizons/Components/SizeControllers/SizeController.cs index 334f5a84d..7684908bd 100644 --- a/NewHorizons/Components/SizeControllers/SizeController.cs +++ b/NewHorizons/Components/SizeControllers/SizeController.cs @@ -1,25 +1,71 @@ using NewHorizons.Utility; using UnityEngine; + namespace NewHorizons.Components.SizeControllers { public class SizeController : MonoBehaviour { - public AnimationCurve scaleCurve { get; protected set; } + public AnimationCurve scaleCurve; public float CurrentScale { get; protected set; } public float size = 1f; - protected void FixedUpdate() + public void Awake() + { + UpdateScale(); + + if (CurrentScale == 0f) + { + Vanish(); + } + } + + protected void UpdateScale() { if(scaleCurve != null) { + var prevScale = CurrentScale; CurrentScale = scaleCurve.Evaluate(TimeLoop.GetMinutesElapsed()) * size; + + // #514 setting something's scale value to 0 should disable it + if (prevScale != CurrentScale) + { + if (CurrentScale == 0f) + { + Vanish(); + } + else if (prevScale == 0f) + { + Appear(); + } + } } else { CurrentScale = size; } + } + + protected virtual void Vanish() + { + foreach (var child in gameObject.GetAllChildren()) + { + child.SetActive(false); + } + } + + protected virtual void Appear() + { + foreach (var child in gameObject.GetAllChildren()) + { + child.SetActive(true); + } + } + + public virtual void FixedUpdate() + { + UpdateScale(); - base.transform.localScale = Vector3.one * CurrentScale; + transform.localScale = Vector3.one * CurrentScale; } public void SetScaleCurve(TimeValuePair[] curve) From 9080b45c1452c38eacf96694d31e01107e872af0 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 15:00:20 -0400 Subject: [PATCH 038/119] Make sure disabling volume works --- NewHorizons/Components/Volumes/LoadCreditsVolume.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index 119908406..ef2c930e7 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -9,7 +9,7 @@ internal class LoadCreditsVolume : BaseVolume public override void OnTriggerVolumeEntry(GameObject hitObj) { - if (hitObj.CompareTag("PlayerDetector")) + if (hitObj.CompareTag("PlayerDetector") && enabled) { switch(creditsType) { From bd61a87cf62310ee438d86d908f469d7892f1b3d Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 16:04:53 -0400 Subject: [PATCH 039/119] Add game over text and death type to credits volume, but doesnt work --- .../Builder/Volumes/CreditsVolumeBuilder.cs | 3 + .../Components/Volumes/LoadCreditsVolume.cs | 75 +++++++++++++++---- NewHorizons/External/Modules/VolumesModule.cs | 10 +++ 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs index c34745c1b..ef8856e51 100644 --- a/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/CreditsVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; +using OWML.Utils; using UnityEngine; namespace NewHorizons.Builder.Volumes @@ -11,6 +12,8 @@ public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, Volumes var volume = VolumeBuilder.Make(planetGO, sector, info); volume.creditsType = info.creditsType; + volume.gameOverText = info.gameOverText; + volume.deathType = EnumUtils.Parse(info.deathType.ToString(), DeathType.Default); return volume; } diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index ef2c930e7..acd07eebb 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -1,4 +1,6 @@ using NewHorizons.External.Modules; +using NewHorizons.Handlers; +using System.Collections; using UnityEngine; namespace NewHorizons.Components.Volumes @@ -7,29 +9,74 @@ internal class LoadCreditsVolume : BaseVolume { public VolumesModule.LoadCreditsVolumeInfo.CreditsType creditsType = VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast; + public string gameOverText; + public DeathType deathType = DeathType.Default; + + private GameOverController _gameOverController; + private PlayerCameraEffectController _playerCameraEffectController; + + public void Start() + { + _gameOverController = GameObject.FindObjectOfType(); + _playerCameraEffectController = GameObject.FindObjectOfType(); + } + public override void OnTriggerVolumeEntry(GameObject hitObj) { if (hitObj.CompareTag("PlayerDetector") && enabled) { - switch(creditsType) - { - case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: - LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); - break; - case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final: - LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack); - break; - case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo: - TimelineObliterationController.s_hasRealityEnded = true; - LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); - break; - } + StartCoroutine(GameOver()); } } - public override void OnTriggerVolumeExit(GameObject hitObj) + private IEnumerator GameOver() { + OWInput.ChangeInputMode(InputMode.None); + ReticleController.Hide(); + Locator.GetPromptManager().SetPromptsVisible(false); + Locator.GetPauseCommandListener().AddPauseCommandLock(); + + _playerCameraEffectController.OnPlayerDeath(deathType); + + yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength); + + if (!string.IsNullOrEmpty(gameOverText) && _gameOverController != null) + { + _gameOverController._deathText.text = TranslationHandler.GetTranslation(gameOverText, TranslationHandler.TextType.UI); + _gameOverController.SetupGameOverScreen(5f); + + // We set this to true to stop it from loading the credits scene, so we can do it ourselves + _gameOverController._loading = true; + + yield return new WaitUntil(ReadytoLoadCreditsScene); + LoadCreditsScene(); + } + else + { + LoadCreditsScene(); + } + } + + private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete(); + + public override void OnTriggerVolumeExit(GameObject hitObj) { } + + private void LoadCreditsScene() + { + switch (creditsType) + { + case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: + LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); + break; + case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final: + LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack); + break; + case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo: + TimelineObliterationController.s_hasRealityEnded = true; + LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack); + break; + } } } } diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 797428305..76257e486 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -171,6 +171,16 @@ public enum CreditsType [DefaultValue("fast")] public CreditsType creditsType = CreditsType.Fast; + + /// + /// Text displayed in orange on game over. For localization, put translations under UI. + /// + public string gameOverText; + + /// + /// The type of death the player will have if they enter this volume. + /// + [DefaultValue("default")] public DeathType deathType = DeathType.Default; } [JsonObject] From 577472c21bee3a59dd174abe26542405d6502151 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 13:05:39 -0700 Subject: [PATCH 040/119] do another pass on patches --- .../CameraPatches/NomaiRemoteCameraPatches.cs | 6 +- .../Patches/CameraPatches/OWCameraPatches.cs | 2 +- .../CreditsEntryPatches.cs | 8 +-- .../CreditsScenePatches/CreditsPatches.cs | 2 +- .../AlignToSurfaceFluidDetectorPatches.cs | 4 +- .../VisionTorchItemPatches.cs | 4 +- .../MapPatches/MapControllerPatches.cs | 2 +- .../Patches/MeteorControllerPatches.cs | 1 + .../PlayerPatches/PlayerDataPatches.cs | 71 ++++++++----------- .../ShipLogPatches/UIStyleManagerPatches.cs | 6 +- .../SignalPatches/AudioSignalPatches.cs | 20 +++--- .../SignalPatches/SignalscopePatches.cs | 3 +- .../ToolPatches/SurveyorProbePatches.cs | 2 +- .../VolumePatches/DestructionVolumePatches.cs | 8 +-- .../VolumePatches/FogWarpVolumePatches.cs | 4 +- .../EyeCoordinatePromptTriggerPatches.cs | 10 +-- .../NomaiCoordinateInterfacePatches.cs | 8 ++- 17 files changed, 76 insertions(+), 85 deletions(-) diff --git a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs index 02e3a8be8..c5c591e25 100644 --- a/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs +++ b/NewHorizons/Patches/CameraPatches/NomaiRemoteCameraPatches.cs @@ -16,9 +16,9 @@ public static void NomaiRemoteCamera_Awake(NomaiRemoteCamera __instance) // These layers were left on because it doesnt come up in base game (Dreamworld is inactive, player is far away) __instance._camera.mainCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("DreamSimulation")); - __instance._camera.mainCamera.cullingMask &= ~(1 < __result) + public static bool PlayerData_GetNewlyRevealedFactIDs_Prefix(ref List __result) { var newHorizonsNewlyRevealedFactIDs = NewHorizonsData.GetNewlyRevealedFactIDs(); if (newHorizonsNewlyRevealedFactIDs != null) @@ -110,35 +106,30 @@ public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List __result __result = PlayerData._currentGameSave.newlyRevealedFactIDs.Concat(newHorizonsNewlyRevealedFactIDs).ToList(); return false; } - else - { - Logger.LogError("Newly Revealed Fact IDs is null!"); - return true; - } + Logger.LogError("Newly Revealed Fact IDs is null!"); + return true; } - [HarmonyPrefix] - [HarmonyPatch(nameof(PlayerData.ClearNewlyRevealedFactIDs))] - public static bool OnPlayerDataClearNewlyRevealedFactIDs() + [HarmonyPostfix] + [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))] + public static void PlayerData_GetNewlyRevealedFactIDs_Postfix(ref List __result) { - PlayerData._currentGameSave.newlyRevealedFactIDs.Clear(); - NewHorizonsData.ClearNewlyRevealedFactIDs(); - return false; + var manager = Locator.GetShipLogManager(); + __result = __result.Where(id => manager.GetFact(id) != null).ToList(); } [HarmonyPostfix] - [HarmonyPatch(nameof(PlayerData.ResetGame))] - public static void OnPlayerDataResetGame() + [HarmonyPatch(nameof(PlayerData.ClearNewlyRevealedFactIDs))] + public static void PlayerData_ClearNewlyRevealedFactIDs() { - NewHorizonsData.Reset(); + NewHorizonsData.ClearNewlyRevealedFactIDs(); } [HarmonyPostfix] - [HarmonyPatch(nameof(PlayerData.GetNewlyRevealedFactIDs))] - public static void PlayerData_GetNewlyRevealedFactIDs(ref List __result) + [HarmonyPatch(nameof(PlayerData.ResetGame))] + public static void PlayerData_ResetGame() { - ShipLogManager manager = Locator.GetShipLogManager(); - __result = __result.Where(e => manager.GetFact(e) != null).ToList(); + NewHorizonsData.Reset(); } } } diff --git a/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs b/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs index be44f0364..7941299f6 100644 --- a/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs +++ b/NewHorizons/Patches/ShipLogPatches/UIStyleManagerPatches.cs @@ -9,15 +9,15 @@ public static class UIStyleManagerPatches { [HarmonyPrefix] [HarmonyPatch(nameof(UIStyleManager.GetCuriosityColor))] - public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result) + public static bool UIStyleManager_GetCuriosityColor(UIStyleManager __instance, CuriosityName curiosityName, bool highlight, ref Color __result) { - if ((int)__0 < 7) + if ((int)curiosityName < 7) { return true; } else { - __result = RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight); + __result = RumorModeBuilder.GetCuriosityColor(curiosityName, highlight, __instance._neutralColor, __instance._neutralHighlight); return false; } } diff --git a/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs b/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs index 5470d5f2f..32318a5c7 100644 --- a/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs +++ b/NewHorizons/Patches/SignalPatches/AudioSignalPatches.cs @@ -12,9 +12,9 @@ public static class AudioSignalPatches { [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.SignalNameToString))] - public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __result) + public static bool AudioSignal_SignalNameToString(SignalName name, ref string __result) { - var customSignalName = SignalBuilder.GetCustomSignalName(__0); + var customSignalName = SignalBuilder.GetCustomSignalName(name); if (!string.IsNullOrEmpty(customSignalName)) { __result = TranslationHandler.GetTranslation(customSignalName, TranslationHandler.TextType.UI, false).ToUpper(); @@ -25,9 +25,9 @@ public static bool AudioSignal_SignalNameToString(SignalName __0, ref string __r [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.FrequencyToIndex))] - public static bool AudioSignal_FrequencyToIndex(SignalFrequency __0, ref int __result) + public static bool AudioSignal_FrequencyToIndex(SignalFrequency frequency, out int __result) { - __result = __0 switch + __result = frequency switch { SignalFrequency.Default => 0, SignalFrequency.Traveler => 1, @@ -37,16 +37,16 @@ public static bool AudioSignal_FrequencyToIndex(SignalFrequency __0, ref int __r SignalFrequency.HideAndSeek => 5, SignalFrequency.Radio => 6, SignalFrequency.Statue => 7, - _ => (int)(Mathf.Log((float)__0) / Mathf.Log(2f)),// Frequencies are in powers of 2 + _ => (int)(Mathf.Log((float)frequency) / Mathf.Log(2f)),// Frequencies are in powers of 2 }; return false; } [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.IndexToFrequency))] - public static bool AudioSignal_IndexToFrequency(int __0, ref SignalFrequency __result) + public static bool AudioSignal_IndexToFrequency(int index, out SignalFrequency __result) { - __result = __0 switch + __result = index switch { 0 => SignalFrequency.Default, 1 => SignalFrequency.Traveler, @@ -56,16 +56,16 @@ public static bool AudioSignal_IndexToFrequency(int __0, ref SignalFrequency __r 5 => SignalFrequency.HideAndSeek, 6 => SignalFrequency.Radio, 7 => SignalFrequency.Statue, - _ => (SignalFrequency)Math.Pow(2, __0), + _ => (SignalFrequency)Math.Pow(2, index), }; return false; } [HarmonyPrefix] [HarmonyPatch(nameof(AudioSignal.FrequencyToString))] - public static bool AudioSignal_FrequencyToString(SignalFrequency __0, ref string __result) + public static bool AudioSignal_FrequencyToString(SignalFrequency frequency, ref string __result) { - var customName = SignalBuilder.GetCustomFrequencyName(__0); + var customName = SignalBuilder.GetCustomFrequencyName(frequency); if (!string.IsNullOrEmpty(customName)) { if (NewHorizonsData.KnowsFrequency(customName)) __result = TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI, false).ToUpper(); diff --git a/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs b/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs index b6e241a46..6b401d452 100644 --- a/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs +++ b/NewHorizons/Patches/SignalPatches/SignalscopePatches.cs @@ -15,9 +15,8 @@ public static void Signalscope_Awake(Signalscope __instance) [HarmonyPrefix] [HarmonyPatch(nameof(Signalscope.SwitchFrequencyFilter))] - public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int __0) + public static bool Signalscope_SwitchFrequencyFilter(Signalscope __instance, int increment) { - var increment = __0; var count = SignalBuilder.NumberOfFrequencies; __instance._frequencyFilterIndex += increment; __instance._frequencyFilterIndex = __instance._frequencyFilterIndex >= count ? 0 : __instance._frequencyFilterIndex; diff --git a/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs b/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs index 08cd5d15c..a5f33f20a 100644 --- a/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs +++ b/NewHorizons/Patches/ToolPatches/SurveyorProbePatches.cs @@ -9,7 +9,7 @@ public static class SurveyorProbePatches // This is to stop the game throwing too many errors if the probe is destroyed by a blackhole [HarmonyPrefix] [HarmonyPatch(nameof(SurveyorProbe.IsLaunched))] - public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, ref bool __result) + public static bool SurveyorProbe_IsLaunched(SurveyorProbe __instance, out bool __result) { __result = __instance?.gameObject?.activeSelf ?? false; return false; diff --git a/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs b/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs index 45564b50b..3203e3359 100644 --- a/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs +++ b/NewHorizons/Patches/VolumePatches/DestructionVolumePatches.cs @@ -8,14 +8,14 @@ namespace NewHorizons.Patches.VolumePatches { - [HarmonyPatch] + [HarmonyPatch(typeof(DestructionVolume))] public static class DestructionVolumePatches { [HarmonyPrefix] - [HarmonyPatch(typeof(DestructionVolume), nameof(DestructionVolume.Vanish))] - public static bool DestructionVolume_Vanish(OWRigidbody __0) + [HarmonyPatch(nameof(DestructionVolume.Vanish))] + public static bool DestructionVolume_Vanish(OWRigidbody bodyToVanish) { - var quantumPlanet = __0.gameObject.GetComponent(); + var quantumPlanet = bodyToVanish.gameObject.GetComponent(); if (quantumPlanet == null) return true; diff --git a/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs b/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs index 21283d6e9..f63bad812 100644 --- a/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs +++ b/NewHorizons/Patches/VolumePatches/FogWarpVolumePatches.cs @@ -8,7 +8,7 @@ public static class FogWarpVolumePatches { [HarmonyPrefix] [HarmonyPatch(typeof(SphericalFogWarpVolume), nameof(SphericalFogWarpVolume.IsProbeOnly))] - public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, ref bool __result) + public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __instance, out bool __result) { __result = Mathf.Approximately(__instance._exitRadius / __instance._warpRadius, 2f); // Check the ratio between these to determine if seed, instead of just < 10 return false; @@ -16,7 +16,7 @@ public static bool SphericalFogWarpVolume_IsProbeOnly(SphericalFogWarpVolume __i [HarmonyPrefix] [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.GetFogThickness))] - public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, ref float __result) + public static bool FogWarpVolume_GetFogThickness(FogWarpVolume __instance, out float __result) { if (__instance is InnerFogWarpVolume sph) __result = sph._exitRadius; else __result = 50; // 50f is hardcoded as the return value in the base game diff --git a/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs b/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs index 9afd44e93..af2cb69bb 100644 --- a/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs +++ b/NewHorizons/Patches/WarpPatches/EyeCoordinatePromptTriggerPatches.cs @@ -4,11 +4,11 @@ namespace NewHorizons.Patches.WarpPatches { - [HarmonyPatch] + [HarmonyPatch(typeof(EyeCoordinatePromptTrigger))] public static class EyeCoordinatePromptTriggerPatches { [HarmonyPrefix] - [HarmonyPatch(typeof(EyeCoordinatePromptTrigger), nameof(EyeCoordinatePromptTrigger.Update))] + [HarmonyPatch(nameof(EyeCoordinatePromptTrigger.Update))] public static bool EyeCoordinatePromptTrigger_Update(EyeCoordinatePromptTrigger __instance) { var showPrompts = __instance._warpController.HasPower(); @@ -22,10 +22,10 @@ public static bool EyeCoordinatePromptTrigger_Update(EyeCoordinatePromptTrigger } [HarmonyPrefix] - [HarmonyPatch(typeof(EyeCoordinatePromptTrigger), nameof(EyeCoordinatePromptTrigger.OnExit))] - public static void EyeCoordinatePromptTrigger_OnExit(GameObject __0) + [HarmonyPatch(nameof(EyeCoordinatePromptTrigger.OnExit))] + public static void EyeCoordinatePromptTrigger_OnExit(GameObject hitObj) { - if (__0.CompareTag("PlayerDetector")) + if (hitObj.CompareTag("PlayerDetector")) { VesselCoordinatePromptHandler.SetPromptVisibility(false); } diff --git a/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs b/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs index f34b97855..38d1aa36f 100644 --- a/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs +++ b/NewHorizons/Patches/WarpPatches/NomaiCoordinateInterfacePatches.cs @@ -11,8 +11,12 @@ public static class NomaiCoordinateInterfacePatches public static bool NomaiCoordinateInterface_SetPillarRaised(NomaiCoordinateInterface __instance, bool raised) { if (raised) - return !(!__instance._powered || __instance.CheckEyeCoordinates() && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || __instance.CheckAllCoordinates(out string targetSystem) && Main.Instance.CurrentStarSystem != targetSystem); + return !( + !__instance._powered || + __instance.CheckEyeCoordinates() && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse" || + __instance.CheckAllCoordinates(out var targetSystem) && Main.Instance.CurrentStarSystem != targetSystem + ); return true; } } -} +} \ No newline at end of file From 6cea038134033b5584d7d0c62ff2bcf5917d496a Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 15:17:32 -0500 Subject: [PATCH 041/119] Revert geyser alignment because idk --- NewHorizons/Builder/Props/GeyserBuilder.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index 2b4819fd0..e98d41d90 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -18,9 +18,9 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf { InitPrefab(); - var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", sector?.transform ?? planetGO.transform, info, true); - - var pos = info.isRelativeToParent ? geyserGO.transform.parent.TransformPoint((Vector3)info.position) : (Vector3)info.position; + var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", sector?.transform ?? planetGO.transform, info); + + var pos = planetGO.transform.InverseTransformPoint(geyserGO.transform.position); // Offset height, default -97.5 pushes it underground so the spout is at the surface var length = pos.magnitude + info.offset; @@ -30,6 +30,11 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf geyserGO.transform.localScale = Vector3.one; + // Geyser alignment is technically incorrect due to inheriting the prefab's rotation but we need backwards compat so explicitly applying it here + geyserGO.transform.rotation = _geyserPrefab.transform.rotation; + var up = planetGO.transform.TransformPoint(pos) - planetGO.transform.position; + geyserGO.transform.rotation = Quaternion.FromToRotation(geyserGO.transform.up, up) * _geyserPrefab.transform.rotation; + var bubbles = geyserGO.FindChild("GeyserParticles/GeyserBubbles"); var shaft = geyserGO.FindChild("GeyserParticles/GeyserShaft"); var spout = geyserGO.FindChild("GeyserParticles/GeyserSpout"); From d8f5f71249b993e25d991858bdf28cf9bd5ad218 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 15:17:48 -0500 Subject: [PATCH 042/119] Fix out-of-date name in comment --- NewHorizons/External/Configs/PlanetConfig.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index d7bc96b15..abc1f522b 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -467,7 +467,7 @@ public void Migrate() ShockEffect = new ShockEffectModule() { hasSupernovaShockEffect = true }; } - // Spawn points reorganized to use GenericPropInfo + // Spawn points reorganized to use GeneralPointPropInfo if (Spawn != null && Spawn.playerSpawn == null && Spawn.playerSpawnPoint != null) { Spawn.playerSpawn = new SpawnModule.PlayerSpawnPoint() @@ -486,7 +486,7 @@ public void Migrate() }; } - // Remote dialogue trigger reorganized to use GenericPropInfo + // Remote dialogue trigger reorganized to use GeneralPointPropInfo if (Props != null && Props.dialogue != null) { foreach (var dialogue in Props.dialogue) From af96853afbbd75001958b98ec8912ccfc7fd308e Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 15:17:58 -0500 Subject: [PATCH 043/119] Fix parent path fetching --- .../Builder/Props/GeneralPropBuilder.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 691f10831..7fc8dc95c 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -18,10 +18,11 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM if (info is PropModule.GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) { + // This can fail if the prop is built before the target planet. Only use it for SolarSystem module props var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody); if (targetPlanet != null) { - parent = targetPlanet.transform; + parent = targetPlanet._rootSector?.transform ?? targetPlanet.transform; } else { Logger.LogError($"Cannot find parent body named {solarSystemInfo.parentBody}"); @@ -37,16 +38,16 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM var parentPath = info.parentPath ?? defaultParentPath; - if (!string.IsNullOrEmpty(parentPath)) + if (parent && !string.IsNullOrEmpty(parentPath)) { - var newParent = go.transform.Find(parentPath); + var newParent = parent.root.transform.Find(parentPath); if (newParent != null) { go.transform.parent = newParent.transform; } else { - Logger.LogError($"Cannot find parent object at path: {go.name}/{parentPath}"); + Logger.LogError($"Cannot find parent object at path: {parent.name}/{parentPath}"); } } @@ -62,8 +63,8 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM go.transform.localRotation = rot; } else if (parent) { - go.transform.position = parent.root.TransformPoint(pos); - go.transform.rotation = parent.root.TransformRotation(rot); + go.transform.position = parent.root.transform.TransformPoint(pos); + go.transform.rotation = parent.root.transform.TransformRotation(rot); } else { go.transform.position = pos; @@ -71,10 +72,9 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM } if (alignToBody) { - var up = (go.transform.position - parent.position).normalized; + var up = (go.transform.position - parent.root.position).normalized; if (normal != null) up = parent.TransformDirection(normal); - go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up); - go.transform.rotation *= rot; + go.transform.rotation = Quaternion.FromToRotation(go.transform.up, up) * rot; } return go; } From 3523bd3cabada7880fcccd0c86fa07605dd72b9d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 15:26:35 -0500 Subject: [PATCH 044/119] Move GeneralPropInfo out into its own file --- .../Builder/Props/GeneralPropBuilder.cs | 10 ++-- .../External/Configs/StarSystemConfig.cs | 4 +- NewHorizons/External/Modules/BrambleModule.cs | 2 +- .../External/Modules/GeneralPropInfo.cs | 48 +++++++++++++++++++ NewHorizons/External/Modules/PropModule.cs | 42 ---------------- NewHorizons/External/Modules/SignalModule.cs | 2 +- NewHorizons/External/Modules/SpawnModule.cs | 4 +- .../Modules/VariableSize/SingularityModule.cs | 2 +- NewHorizons/External/Modules/VolumesModule.cs | 2 +- 9 files changed, 61 insertions(+), 55 deletions(-) create mode 100644 NewHorizons/External/Modules/GeneralPropInfo.cs diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 7fc8dc95c..299b94655 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,11 +12,11 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromExisting(GameObject go, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { if (info == null) return go; - if (info is PropModule.GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) + if (info is GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) { // This can fail if the prop is built before the target planet. Only use it for SolarSystem module props var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody); @@ -53,7 +53,7 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); var rot = Quaternion.identity; - if (info is PropModule.GeneralPropInfo rotInfo) + if (info is GeneralPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; } @@ -79,14 +79,14 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, PropM return go; } - public static GameObject MakeNew(string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeNew(string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = new GameObject(defaultName); go.SetActive(false); return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, PropModule.GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 12a97277c..951a211d3 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -211,12 +211,12 @@ public class VesselModule [Obsolete("warpExitRotation is deprecated, use vesselSpawn.rotation instead")] public MVector3 warpExitRotation; [JsonObject] - public class VesselInfo : PropModule.GeneralSolarSystemPropInfo + public class VesselInfo : GeneralSolarSystemPropInfo { } [JsonObject] - public class WarpExitInfo : PropModule.GeneralSolarSystemPropInfo + public class WarpExitInfo : GeneralSolarSystemPropInfo { /// /// If set, keeps the warp exit attached to the vessel. Overrides `parentPath`. diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 7fec298be..63f48abd9 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -78,7 +78,7 @@ public class BrambleDimensionInfo [JsonObject] - public class BrambleNodeInfo : PropModule.GeneralPropInfo + public class BrambleNodeInfo : GeneralPropInfo { /// /// The physical scale of the node, as a multiplier of the original size. diff --git a/NewHorizons/External/Modules/GeneralPropInfo.cs b/NewHorizons/External/Modules/GeneralPropInfo.cs new file mode 100644 index 000000000..c9ead3469 --- /dev/null +++ b/NewHorizons/External/Modules/GeneralPropInfo.cs @@ -0,0 +1,48 @@ + +using NewHorizons.Utility; +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules +{ + [JsonObject] + public abstract class GeneralPointPropInfo + { + /// + /// Position of the object + /// + public MVector3 position; + + /// + /// 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; + } + + [JsonObject] + public abstract class GeneralPropInfo : GeneralPointPropInfo + { + /// + /// Rotation of the object + /// + public MVector3 rotation; + } + + [JsonObject] + public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo + { + /// + /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. + /// + public string parentBody; + } +} diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 9c21b454a..ae674ddad 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -98,48 +98,6 @@ public class PropModule [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes; - [JsonObject] - public abstract class GeneralPointPropInfo - { - /// - /// Position of the object - /// - public MVector3 position; - - /// - /// 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; - } - - [JsonObject] - public abstract class GeneralPropInfo : GeneralPointPropInfo - { - /// - /// Rotation of the object - /// - public MVector3 rotation; - } - - [JsonObject] - public abstract class GeneralSolarSystemPropInfo : GeneralPropInfo - { - /// - /// The name of the planet that will be used with `parentPath`. Must be set if `parentPath` is set. - /// - public string parentBody; - } - [JsonObject] public class ScatterInfo { diff --git a/NewHorizons/External/Modules/SignalModule.cs b/NewHorizons/External/Modules/SignalModule.cs index cfa66a16f..e06405ff0 100644 --- a/NewHorizons/External/Modules/SignalModule.cs +++ b/NewHorizons/External/Modules/SignalModule.cs @@ -15,7 +15,7 @@ public class SignalModule public SignalInfo[] signals; [JsonObject] - public class SignalInfo : PropModule.GeneralPointPropInfo + public class SignalInfo : GeneralPointPropInfo { [Obsolete("audioClip is deprecated, please use audio instead")] public string audioClip; diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index ea8067c14..a73beb3f2 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -24,7 +24,7 @@ public class SpawnModule [Obsolete("startWithSuit is deprecated. Use playerSpawn.startWithSuit instead")] public bool startWithSuit; [JsonObject] - public class PlayerSpawnPoint : PropModule.GeneralPropInfo { + public class PlayerSpawnPoint : GeneralPropInfo { /// /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) /// @@ -32,7 +32,7 @@ public class PlayerSpawnPoint : PropModule.GeneralPropInfo { } [JsonObject] - public class ShipSpawnPoint : PropModule.GeneralPropInfo { + public class ShipSpawnPoint : GeneralPropInfo { } } diff --git a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs index 58b35b9a4..522ca7c48 100644 --- a/NewHorizons/External/Modules/VariableSize/SingularityModule.cs +++ b/NewHorizons/External/Modules/VariableSize/SingularityModule.cs @@ -9,7 +9,7 @@ namespace NewHorizons.External.Modules.VariableSize { [JsonObject] - public class SingularityModule : PropModule.GeneralPropInfo + public class SingularityModule : GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum SingularityType diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 8b60df6ea..e8cf2effd 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -117,7 +117,7 @@ public class VolumesModule public LoadCreditsVolumeInfo[] creditsVolume; [JsonObject] - public class VolumeInfo : PropModule.GeneralPointPropInfo + public class VolumeInfo : GeneralPointPropInfo { /// /// The radius of this volume. From b04037312376bd4a2a956a766b44e00dc5782689 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 16:28:05 -0400 Subject: [PATCH 045/119] Does it break if I do this --- NewHorizons/Builder/Body/BrambleDimensionBuilder.cs | 1 + NewHorizons/Builder/Body/CloakBuilder.cs | 1 + NewHorizons/Builder/Body/FunnelBuilder.cs | 1 + NewHorizons/Builder/Body/SingularityBuilder.cs | 1 + NewHorizons/Builder/Body/WaterBuilder.cs | 1 + NewHorizons/Builder/General/AstroObjectBuilder.cs | 2 +- NewHorizons/Builder/General/SpawnPointBuilder.cs | 1 + NewHorizons/Builder/Orbital/OrbitlineBuilder.cs | 1 + NewHorizons/Builder/Props/BrambleNodeBuilder.cs | 1 + NewHorizons/Builder/Props/GeyserBuilder.cs | 1 + NewHorizons/Builder/Props/NomaiTextBuilder.cs | 1 + NewHorizons/Builder/Props/QuantumBuilder.cs | 2 +- NewHorizons/Builder/Props/ScatterBuilder.cs | 1 + NewHorizons/Builder/Props/SignalBuilder.cs | 1 + NewHorizons/Builder/Props/TornadoBuilder.cs | 1 + .../Builder/Props/TranslatorText/NomaiTextArcArranger.cs | 2 +- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 2 ++ NewHorizons/Builder/Props/VolcanoBuilder.cs | 1 + NewHorizons/Builder/ShipLog/RumorModeBuilder.cs | 1 + NewHorizons/Builder/StarSystem/SkyboxBuilder.cs | 1 + NewHorizons/Components/RingOpacityController.cs | 1 - NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs | 1 + NewHorizons/Components/ShipWarpController.cs | 1 + NewHorizons/Components/SizeControllers/SizeController.cs | 2 +- .../Components/SizeControllers/StarEvolutionController.cs | 1 + NewHorizons/External/Modules/RingModule.cs | 2 +- .../Modules/VariableSize}/TimeValuePair.cs | 2 +- .../External/Modules/VariableSize/VariableSizeModule.cs | 1 - NewHorizons/Handlers/AudioTypeHandler.cs | 1 + NewHorizons/Handlers/PlanetCreationHandler.cs | 1 + NewHorizons/Handlers/PlanetDestructionHandler.cs | 1 + NewHorizons/Handlers/RemoteHandler.cs | 2 +- NewHorizons/Handlers/SystemCreationHandler.cs | 2 ++ NewHorizons/Handlers/VesselWarpHandler.cs | 1 + .../Patches/WarpPatches/VesselWarpControllerPatches.cs | 1 + NewHorizons/Utility/Cache.cs | 2 -- NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs | 1 + NewHorizons/Utility/{ => Geometry}/AddDebugShape.cs | 4 ++-- NewHorizons/Utility/{ => Geometry}/BoxShapeVisualizer.cs | 8 +------- NewHorizons/Utility/{ => Geometry}/MakeMeshDoubleFaced.cs | 5 +++-- NewHorizons/Utility/{ => Geometry}/MeshUtilities.cs | 8 ++------ NewHorizons/Utility/Logger.cs | 3 +-- NewHorizons/Utility/{ => OWMLUtilities}/Delay.cs | 2 +- NewHorizons/Utility/{ => OWMLUtilities}/EnumUtilities.cs | 5 ++--- .../Utility/{ => OWUtilities}/TimeLoopUtilities.cs | 2 +- NewHorizons/Utility/RandomUtility.cs | 3 ++- 46 files changed, 51 insertions(+), 36 deletions(-) rename NewHorizons/{Utility => External/Modules/VariableSize}/TimeValuePair.cs (85%) rename NewHorizons/Utility/{ => Geometry}/AddDebugShape.cs (91%) rename NewHorizons/Utility/{ => Geometry}/BoxShapeVisualizer.cs (70%) rename NewHorizons/Utility/{ => Geometry}/MakeMeshDoubleFaced.cs (96%) rename NewHorizons/Utility/{ => Geometry}/MeshUtilities.cs (79%) rename NewHorizons/Utility/{ => OWMLUtilities}/Delay.cs (91%) rename NewHorizons/Utility/{ => OWMLUtilities}/EnumUtilities.cs (95%) rename NewHorizons/Utility/{ => OWUtilities}/TimeLoopUtilities.cs (96%) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 02f32731e..132914465 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -10,6 +10,7 @@ using UnityEngine; using Logger = NewHorizons.Utility.Logger; using static NewHorizons.Main; +using NewHorizons.Utility.OWMLUtilities; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index 4b0ee5588..338049594 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Components; using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index aeeea8819..a7ce37244 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -5,6 +5,7 @@ using Logger = NewHorizons.Utility.Logger; using NewHorizons.External.Modules.VariableSize; using NewHorizons.Components.Orbital; +using NewHorizons.Utility.OWMLUtilities; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 96466121b..79b4d61b8 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -10,6 +10,7 @@ using System.Drawing; using Color = UnityEngine.Color; using NewHorizons.Components.Volumes; +using NewHorizons.Utility.OWMLUtilities; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 857358e56..e71e957cb 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -3,6 +3,7 @@ using UnityEngine; using NewHorizons.External.Modules.VariableSize; using Tessellation; +using NewHorizons.Utility.OWMLUtilities; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/General/AstroObjectBuilder.cs b/NewHorizons/Builder/General/AstroObjectBuilder.cs index 26eb7f3b4..c11201590 100644 --- a/NewHorizons/Builder/General/AstroObjectBuilder.cs +++ b/NewHorizons/Builder/General/AstroObjectBuilder.cs @@ -1,6 +1,6 @@ using NewHorizons.Components.Orbital; using NewHorizons.External.Configs; -using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.General diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 437fb1b6b..f773fc857 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using System; using System.Reflection; using UnityEngine; diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index 88ebf55bf..e0fa3a58a 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Components.Orbital; using NewHorizons.External.Configs; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using UnityEngine; namespace NewHorizons.Builder.Orbital { diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 6b8415cd0..a4bdeebb2 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -3,6 +3,7 @@ using NewHorizons.External.Configs; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index 11c9f02cc..5315e0912 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 5e630fec9..c0910bfa3 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using OWML.Utils; using System; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 8a5a383b8..e7e1423fe 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -2,7 +2,7 @@ using NewHorizons.Components.Quantum; using NewHorizons.External.Configs; using NewHorizons.External.Modules; -using NewHorizons.Utility; +using NewHorizons.Utility.UnityUtilities; using OWML.Common; using System; using System.Collections.Generic; diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index f6583c4d2..827453df3 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using System; using System.Collections.Generic; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 876fc2c25..b6d0669f0 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using OWML.Utils; using System.Collections.Generic; diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 2b63bd523..4b5b4db86 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using System; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs index d05bda586..1ef745722 100644 --- a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs +++ b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs @@ -1,4 +1,4 @@ -using NewHorizons.Utility; +using NewHorizons.Utility.UnityUtilities; using System.Collections; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 96899393c..533d5fa31 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -13,6 +13,8 @@ using OWML.Utils; using Newtonsoft.Json; using System; +using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.UnityUtilities; namespace NewHorizons.Builder.Props { diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index e5e902355..0a552a389 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs index 0543b0aed..cdba01fa7 100644 --- a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Utils; using System; using System.Collections.Generic; diff --git a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs index 8fb429ea7..0ef97d835 100644 --- a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs +++ b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using System; using UnityEngine; diff --git a/NewHorizons/Components/RingOpacityController.cs b/NewHorizons/Components/RingOpacityController.cs index df707a33d..0f762506e 100644 --- a/NewHorizons/Components/RingOpacityController.cs +++ b/NewHorizons/Components/RingOpacityController.cs @@ -1,6 +1,5 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules.VariableSize; -using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Components diff --git a/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs index 03510628e..8582c1ad9 100644 --- a/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs @@ -1,5 +1,6 @@ using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using System; using System.Collections.Generic; using System.IO; diff --git a/NewHorizons/Components/ShipWarpController.cs b/NewHorizons/Components/ShipWarpController.cs index 3ff96a3ae..8bfa4bee3 100644 --- a/NewHorizons/Components/ShipWarpController.cs +++ b/NewHorizons/Components/ShipWarpController.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.General; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components diff --git a/NewHorizons/Components/SizeControllers/SizeController.cs b/NewHorizons/Components/SizeControllers/SizeController.cs index 334f5a84d..eb9b6264f 100644 --- a/NewHorizons/Components/SizeControllers/SizeController.cs +++ b/NewHorizons/Components/SizeControllers/SizeController.cs @@ -1,4 +1,4 @@ -using NewHorizons.Utility; +using NewHorizons.External.Modules.VariableSize; using UnityEngine; namespace NewHorizons.Components.SizeControllers { diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 6c84317ef..c0d6508e1 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -4,6 +4,7 @@ using NewHorizons.External.Modules.VariableSize; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using System; using System.Linq; using UnityEngine; diff --git a/NewHorizons/External/Modules/RingModule.cs b/NewHorizons/External/Modules/RingModule.cs index a5c93c4cb..ef60c6cf4 100644 --- a/NewHorizons/External/Modules/RingModule.cs +++ b/NewHorizons/External/Modules/RingModule.cs @@ -1,6 +1,6 @@ using System; using System.ComponentModel.DataAnnotations; -using NewHorizons.Utility; +using NewHorizons.External.Modules.VariableSize; using Newtonsoft.Json; namespace NewHorizons.External.Modules diff --git a/NewHorizons/Utility/TimeValuePair.cs b/NewHorizons/External/Modules/VariableSize/TimeValuePair.cs similarity index 85% rename from NewHorizons/Utility/TimeValuePair.cs rename to NewHorizons/External/Modules/VariableSize/TimeValuePair.cs index acacda16e..38ec9be34 100644 --- a/NewHorizons/Utility/TimeValuePair.cs +++ b/NewHorizons/External/Modules/VariableSize/TimeValuePair.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace NewHorizons.Utility +namespace NewHorizons.External.Modules.VariableSize { [JsonObject] public class TimeValuePair diff --git a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs index 92ba2dd13..5e5767b14 100644 --- a/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs +++ b/NewHorizons/External/Modules/VariableSize/VariableSizeModule.cs @@ -1,4 +1,3 @@ -using NewHorizons.Utility; using Newtonsoft.Json; using UnityEngine; diff --git a/NewHorizons/Handlers/AudioTypeHandler.cs b/NewHorizons/Handlers/AudioTypeHandler.cs index ee12465a2..db7c784b5 100644 --- a/NewHorizons/Handlers/AudioTypeHandler.cs +++ b/NewHorizons/Handlers/AudioTypeHandler.cs @@ -1,4 +1,5 @@ using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using OWML.Utils; using System; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index e69411ee8..c4ec19806 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -9,6 +9,7 @@ using NewHorizons.Components.Stars; using NewHorizons.OtherMods.OWRichPresence; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using System; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 05ad3455d..3bc3b6c24 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -1,5 +1,6 @@ using NewHorizons.Components.Stars; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Utils; using System; using System.Collections.Generic; diff --git a/NewHorizons/Handlers/RemoteHandler.cs b/NewHorizons/Handlers/RemoteHandler.cs index a012074fd..539dcf28b 100644 --- a/NewHorizons/Handlers/RemoteHandler.cs +++ b/NewHorizons/Handlers/RemoteHandler.cs @@ -1,4 +1,4 @@ -using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using OWML.Utils; using System; diff --git a/NewHorizons/Handlers/SystemCreationHandler.cs b/NewHorizons/Handlers/SystemCreationHandler.cs index cd0dc3463..594128e8f 100644 --- a/NewHorizons/Handlers/SystemCreationHandler.cs +++ b/NewHorizons/Handlers/SystemCreationHandler.cs @@ -1,6 +1,8 @@ using NewHorizons.Builder.StarSystem; using NewHorizons.Components; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; using Object = UnityEngine.Object; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index adcbf3fb5..a056d95cc 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -7,6 +7,7 @@ using Logger = NewHorizons.Utility.Logger; using static NewHorizons.Main; using NewHorizons.Components.Orbital; +using NewHorizons.Utility.OWMLUtilities; namespace NewHorizons.Handlers { diff --git a/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs b/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs index 1a6df7435..39eb3d729 100644 --- a/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs +++ b/NewHorizons/Patches/WarpPatches/VesselWarpControllerPatches.cs @@ -1,5 +1,6 @@ using HarmonyLib; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Patches.WarpPatches { diff --git a/NewHorizons/Utility/Cache.cs b/NewHorizons/Utility/Cache.cs index 0c98d0211..f19aaceda 100644 --- a/NewHorizons/Utility/Cache.cs +++ b/NewHorizons/Utility/Cache.cs @@ -1,10 +1,8 @@ using Newtonsoft.Json; using OWML.Common; -using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.Serialization; namespace NewHorizons.Utility { diff --git a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs index 9433eda9e..d8a65a6b5 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using NewHorizons.Handlers; +using NewHorizons.Utility.UnityUtilities; using UnityEngine; using UnityEngine.InputSystem; diff --git a/NewHorizons/Utility/AddDebugShape.cs b/NewHorizons/Utility/Geometry/AddDebugShape.cs similarity index 91% rename from NewHorizons/Utility/AddDebugShape.cs rename to NewHorizons/Utility/Geometry/AddDebugShape.cs index 50fb4816a..53a4af5db 100644 --- a/NewHorizons/Utility/AddDebugShape.cs +++ b/NewHorizons/Utility/Geometry/AddDebugShape.cs @@ -1,5 +1,5 @@ using UnityEngine; -namespace NewHorizons.Utility +namespace NewHorizons.Utility.UnityUtilities { public static class AddDebugShape { @@ -20,7 +20,7 @@ public static GameObject AddSphere(GameObject obj, float radius, Color color) catch { // Something went wrong so make sure the sphere is deleted - GameObject.Destroy(sphere); + Object.Destroy(sphere); } return sphere.gameObject; diff --git a/NewHorizons/Utility/BoxShapeVisualizer.cs b/NewHorizons/Utility/Geometry/BoxShapeVisualizer.cs similarity index 70% rename from NewHorizons/Utility/BoxShapeVisualizer.cs rename to NewHorizons/Utility/Geometry/BoxShapeVisualizer.cs index df5b5af2a..77dbf6cfd 100644 --- a/NewHorizons/Utility/BoxShapeVisualizer.cs +++ b/NewHorizons/Utility/Geometry/BoxShapeVisualizer.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; -using Popcron; -namespace NewHorizons.Utility +namespace NewHorizons.Utility.Geometry { public class BoxShapeVisualizer : MonoBehaviour { diff --git a/NewHorizons/Utility/MakeMeshDoubleFaced.cs b/NewHorizons/Utility/Geometry/MakeMeshDoubleFaced.cs similarity index 96% rename from NewHorizons/Utility/MakeMeshDoubleFaced.cs rename to NewHorizons/Utility/Geometry/MakeMeshDoubleFaced.cs index ce3e036cb..6bbae8b72 100644 --- a/NewHorizons/Utility/MakeMeshDoubleFaced.cs +++ b/NewHorizons/Utility/Geometry/MakeMeshDoubleFaced.cs @@ -1,5 +1,6 @@ -using UnityEngine; -namespace NewHorizons.Utility +using UnityEngine; + +namespace NewHorizons.Utility.Geometry { public class MakeMeshDoubleFaced : MonoBehaviour { diff --git a/NewHorizons/Utility/MeshUtilities.cs b/NewHorizons/Utility/Geometry/MeshUtilities.cs similarity index 79% rename from NewHorizons/Utility/MeshUtilities.cs rename to NewHorizons/Utility/Geometry/MeshUtilities.cs index b9f2d3205..1631bffda 100644 --- a/NewHorizons/Utility/MeshUtilities.cs +++ b/NewHorizons/Utility/Geometry/MeshUtilities.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; -namespace NewHorizons.Utility +namespace NewHorizons.Utility.Geometry { public class MeshUtilities { @@ -19,7 +15,7 @@ public static Mesh RectangleMeshFromCorners(Vector3[] corners) }; MVector3[] normals = new MVector3[verts.Length]; - for (int i = 0; i Date: Sat, 18 Mar 2023 16:28:44 -0400 Subject: [PATCH 046/119] Make a static class for layers --- .../Utility/OWUtilities/LayerUtilities.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 NewHorizons/Utility/OWUtilities/LayerUtilities.cs diff --git a/NewHorizons/Utility/OWUtilities/LayerUtilities.cs b/NewHorizons/Utility/OWUtilities/LayerUtilities.cs new file mode 100644 index 000000000..bfd5e7436 --- /dev/null +++ b/NewHorizons/Utility/OWUtilities/LayerUtilities.cs @@ -0,0 +1,36 @@ +using UnityEngine; + +namespace NewHorizons.Utility.OWUtilities +{ + public static class LayerUtilities + { + public static int Default = LayerMask.NameToLayer(nameof(Default)); + public static int TransparentFX = LayerMask.NameToLayer(nameof(TransparentFX)); + public static int IgnoreRaycast = LayerMask.NameToLayer(nameof(IgnoreRaycast)); + public static int Water = LayerMask.NameToLayer(nameof(Water)); + public static int UI = LayerMask.NameToLayer(nameof(UI)); + public static int PlayerSafetyCollider = LayerMask.NameToLayer(nameof(PlayerSafetyCollider)); + public static int Sun = LayerMask.NameToLayer(nameof(Sun)); + public static int ShipInterior = LayerMask.NameToLayer(nameof(ShipInterior)); + public static int HelmetUVPass = LayerMask.NameToLayer(nameof(HelmetUVPass)); + public static int AdvancedDetector = LayerMask.NameToLayer(nameof(AdvancedDetector)); + public static int Primitive = LayerMask.NameToLayer(nameof(Primitive)); + public static int IgnoreSun = LayerMask.NameToLayer(nameof(IgnoreSun)); + public static int AdvancedEffectVolume = LayerMask.NameToLayer(nameof(AdvancedEffectVolume)); + public static int BasicEffectVolume = LayerMask.NameToLayer(nameof(BasicEffectVolume)); + public static int ProxyPrimitive = LayerMask.NameToLayer(nameof(ProxyPrimitive)); + public static int ReferenceFrameVolume = LayerMask.NameToLayer(nameof(ReferenceFrameVolume)); + public static int BasicDetector = LayerMask.NameToLayer(nameof(BasicDetector)); + public static int Interactible = LayerMask.NameToLayer(nameof(Interactible)); + public static int VisibleToProbe = LayerMask.NameToLayer(nameof(VisibleToProbe)); + public static int HeadsUpDisplay = LayerMask.NameToLayer(nameof(HeadsUpDisplay)); + public static int CloseRangeRFVolume = LayerMask.NameToLayer(nameof(CloseRangeRFVolume)); + public static int ProxyPrimitive2 = LayerMask.NameToLayer(nameof(ProxyPrimitive2)); + public static int PhysicalDetector = LayerMask.NameToLayer(nameof(PhysicalDetector)); + public static int VisibleToPlayer = LayerMask.NameToLayer(nameof(VisibleToPlayer)); + public static int DreamSimulation = LayerMask.NameToLayer(nameof(DreamSimulation)); + public static int Skybox = LayerMask.NameToLayer(nameof(Skybox)); + public static int IgnoreOrbRaycast = LayerMask.NameToLayer(nameof(IgnoreOrbRaycast)); + public static int Flashback = LayerMask.NameToLayer(nameof(Flashback)); + } +} From 851b4608c26f68042d7d26f8c51af13bde9380ac Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 16:48:31 -0400 Subject: [PATCH 047/119] Use layer util --- NewHorizons/Builder/Atmosphere/AirBuilder.cs | 3 +- .../Builder/Atmosphere/CloudsBuilder.cs | 7 +- NewHorizons/Builder/Body/RingBuilder.cs | 3 +- .../Builder/Body/SingularityBuilder.cs | 3 +- NewHorizons/Builder/Body/StarBuilder.cs | 9 +- NewHorizons/Builder/Body/WaterBuilder.cs | 5 +- .../Builder/General/DetectorBuilder.cs | 5 +- NewHorizons/Builder/General/GravityBuilder.cs | 3 +- .../Builder/General/RFVolumeBuilder.cs | 3 +- .../Builder/General/SpawnPointBuilder.cs | 7 +- NewHorizons/Builder/Props/DialogueBuilder.cs | 5 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 2 +- NewHorizons/Builder/Props/RemoteBuilder.cs | 3 +- NewHorizons/Builder/Props/SignalBuilder.cs | 3 +- .../TranslatorText/NomaiTextArcArranger.cs | 175 +++++++++--------- .../TranslatorText/TranslatorTextBuilder.cs | 12 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 3 +- .../Builder/StarSystem/SkyboxBuilder.cs | 8 +- .../Builder/Volumes/AudioVolumeBuilder.cs | 3 +- .../Builder/Volumes/HazardVolumeBuilder.cs | 5 +- .../Volumes/NotificationVolumeBuilder.cs | 3 +- .../Builder/Volumes/VanishVolumeBuilder.cs | 3 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 3 +- .../Achievement/AchievementObserveTrigger.cs | 3 +- NewHorizons/Components/AddPhysics.cs | 5 +- NewHorizons/Main.cs | 2 + .../Utility/DebugUtilities/DebugRaycaster.cs | 58 +++--- NewHorizons/Utility/Geometry/AddDebugShape.cs | 2 +- 28 files changed, 184 insertions(+), 162 deletions(-) diff --git a/NewHorizons/Builder/Atmosphere/AirBuilder.cs b/NewHorizons/Builder/Atmosphere/AirBuilder.cs index e4518e4cc..f71d49378 100644 --- a/NewHorizons/Builder/Atmosphere/AirBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AirBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Configs; +using NewHorizons.Utility.OWUtilities; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { @@ -8,7 +9,7 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) { var airGO = new GameObject("Air"); airGO.SetActive(false); - airGO.layer = 17; + airGO.layer = LayerUtilities.BasicEffectVolume; airGO.transform.parent = sector?.transform ?? planetGO.transform; var sc = airGO.AddComponent(); diff --git a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs index 7eb98eb18..087b0ff7f 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -7,6 +7,7 @@ using Logger = NewHorizons.Utility.Logger; using System.Collections.Generic; using Tessellation; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Atmosphere { @@ -118,7 +119,7 @@ public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atm GameObject cloudsFluidGO = new GameObject("CloudsFluid"); cloudsFluidGO.SetActive(false); - cloudsFluidGO.layer = 17; + cloudsFluidGO.layer = LayerUtilities.BasicEffectVolume; cloudsFluidGO.transform.parent = cloudsMainGO.transform; SphereCollider fluidSC = cloudsFluidGO.AddComponent(); @@ -251,7 +252,7 @@ public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule a if (atmo.clouds.unlit) { - cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun"); + cloudsTopGO.layer = LayerUtilities.IgnoreSun; } if (atmo.clouds.rotationSpeed != 0f) @@ -303,7 +304,7 @@ public static GameObject MakeTransparentClouds(GameObject rootObject, Atmosphere { GameObject tcrqcGO = new GameObject("TransparentCloudRenderQueueController"); tcrqcGO.transform.SetParent(cloudsTransparentGO.transform, false); - tcrqcGO.layer = LayerMask.NameToLayer("BasicEffectVolume"); + tcrqcGO.layer = LayerUtilities.BasicEffectVolume; var shape = tcrqcGO.AddComponent(); shape.radius = 1; diff --git a/NewHorizons/Builder/Body/RingBuilder.cs b/NewHorizons/Builder/Body/RingBuilder.cs index 40d5953f5..c2adc5b28 100644 --- a/NewHorizons/Builder/Body/RingBuilder.cs +++ b/NewHorizons/Builder/Body/RingBuilder.cs @@ -8,6 +8,7 @@ using UnityEngine; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components.Volumes; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Body { @@ -30,7 +31,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, RingModule rin ringVolume.transform.localPosition = Vector3.zero; ringVolume.transform.localScale = Vector3.one; ringVolume.transform.localRotation = Quaternion.identity; - ringVolume.layer = LayerMask.NameToLayer("BasicEffectVolume"); + ringVolume.layer = LayerUtilities.BasicEffectVolume; var ringShape = ringVolume.AddComponent(); ringShape.innerRadius = ring.innerRadius; diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 79b4d61b8..79a1ed8f9 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -11,6 +11,7 @@ using Color = UnityEngine.Color; using NewHorizons.Components.Volumes; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Body { @@ -191,7 +192,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam if (hasDestructionVolume || targetStarSystem != null) { var destructionVolumeGO = new GameObject("DestructionVolume"); - destructionVolumeGO.layer = LayerMask.NameToLayer("BasicEffectVolume"); + destructionVolumeGO.layer = LayerUtilities.BasicEffectVolume; destructionVolumeGO.transform.parent = singularity.transform; destructionVolumeGO.transform.localScale = Vector3.one; destructionVolumeGO.transform.localPosition = Vector3.zero; diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 2da12c1e5..f9ee9ceb4 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -9,6 +9,7 @@ using UnityEngine.InputSystem.XR; using System.Linq; using NewHorizons.Components.Stars; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Body { @@ -122,7 +123,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( heatVolume.transform.SetParent(starGO.transform, false); heatVolume.transform.localPosition = Vector3.zero; heatVolume.transform.localScale = Vector3.one; - heatVolume.layer = LayerMask.NameToLayer("BasicEffectVolume"); + heatVolume.layer = LayerUtilities.BasicEffectVolume; heatVolume.AddComponent().radius = 1.1f; heatVolume.AddComponent(); heatVolume.AddComponent()._damagePerSecond = 20f; @@ -132,7 +133,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( deathVolume.transform.SetParent(starGO.transform, false); deathVolume.transform.localPosition = Vector3.zero; deathVolume.transform.localScale = Vector3.one; - deathVolume.layer = LayerMask.NameToLayer("BasicEffectVolume"); + deathVolume.layer = LayerUtilities.BasicEffectVolume; var sphereCollider = deathVolume.AddComponent(); sphereCollider.radius = 1f; sphereCollider.isTrigger = true; @@ -148,7 +149,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( planetDestructionVolume.transform.SetParent(starGO.transform, false); planetDestructionVolume.transform.localPosition = Vector3.zero; planetDestructionVolume.transform.localScale = Vector3.one; - planetDestructionVolume.layer = LayerMask.NameToLayer("BasicEffectVolume"); + planetDestructionVolume.layer = LayerUtilities.BasicEffectVolume; var planetSphereCollider = planetDestructionVolume.AddComponent(); planetSphereCollider.radius = 0.8f; planetSphereCollider.isTrigger = true; @@ -445,7 +446,7 @@ public static StellarDeathController MakeSupernova(GameObject starGO, StarModule supernovaWallAudio.transform.SetParent(supernovaGO.transform, false); supernovaWallAudio.transform.localPosition = Vector3.zero; supernovaWallAudio.transform.localScale = Vector3.one; - supernovaWallAudio.layer = LayerMask.NameToLayer("BasicEffectVolume"); + supernovaWallAudio.layer = LayerUtilities.BasicEffectVolume; var audioSource = supernovaWallAudio.AddComponent(); audioSource.loop = true; audioSource.maxDistance = 2000; diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index e71e957cb..e08669bca 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -4,6 +4,7 @@ using NewHorizons.External.Modules.VariableSize; using Tessellation; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Body { @@ -53,7 +54,7 @@ public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigid // Don't ignore sun when not under clouds waterGO.layer = 0; - Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = 15; }); + Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = LayerUtilities.IgnoreSun; }); TessellatedSphereRenderer TSR = waterGO.AddComponent(); TSR.tessellationMeshGroup = ScriptableObject.CreateInstance(); @@ -100,7 +101,7 @@ public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigid var buoyancyObject = new GameObject("WaterVolume"); buoyancyObject.transform.parent = waterGO.transform; buoyancyObject.transform.localScale = Vector3.one; - buoyancyObject.layer = LayerMask.NameToLayer("BasicEffectVolume"); + buoyancyObject.layer = LayerUtilities.BasicEffectVolume; var sphereCollider = buoyancyObject.AddComponent(); sphereCollider.radius = 1; diff --git a/NewHorizons/Builder/General/DetectorBuilder.cs b/NewHorizons/Builder/General/DetectorBuilder.cs index fff255b5a..d557c9cfc 100644 --- a/NewHorizons/Builder/General/DetectorBuilder.cs +++ b/NewHorizons/Builder/General/DetectorBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Components.Orbital; using NewHorizons.External.Configs; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System.Collections.Generic; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -81,7 +82,7 @@ public static GameObject Make(GameObject planetGO, OWRigidbody OWRB, AstroObject detectorGO.SetActive(false); detectorGO.transform.parent = planetGO.transform; detectorGO.transform.localPosition = Vector3.zero; - detectorGO.layer = LayerMask.NameToLayer("BasicDetector"); + detectorGO.layer = LayerUtilities.BasicDetector; ConstantForceDetector forceDetector = detectorGO.AddComponent(); forceDetector._inheritElement0 = true; @@ -90,7 +91,7 @@ public static GameObject Make(GameObject planetGO, OWRigidbody OWRB, AstroObject // For falling into sun if (!config.Base.invulnerableToSun && config.Star == null && config.FocalPoint == null) { - detectorGO.layer = LayerMask.NameToLayer("AdvancedDetector"); + detectorGO.layer = LayerUtilities.AdvancedDetector; var fluidDetector = detectorGO.AddComponent(); var sphereCollider = detectorGO.AddComponent(); diff --git a/NewHorizons/Builder/General/GravityBuilder.cs b/NewHorizons/Builder/General/GravityBuilder.cs index 997e7a04f..e90f02d79 100644 --- a/NewHorizons/Builder/General/GravityBuilder.cs +++ b/NewHorizons/Builder/General/GravityBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; +using NewHorizons.Utility.OWUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.General @@ -23,7 +24,7 @@ public static GravityVolume Make(GameObject planetGO, AstroObject ao, OWRigidbod var gravityGO = new GameObject("GravityWell"); gravityGO.transform.parent = planetGO.transform; gravityGO.transform.localPosition = Vector3.zero; - gravityGO.layer = 17; + gravityGO.layer = LayerUtilities.BasicEffectVolume; gravityGO.SetActive(false); var SC = gravityGO.AddComponent(); diff --git a/NewHorizons/Builder/General/RFVolumeBuilder.cs b/NewHorizons/Builder/General/RFVolumeBuilder.cs index 7ea5ab61c..e5dbc6432 100644 --- a/NewHorizons/Builder/General/RFVolumeBuilder.cs +++ b/NewHorizons/Builder/General/RFVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; +using NewHorizons.Utility.OWUtilities; using UnityEngine; namespace NewHorizons.Builder.General { @@ -12,7 +13,7 @@ public static GameObject Make(GameObject planetGO, OWRigidbody owrb, float spher var rfGO = new GameObject("RFVolume"); rfGO.transform.parent = planetGO.transform; rfGO.transform.localPosition = Vector3.zero; - rfGO.layer = 19; + rfGO.layer = LayerUtilities.ReferenceFrameVolume; rfGO.SetActive(false); var SC = rfGO.AddComponent(); diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index f773fc857..acce4bcfd 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using System; using System.Reflection; using UnityEngine; @@ -17,7 +18,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo { GameObject spawnGO = new GameObject("PlayerSpawnPoint"); spawnGO.transform.parent = planetGO.transform; - spawnGO.layer = 8; + spawnGO.layer = LayerUtilities.PlayerSafetyCollider; spawnGO.transform.localPosition = module.playerSpawnPoint; @@ -39,7 +40,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo { GameObject spawnGO = new GameObject("ShipSpawnPoint"); spawnGO.transform.parent = planetGO.transform; - spawnGO.layer = 8; + spawnGO.layer = LayerUtilities.PlayerSafetyCollider; spawnGO.transform.localPosition = module.shipSpawnPoint; @@ -70,7 +71,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo Logger.LogVerbose("Overriding player spawn to be inside ship"); GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint"); playerSpawnGO.transform.parent = ship.transform; - playerSpawnGO.layer = 8; + playerSpawnGO.layer = LayerUtilities.PlayerSafetyCollider; playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0); diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index d412e839e..1daae87b6 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -7,6 +7,7 @@ using NewHorizons.Utility; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Props { @@ -103,7 +104,7 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S var conversationZone = new GameObject("ConversationZone"); conversationZone.SetActive(false); - conversationZone.layer = LayerMask.NameToLayer("Interactible"); + conversationZone.layer = LayerUtilities.Interactible; var sphere = conversationZone.AddComponent(); sphere.radius = info.radius; @@ -259,7 +260,7 @@ private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree var playerTrackingZone = new GameObject("PlayerTrackingZone"); playerTrackingZone.SetActive(false); - playerTrackingZone.layer = LayerMask.NameToLayer("BasicEffectVolume"); + playerTrackingZone.layer = LayerUtilities.BasicEffectVolume; playerTrackingZone.SetActive(false); var sphereCollider = playerTrackingZone.AddComponent(); diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index e7e1423fe..657e6d14a 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -2,7 +2,7 @@ using NewHorizons.Components.Quantum; using NewHorizons.External.Configs; using NewHorizons.External.Modules; -using NewHorizons.Utility.UnityUtilities; +using NewHorizons.Utility.Geometry; using OWML.Common; using System; using System.Collections.Generic; diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 4fa179f38..08ce1a915 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using System; using System.Linq; @@ -86,7 +87,7 @@ internal static void InitPrefabs() if (_shareStonePrefab == null) { GameObject stone = new GameObject("ShareStoneFallback"); - stone.layer = LayerMask.NameToLayer("Interactible"); + stone.layer = LayerUtilities.Interactible; stone.SetActive(false); SphereCollider sc = stone.AddComponent(); sc.center = Vector3.zero; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index b6d0669f0..0e46ba534 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using OWML.Utils; using System.Collections.Generic; @@ -130,7 +131,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.S var pos = (Vector3)(info.position ?? Vector3.zero); if (info.isRelativeToParent) signalGO.transform.localPosition = pos; else signalGO.transform.position = planetGO.transform.TransformPoint(pos); - signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); + signalGO.layer = LayerUtilities.AdvancedEffectVolume; var source = signalGO.AddComponent(); var owAudioSource = signalGO.AddComponent(); diff --git a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs index 1ef745722..b94f3e6da 100644 --- a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs +++ b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs @@ -1,14 +1,13 @@ -using NewHorizons.Utility.UnityUtilities; -using System.Collections; +using NewHorizons.Utility.Geometry; using System.Collections.Generic; using System.Linq; using UnityEngine; -using UnityEngine.Profiling; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Props { - public class NomaiTextArcArranger : MonoBehaviour { + public class NomaiTextArcArranger : MonoBehaviour + { private static int MAX_MOVE_DISTANCE = 2; public List spirals = new List(); @@ -23,7 +22,7 @@ public class NomaiTextArcArranger : MonoBehaviour { public float maxY = 2.6f; public float minY = -1f; - public static SpiralManipulator CreateSpiral(NomaiTextArcBuilder.SpiralProfile profile, GameObject spiralMeshHolder) + public static SpiralManipulator CreateSpiral(NomaiTextArcBuilder.SpiralProfile profile, GameObject spiralMeshHolder) { var rootArc = NomaiTextArcBuilder.BuildSpiralGameObject(profile); rootArc.transform.parent = spiralMeshHolder.transform; @@ -31,7 +30,7 @@ public static SpiralManipulator CreateSpiral(NomaiTextArcBuilder.SpiralProfile p var manip = rootArc.AddComponent(); if (Random.value < 0.5) manip.transform.localScale = new Vector3(-1, 1, 1); // randomly mirror - + // add to arranger var arranger = spiralMeshHolder.GetAddComponent(); if (arranger.root == null) arranger.root = manip; @@ -40,11 +39,11 @@ public static SpiralManipulator CreateSpiral(NomaiTextArcBuilder.SpiralProfile p return manip; } - - public void FDGSimulationStep() + + public void FDGSimulationStep() { - if (updateToposortOnNextStep) - { + if (updateToposortOnNextStep) + { updateToposortOnNextStep = false; GenerateReverseToposort(); } @@ -56,13 +55,13 @@ public void FDGSimulationStep() Vector2 force = Vector2.zero; // accumulate the force the children feel - if (childForces.ContainsKey(s1)) + if (childForces.ContainsKey(s1)) { force += 0.9f * childForces[s1]; } - + // push away from fellow spirals - foreach (var s2 in spirals) + foreach (var s2 in spirals) { if (s1 == s2) continue; if (s1.parent == s2) continue; @@ -74,29 +73,29 @@ public void FDGSimulationStep() var f2 = (s2.localPosition - s1.localPosition); force -= f2 / Mathf.Pow(f2.magnitude, 6); } - + // push away from the edges var MAX_EDGE_PUSH_FORCE = 1; - force += new Vector2(0, -1) * Mathf.Max(0, (s1.transform.localPosition.y + maxY)*(MAX_EDGE_PUSH_FORCE / maxY) - MAX_EDGE_PUSH_FORCE); - force += new Vector2(0, 1) * Mathf.Max(0, (s1.transform.localPosition.y + minY)*(MAX_EDGE_PUSH_FORCE / minY) - MAX_EDGE_PUSH_FORCE); - force += new Vector2(-1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + maxX)*(MAX_EDGE_PUSH_FORCE / maxX) - MAX_EDGE_PUSH_FORCE); - force += new Vector2(1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + minX)*(MAX_EDGE_PUSH_FORCE / minX) - MAX_EDGE_PUSH_FORCE); + force += new Vector2(0, -1) * Mathf.Max(0, (s1.transform.localPosition.y + maxY) * (MAX_EDGE_PUSH_FORCE / maxY) - MAX_EDGE_PUSH_FORCE); + force += new Vector2(0, 1) * Mathf.Max(0, (s1.transform.localPosition.y + minY) * (MAX_EDGE_PUSH_FORCE / minY) - MAX_EDGE_PUSH_FORCE); + force += new Vector2(-1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + maxX) * (MAX_EDGE_PUSH_FORCE / maxX) - MAX_EDGE_PUSH_FORCE); + force += new Vector2(1, 0) * Mathf.Max(0, (s1.transform.localPosition.x + minX) * (MAX_EDGE_PUSH_FORCE / minX) - MAX_EDGE_PUSH_FORCE); // push up just to make everything a little more pretty (this is not neccessary to get an arrangement that simply has no overlap/spirals exiting the bounds) - force += new Vector2(0, 1) * 1; - + force += new Vector2(0, 1) * 1; + // renormalize the force magnitude (keeps force sizes reasonable, and improves stability in the case of small forces) var avg = 1; // the size of vector required to get a medium push var scale = 0.75f; - force = force.normalized * scale * (1 / (1 + Mathf.Exp(avg-force.magnitude)) - 1 / (1 + Mathf.Exp(avg))); // apply a sigmoid-ish smoothing operation, so only giant forces actually move the spirals + force = force.normalized * scale * (1 / (1 + Mathf.Exp(avg - force.magnitude)) - 1 / (1 + Mathf.Exp(avg))); // apply a sigmoid-ish smoothing operation, so only giant forces actually move the spirals // if this is the root spiral, then rotate it instead of trying to move it - if (s1.parent == null) + if (s1.parent == null) { // this is the root spiral, so rotate instead of moving var finalAngle = Mathf.Atan2(force.y, force.x); // root spiral is always at 0, 0 var currentAngle = Mathf.Atan2(s1.center.y, s1.center.x); // root spiral is always at 0, 0 - s1.transform.localEulerAngles = new Vector3(0, 0, finalAngle-currentAngle); + s1.transform.localEulerAngles = new Vector3(0, 0, finalAngle - currentAngle); s1.UpdateChildren(); continue; @@ -105,11 +104,11 @@ public void FDGSimulationStep() // pick the parent point that's closest to center+force, and move to there var spiral = s1; var parentPoints = spiral.parent.GetComponent().GetPoints(); - + var idealPoint = spiral.position + force; var bestPointIndex = 0; var bestPointDistance = 99999999f; - for (var j = SpiralManipulator.MIN_PARENT_POINT; j < SpiralManipulator.MAX_PARENT_POINT && j < parentPoints.Length; j++) + for (var j = SpiralManipulator.MIN_PARENT_POINT; j < SpiralManipulator.MAX_PARENT_POINT && j < parentPoints.Length; j++) { // don't put this spiral on a point already occupied by a sibling if (j != spiral._parentPointIndex && spiral.parent.pointsOccupiedByChildren.Contains(j)) continue; @@ -118,33 +117,34 @@ public void FDGSimulationStep() point = spiral.parent.transform.TransformPoint(point); var dist = Vector2.Distance(point, idealPoint); - if (dist < bestPointDistance) { + if (dist < bestPointDistance) + { bestPointDistance = dist; bestPointIndex = j; } } - + // limit the distance a spiral can move in a single step bestPointIndex = spiral._parentPointIndex + Mathf.Min(MAX_MOVE_DISTANCE, Mathf.Max(-MAX_MOVE_DISTANCE, bestPointIndex - spiral._parentPointIndex)); // minimize step size to help stability - + // actually move the spiral spiral.PlaceOnParentPoint(bestPointIndex); - + // Enforce bounds - if (OutsideBounds(s1)) + if (OutsideBounds(s1)) { var start = s1._parentPointIndex; var originalMirror = s1.Mirrored; var success = AttemptToPushSpiralInBounds(s1, start); - if (!success) + if (!success) { // try flipping it if nothing worked with original mirror state - s1.Mirror(); + s1.Mirror(); success = AttemptToPushSpiralInBounds(s1, start); } - if (!success) + if (!success) { // if we couldn't put it inside the bounds, put it back how we found it (this increases stability of the rest of the spirals) if (s1.Mirrored != originalMirror) s1.Mirror(); @@ -164,22 +164,22 @@ public void GenerateReverseToposort() reverseToposortedSpirals = new List(); Queue frontierQueue = new Queue(); frontierQueue.Enqueue(root); - - while(frontierQueue.Count > 0) + + while (frontierQueue.Count > 0) { var spiral = frontierQueue.Dequeue(); reverseToposortedSpirals.Add(spiral); - - foreach(var child in spiral.children) frontierQueue.Enqueue(child); + + foreach (var child in spiral.children) frontierQueue.Enqueue(child); } - + reverseToposortedSpirals.Reverse(); } #region overlap handling // returns whether there was overlap or not - public bool AttemptOverlapResolution() + public bool AttemptOverlapResolution() { var overlappingSpirals = FindOverlap(); if (overlappingSpirals.x < 0) return false; @@ -195,27 +195,27 @@ public bool AttemptOverlapResolution() return true; } - - public Vector2Int FindOverlap() + + public Vector2Int FindOverlap() { var index = -1; - foreach (var s1 in spirals) + foreach (var s1 in spirals) { index++; if (s1.parent == null) continue; var jndex = -1; - foreach (var s2 in spirals) + foreach (var s2 in spirals) { jndex++; - if (SpiralsOverlap(s1, s2)) return new Vector2Int(index, jndex);; + if (SpiralsOverlap(s1, s2)) return new Vector2Int(index, jndex); ; } } return new Vector2Int(-1, -1); } - public bool SpiralsOverlap(SpiralManipulator s1, SpiralManipulator s2) + public bool SpiralsOverlap(SpiralManipulator s1, SpiralManipulator s2) { if (s1 == s2) return false; if (Vector3.Distance(s1.center, s2.center) > Mathf.Max(s1.NomaiTextLine.GetWorldRadius(), s2.NomaiTextLine.GetWorldRadius())) return false; // no overlap possible - too far away @@ -229,31 +229,32 @@ public bool SpiralsOverlap(SpiralManipulator s1, SpiralManipulator s2) if (s1.parent == s2) s1Points.RemoveAt(0); // don't consider the base points so that we can check if children overlap their parents if (s2.parent == s1) s2Points.RemoveAt(0); // (note: the base point of a child is always exactly overlapping with one of the parent's points) - foreach(var p1 in s1Points) + foreach (var p1 in s1Points) { - foreach(var p2 in s2Points) + foreach (var p2 in s2Points) { - if (Vector3.SqrMagnitude(p1-p2) <= thresholdForOverlap) return true; // s1 and s2 overlap + if (Vector3.SqrMagnitude(p1 - p2) <= thresholdForOverlap) return true; // s1 and s2 overlap } } return false; } - + #endregion overlap handling - + #region bounds handling - public bool OutsideBounds(SpiralManipulator spiral) + public bool OutsideBounds(SpiralManipulator spiral) { var points = spiral.NomaiTextLine.GetPoints() .Select(p => spiral.transform.TransformPoint(p)) .Select(p => spiral.transform.parent.InverseTransformPoint(p)) .ToList(); - foreach(var point in points) { + foreach (var point in points) + { if (point.x < minX || point.x > maxX || - point.y < minY || point.y > maxY) + point.y < minY || point.y > maxY) { return true; } @@ -262,29 +263,29 @@ public bool OutsideBounds(SpiralManipulator spiral) return false; } - private bool AttemptToPushSpiralInBounds(SpiralManipulator s1, int start) + private bool AttemptToPushSpiralInBounds(SpiralManipulator s1, int start) { - var range = Mathf.Max(start-SpiralManipulator.MIN_PARENT_POINT, SpiralManipulator.MAX_PARENT_POINT-start); + var range = Mathf.Max(start - SpiralManipulator.MIN_PARENT_POINT, SpiralManipulator.MAX_PARENT_POINT - start); for (var i = 1; i <= range; i++) { - if (start-i >= SpiralManipulator.MIN_PARENT_POINT) - { - s1.PlaceOnParentPoint(start-i); + if (start - i >= SpiralManipulator.MIN_PARENT_POINT) + { + s1.PlaceOnParentPoint(start - i); if (!OutsideBounds(s1)) return true; } - - if (start+i <= SpiralManipulator.MAX_PARENT_POINT) - { - s1.PlaceOnParentPoint(start+i); + + if (start + i <= SpiralManipulator.MAX_PARENT_POINT) + { + s1.PlaceOnParentPoint(start + i); if (!OutsideBounds(s1)) return true; } } return false; } - - public void DrawBoundsWithDebugSpheres() + + public void DrawBoundsWithDebugSpheres() { AddDebugShape.AddSphere(this.gameObject, 0.1f, Color.green).transform.localPosition = new Vector3(minX, minY, 0); AddDebugShape.AddSphere(this.gameObject, 0.1f, Color.green).transform.localPosition = new Vector3(minX, maxY, 0); @@ -292,17 +293,18 @@ public void DrawBoundsWithDebugSpheres() AddDebugShape.AddSphere(this.gameObject, 0.1f, Color.green).transform.localPosition = new Vector3(maxX, minY, 0); AddDebugShape.AddSphere(this.gameObject, 0.1f, Color.red).transform.localPosition = new Vector3(0, 0, 0); } - + #endregion bounds handling } - public class SpiralManipulator : MonoBehaviour { + public class SpiralManipulator : MonoBehaviour + { public SpiralManipulator parent; public List children = new List(); public HashSet pointsOccupiedByChildren = new HashSet(); public int _parentPointIndex = -1; - + public static int MIN_PARENT_POINT = 3; public static int MAX_PARENT_POINT = 26; @@ -311,32 +313,33 @@ public class SpiralManipulator : MonoBehaviour { public bool Mirrored { get { return this.transform.localScale.x < 0; } } private NomaiTextLine _NomaiTextLine; - public NomaiTextLine NomaiTextLine + public NomaiTextLine NomaiTextLine { - get + get { if (_NomaiTextLine == null) _NomaiTextLine = GetComponent(); return _NomaiTextLine; } } - public Vector2 center - { - get { return NomaiTextLine.GetWorldCenter(); } + public Vector2 center + { + get { return NomaiTextLine.GetWorldCenter(); } } - public Vector2 localPosition + public Vector2 localPosition { get { return new Vector2(this.transform.localPosition.x, this.transform.localPosition.y); } } - public Vector2 position + public Vector2 position { get { return new Vector2(this.transform.position.x, this.transform.position.y); } } - + #endregion properties - - public SpiralManipulator AddChild(NomaiTextArcBuilder.SpiralProfile profile) { + + public SpiralManipulator AddChild(NomaiTextArcBuilder.SpiralProfile profile) + { var child = NomaiTextArcArranger.CreateSpiral(profile, this.transform.parent.gameObject); var index = Random.Range(MIN_PARENT_POINT, MAX_PARENT_POINT); @@ -348,33 +351,33 @@ public Vector2 position return child; } - public void Mirror() - { + public void Mirror() + { this.transform.localScale = new Vector3(-this.transform.localScale.x, 1, 1); if (this.parent != null) this.PlaceOnParentPoint(this._parentPointIndex); } - - public void UpdateChildren() + + public void UpdateChildren() { - foreach(var child in this.children) + foreach (var child in this.children) { child.PlaceOnParentPoint(child._parentPointIndex); } } - public int PlaceOnParentPoint(int parentPointIndex, bool updateChildren=true) + public int PlaceOnParentPoint(int parentPointIndex, bool updateChildren = true) { // validate var _points = parent.GetComponent().GetPoints(); - parentPointIndex = Mathf.Max(0, Mathf.Min(parentPointIndex, _points.Length-1)); - + parentPointIndex = Mathf.Max(0, Mathf.Min(parentPointIndex, _points.Length - 1)); + // track occupied points if (this._parentPointIndex != -1) parent.pointsOccupiedByChildren.Remove(this._parentPointIndex); this._parentPointIndex = parentPointIndex; parent.pointsOccupiedByChildren.Add(parentPointIndex); // calculate the normal - var normal = _points[Mathf.Min(parentPointIndex+1, _points.Length-1)] - _points[Mathf.Max(parentPointIndex-1, 0)]; + var normal = _points[Mathf.Min(parentPointIndex + 1, _points.Length - 1)] - _points[Mathf.Max(parentPointIndex - 1, 0)]; if (parent.transform.localScale.x < 0) normal = new Vector3(normal.x, -normal.y, -normal.z); float rot = Mathf.Atan2(normal.y, normal.x) * Mathf.Rad2Deg; diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 533d5fa31..a712a3f03 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -1,20 +1,18 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; -using OWML.Common; +using NewHorizons.Utility.Geometry; +using NewHorizons.Utility.OWMLUtilities; +using Newtonsoft.Json; +using OWML.Utils; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml; using UnityEngine; -using Enum = System.Enum; using Logger = NewHorizons.Utility.Logger; using Random = UnityEngine.Random; -using OWML.Utils; -using Newtonsoft.Json; -using System; -using NewHorizons.Utility.OWMLUtilities; -using NewHorizons.Utility.UnityUtilities; namespace NewHorizons.Builder.Props { diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 87c2e1034..a4f0b0c19 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components.Achievement; using NewHorizons.External.Modules; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -122,7 +123,7 @@ private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.Reve private static void MakeObservable(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { - go.layer = LayerMask.NameToLayer("Interactible"); + go.layer = LayerUtilities.Interactible; var sphere = go.AddComponent(); sphere.radius = info.radius; diff --git a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs index 0ef97d835..aa6231b71 100644 --- a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs +++ b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs @@ -1,15 +1,15 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using OWML.Common; -using System; using UnityEngine; using Logger = NewHorizons.Utility.Logger; + namespace NewHorizons.Builder.StarSystem { public static class SkyboxBuilder { - private static readonly int _skyboxLayer = LayerMask.NameToLayer("Skybox"); private static readonly Shader _unlitShader = Shader.Find("Unlit/Texture"); public static void Make(StarSystemConfig.SkyboxModule module, IModBehaviour mod) @@ -33,7 +33,7 @@ public static GameObject BuildSkySphere(StarSystemConfig.SkyboxModule module, IM var skySphere = new GameObject("Sky Sphere"); skySphere.transform.SetParent(skybox.transform, false); - skySphere.layer = _skyboxLayer; + skySphere.layer = LayerUtilities.Skybox; skySphere.transform.localScale = Vector3.one * 5f; BuildSkySphereFace(skySphere, "Right", Quaternion.Euler(0f, 90f, 0f), mesh, rightTex); @@ -56,7 +56,7 @@ public static GameObject BuildSkySphereFace(GameObject skySphere, string name, Q var go = new GameObject(name) { - layer = _skyboxLayer + layer = LayerUtilities.Skybox }; var mf = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 8711ddf78..8bf31a785 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using OWML.Utils; using System; @@ -42,7 +43,7 @@ public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule var pos = (Vector3)(info.position ?? Vector3.zero); if (info.isRelativeToParent) go.transform.localPosition = pos; else go.transform.position = planetGO.transform.TransformPoint(pos); - go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); + go.layer = LayerUtilities.AdvancedEffectVolume; var audioSource = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index 23a4f1bba..f1c9495bb 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using OWML.Utils; using System; @@ -39,7 +40,7 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody var pos = (Vector3)(info.position ?? Vector3.zero); if (info.isRelativeToParent) go.transform.localPosition = pos; else go.transform.position = planetGO.transform.TransformPoint(pos); - go.layer = LayerMask.NameToLayer("BasicEffectVolume"); + go.layer = LayerUtilities.BasicEffectVolume; var shape = go.AddComponent(); shape.radius = info.radius; @@ -74,7 +75,7 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody var detectorGO = new GameObject("ConstantFluidDetector"); detectorGO.transform.parent = go.transform; detectorGO.transform.localPosition = Vector3.zero; - detectorGO.layer = LayerMask.NameToLayer("BasicDetector"); + detectorGO.layer = LayerUtilities.BasicDetector; var detector = detectorGO.AddComponent(); detector._onlyDetectableFluid = water; detector._buoyancy.boundingRadius = 1; diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index 1e3f07b86..957e5f0e2 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using System; using System.Collections.Generic; @@ -42,7 +43,7 @@ public static NHNotificationVolume Make(GameObject planetGO, Sector sector, Volu var pos = (Vector3)(info.position ?? Vector3.zero); if (info.isRelativeToParent) go.transform.localPosition = pos; else go.transform.position = planetGO.transform.TransformPoint(pos); - go.layer = LayerMask.NameToLayer("BasicEffectVolume"); + go.layer = LayerUtilities.BasicEffectVolume; var shape = go.AddComponent(); shape.radius = info.radius; diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index 2048159fa..ff2abdad3 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components; using NewHorizons.External.Modules; +using NewHorizons.Utility.OWUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -35,7 +36,7 @@ public static class VanishVolumeBuilder var pos = (Vector3)(info.position ?? Vector3.zero); if (info.isRelativeToParent) go.transform.localPosition = pos; else go.transform.position = planetGO.transform.TransformPoint(pos); - go.layer = LayerMask.NameToLayer("BasicEffectVolume"); + go.layer = LayerUtilities.BasicEffectVolume; var collider = go.AddComponent(); collider.isTrigger = true; diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index cc35c636c..ae4944181 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components; using NewHorizons.External.Modules; +using NewHorizons.Utility.OWUtilities; using UnityEngine; using Logger = NewHorizons.Utility.Logger; @@ -35,7 +36,7 @@ public static class VolumeBuilder var pos = (Vector3)(info.position ?? Vector3.zero); if (info.isRelativeToParent) go.transform.localPosition = pos; else go.transform.position = planetGO.transform.TransformPoint(pos); - go.layer = LayerMask.NameToLayer("BasicEffectVolume"); + go.layer = LayerUtilities.BasicEffectVolume; var shape = go.AddComponent(); shape.radius = info.radius; diff --git a/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs b/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs index 1a6acf5fe..f0c0a51f8 100644 --- a/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs +++ b/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs @@ -1,4 +1,5 @@ using NewHorizons.OtherMods.AchievementsPlus; +using NewHorizons.Utility.OWUtilities; using System; using System.Collections.Generic; using System.Linq; @@ -20,7 +21,7 @@ public class AchievementObserveTrigger : MonoBehaviour, IObservable private void Reset() { - gameObject.layer = LayerMask.NameToLayer("Interactible"); + gameObject.layer = LayerUtilities.Interactible; } private void Awake() diff --git a/NewHorizons/Components/AddPhysics.cs b/NewHorizons/Components/AddPhysics.cs index 14785f9f9..8f614994b 100644 --- a/NewHorizons/Components/AddPhysics.cs +++ b/NewHorizons/Components/AddPhysics.cs @@ -1,4 +1,5 @@ -using System.Collections; +using NewHorizons.Utility.OWUtilities; +using System.Collections; using UnityEngine; namespace NewHorizons.Components; @@ -38,7 +39,7 @@ private IEnumerator Start() var owRigidbody = bodyGo.AddComponent(); owRigidbody._simulateInSector = Sector; - bodyGo.layer = LayerMask.NameToLayer("PhysicalDetector"); + bodyGo.layer = LayerUtilities.PhysicalDetector; bodyGo.tag = "DynamicPropDetector"; // this collider is not included in groups. oh well bodyGo.AddComponent().radius = Radius; diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index a8518b84e..1538d7bb4 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -16,6 +16,8 @@ using NewHorizons.Utility; using NewHorizons.Utility.DebugMenu; using NewHorizons.Utility.DebugUtilities; +using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using OWML.ModHelper; using OWML.Utils; diff --git a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs index d8a65a6b5..03542ecc5 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs @@ -1,7 +1,5 @@ -using NewHorizons.Builder.Props; -using NewHorizons.External.Modules; using NewHorizons.Handlers; -using NewHorizons.Utility.UnityUtilities; +using NewHorizons.Utility.Geometry; using UnityEngine; using UnityEngine.InputSystem; @@ -32,7 +30,7 @@ private void Start() Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false); } } - + private void OnDestroy() { if (_raycastPrompt != null) @@ -79,14 +77,14 @@ internal void PrintRaycast() var posText = Vector3ToString(data.pos); var normText = Vector3ToString(data.norm); var rotText = Vector3ToString(data.rot.eulerAngles); - - if(_surfaceSphere != null) GameObject.Destroy(_surfaceSphere); - if(_normalSphere1 != null) GameObject.Destroy(_normalSphere1); - if(_normalSphere2 != null) GameObject.Destroy(_normalSphere2); - if(_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere ); - if(_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere ); - if(_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere ); - if(_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere); + + if (_surfaceSphere != null) GameObject.Destroy(_surfaceSphere); + if (_normalSphere1 != null) GameObject.Destroy(_normalSphere1); + if (_normalSphere2 != null) GameObject.Destroy(_normalSphere2); + if (_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere); + if (_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere); + if (_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere); + if (_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere); _surfaceSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.1f, Color.green); _normalSphere1 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red); @@ -95,22 +93,22 @@ internal void PrintRaycast() _surfaceSphere.transform.localPosition = data.pos; _normalSphere1.transform.localPosition = data.pos + data.norm * 0.5f; _normalSphere2.transform.localPosition = data.pos + data.norm; - + // plane corners var planeSize = 0.5f; var planePointSize = 0.05f; - _planeUpRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.green); - _planeUpLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan) ; - _planeDownLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.blue) ; - _planeDownRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan) ; - - _planeUpRightSphere .transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*1*planeSize; - _planeUpLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*1*planeSize; - _planeDownLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*-1*planeSize; - _planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*-1*planeSize; + _planeUpRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.green); + _planeUpLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan); + _planeDownLeftSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.blue); + _planeDownRightSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, planePointSize, Color.cyan); + + _planeUpRightSphere.transform.localPosition = data.plane.origin + data.plane.u * 1 * planeSize + data.plane.v * 1 * planeSize; + _planeUpLeftSphere.transform.localPosition = data.plane.origin + data.plane.u * -1 * planeSize + data.plane.v * 1 * planeSize; + _planeDownLeftSphere.transform.localPosition = data.plane.origin + data.plane.u * -1 * planeSize + data.plane.v * -1 * planeSize; + _planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u * 1 * planeSize + data.plane.v * -1 * planeSize; Logger.Log($"Raycast hit\n\n\"position\": {posText},\n\"rotation\": {rotText},\n\"normal\": {normText}\n\non collider [{data.colliderPath}] " + - (data.bodyPath != null? $"at rigidbody [{data.bodyPath}]" : "not attached to a rigidbody")); + (data.bodyPath != null ? $"at rigidbody [{data.bodyPath}]" : "not attached to a rigidbody")); } internal DebugRaycastData Raycast() { @@ -132,12 +130,12 @@ internal DebugRaycastData Raycast() var toOrigin = Vector3.ProjectOnPlane((origin - hitInfo.point).normalized, hitInfo.normal); var worldSpaceRot = Quaternion.LookRotation(toOrigin, hitInfo.normal); data.rot = hitInfo.rigidbody.transform.InverseTransformRotation(worldSpaceRot); - + data.colliderPath = hitInfo.collider.transform.GetPath(); data.bodyPath = hitInfo.rigidbody.transform.GetPath(); data.hitBodyGameObject = hitInfo.rigidbody.gameObject; data.hitObject = hitInfo.collider.gameObject; - + data.plane = ConstructPlane(data); } } @@ -155,7 +153,7 @@ internal DebugRaycastPlane ConstructPlane(DebugRaycastData data) var U = data.pos - Vector3.zero; // U is the local "up" direction. the direction directly away from the center of the planet at this point. // pos is always relative to the body, so the body is considered to be at 0,0,0. var R = data.pos; // R is our origin point for the plane var N = data.norm.normalized; // N is the normal for this plane - + if (Vector3.Cross(U, N) == Vector3.zero) U = new Vector3(0, 0, 1); if (Vector3.Cross(U, N) == Vector3.zero) U = new Vector3(0, 1, 0); // if 0,0,1 was actually the same vector U already was (lol), try (0,1,0) instead @@ -163,11 +161,11 @@ internal DebugRaycastPlane ConstructPlane(DebugRaycastData data) // stackoverflow.com/a/9605695 // I don't know exactly how this works, but I'm projecting a point that is located above the plane's origin, relative to the planet, onto the plane. this gets us our v vector - var q = (2*U)-R; + var q = (2 * U) - R; var dist = Vector3.Dot(N, q); - var v_raw = 2*U - dist*N; - var v = (R-v_raw).normalized; - + var v_raw = 2 * U - dist * N; + var v = (R - v_raw).normalized; + var u = Vector3.Cross(N, v); DebugRaycastPlane p = new DebugRaycastPlane() diff --git a/NewHorizons/Utility/Geometry/AddDebugShape.cs b/NewHorizons/Utility/Geometry/AddDebugShape.cs index 53a4af5db..d917d8729 100644 --- a/NewHorizons/Utility/Geometry/AddDebugShape.cs +++ b/NewHorizons/Utility/Geometry/AddDebugShape.cs @@ -1,5 +1,5 @@ using UnityEngine; -namespace NewHorizons.Utility.UnityUtilities +namespace NewHorizons.Utility.Geometry { public static class AddDebugShape { From 8d985fe169e2e6c0d4bce358488a6913388469fb Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 17:38:55 -0400 Subject: [PATCH 048/119] Fixed coroutine --- .../Components/Volumes/LoadCreditsVolume.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index acd07eebb..dd2d83eeb 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -2,6 +2,7 @@ using NewHorizons.Handlers; using System.Collections; using UnityEngine; +using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components.Volumes { @@ -25,7 +26,8 @@ public override void OnTriggerVolumeEntry(GameObject hitObj) { if (hitObj.CompareTag("PlayerDetector") && enabled) { - StartCoroutine(GameOver()); + // Have to run it off the mod behaviour since the game over controller disables everything + Main.Instance.StartCoroutine(GameOver()); } } @@ -36,6 +38,9 @@ private IEnumerator GameOver() Locator.GetPromptManager().SetPromptsVisible(false); Locator.GetPauseCommandListener().AddPauseCommandLock(); + // The PlayerCameraEffectController is what actually kills us, so convince it we're already dead + Locator.GetDeathManager()._isDead = true; + _playerCameraEffectController.OnPlayerDeath(deathType); yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength); @@ -49,13 +54,9 @@ private IEnumerator GameOver() _gameOverController._loading = true; yield return new WaitUntil(ReadytoLoadCreditsScene); - - LoadCreditsScene(); - } - else - { - LoadCreditsScene(); } + + LoadCreditsScene(); } private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete(); @@ -64,6 +65,8 @@ private IEnumerator GameOver() private void LoadCreditsScene() { + Logger.LogVerbose($"Load credits {creditsType}"); + switch (creditsType) { case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast: From 85758d6a87976319ca99ce8c4e085fde8643c839 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 17:49:05 -0400 Subject: [PATCH 049/119] Fix the DeathType --- NewHorizons/External/Modules/VolumesModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/External/Modules/VolumesModule.cs b/NewHorizons/External/Modules/VolumesModule.cs index 76257e486..e71828968 100644 --- a/NewHorizons/External/Modules/VolumesModule.cs +++ b/NewHorizons/External/Modules/VolumesModule.cs @@ -180,7 +180,7 @@ public enum CreditsType /// /// The type of death the player will have if they enter this volume. /// - [DefaultValue("default")] public DeathType deathType = DeathType.Default; + [DefaultValue("default")] public DestructionVolumeInfo.DeathType deathType = DestructionVolumeInfo.DeathType.Default; } [JsonObject] From fe9082d0ff287b85fe83f5c2add374ec53bb8dd0 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 18 Mar 2023 21:51:19 +0000 Subject: [PATCH 050/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 624fc8218..c768e6a50 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -3890,6 +3890,15 @@ "creditsType": { "default": "fast", "$ref": "#/definitions/CreditsType" + }, + "gameOverText": { + "type": "string", + "description": "Text displayed in orange on game over. For localization, put translations under UI." + }, + "deathType": { + "description": "The type of death the player will have if they enter this volume.", + "default": "default", + "$ref": "#/definitions/DeathType" } } }, From ace2c7898599782bc338d410d21b673487e6768e Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 16:53:48 -0500 Subject: [PATCH 051/119] Switch to planetGO and sector for GeneralPropBuilder --- .../Builder/Body/SingularityBuilder.cs | 2 +- .../Builder/General/SpawnPointBuilder.cs | 4 +- .../Builder/Props/BrambleNodeBuilder.cs | 2 +- NewHorizons/Builder/Props/DetailBuilder.cs | 4 +- NewHorizons/Builder/Props/DialogueBuilder.cs | 4 +- .../Builder/Props/GeneralPropBuilder.cs | 47 ++++++++++++------- NewHorizons/Builder/Props/GeyserBuilder.cs | 2 +- .../Builder/Props/ProjectionBuilder.cs | 4 +- NewHorizons/Builder/Props/QuantumBuilder.cs | 2 +- NewHorizons/Builder/Props/RaftBuilder.cs | 2 +- NewHorizons/Builder/Props/RemoteBuilder.cs | 2 +- NewHorizons/Builder/Props/SignalBuilder.cs | 2 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 2 +- .../TranslatorText/TranslatorTextBuilder.cs | 10 ++-- NewHorizons/Builder/Props/VolcanoBuilder.cs | 2 +- .../Builder/ShipLog/EntryLocationBuilder.cs | 2 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 2 +- .../Builder/Volumes/AudioVolumeBuilder.cs | 2 +- .../Builder/Volumes/HazardVolumeBuilder.cs | 2 +- .../Volumes/NotificationVolumeBuilder.cs | 2 +- .../Builder/Volumes/VanishVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 2 +- NewHorizons/Handlers/VesselWarpHandler.cs | 4 +- 23 files changed, 61 insertions(+), 48 deletions(-) diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 97c530103..1f913ec92 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -149,7 +149,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam rename = rename, }; - var singularity = GeneralPropBuilder.MakeNew(polarity ? "BlackHole" : "WhiteHole", sector?.transform ?? planetGO.transform, info); + var singularity = GeneralPropBuilder.MakeNew(polarity ? "BlackHole" : "WhiteHole", planetGO, sector, info); var singularityRenderer = MakeSingularityGraphics(singularity, polarity, horizon, distort, renderQueue); diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 7c1421eb5..e4291196b 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -17,7 +17,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && module.playerSpawn != null) { bool alignToBody = module.playerSpawn.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO.transform, module.playerSpawn, alignToBody); + GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn, alignToBody: alignToBody); spawnGO.layer = 8; playerSpawn = spawnGO.AddComponent(); @@ -28,7 +28,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo if (module.shipSpawn != null) { bool alignToBody = module.shipSpawn.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO.transform, module.shipSpawn, alignToBody); + GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, module.shipSpawn, alignToBody: alignToBody); spawnGO.layer = 8; var spawnPoint = spawnGO.AddComponent(); diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 4a836fb4b..89c78c6c4 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -182,7 +182,7 @@ public static GameObject Make(GameObject go, Sector sector, BrambleNodeInfo conf var prefab = config.isSeed ? _brambleSeedPrefab : _brambleNodePrefab; // Spawn the bramble node - var brambleNode = GeneralPropBuilder.MakeFromPrefab(prefab, config.name ?? "Bramble Node to " + config.linksTo, sector?.transform ?? go.transform, config); + var brambleNode = GeneralPropBuilder.MakeFromPrefab(prefab, config.name ?? "Bramble Node to " + config.linksTo, go, sector, config); foreach (var collider in brambleNode.GetComponentsInChildren(true)) { collider.enabled = true; diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 88aa7db54..da7329704 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -90,12 +90,12 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P // We save copies with all their components fixed, good if the user is placing the same detail more than once if (detail?.path != null && _fixedPrefabCache.TryGetValue((sector, detail.path), out var storedPrefab)) { - prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, sector?.transform ?? go.transform, detail, detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail, alignToBody: detail.alignToNormal); isItem = storedPrefab.isItem; } else { - prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, sector?.transform ?? go.transform, detail, detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail, alignToBody: detail.alignToNormal); StreamingHandler.SetUpStreaming(prop, sector); diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index f81d8ac29..86d9b33d1 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -40,7 +40,7 @@ public static (CharacterDialogueTree, RemoteDialogueTrigger) Make(GameObject go, private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue) { - var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", sector?.transform ?? planetGO.transform, info.remoteTrigger, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); + var conversationTrigger = GeneralPropBuilder.MakeNew("ConversationTrigger", planetGO, sector, info.remoteTrigger, defaultPosition: info.position, defaultParentPath: info.pathToAnimController); var remoteDialogueTrigger = conversationTrigger.AddComponent(); var sphereCollider = conversationTrigger.AddComponent(); @@ -71,7 +71,7 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, IModHelper mod) { - var conversationZone = GeneralPropBuilder.MakeNew("ConversationZone", sector?.transform ?? planetGO.transform, info, defaultParentPath: info.pathToAnimController); + var conversationZone = GeneralPropBuilder.MakeNew("ConversationZone", planetGO, sector, info, defaultParentPath: info.pathToAnimController); conversationZone.layer = LayerMask.NameToLayer("Interactible"); diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 299b94655..b1bf4b84b 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,17 +12,21 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform defaultParent = null) { if (info == null) return go; + go.transform.parent = defaultParent ?? sector?.transform ?? planetGO?.transform; + if (info is GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) { // This can fail if the prop is built before the target planet. Only use it for SolarSystem module props var targetPlanet = AstroObjectLocator.GetAstroObject(solarSystemInfo.parentBody); if (targetPlanet != null) { - parent = targetPlanet._rootSector?.transform ?? targetPlanet.transform; + planetGO = targetPlanet.gameObject; + sector = targetPlanet.GetRootSector() ?? targetPlanet.GetComponentInChildren(); + go.transform.parent = sector?.transform ?? planetGO?.transform ?? go.transform.parent; } else { Logger.LogError($"Cannot find parent body named {solarSystemInfo.parentBody}"); @@ -34,20 +38,19 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, Gener go.name = info.rename; } - go.transform.parent = parent; - var parentPath = info.parentPath ?? defaultParentPath; - if (parent && !string.IsNullOrEmpty(parentPath)) + if (planetGO && !string.IsNullOrEmpty(parentPath)) { - var newParent = parent.root.transform.Find(parentPath); + var newParent = planetGO.transform.Find(parentPath); if (newParent != null) { - go.transform.parent = newParent.transform; + go.transform.parent = newParent; + sector = newParent.GetComponentInParent(); } else { - Logger.LogError($"Cannot find parent object at path: {parent.name}/{parentPath}"); + Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{parentPath}"); } } @@ -61,10 +64,10 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, Gener { go.transform.localPosition = pos; go.transform.localRotation = rot; - } else if (parent) + } else if (planetGO) { - go.transform.position = parent.root.transform.TransformPoint(pos); - go.transform.rotation = parent.root.transform.TransformRotation(rot); + go.transform.position = planetGO.transform.TransformPoint(pos); + go.transform.rotation = planetGO.transform.TransformRotation(rot); } else { go.transform.position = pos; @@ -72,25 +75,35 @@ public static GameObject MakeFromExisting(GameObject go, Transform parent, Gener } if (alignToBody) { - var up = (go.transform.position - parent.root.position).normalized; - if (normal != null) up = parent.TransformDirection(normal); + var up = (go.transform.position - planetGO.transform.position).normalized; + if (normal != null) + { + if (info.isRelativeToParent) + { + up = go.transform.parent.TransformDirection(normal); + } + else + { + up = planetGO.transform.TransformDirection(normal); + } + } go.transform.rotation = Quaternion.FromToRotation(go.transform.up, up) * rot; } return go; } - public static GameObject MakeNew(string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform defaultParent = null) { var go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, defaultParent); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, Transform parent, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform defaultParent = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, parent, info, alignToBody, normal, defaultPosition, defaultParentPath); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, defaultParent); } } } diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index e98d41d90..a34f7c900 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -18,7 +18,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf { InitPrefab(); - var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", sector?.transform ?? planetGO.transform, info); + var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", planetGO, sector, info); var pos = planetGO.transform.InverseTransformPoint(geyserGO.transform.position); diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index d7fd2668c..19e1225ff 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -93,7 +93,7 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Prop if (_slideReelPrefab == null) return null; - var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", sector?.transform ?? planetGO.transform, info); + var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info); var slideReel = slideReelObj.GetComponent(); slideReel.SetSector(sector); @@ -166,7 +166,7 @@ public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, P if (_autoPrefab == null) return null; - var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", sector?.transform ?? planetGO.transform, info); + var projectorObj = GeneralPropBuilder.MakeFromPrefab(_autoPrefab, $"Prefab_IP_AutoProjector_{mod.ModHelper.Manifest.Name}", planetGO, sector, info); var autoProjector = projectorObj.GetComponent(); autoProjector._sector = sector; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 0697c5a0a..e563818f2 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,7 +50,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = GeneralPropBuilder.MakeNew("Socket " + i, groupRoot.transform, socketInfo); + var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, defaultParent: groupRoot.transform); sockets[i] = socket.AddComponent(); sockets[i]._lightSources = new Light[0]; diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index 663fa27e1..4440dbfab 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -52,7 +52,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Raf if (_prefab == null || sector == null) return null; - GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", sector?.transform ?? planetGO.transform, info); + GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info); StreamingHandler.SetUpStreaming(raftObject, sector); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 75e273748..2f77e21ae 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -251,7 +251,7 @@ public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraP public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.StoneInfo info, IModBehaviour mod) { - var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), sector?.transform ?? go.transform, info); + var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), go, sector, info); shareStone.GetComponent()._connectedPlatform = id; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 1665c33cc..2cbf1118a 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -109,7 +109,7 @@ public static string GetCustomSignalName(SignalName signalName) public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) { - var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", sector?.transform ?? planetGO.transform, info); + var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", planetGO, sector, info); signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var source = signalGO.AddComponent(); diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 1aad9a6e8..4fbf081d6 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -99,7 +99,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoIn private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); - var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", sector?.transform ?? planetGO.transform, info, true, defaultPosition: position); + var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true, defaultPosition: position); // Add the sound thing before changing the scale var soundGO = _soundPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 1d4a29fcc..ea1bd2bcd 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -161,7 +161,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { - var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, sector?.transform ?? planetGO.transform, info); + var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); nomaiWallText.transform.parent = customScroll.transform; @@ -213,7 +213,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Computer: { - var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, sector?.transform ?? planetGO.transform, info, true, info.normal); + var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info, alignToBody: true, normal: info.normal); var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -286,7 +286,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: { var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; - var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); + var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); // Idk do we have to set it active before finding things? cairnObject.SetActive(true); @@ -349,7 +349,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: { - var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, sector?.transform ?? planetGO.transform, info, info.rotation == null); + var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); // shrink because that is what mobius does on all trailmarkers or else they are the size of the player trailmarkerObject.transform.localScale = Vector3.one * 0.75f; @@ -380,7 +380,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) { - GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", sector?.transform ?? go.transform, info); + GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", go, sector, info); var box = nomaiWallTextObj.AddComponent(); box.center = new Vector3(-0.0643f, 1.1254f, 0f); diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index ced0ad9c2..af0224256 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -45,7 +45,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoIn { InitPrefab(); - var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", sector?.transform ?? planetGO.transform, info, true); + var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info, alignToBody: true); var meteorLauncher = launcherGO.GetComponent(); meteorLauncher._audioSector = sector; diff --git a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs index 7f6d591f2..ace39be31 100644 --- a/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs +++ b/NewHorizons/Builder/ShipLog/EntryLocationBuilder.cs @@ -12,7 +12,7 @@ public static class EntryLocationBuilder private static readonly List _locationsToInitialize = new List(); public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModBehaviour mod) { - GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", sector?.transform ?? go.transform, info); + GameObject entryLocationGameObject = GeneralPropBuilder.MakeNew("Entry Location (" + info.id + ")", go, sector, info); ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent(); newLocation._entryID = info.id; diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index 349c3649a..76fff0398 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -10,7 +10,7 @@ public static class RevealBuilder { public static void Make(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { - var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", sector?.transform ?? go.transform, info); + var newRevealGO = GeneralPropBuilder.MakeNew("Reveal Volume (" + info.revealOn + ")", go, sector, info); switch (info.revealOn) { case VolumesModule.RevealVolumeInfo.RevealVolumeType.Enter: diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 34269fe67..1a5f2f2ab 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -17,7 +17,7 @@ public static class AudioVolumeBuilder { public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule.AudioVolumeInfo info, IModBehaviour mod) { - var go = GeneralPropBuilder.MakeNew("AudioVolume", sector?.transform ?? planetGO.transform, info); + var go = GeneralPropBuilder.MakeNew("AudioVolume", planetGO, sector, info); go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); var audioSource = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index bb82013ce..3a12aeb2a 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -14,7 +14,7 @@ public static class HazardVolumeBuilder { public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod) { - var go = GeneralPropBuilder.MakeNew("HazardVolume", sector?.transform ?? planetGO.transform, info); + var go = GeneralPropBuilder.MakeNew("HazardVolume", planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index 574aa6daa..d9d6fa02a 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -17,7 +17,7 @@ public static class NotificationVolumeBuilder { public static NHNotificationVolume Make(GameObject planetGO, Sector sector, VolumesModule.NotificationVolumeInfo info, IModBehaviour mod) { - var go = GeneralPropBuilder.MakeNew("NotificationVolume", sector?.transform ?? planetGO.transform, info); + var go = GeneralPropBuilder.MakeNew("NotificationVolume", planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index 23628b122..fd625ccbb 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -10,7 +10,7 @@ public static class VanishVolumeBuilder { public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VanishVolumeInfo info) where TVolume : VanishVolume { - var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); + var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var collider = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index 8d29c9a95..a94a6c23e 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -10,7 +10,7 @@ public static class VolumeBuilder { public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. { - var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, sector?.transform ?? planetGO.transform, info); + var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); go.layer = LayerMask.NameToLayer("BasicEffectVolume"); var shape = go.AddComponent(); diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index f88dfb201..7cdda9a1d 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -85,7 +85,7 @@ public static EyeSpawnPoint CreateVessel() if (VesselPrefab == null) return null; Logger.LogVerbose("Creating Vessel"); - var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, system.Config.Vessel?.vesselSpawn); + var vesselObject = GeneralPropBuilder.MakeFromPrefab(VesselPrefab, VesselPrefab.name, null, null, system.Config.Vessel?.vesselSpawn); VesselObject = vesselObject; var vesselAO = vesselObject.AddComponent(); @@ -146,7 +146,7 @@ public static EyeSpawnPoint CreateVessel() var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false; var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent; - var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, attachWarpExitToVessel ? warpExitParent : null, system.Config.Vessel?.warpExit); + var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, null, null, system.Config.Vessel?.warpExit, defaultParent: attachWarpExitToVessel ? warpExitParent : null); if (attachWarpExitToVessel) { warpExit.transform.parent = warpExitParent; From 3c5b3c403ddf5f30b2a5d04c7efce7cb2297e1ec Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 15:03:19 -0700 Subject: [PATCH 052/119] rename to parentOverride since it overrides planetgo and sector --- .../Builder/Props/GeneralPropBuilder.cs | 30 +++++++++++++------ NewHorizons/Builder/Props/QuantumBuilder.cs | 2 +- NewHorizons/Handlers/VesselWarpHandler.cs | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index b1bf4b84b..55bfaf9b7 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -12,11 +12,14 @@ namespace NewHorizons.Builder.Props { public static class GeneralPropBuilder { - public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform defaultParent = null) + public static GameObject MakeFromExisting(GameObject go, + GameObject planetGO, Sector sector, GeneralPointPropInfo info, + bool alignToBody = false, MVector3 normal = null, + MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { if (info == null) return go; - go.transform.parent = defaultParent ?? sector?.transform ?? planetGO?.transform; + go.transform.parent = parentOverride ?? sector?.transform ?? planetGO?.transform; if (info is GeneralSolarSystemPropInfo solarSystemInfo && !string.IsNullOrEmpty(solarSystemInfo.parentBody)) { @@ -27,7 +30,8 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se planetGO = targetPlanet.gameObject; sector = targetPlanet.GetRootSector() ?? targetPlanet.GetComponentInChildren(); go.transform.parent = sector?.transform ?? planetGO?.transform ?? go.transform.parent; - } else + } + else { Logger.LogError($"Cannot find parent body named {solarSystemInfo.parentBody}"); } @@ -64,11 +68,13 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se { go.transform.localPosition = pos; go.transform.localRotation = rot; - } else if (planetGO) + } + else if (planetGO) { go.transform.position = planetGO.transform.TransformPoint(pos); go.transform.rotation = planetGO.transform.TransformRotation(rot); - } else + } + else { go.transform.position = pos; go.transform.rotation = rot; @@ -92,18 +98,24 @@ public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Se return go; } - public static GameObject MakeNew(string defaultName, GameObject planetGO, Sector sector, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform defaultParent = null) + public static GameObject MakeNew(string defaultName, + GameObject planetGO, Sector sector, GeneralPointPropInfo info, + bool alignToBody = false, MVector3 normal = null, + MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { var go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, defaultParent); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, parentOverride); } - public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, GeneralPointPropInfo info, bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform defaultParent = null) + public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, + GameObject planetGO, Sector sector, GeneralPointPropInfo info, + bool alignToBody = false, MVector3 normal = null, + MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, defaultParent); + return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, parentOverride); } } } diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index e563818f2..a6c40420c 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -50,7 +50,7 @@ public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig co { var socketInfo = quantumGroup.sockets[i]; - var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, defaultParent: groupRoot.transform); + var socket = GeneralPropBuilder.MakeNew("Socket " + i, go, sector, socketInfo, parentOverride: groupRoot.transform); sockets[i] = socket.AddComponent(); sockets[i]._lightSources = new Light[0]; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 7cdda9a1d..3746a446e 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -146,7 +146,7 @@ public static EyeSpawnPoint CreateVessel() var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false; var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent; - var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, null, null, system.Config.Vessel?.warpExit, defaultParent: attachWarpExitToVessel ? warpExitParent : null); + var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, null, null, system.Config.Vessel?.warpExit, parentOverride: attachWarpExitToVessel ? warpExitParent : null); if (attachWarpExitToVessel) { warpExit.transform.parent = warpExitParent; From eb21f009572fd465583209411bec8c295bdf027b Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 15:05:04 -0700 Subject: [PATCH 053/119] do null check instead of implicit bool cast for silly consistency --- NewHorizons/Builder/Props/GeneralPropBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 55bfaf9b7..abd735b0d 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -44,7 +44,7 @@ public static class GeneralPropBuilder var parentPath = info.parentPath ?? defaultParentPath; - if (planetGO && !string.IsNullOrEmpty(parentPath)) + if (planetGO != null && !string.IsNullOrEmpty(parentPath)) { var newParent = planetGO.transform.Find(parentPath); if (newParent != null) @@ -69,7 +69,7 @@ public static class GeneralPropBuilder go.transform.localPosition = pos; go.transform.localRotation = rot; } - else if (planetGO) + else if (planetGO != null) { go.transform.position = planetGO.transform.TransformPoint(pos); go.transform.rotation = planetGO.transform.TransformRotation(rot); From 8a30017c8a2ba553fd40d7c99e8e9a0e16902f42 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 18:24:22 -0400 Subject: [PATCH 054/119] Move more stuff --- NewHorizons/Builder/Body/FunnelBuilder.cs | 1 + NewHorizons/Builder/Body/Geometry/CubeSphere.cs | 2 +- NewHorizons/Builder/Orbital/InitialMotionBuilder.cs | 2 +- NewHorizons/Builder/Props/BrambleNodeBuilder.cs | 1 + NewHorizons/Builder/Props/ScatterBuilder.cs | 1 + NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 1 + NewHorizons/Components/NHProxy.cs | 2 +- NewHorizons/Components/Quantum/QuantumPlanet.cs | 2 +- NewHorizons/Handlers/PlanetCreationHandler.cs | 1 + NewHorizons/Handlers/PlanetDestructionHandler.cs | 1 + NewHorizons/Handlers/PlanetGraphHandler.cs | 1 + NewHorizons/Handlers/ShipLogHandler.cs | 1 + NewHorizons/Handlers/VesselWarpHandler.cs | 1 + NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs | 2 ++ NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs | 1 + NewHorizons/Utility/{ => Geometry}/CoordinateUtilities.cs | 2 +- NewHorizons/Utility/{ => OWUtilities}/AstroObjectLocator.cs | 4 ++-- 17 files changed, 19 insertions(+), 7 deletions(-) rename NewHorizons/Utility/{ => Geometry}/CoordinateUtilities.cs (97%) rename NewHorizons/Utility/{ => OWUtilities}/AstroObjectLocator.cs (98%) diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index a7ce37244..67a13ad0f 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -6,6 +6,7 @@ using NewHorizons.External.Modules.VariableSize; using NewHorizons.Components.Orbital; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/Body/Geometry/CubeSphere.cs b/NewHorizons/Builder/Body/Geometry/CubeSphere.cs index 0e4173142..d8257fd12 100644 --- a/NewHorizons/Builder/Body/Geometry/CubeSphere.cs +++ b/NewHorizons/Builder/Body/Geometry/CubeSphere.cs @@ -1,4 +1,4 @@ -using NewHorizons.Utility; +using NewHorizons.Utility.Geometry; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Body.Geometry diff --git a/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs b/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs index 969347f3e..a6fce3fce 100644 --- a/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs +++ b/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs @@ -1,6 +1,6 @@ using NewHorizons.Components.Orbital; using NewHorizons.External.Modules; -using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System.Linq; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index a4bdeebb2..09e5e429c 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -4,6 +4,7 @@ using NewHorizons.Handlers; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index 827453df3..b963b0127 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.Geometry; using NewHorizons.Utility.OWMLUtilities; using OWML.Common; using System; diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index 0eaf91aab..8d01bf62b 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -9,6 +9,7 @@ using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; using NewHorizons.Components.ShipLog; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Builder.ShipLog { diff --git a/NewHorizons/Components/NHProxy.cs b/NewHorizons/Components/NHProxy.cs index 92a81e0ec..6df1383a2 100644 --- a/NewHorizons/Components/NHProxy.cs +++ b/NewHorizons/Components/NHProxy.cs @@ -1,6 +1,6 @@ using NewHorizons.Components.SizeControllers; using NewHorizons.Handlers; -using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/NewHorizons/Components/Quantum/QuantumPlanet.cs b/NewHorizons/Components/Quantum/QuantumPlanet.cs index 9b551cd7e..89eebdbbe 100644 --- a/NewHorizons/Components/Quantum/QuantumPlanet.cs +++ b/NewHorizons/Components/Quantum/QuantumPlanet.cs @@ -3,7 +3,7 @@ using NewHorizons.Components.Orbital; using NewHorizons.External.Modules; using NewHorizons.Handlers; -using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index c4ec19806..b32dda4ed 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -10,6 +10,7 @@ using NewHorizons.OtherMods.OWRichPresence; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using System; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 3bc3b6c24..3cd344668 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -1,6 +1,7 @@ using NewHorizons.Components.Stars; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; using OWML.Utils; using System; using System.Collections.Generic; diff --git a/NewHorizons/Handlers/PlanetGraphHandler.cs b/NewHorizons/Handlers/PlanetGraphHandler.cs index b31535d2d..126f5801c 100644 --- a/NewHorizons/Handlers/PlanetGraphHandler.cs +++ b/NewHorizons/Handlers/PlanetGraphHandler.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System; using System.Collections; using System.Collections.Generic; diff --git a/NewHorizons/Handlers/ShipLogHandler.cs b/NewHorizons/Handlers/ShipLogHandler.cs index 649624906..8618e0cfe 100644 --- a/NewHorizons/Handlers/ShipLogHandler.cs +++ b/NewHorizons/Handlers/ShipLogHandler.cs @@ -1,4 +1,5 @@ using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index a056d95cc..bb7d7fb6f 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -8,6 +8,7 @@ using static NewHorizons.Main; using NewHorizons.Components.Orbital; using NewHorizons.Utility.OWMLUtilities; +using NewHorizons.Utility.OWUtilities; namespace NewHorizons.Handlers { diff --git a/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs b/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs index e6f5d8fe8..a518c844e 100644 --- a/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs +++ b/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs @@ -2,6 +2,8 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility.DebugUtilities; +using NewHorizons.Utility.Geometry; +using NewHorizons.Utility.OWUtilities; using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index 04554fd14..e9632c3be 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -2,6 +2,7 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Handlers; +using NewHorizons.Utility.OWUtilities; using System.Collections.Generic; using System.Linq; using UnityEngine; diff --git a/NewHorizons/Utility/CoordinateUtilities.cs b/NewHorizons/Utility/Geometry/CoordinateUtilities.cs similarity index 97% rename from NewHorizons/Utility/CoordinateUtilities.cs rename to NewHorizons/Utility/Geometry/CoordinateUtilities.cs index 62d98eb94..10f8728d6 100644 --- a/NewHorizons/Utility/CoordinateUtilities.cs +++ b/NewHorizons/Utility/Geometry/CoordinateUtilities.cs @@ -1,5 +1,5 @@ using UnityEngine; -namespace NewHorizons.Utility +namespace NewHorizons.Utility.Geometry { public static class CoordinateUtilities { diff --git a/NewHorizons/Utility/AstroObjectLocator.cs b/NewHorizons/Utility/OWUtilities/AstroObjectLocator.cs similarity index 98% rename from NewHorizons/Utility/AstroObjectLocator.cs rename to NewHorizons/Utility/OWUtilities/AstroObjectLocator.cs index 90552bb35..cd1690531 100644 --- a/NewHorizons/Utility/AstroObjectLocator.cs +++ b/NewHorizons/Utility/OWUtilities/AstroObjectLocator.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace NewHorizons.Utility +namespace NewHorizons.Utility.OWUtilities { public static class AstroObjectLocator { @@ -10,7 +10,7 @@ public static class AstroObjectLocator public static void Init() { _customAstroObjectDictionary = new Dictionary(); - foreach (AstroObject ao in GameObject.FindObjectsOfType()) + foreach (AstroObject ao in Object.FindObjectsOfType()) { // Ignore the sun station debris, we handle it as a child of the sun station if (ao.gameObject.name == "SS_Debris_Body") continue; From 110773d1516dbe350ec507e2e7ec52f0cca7d973 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 18:30:11 -0400 Subject: [PATCH 055/119] Fix bad merge --- .../Components/SizeControllers/SingularitySizeController.cs | 1 + NewHorizons/Components/SizeControllers/SizeController.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/NewHorizons/Components/SizeControllers/SingularitySizeController.cs b/NewHorizons/Components/SizeControllers/SingularitySizeController.cs index 52cb7d3e3..2caa779a5 100644 --- a/NewHorizons/Components/SizeControllers/SingularitySizeController.cs +++ b/NewHorizons/Components/SizeControllers/SingularitySizeController.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Body; using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; using UnityEngine; namespace NewHorizons.Components.SizeControllers diff --git a/NewHorizons/Components/SizeControllers/SizeController.cs b/NewHorizons/Components/SizeControllers/SizeController.cs index aa4f7e877..4e645f56f 100644 --- a/NewHorizons/Components/SizeControllers/SizeController.cs +++ b/NewHorizons/Components/SizeControllers/SizeController.cs @@ -1,4 +1,5 @@ using NewHorizons.External.Modules.VariableSize; +using NewHorizons.Utility; using UnityEngine; namespace NewHorizons.Components.SizeControllers From 8aa22a639f76b255e00f36a833a1a74d1e7542f6 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 18:34:15 -0400 Subject: [PATCH 056/119] Fix bad merge --- NewHorizons/Builder/Props/GeneralPropBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index abd735b0d..28f1c13e9 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using System; using System.Collections.Generic; using System.Linq; From fbedd57016613771e6d7b5fca7edbd04b766759b Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 18 Mar 2023 19:01:41 -0400 Subject: [PATCH 057/119] 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 c5bbf50d1..99486e9b2 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.9.0", + "version": "1.9.1", "owmlVersion": "2.9.0", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From d7b76718f85690153e834cf87210043e5d98cfc5 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 19:54:52 -0500 Subject: [PATCH 058/119] Vessel spawning and parenting --- .../External/Configs/StarSystemConfig.cs | 10 ++++++++ NewHorizons/Handlers/VesselWarpHandler.cs | 25 ++++++++++++++----- NewHorizons/Main.cs | 5 +++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 951a211d3..1af579737 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -190,6 +190,16 @@ public class VesselModule /// public string promptFact; + /// + /// Whether the vessel should spawn in this system even if it wasn't used to warp to it. + /// + public bool alwaysPresent; + + /// + /// Whether to always spawn the player on the vessel, even if it wasn't used to warp to the system. + /// + public bool spawnOnVessel; + /// /// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body. /// diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index e84a49b22..f159a8c6b 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -29,13 +29,16 @@ public static void Initialize() public static void LoadVessel() { + var system = SystemDict[Instance.CurrentStarSystem]; if (Instance.CurrentStarSystem == "EyeOfTheUniverse") { _vesselSpawnPoint = SearchUtilities.Find("Vessel_Body/SPAWN_Vessel").GetComponent(); return; } - if (Instance.IsWarpingFromVessel) + var vesselIsPresent = system.Config?.Vessel?.alwaysPresent ?? false; + + if (Instance.IsWarpingFromVessel || vesselIsPresent) _vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel(); else _vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren(); @@ -91,11 +94,7 @@ public static EyeSpawnPoint CreateVessel() VesselObject = vesselObject; var vesselAO = vesselObject.AddComponent(); - if (system.Config.Vessel?.hasPhysics ?? true) - { - vesselAO._owRigidbody = vesselObject.GetComponent(); - vesselObject.transform.parent = null; - } + vesselAO._owRigidbody = vesselObject.GetComponent(); vesselAO._rootSector = vesselObject.GetComponentInChildren(true); vesselAO._customName = "Vessel"; vesselAO._name = AstroObject.Name.CustomString; @@ -159,6 +158,20 @@ public static EyeSpawnPoint CreateVessel() EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren(true); system.SpawnPoint = eyeSpawnPoint; + if (system.Config.Vessel?.hasPhysics ?? true) + { + vesselObject.transform.parent = null; + } + else + { + vesselAO._owRigidbody = null; + UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + } + vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody(); + vesselObject.SetActive(true); Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController)); diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 1538d7bb4..eae48e17a 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -400,8 +400,11 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) } if (HasWarpDrive == true) EnableWarpDrive(); + var vesselIsPresent = SystemDict[CurrentStarSystem].Config?.Vessel?.alwaysPresent ?? false; + var shouldSpawnOnVessel = vesselIsPresent && (SystemDict[CurrentStarSystem].Config?.Vessel?.spawnOnVessel ?? false); + var shouldWarpInFromShip = IsWarpingFromShip && _shipWarpController != null; - var shouldWarpInFromVessel = IsWarpingFromVessel && VesselWarpHandler.VesselSpawnPoint != null; + var shouldWarpInFromVessel = (IsWarpingFromVessel || shouldSpawnOnVessel) && VesselWarpHandler.VesselSpawnPoint != null; Delay.RunWhen(() => IsSystemReady, () => OnSystemReady(shouldWarpInFromShip, shouldWarpInFromVessel)); IsWarpingFromShip = false; From 70a4951819bb440c619e754dc5d113e5e1380a05 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 19 Mar 2023 00:58:44 +0000 Subject: [PATCH 059/119] Updated Schemas --- NewHorizons/Schemas/star_system_schema.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index c31343262..34b8a93b2 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -143,6 +143,14 @@ "type": "string", "description": "A ship log fact which will make a prompt appear showing the coordinates when you're in the Vessel." }, + "alwaysPresent": { + "type": "boolean", + "description": "Whether the vessel should spawn in this system even if it wasn't used to warp to it." + }, + "spawnOnVessel": { + "type": "boolean", + "description": "Whether to always spawn the player on the vessel, even if it wasn't used to warp to the system." + }, "hasPhysics": { "type": "boolean", "description": "Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.", From 0b9296645852c6c56de2cb7bd4840d438488ff8d Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 18:38:37 -0700 Subject: [PATCH 060/119] doc --- NewHorizons/External/Modules/PropModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index ae674ddad..1f4169ceb 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -535,7 +535,7 @@ public enum NomaiTextLocation [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; /// - /// The location of this object. + /// The location of this object. Arcs will be blue if their locations match the wall, else orange. /// [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; @@ -825,7 +825,7 @@ public class SharedNomaiTextInfo public int seed; // For randomizing arcs /// - /// The location of this object. + /// The location of this object. Arcs will be blue if their locations match the wall, else orange. /// [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; From e24f3ea48be4c38fe05306ca9a1447968770af30 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 19 Mar 2023 01:41:49 +0000 Subject: [PATCH 061/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index e750bd91d..ee1b4f368 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1415,7 +1415,7 @@ "$ref": "#/definitions/NomaiTextType" }, "location": { - "description": "The location of this object. ", + "description": "The location of this object. Arcs will be blue if their locations match the wall, else orange.", "default": "unspecified", "$ref": "#/definitions/NomaiTextLocation" }, @@ -2213,7 +2213,7 @@ "format": "int32" }, "location": { - "description": "The location of this object. ", + "description": "The location of this object. Arcs will be blue if their locations match the wall, else orange.", "default": "unspecified", "$ref": "#/definitions/NomaiTextLocation" }, From 384312a118f2779091c587e1575f1be089d98572 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Sat, 18 Mar 2023 21:25:00 -0500 Subject: [PATCH 062/119] Fix scroll alignment --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 7ef25bcfe..1e5ad5935 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -161,7 +161,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextInfo.NomaiTextType.Scroll: { - var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); + var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); nomaiWallText.transform.parent = customScroll.transform; From de4c2ec7e2e3bfe5476c1101f2d58f755b2a31f2 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 22:55:26 -0700 Subject: [PATCH 063/119] move GeneralPropBuilder out of MakeWallText --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 1e5ad5935..62703c636 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -131,6 +131,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; + nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info); if (info.normal != null) { @@ -380,7 +381,8 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) { - GameObject nomaiWallTextObj = GeneralPropBuilder.MakeNew("NomaiWallText", go, sector, info); + GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); + nomaiWallTextObj.SetActive(false); var box = nomaiWallTextObj.AddComponent(); box.center = new Vector3(-0.0643f, 1.1254f, 0f); From 75b703716106773edd4776d111f9fabc9d97c721 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 23:01:09 -0700 Subject: [PATCH 064/119] (TODO: TEST MORE) use GeneralPropBuilder for normal --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 62703c636..ef1861fb7 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -131,8 +131,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; - nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info); + // TODO: hawkbar says normal doesnt work, but it seems to be fine in examples. further testing required probably (im lazy) + nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info, normal: info.normal); + /* if (info.normal != null) { // In global coordinates (normal was in local coordinates) @@ -152,6 +154,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); } } + */ // nomaiWallTextObj.GetComponent().DrawBoundsWithDebugSpheres(); From 3c691d351159bae3e414e0a243aa7670c8a3a8d2 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 18 Mar 2023 23:05:44 -0700 Subject: [PATCH 065/119] Revert "(TODO: TEST MORE) use GeneralPropBuilder for normal" This reverts commit 75b703716106773edd4776d111f9fabc9d97c721. --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index ef1861fb7..9361fd22b 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -131,10 +131,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextInfo.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; - // TODO: hawkbar says normal doesnt work, but it seems to be fine in examples. further testing required probably (im lazy) - nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info, normal: info.normal); + nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info); - /* + // using GeneralPropBuilder normal here does not work so have to do it manually if (info.normal != null) { // In global coordinates (normal was in local coordinates) @@ -154,7 +153,6 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); } } - */ // nomaiWallTextObj.GetComponent().DrawBoundsWithDebugSpheres(); From 80c576bd01f067b1ce10d93475af06427b855666 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Mon, 20 Mar 2023 22:31:21 -0500 Subject: [PATCH 066/119] alignRadial migration plus cleanup of translator text normal handling --- .../Builder/General/SpawnPointBuilder.cs | 9 +- NewHorizons/Builder/Props/DetailBuilder.cs | 4 +- .../Builder/Props/GeneralPropBuilder.cs | 26 ++--- NewHorizons/Builder/Props/GeyserBuilder.cs | 13 +-- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 22 ++--- NewHorizons/Builder/Props/RemoteBuilder.cs | 4 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 2 +- .../TranslatorText/TranslatorTextBuilder.cs | 73 ++++++-------- NewHorizons/Builder/Props/VolcanoBuilder.cs | 2 +- NewHorizons/External/Configs/PlanetConfig.cs | 62 +++++++++++- .../External/Modules/GeneralPropInfo.cs | 6 ++ NewHorizons/External/Modules/PropModule.cs | 97 ++++++++++++------- NewHorizons/NewHorizonsApi.cs | 4 +- .../Utility/DebugUtilities/DebugPropPlacer.cs | 2 +- 14 files changed, 194 insertions(+), 132 deletions(-) diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 9e50184c8..82ac960e2 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -1,3 +1,4 @@ +using Epic.OnlineServices.Presence; using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using NewHorizons.Utility; @@ -18,8 +19,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && module.playerSpawn != null) { - bool alignToBody = module.playerSpawn.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn, alignToBody: alignToBody); + GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn); spawnGO.layer = LayerUtilities.PlayerSafetyCollider; playerSpawn = spawnGO.AddComponent(); @@ -29,8 +29,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo } if (module.shipSpawn != null) { - bool alignToBody = module.shipSpawn.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, module.shipSpawn, alignToBody: alignToBody); + GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, module.shipSpawn); spawnGO.layer = LayerUtilities.PlayerSafetyCollider; var spawnPoint = spawnGO.AddComponent(); @@ -44,7 +43,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo ship.transform.rotation = spawnGO.transform.rotation; // Move it up a bit more when aligning to surface - if (alignToBody) + if (module.shipSpawn.alignRadial.GetValueOrDefault()) { ship.transform.position += ship.transform.up * 4f; } diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index da7329704..e4e59795e 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -90,12 +90,12 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P // We save copies with all their components fixed, good if the user is placing the same detail more than once if (detail?.path != null && _fixedPrefabCache.TryGetValue((sector, detail.path), out var storedPrefab)) { - prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail, alignToBody: detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail); isItem = storedPrefab.isItem; } else { - prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail, alignToBody: detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail); StreamingHandler.SetUpStreaming(prop, sector); diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 28f1c13e9..eae23d74d 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -15,7 +15,6 @@ public static class GeneralPropBuilder { public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, GeneralPointPropInfo info, - bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { if (info == null) return go; @@ -61,9 +60,11 @@ public static class GeneralPropBuilder var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); var rot = Quaternion.identity; + var alignRadial = false; if (info is GeneralPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; + alignRadial = rotInfo.alignRadial.HasValue && rotInfo.alignRadial.Value; } if (info.isRelativeToParent) { @@ -80,43 +81,30 @@ public static class GeneralPropBuilder go.transform.position = pos; go.transform.rotation = rot; } - if (alignToBody) + if (alignRadial) { var up = (go.transform.position - planetGO.transform.position).normalized; - if (normal != null) - { - if (info.isRelativeToParent) - { - up = go.transform.parent.TransformDirection(normal); - } - else - { - up = planetGO.transform.TransformDirection(normal); - } - } - go.transform.rotation = Quaternion.FromToRotation(go.transform.up, up) * rot; + go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * rot; } return go; } public static GameObject MakeNew(string defaultName, - GameObject planetGO, Sector sector, GeneralPointPropInfo info, - bool alignToBody = false, MVector3 normal = null, + GameObject planetGO, Sector sector, GeneralPointPropInfo info, MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { var go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, parentOverride); + return MakeFromExisting(go, planetGO, sector, info, defaultPosition, defaultParentPath, parentOverride); } public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, GeneralPointPropInfo info, - bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, parentOverride); + return MakeFromExisting(go, planetGO, sector, info, defaultPosition, defaultParentPath, parentOverride); } } } diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index e8b1f723b..cdd9c714f 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -20,22 +20,11 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInf InitPrefab(); var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", planetGO, sector, info); - - var pos = planetGO.transform.InverseTransformPoint(geyserGO.transform.position); - // Offset height, default -97.5 pushes it underground so the spout is at the surface - var length = pos.magnitude + info.offset; - - // About 130 high, bubbles start at 10, shaft starts at 67, spout starts at 97.5 - geyserGO.transform.position = planetGO.transform.TransformPoint(pos.normalized * length); + geyserGO.transform.position += geyserGO.transform.up * info.offset; geyserGO.transform.localScale = Vector3.one; - // Geyser alignment is technically incorrect due to inheriting the prefab's rotation but we need backwards compat so explicitly applying it here - geyserGO.transform.rotation = _geyserPrefab.transform.rotation; - var up = planetGO.transform.TransformPoint(pos) - planetGO.transform.position; - geyserGO.transform.rotation = Quaternion.FromToRotation(geyserGO.transform.up, up) * _geyserPrefab.transform.rotation; - var bubbles = geyserGO.FindChild("GeyserParticles/GeyserBubbles"); var shaft = geyserGO.FindChild("GeyserParticles/GeyserShaft"); var spout = geyserGO.FindChild("GeyserParticles/GeyserSpout"); diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index c0910bfa3..400170b67 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -151,7 +151,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom switch (info.type) { - case PropModule.NomaiTextInfo.NomaiTextType.Wall: + case PropModule.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject; @@ -216,7 +216,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return nomaiWallTextObj; } - case PropModule.NomaiTextInfo.NomaiTextType.Scroll: + case PropModule.NomaiTextType.Scroll: { var customScroll = _scrollPrefab.InstantiateInactive(); @@ -305,7 +305,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return customScroll; } - case PropModule.NomaiTextInfo.NomaiTextType.Computer: + case PropModule.NomaiTextType.Computer: { var computerObject = _computerPrefab.InstantiateInactive(); @@ -358,7 +358,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: + case PropModule.NomaiTextType.PreCrashComputer: { var detailInfo = new PropModule.DetailInfo() { @@ -408,10 +408,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Cairn: - case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: + case PropModule.NomaiTextType.Cairn: + case PropModule.NomaiTextType.CairnVariant: { - var cairnObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); + var cairnObject = (info.type == PropModule.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); if (!string.IsNullOrEmpty(info.rename)) { @@ -483,10 +483,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return cairnObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case PropModule.NomaiTextInfo.NomaiTextType.Recorder: + case PropModule.NomaiTextType.PreCrashRecorder: + case PropModule.NomaiTextType.Recorder: { - var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); var detailInfo = new PropModule.DetailInfo { parentPath = info.parentPath, rotation = info.rotation, @@ -518,7 +518,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: + case PropModule.NomaiTextType.Trailmarker: { var trailmarkerObject = _trailmarkerPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 2bee70b9d..b62e1f75f 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -195,7 +195,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer { var textInfo = info.nomaiText[i]; component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id); - var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.NomaiTextInfo + var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.TranslatorTextInfo { arcInfo = textInfo.arcInfo, location = textInfo.location, @@ -204,7 +204,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer rename = textInfo.rename, rotation = Vector3.zero, seed = textInfo.seed, - type = PropModule.NomaiTextInfo.NomaiTextType.Wall, + type = PropModule.NomaiTextType.Wall, xmlFile = textInfo.xmlFile }, nhBody).GetComponent(); wallText._showTextOnStart = false; diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 17cebf597..2341211f2 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -100,7 +100,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoIn private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); - var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true, defaultPosition: position); + var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, defaultPosition: position); // Add the sound thing before changing the scale var soundGO = _soundPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 9361fd22b..6dc4bc907 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -37,9 +37,9 @@ public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(PropModule.Nomai return arcInfoToCorrespondingSpawnedGameObject[arc]; } - private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) + public static GameObject GetSpawnedGameObjectByTranslatorTextInfo(PropModule.TranslatorTextInfo convo) { Logger.LogVerbose("Retrieving wall text obj for " + convo); if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; @@ -120,7 +120,7 @@ internal static void InitPrefabs() } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.TranslatorTextInfo info, NewHorizonsBody nhBody) { InitPrefabs(); @@ -128,30 +128,21 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom switch (info.type) { - case PropModule.NomaiTextInfo.NomaiTextType.Wall: + case PropModule.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info); - - // using GeneralPropBuilder normal here does not work so have to do it manually + if (info.normal != null) { - // In global coordinates (normal was in local coordinates) var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; var forward = planetGO.transform.TransformDirection(info.normal).normalized; - if (info.isRelativeToParent) - { - nomaiWallTextObj.transform.up = up; - nomaiWallTextObj.transform.forward = forward; - } else - { - nomaiWallTextObj.transform.forward = forward; + nomaiWallTextObj.transform.forward = forward; - var desiredUp = Vector3.ProjectOnPlane(up, forward); - var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward); - nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); - } + var desiredUp = Vector3.ProjectOnPlane(up, forward); + var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward); + nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); } // nomaiWallTextObj.GetComponent().DrawBoundsWithDebugSpheres(); @@ -161,9 +152,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return nomaiWallTextObj; } - case PropModule.NomaiTextInfo.NomaiTextType.Scroll: + case PropModule.NomaiTextType.Scroll: { - var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); + var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); nomaiWallText.transform.parent = customScroll.transform; @@ -213,9 +204,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return customScroll; } - case PropModule.NomaiTextInfo.NomaiTextType.Computer: + case PropModule.NomaiTextType.Computer: { - var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info, alignToBody: true, normal: info.normal); + var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info); var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -234,22 +225,20 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: + case PropModule.NomaiTextType.PreCrashComputer: { var detailInfo = new PropModule.DetailInfo() { position = info.position, + rotation = info.rotation, parentPath = info.parentPath, isRelativeToParent = info.isRelativeToParent, + alignRadial = info.alignRadial, rename = info.rename }; var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, detailInfo); computerObject.SetActive(false); - var up = computerObject.transform.position - planetGO.transform.position; - if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal); - computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation; - var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -284,11 +273,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Cairn: - case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: + case PropModule.NomaiTextType.Cairn: + case PropModule.NomaiTextType.CairnVariant: { - var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; - var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); + var cairnPrefab = info.type == PropModule.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; + var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info); // Idk do we have to set it active before finding things? cairnObject.SetActive(true); @@ -319,17 +308,17 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom return cairnObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case PropModule.NomaiTextInfo.NomaiTextType.Recorder: + case PropModule.NomaiTextType.PreCrashRecorder: + case PropModule.NomaiTextType.Recorder: { - var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); var detailInfo = new PropModule.DetailInfo { parentPath = info.parentPath, rotation = info.rotation, position = info.position, isRelativeToParent = info.isRelativeToParent, rename = info.rename, - alignToNormal = info.rotation == null, + alignRadial = info.alignRadial, }; var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo); recorderObject.SetActive(false); @@ -349,9 +338,9 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: + case PropModule.NomaiTextType.Trailmarker: { - var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); + var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info); // shrink because that is what mobius does on all trailmarkers or else they are the size of the player trailmarkerObject.transform.localScale = Vector3.one * 0.75f; @@ -380,7 +369,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.TranslatorTextInfo info, string xmlPath, NewHorizonsBody nhBody) { GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); nomaiWallTextObj.SetActive(false); @@ -417,7 +406,7 @@ private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModu return nomaiWallText; } - internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) + internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.TranslatorTextInfo info, NewHorizonsBody nhBody) { var dict = MakeNomaiTextDict(xml); @@ -437,7 +426,7 @@ private struct ArcCacheData public bool mirrored; } - internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey) + internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.TranslatorTextInfo info, NewHorizonsBody nhBody, string cacheKey) { var dict = nomaiWallText._dictNomaiTextData; Random.InitState(info.seed == 0 ? info.xmlFile.GetHashCode() : info.seed); @@ -451,8 +440,8 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers } ArcCacheData[] cachedData = null; - if (nhBody.Cache?.ContainsKey(cacheKey) ?? false) - cachedData = nhBody.Cache.Get(cacheKey); + //if (nhBody.Cache?.ContainsKey(cacheKey) ?? false) + // cachedData = nhBody.Cache.Get(cacheKey); var arranger = nomaiWallText.gameObject.AddComponent(); diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index aaf541cf3..6d39a591b 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -46,7 +46,7 @@ public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoIn { InitPrefab(); - var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info, alignToBody: true); + var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info); var meteorLauncher = launcherGO.GetComponent(); meteorLauncher._audioSector = sector; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index abc1f522b..20eed396e 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -487,7 +487,7 @@ public void Migrate() } // Remote dialogue trigger reorganized to use GeneralPointPropInfo - if (Props != null && Props.dialogue != null) + if (Props?.dialogue != null) { foreach (var dialogue in Props.dialogue) { @@ -502,6 +502,66 @@ public void Migrate() } } } + + // alignRadial added to all props with rotation; default behavior varies + if (Spawn?.playerSpawn != null && Spawn.playerSpawn.rotation == null && !Spawn.playerSpawn.alignRadial.HasValue) + { + Spawn.playerSpawn.alignRadial = true; + } + if (Spawn?.shipSpawn != null && Spawn.shipSpawn.rotation == null && !Spawn.shipSpawn.alignRadial.HasValue) + { + Spawn.playerSpawn.alignRadial = true; + } + if (Props?.details != null) + { + foreach (var detail in Props.details) + { + if (!detail.alignRadial.HasValue) + { + detail.alignRadial = detail.alignToNormal; + } + } + } + if (Props?.proxyDetails != null) + { + foreach (var detail in Props.proxyDetails) + { + if (!detail.alignRadial.HasValue) + { + detail.alignRadial = detail.alignToNormal; + } + } + } + if (Props?.geysers != null) + { + foreach (var geyser in Props.geysers) + { + if (!geyser.alignRadial.HasValue && geyser.rotation == null) + { + geyser.alignRadial = true; + } + } + } + if (Props?.tornados != null) + { + foreach (var tornado in Props.tornados) + { + if (!tornado.alignRadial.HasValue && tornado.rotation == null) + { + tornado.alignRadial = true; + } + } + } + if (Props?.volcanoes != null) + { + foreach (var volcano in Props.volcanoes) + { + if (!volcano.alignRadial.HasValue && volcano.rotation == null) + { + volcano.alignRadial = true; + } + } + } } } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/GeneralPropInfo.cs b/NewHorizons/External/Modules/GeneralPropInfo.cs index c9ead3469..8ab528a1e 100644 --- a/NewHorizons/External/Modules/GeneralPropInfo.cs +++ b/NewHorizons/External/Modules/GeneralPropInfo.cs @@ -35,6 +35,12 @@ public abstract class GeneralPropInfo : GeneralPointPropInfo /// Rotation of the object /// public MVector3 rotation; + + /// + /// Do we try to automatically align this object to stand upright relative to the body's center? Stacks with rotation. + /// Defaults to true for geysers, tornados, and volcanoes, and false for everything else. + /// + public bool? alignRadial; } [JsonObject] diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 1f4169ceb..5772cd265 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -42,7 +42,7 @@ public class PropModule /// /// Add translatable text to this planet /// - public NomaiTextInfo[] translatorText; + public TranslatorTextInfo[] translatorText; /// /// Details which will be shown from 50km away. Meant to be lower resolution. @@ -165,12 +165,6 @@ public class ScatterInfo [JsonObject] public class DetailInfo : GeneralPropInfo { - - /// - /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? - /// - public bool alignToNormal; - /// /// Relative filepath to an asset-bundle to load the prefab defined in `path` from /// @@ -229,10 +223,12 @@ public class DetailInfo : GeneralPropInfo /// If there's already good colliders on the detail, you can make this 0. /// [DefaultValue(1f)] public float physicsRadius = 1f; + + [Obsolete("alignToNormal is deprecated. Use alignRadial instead")] public bool alignToNormal; } [JsonObject] - public class RaftInfo : GeneralPointPropInfo + public class RaftInfo : GeneralPropInfo { /// /// Acceleration of the raft. Default acceleration is 5. @@ -241,7 +237,7 @@ public class RaftInfo : GeneralPointPropInfo } [JsonObject] - public class GeyserInfo : GeneralPointPropInfo + public class GeyserInfo : GeneralPropInfo { /// /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. @@ -280,7 +276,7 @@ public class GeyserInfo : GeneralPointPropInfo } [JsonObject] - public class TornadoInfo : GeneralPointPropInfo + public class TornadoInfo : GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum TornadoType @@ -342,7 +338,7 @@ public enum TornadoType } [JsonObject] - public class VolcanoInfo : GeneralPointPropInfo + public class VolcanoInfo : GeneralPropInfo { /// /// The colour of the meteor's lava. @@ -474,39 +470,74 @@ public class EntryLocationInfo : GeneralPointPropInfo } [JsonObject] - public class NomaiTextInfo : GeneralPointPropInfo + public class TranslatorTextInfo : GeneralPropInfo { - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextType - { - [EnumMember(Value = @"wall")] Wall = 0, + /// + /// Additional information about each arc in the text + /// + public NomaiTextArcInfo[] arcInfo; + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; + + /// + /// Only for wall text. Aligns wall text to face towards the given direction, with 'up' oriented relative to its current rotation or alignment. + /// + public MVector3 normal; + + /// + /// The type of object this is. + /// + [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; - [EnumMember(Value = @"scroll")] Scroll = 1, + /// + /// The location of this object. Arcs will be blue if their locations match the wall, else orange. + /// + [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; - [EnumMember(Value = @"computer")] Computer = 2, + /// + /// The relative path to the xml file for this object. + /// + public string xmlFile; + } - [EnumMember(Value = @"cairn")] Cairn = 3, + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextType + { + [EnumMember(Value = @"wall")] Wall = 0, - [EnumMember(Value = @"recorder")] Recorder = 4, + [EnumMember(Value = @"scroll")] Scroll = 1, - [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, + [EnumMember(Value = @"computer")] Computer = 2, - [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, + [EnumMember(Value = @"cairn")] Cairn = 3, - [EnumMember(Value = @"trailmarker")] Trailmarker = 7, + [EnumMember(Value = @"recorder")] Recorder = 4, - [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, - } + [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextLocation - { - [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, + [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, - [EnumMember(Value = @"a")] A = 1, + [EnumMember(Value = @"trailmarker")] Trailmarker = 7, - [EnumMember(Value = @"b")] B = 2 - } + [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextLocation + { + [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, + + [EnumMember(Value = @"a")] A = 1, + + [EnumMember(Value = @"b")] B = 2 + } + + [JsonObject] + public class NomaiTextInfo : GeneralPointPropInfo + { /// /// Additional information about each arc in the text @@ -827,7 +858,7 @@ public class SharedNomaiTextInfo /// /// The location of this object. Arcs will be blue if their locations match the wall, else orange. /// - [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; + [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; /// /// The relative path to the xml file for this object. diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index ce358343a..7c0bdc712 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -155,14 +155,14 @@ public object QuerySystem(Type outType, string jsonPath) } public GameObject SpawnObject(GameObject planet, Sector sector, string propToCopyPath, Vector3 position, Vector3 eulerAngles, - float scale, bool alignWithNormal) + float scale, bool alignRadial) { var prefab = SearchUtilities.Find(propToCopyPath); var detailInfo = new PropModule.DetailInfo() { position = position, rotation = eulerAngles, scale = scale, - alignToNormal = alignWithNormal + alignRadial = alignRadial }; return DetailBuilder.Make(planet, sector, prefab, detailInfo); } diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index e9632c3be..da3ceeef6 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -273,7 +273,7 @@ private PropPlacementData RegisterProp_WithReturn(AstroObject body, GameObject p // So we can't use local position/rotation here, we have to inverse transform the global position/rotation relative to root object prop.detailInfo.position = rootTransform.InverseTransformPoint(prop.gameObject.transform.position); prop.detailInfo.scale = prop.gameObject.transform.localScale.x; - if (!prop.detailInfo.alignToNormal) prop.detailInfo.rotation = rootTransform.InverseTransformRotation(prop.gameObject.transform.rotation).eulerAngles; + if (!prop.detailInfo.alignRadial.GetValueOrDefault()) prop.detailInfo.rotation = rootTransform.InverseTransformRotation(prop.gameObject.transform.rotation).eulerAngles; infoArray[i] = prop.detailInfo; } From 33f93ce7986fb0b6a73776a75ca854b5ac9d4227 Mon Sep 17 00:00:00 2001 From: Ben C Date: Tue, 21 Mar 2023 03:34:00 +0000 Subject: [PATCH 067/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 145 ++++++++++++++++++-- NewHorizons/Schemas/star_system_schema.json | 14 ++ 2 files changed, 145 insertions(+), 14 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index ee1b4f368..09f4f41de 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -662,6 +662,13 @@ "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" @@ -1009,7 +1016,7 @@ "type": "array", "description": "Add translatable text to this planet", "items": { - "$ref": "#/definitions/NomaiTextInfo" + "$ref": "#/definitions/TranslatorTextInfo" } }, "proxyDetails": { @@ -1092,6 +1099,13 @@ "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" @@ -1108,10 +1122,6 @@ "type": "string", "description": "An optional rename of this object" }, - "alignToNormal": { - "type": "boolean", - "description": "Do we override rotation and try to automatically align this object to stand upright on the body's surface?" - }, "assetBundle": { "type": "string", "description": "Relative filepath to an asset-bundle to load the prefab defined in `path` from" @@ -1305,6 +1315,17 @@ "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" @@ -1369,10 +1390,21 @@ } } }, - "NomaiTextInfo": { + "TranslatorTextInfo": { "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" @@ -1396,19 +1428,15 @@ "$ref": "#/definitions/NomaiTextArcInfo" } }, - "normal": { - "description": "The normal vector for this object. Used for writing on walls and positioning computers.", - "$ref": "#/definitions/MVector3" - }, - "rotation": { - "description": "The euler angle rotation of this object. Not required if setting the normal. Computers and cairns will orient\nthemselves to the surface of the planet automatically.", - "$ref": "#/definitions/MVector3" - }, "seed": { "type": "integer", "description": "The random seed used to pick what the text arcs will look like.", "format": "int32" }, + "normal": { + "description": "Only for wall text. Aligns wall text to face towards the given direction, with 'up' oriented relative to its current rotation or alignment.", + "$ref": "#/definitions/MVector3" + }, "type": { "description": "The type of object this is.", "default": "wall", @@ -1533,6 +1561,17 @@ "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" @@ -1632,6 +1671,13 @@ "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" @@ -1809,6 +1855,13 @@ "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" @@ -1837,6 +1890,17 @@ "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" @@ -1920,6 +1984,17 @@ "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" @@ -1983,6 +2058,13 @@ "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" @@ -2163,6 +2245,13 @@ "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" @@ -2235,6 +2324,13 @@ "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" @@ -2274,6 +2370,13 @@ "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" @@ -2562,6 +2665,13 @@ "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" @@ -2592,6 +2702,13 @@ "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" diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 34b8a93b2..4ab0cdb8d 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -214,6 +214,13 @@ "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" @@ -262,6 +269,13 @@ "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" From 325303d94740ede45782c5f784a82ebc3fa6d308 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Mon, 20 Mar 2023 23:46:15 -0500 Subject: [PATCH 068/119] Reenable arc caching --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 6dc4bc907..8b36a0a8b 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -440,8 +440,8 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers } ArcCacheData[] cachedData = null; - //if (nhBody.Cache?.ContainsKey(cacheKey) ?? false) - // cachedData = nhBody.Cache.Get(cacheKey); + if (nhBody.Cache?.ContainsKey(cacheKey) ?? false) + cachedData = nhBody.Cache.Get(cacheKey); var arranger = nomaiWallText.gameObject.AddComponent(); From ced1c5e30884c01e6d4b60c8179f4c7d68b7178d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Mon, 20 Mar 2023 23:46:23 -0500 Subject: [PATCH 069/119] Fix typo breaking ship spawns --- NewHorizons/External/Configs/PlanetConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 20eed396e..d5cd663df 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -510,7 +510,7 @@ public void Migrate() } if (Spawn?.shipSpawn != null && Spawn.shipSpawn.rotation == null && !Spawn.shipSpawn.alignRadial.HasValue) { - Spawn.playerSpawn.alignRadial = true; + Spawn.shipSpawn.alignRadial = true; } if (Props?.details != null) { From 357b4463f013afd2fd0cc21cc145b472c42fa582 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 12:50:42 -0500 Subject: [PATCH 070/119] Better handling of vessel spawn flags --- NewHorizons/Handlers/VesselWarpHandler.cs | 19 ++++++++++++++++--- NewHorizons/Main.cs | 12 +++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index f159a8c6b..085f6a09f 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -27,6 +27,21 @@ public static void Initialize() VesselPrefab = Main.NHPrivateAssetBundle.LoadAsset("Vessel_Body"); } + public static bool IsVesselPresent() + { + var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; + var isDefaultSolarSystem = Instance.CurrentStarSystem == "SolarSystem"; + var vesselIsPresent = vesselConfig?.alwaysPresent ?? isDefaultSolarSystem; + return Instance.IsWarpingFromVessel || vesselIsPresent; + } + + public static bool ShouldSpawnAtVessel() + { + var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; + var shouldSpawnOnVessel = IsVesselPresent() && (vesselConfig?.spawnOnVessel ?? false); + return Instance.IsWarpingFromVessel || (IsVesselPresent() && shouldSpawnOnVessel); + } + public static void LoadVessel() { var system = SystemDict[Instance.CurrentStarSystem]; @@ -36,9 +51,7 @@ public static void LoadVessel() return; } - var vesselIsPresent = system.Config?.Vessel?.alwaysPresent ?? false; - - if (Instance.IsWarpingFromVessel || vesselIsPresent) + if (IsVesselPresent()) _vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel(); else _vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren(); diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index eae48e17a..390072a72 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -146,7 +146,8 @@ public void ResetConfigs(bool resetTranslation = true) x = new int[5]{ 0,3,2,1,5 }, y = new int[5]{ 4,5,3,2,1 }, z = new int[5]{ 4,1,2,5,0 } - } + }, + alwaysPresent = true, } } }; @@ -364,6 +365,10 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) NewHorizonsData.Load(); + // If the vessel is forcing the player to spawn there, allow it to override + IsWarpingFromVessel = VesselWarpHandler.ShouldSpawnAtVessel(); + Logger.LogWarning("Spawning from vessel: " + IsWarpingFromVessel); + // Some builders have to be reset each loop SignalBuilder.Init(); BrambleDimensionBuilder.Init(); @@ -400,11 +405,8 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) } if (HasWarpDrive == true) EnableWarpDrive(); - var vesselIsPresent = SystemDict[CurrentStarSystem].Config?.Vessel?.alwaysPresent ?? false; - var shouldSpawnOnVessel = vesselIsPresent && (SystemDict[CurrentStarSystem].Config?.Vessel?.spawnOnVessel ?? false); - var shouldWarpInFromShip = IsWarpingFromShip && _shipWarpController != null; - var shouldWarpInFromVessel = (IsWarpingFromVessel || shouldSpawnOnVessel) && VesselWarpHandler.VesselSpawnPoint != null; + var shouldWarpInFromVessel = IsWarpingFromVessel && VesselWarpHandler.VesselSpawnPoint != null; Delay.RunWhen(() => IsSystemReady, () => OnSystemReady(shouldWarpInFromShip, shouldWarpInFromVessel)); IsWarpingFromShip = false; From 7fe2f80b06de4f3eb57efd2d23e3a4adc7fe5729 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 12:50:51 -0500 Subject: [PATCH 071/119] Merge vessel spawn flags --- NewHorizons/External/Configs/StarSystemConfig.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 1af579737..00281a494 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -271,6 +271,11 @@ public void Merge(StarSystemConfig otherConfig) startHere = startHere || otherConfig.startHere; Vessel = Vessel == null ? otherConfig.Vessel : Vessel; + if (Vessel != null) + { + Vessel.spawnOnVessel = Vessel.spawnOnVessel || otherConfig.Vessel.spawnOnVessel; + Vessel.alwaysPresent = Vessel.alwaysPresent || otherConfig.Vessel.alwaysPresent; + } entryPositions = Concatenate(entryPositions, otherConfig.entryPositions); curiosities = Concatenate(curiosities, otherConfig.curiosities); From d9134a4fd428632ab1e5460c2f3094eaab85fff5 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 12:51:28 -0500 Subject: [PATCH 072/119] Patch bug when suiting up inside force volume on initial spawn --- .../PlayerCameraControllerPatches.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 NewHorizons/Patches/PlayerPatches/PlayerCameraControllerPatches.cs diff --git a/NewHorizons/Patches/PlayerPatches/PlayerCameraControllerPatches.cs b/NewHorizons/Patches/PlayerPatches/PlayerCameraControllerPatches.cs new file mode 100644 index 000000000..12ae0e8cb --- /dev/null +++ b/NewHorizons/Patches/PlayerPatches/PlayerCameraControllerPatches.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using NewHorizons.Utility.OWMLUtilities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.Patches.PlayerPatches +{ + [HarmonyPatch(typeof(PlayerCameraController))] + public static class PlayerCameraControllerPatches + { + [HarmonyPrefix] + [HarmonyPatch(nameof(PlayerCameraController.SnapToDegreesOverSeconds))] + public static bool PlayerCameraController_SnapToDegreesOverSeconds(PlayerCameraController __instance, float targetX, float targetY, float duration, bool smoothStep) + { + // AlignPlayerWithForce.OnSuitUp snaps the camera to center, but it never unsnaps because duration == 0f + if (duration <= 0f) + { + __instance._degreesX = targetX; + __instance._degreesY = targetY; + return false; + } + return true; + } + } +} From 2032fb566ccda860bfdbfb0348a83e5c92daa3c8 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 21 Mar 2023 20:00:20 -0400 Subject: [PATCH 073/119] 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 99486e9b2..5236f06a9 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.9.1", + "version": "1.10.0", "owmlVersion": "2.9.0", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], From 5d93b7c3cfe14c3870cb22e296ec70a80d894f7f Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 21 Mar 2023 20:13:51 -0400 Subject: [PATCH 074/119] Fix star system vessel merge NRE --- NewHorizons/External/Configs/StarSystemConfig.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 00281a494..845696b9d 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -270,12 +270,15 @@ public void Merge(StarSystemConfig otherConfig) respawnHere = respawnHere || otherConfig.respawnHere; startHere = startHere || otherConfig.startHere; - Vessel = Vessel == null ? otherConfig.Vessel : Vessel; - if (Vessel != null) + if (Vessel != null && otherConfig.Vessel != null) { Vessel.spawnOnVessel = Vessel.spawnOnVessel || otherConfig.Vessel.spawnOnVessel; Vessel.alwaysPresent = Vessel.alwaysPresent || otherConfig.Vessel.alwaysPresent; } + else + { + Vessel ??= otherConfig.Vessel; + } entryPositions = Concatenate(entryPositions, otherConfig.entryPositions); curiosities = Concatenate(curiosities, otherConfig.curiosities); From 9d2d8a4bc38bed68494063f9ea03759e9196b896 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 21 Mar 2023 17:25:36 -0700 Subject: [PATCH 075/119] fix namespaces --- NewHorizons/Builder/Props/PropBuildManager.cs | 1 + NewHorizons/Builder/Props/RemoteBuilder.cs | 1 + .../Builder/Props/TranslatorText/NomaiTextArcArranger.cs | 2 +- .../Builder/Props/TranslatorText/NomaiTextArcBuilder.cs | 3 +-- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 2 +- .../Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs | 2 +- NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs | 2 +- NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs | 2 +- .../Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs | 2 +- .../Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumesBuildManager.cs | 2 ++ NewHorizons/Components/EyeAstroObject.cs | 4 +--- NewHorizons/Main.cs | 1 + NewHorizons/UsedInUnityProjectAttribute.cs | 2 ++ 14 files changed, 16 insertions(+), 12 deletions(-) diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index 4758e43a4..3b96432fb 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -1,4 +1,5 @@ using NewHorizons.Builder.Body; +using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.Builder.ShipLog; using NewHorizons.External.Configs; using NewHorizons.Utility; diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index b62e1f75f..b9e5be418 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -1,3 +1,4 @@ +using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; diff --git a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs index b94f3e6da..17e44ce1b 100644 --- a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs +++ b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcArranger.cs @@ -4,7 +4,7 @@ using UnityEngine; using Logger = NewHorizons.Utility.Logger; -namespace NewHorizons.Builder.Props +namespace NewHorizons.Builder.Props.TranslatorText { public class NomaiTextArcArranger : MonoBehaviour { diff --git a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs index cb7343fa8..e8f5e8ec7 100644 --- a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs @@ -1,9 +1,8 @@ -using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace NewHorizons.Builder.Props +namespace NewHorizons.Builder.Props.TranslatorText { public static class NomaiTextArcBuilder { // TODO: stranger arcs diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 8b36a0a8b..4cf691044 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -14,7 +14,7 @@ using Logger = NewHorizons.Utility.Logger; using Random = UnityEngine.Random; -namespace NewHorizons.Builder.Props +namespace NewHorizons.Builder.Props.TranslatorText { public static class TranslatorTextBuilder { diff --git a/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs index 9ef330de7..b914ba3bd 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/PlayerImpactRulesetBuilder.cs @@ -1,7 +1,7 @@ using NewHorizons.External.Modules; using UnityEngine; -namespace NewHorizons.Builder.Volumes +namespace NewHorizons.Builder.Volumes.Rulesets { public static class PlayerImpactRulesetBuilder { diff --git a/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs index b8293d944..ae9a70ec4 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/ProbeRulesetBuilder.cs @@ -1,7 +1,7 @@ using NewHorizons.External.Modules; using UnityEngine; -namespace NewHorizons.Builder.Volumes +namespace NewHorizons.Builder.Volumes.Rulesets { public static class ProbeRulesetBuilder { diff --git a/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs b/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs index 8541f516b..a2ce52d68 100644 --- a/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs +++ b/NewHorizons/Builder/Volumes/Rulesets/ThrustRulesetBuilder.cs @@ -1,7 +1,7 @@ using NewHorizons.External.Modules; using UnityEngine; -namespace NewHorizons.Builder.Volumes +namespace NewHorizons.Builder.Volumes.Rulesets { public static class ThrustRulesetBuilder { diff --git a/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs index 139e09f90..b96dadfde 100644 --- a/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VisorEffects/VisorFrostEffectVolumeBuilder.cs @@ -1,7 +1,7 @@ using NewHorizons.External.Modules; using UnityEngine; -namespace NewHorizons.Builder.Volumes +namespace NewHorizons.Builder.Volumes.VisorEffects { public static class VisorFrostEffectVolumeBuilder { diff --git a/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs index bf268c8ec..a0de16da5 100644 --- a/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VisorEffects/VisorRainEffectVolumeBuilder.cs @@ -1,7 +1,7 @@ using NewHorizons.External.Modules; using UnityEngine; -namespace NewHorizons.Builder.Volumes +namespace NewHorizons.Builder.Volumes.VisorEffects { public static class VisorRainEffectVolumeBuilder { diff --git a/NewHorizons/Builder/Volumes/VolumesBuildManager.cs b/NewHorizons/Builder/Volumes/VolumesBuildManager.cs index cd1f474ad..9c4357b29 100644 --- a/NewHorizons/Builder/Volumes/VolumesBuildManager.cs +++ b/NewHorizons/Builder/Volumes/VolumesBuildManager.cs @@ -1,6 +1,8 @@ using NewHorizons.Builder.Body; using NewHorizons.Builder.ShipLog; using NewHorizons.Builder.Volumes; +using NewHorizons.Builder.Volumes.Rulesets; +using NewHorizons.Builder.Volumes.VisorEffects; using NewHorizons.Components.Volumes; using NewHorizons.External.Configs; using OWML.Common; diff --git a/NewHorizons/Components/EyeAstroObject.cs b/NewHorizons/Components/EyeAstroObject.cs index 6b78ddb4e..799617bc3 100644 --- a/NewHorizons/Components/EyeAstroObject.cs +++ b/NewHorizons/Components/EyeAstroObject.cs @@ -1,6 +1,4 @@ -using NewHorizons.Utility; - -namespace NewHorizons.Components.Orbital +namespace NewHorizons.Components { public class EyeAstroObject : AstroObject { diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 390072a72..15d99c280 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -3,6 +3,7 @@ using NewHorizons.Builder.Body; using NewHorizons.Builder.General; using NewHorizons.Builder.Props; +using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.Components; using NewHorizons.Components.Fixers; using NewHorizons.Components.SizeControllers; diff --git a/NewHorizons/UsedInUnityProjectAttribute.cs b/NewHorizons/UsedInUnityProjectAttribute.cs index 057b3388e..26a19e7d9 100644 --- a/NewHorizons/UsedInUnityProjectAttribute.cs +++ b/NewHorizons/UsedInUnityProjectAttribute.cs @@ -1,5 +1,7 @@ using System; +namespace NewHorizons; + /// /// denotes that the given type is used in the unity project /// and therefore caution should be used when moving/renaming/deleting From 0cfe62dda5e058726d4ded5732a1a1e5fa49c31f Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 21 Mar 2023 17:27:07 -0700 Subject: [PATCH 076/119] rename LayerUtilities to Layer --- NewHorizons/Builder/Atmosphere/AirBuilder.cs | 2 +- NewHorizons/Builder/Atmosphere/CloudsBuilder.cs | 6 +++--- NewHorizons/Builder/Body/RingBuilder.cs | 2 +- NewHorizons/Builder/Body/SingularityBuilder.cs | 2 +- NewHorizons/Builder/Body/StarBuilder.cs | 8 ++++---- NewHorizons/Builder/Body/WaterBuilder.cs | 4 ++-- NewHorizons/Builder/General/DetectorBuilder.cs | 4 ++-- NewHorizons/Builder/General/GravityBuilder.cs | 2 +- NewHorizons/Builder/General/RFVolumeBuilder.cs | 2 +- NewHorizons/Builder/General/SpawnPointBuilder.cs | 6 +++--- NewHorizons/Builder/Props/DialogueBuilder.cs | 4 ++-- NewHorizons/Builder/Props/RemoteBuilder.cs | 2 +- NewHorizons/Builder/Props/SignalBuilder.cs | 2 +- NewHorizons/Builder/ShipLog/RevealBuilder.cs | 2 +- NewHorizons/Builder/StarSystem/SkyboxBuilder.cs | 4 ++-- NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs | 4 ++-- NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs | 2 +- NewHorizons/Builder/Volumes/VolumeBuilder.cs | 2 +- .../Components/Achievement/AchievementObserveTrigger.cs | 2 +- NewHorizons/Components/AddPhysics.cs | 2 +- .../Utility/OWUtilities/{LayerUtilities.cs => Layer.cs} | 2 +- 23 files changed, 35 insertions(+), 35 deletions(-) rename NewHorizons/Utility/OWUtilities/{LayerUtilities.cs => Layer.cs} (98%) diff --git a/NewHorizons/Builder/Atmosphere/AirBuilder.cs b/NewHorizons/Builder/Atmosphere/AirBuilder.cs index f71d49378..b7a3bd3ed 100644 --- a/NewHorizons/Builder/Atmosphere/AirBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AirBuilder.cs @@ -9,7 +9,7 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) { var airGO = new GameObject("Air"); airGO.SetActive(false); - airGO.layer = LayerUtilities.BasicEffectVolume; + airGO.layer = Layer.BasicEffectVolume; airGO.transform.parent = sector?.transform ?? planetGO.transform; var sc = airGO.AddComponent(); diff --git a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs index 087b0ff7f..d7dde4c8a 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -119,7 +119,7 @@ public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atm GameObject cloudsFluidGO = new GameObject("CloudsFluid"); cloudsFluidGO.SetActive(false); - cloudsFluidGO.layer = LayerUtilities.BasicEffectVolume; + cloudsFluidGO.layer = Layer.BasicEffectVolume; cloudsFluidGO.transform.parent = cloudsMainGO.transform; SphereCollider fluidSC = cloudsFluidGO.AddComponent(); @@ -252,7 +252,7 @@ public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule a if (atmo.clouds.unlit) { - cloudsTopGO.layer = LayerUtilities.IgnoreSun; + cloudsTopGO.layer = Layer.IgnoreSun; } if (atmo.clouds.rotationSpeed != 0f) @@ -304,7 +304,7 @@ public static GameObject MakeTransparentClouds(GameObject rootObject, Atmosphere { GameObject tcrqcGO = new GameObject("TransparentCloudRenderQueueController"); tcrqcGO.transform.SetParent(cloudsTransparentGO.transform, false); - tcrqcGO.layer = LayerUtilities.BasicEffectVolume; + tcrqcGO.layer = Layer.BasicEffectVolume; var shape = tcrqcGO.AddComponent(); shape.radius = 1; diff --git a/NewHorizons/Builder/Body/RingBuilder.cs b/NewHorizons/Builder/Body/RingBuilder.cs index c2adc5b28..581498eab 100644 --- a/NewHorizons/Builder/Body/RingBuilder.cs +++ b/NewHorizons/Builder/Body/RingBuilder.cs @@ -31,7 +31,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, RingModule rin ringVolume.transform.localPosition = Vector3.zero; ringVolume.transform.localScale = Vector3.one; ringVolume.transform.localRotation = Quaternion.identity; - ringVolume.layer = LayerUtilities.BasicEffectVolume; + ringVolume.layer = Layer.BasicEffectVolume; var ringShape = ringVolume.AddComponent(); ringShape.innerRadius = ring.innerRadius; diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 59cf5d57d..8f84e77fc 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -183,7 +183,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam if (hasDestructionVolume || targetStarSystem != null) { var destructionVolumeGO = new GameObject("DestructionVolume"); - destructionVolumeGO.layer = LayerUtilities.BasicEffectVolume; + destructionVolumeGO.layer = Layer.BasicEffectVolume; destructionVolumeGO.transform.parent = singularity.transform; destructionVolumeGO.transform.localScale = Vector3.one; destructionVolumeGO.transform.localPosition = Vector3.zero; diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index f9ee9ceb4..70e09ad96 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -123,7 +123,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( heatVolume.transform.SetParent(starGO.transform, false); heatVolume.transform.localPosition = Vector3.zero; heatVolume.transform.localScale = Vector3.one; - heatVolume.layer = LayerUtilities.BasicEffectVolume; + heatVolume.layer = Layer.BasicEffectVolume; heatVolume.AddComponent().radius = 1.1f; heatVolume.AddComponent(); heatVolume.AddComponent()._damagePerSecond = 20f; @@ -133,7 +133,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( deathVolume.transform.SetParent(starGO.transform, false); deathVolume.transform.localPosition = Vector3.zero; deathVolume.transform.localScale = Vector3.one; - deathVolume.layer = LayerUtilities.BasicEffectVolume; + deathVolume.layer = Layer.BasicEffectVolume; var sphereCollider = deathVolume.AddComponent(); sphereCollider.radius = 1f; sphereCollider.isTrigger = true; @@ -149,7 +149,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make( planetDestructionVolume.transform.SetParent(starGO.transform, false); planetDestructionVolume.transform.localPosition = Vector3.zero; planetDestructionVolume.transform.localScale = Vector3.one; - planetDestructionVolume.layer = LayerUtilities.BasicEffectVolume; + planetDestructionVolume.layer = Layer.BasicEffectVolume; var planetSphereCollider = planetDestructionVolume.AddComponent(); planetSphereCollider.radius = 0.8f; planetSphereCollider.isTrigger = true; @@ -446,7 +446,7 @@ public static StellarDeathController MakeSupernova(GameObject starGO, StarModule supernovaWallAudio.transform.SetParent(supernovaGO.transform, false); supernovaWallAudio.transform.localPosition = Vector3.zero; supernovaWallAudio.transform.localScale = Vector3.one; - supernovaWallAudio.layer = LayerUtilities.BasicEffectVolume; + supernovaWallAudio.layer = Layer.BasicEffectVolume; var audioSource = supernovaWallAudio.AddComponent(); audioSource.loop = true; audioSource.maxDistance = 2000; diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index e08669bca..452aa524c 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -54,7 +54,7 @@ public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigid // Don't ignore sun when not under clouds waterGO.layer = 0; - Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = LayerUtilities.IgnoreSun; }); + Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = Layer.IgnoreSun; }); TessellatedSphereRenderer TSR = waterGO.AddComponent(); TSR.tessellationMeshGroup = ScriptableObject.CreateInstance(); @@ -101,7 +101,7 @@ public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigid var buoyancyObject = new GameObject("WaterVolume"); buoyancyObject.transform.parent = waterGO.transform; buoyancyObject.transform.localScale = Vector3.one; - buoyancyObject.layer = LayerUtilities.BasicEffectVolume; + buoyancyObject.layer = Layer.BasicEffectVolume; var sphereCollider = buoyancyObject.AddComponent(); sphereCollider.radius = 1; diff --git a/NewHorizons/Builder/General/DetectorBuilder.cs b/NewHorizons/Builder/General/DetectorBuilder.cs index d557c9cfc..3610da32d 100644 --- a/NewHorizons/Builder/General/DetectorBuilder.cs +++ b/NewHorizons/Builder/General/DetectorBuilder.cs @@ -82,7 +82,7 @@ public static GameObject Make(GameObject planetGO, OWRigidbody OWRB, AstroObject detectorGO.SetActive(false); detectorGO.transform.parent = planetGO.transform; detectorGO.transform.localPosition = Vector3.zero; - detectorGO.layer = LayerUtilities.BasicDetector; + detectorGO.layer = Layer.BasicDetector; ConstantForceDetector forceDetector = detectorGO.AddComponent(); forceDetector._inheritElement0 = true; @@ -91,7 +91,7 @@ public static GameObject Make(GameObject planetGO, OWRigidbody OWRB, AstroObject // For falling into sun if (!config.Base.invulnerableToSun && config.Star == null && config.FocalPoint == null) { - detectorGO.layer = LayerUtilities.AdvancedDetector; + detectorGO.layer = Layer.AdvancedDetector; var fluidDetector = detectorGO.AddComponent(); var sphereCollider = detectorGO.AddComponent(); diff --git a/NewHorizons/Builder/General/GravityBuilder.cs b/NewHorizons/Builder/General/GravityBuilder.cs index e90f02d79..21b729a8b 100644 --- a/NewHorizons/Builder/General/GravityBuilder.cs +++ b/NewHorizons/Builder/General/GravityBuilder.cs @@ -24,7 +24,7 @@ public static GravityVolume Make(GameObject planetGO, AstroObject ao, OWRigidbod var gravityGO = new GameObject("GravityWell"); gravityGO.transform.parent = planetGO.transform; gravityGO.transform.localPosition = Vector3.zero; - gravityGO.layer = LayerUtilities.BasicEffectVolume; + gravityGO.layer = Layer.BasicEffectVolume; gravityGO.SetActive(false); var SC = gravityGO.AddComponent(); diff --git a/NewHorizons/Builder/General/RFVolumeBuilder.cs b/NewHorizons/Builder/General/RFVolumeBuilder.cs index e5dbc6432..bb3d032bb 100644 --- a/NewHorizons/Builder/General/RFVolumeBuilder.cs +++ b/NewHorizons/Builder/General/RFVolumeBuilder.cs @@ -13,7 +13,7 @@ public static GameObject Make(GameObject planetGO, OWRigidbody owrb, float spher var rfGO = new GameObject("RFVolume"); rfGO.transform.parent = planetGO.transform; rfGO.transform.localPosition = Vector3.zero; - rfGO.layer = LayerUtilities.ReferenceFrameVolume; + rfGO.layer = Layer.ReferenceFrameVolume; rfGO.SetActive(false); var SC = rfGO.AddComponent(); diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 82ac960e2..e93b39e02 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -20,7 +20,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && module.playerSpawn != null) { GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn); - spawnGO.layer = LayerUtilities.PlayerSafetyCollider; + spawnGO.layer = Layer.PlayerSafetyCollider; playerSpawn = spawnGO.AddComponent(); playerSpawn._triggerVolumes = new OWTriggerVolume[0]; @@ -30,7 +30,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo if (module.shipSpawn != null) { GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, module.shipSpawn); - spawnGO.layer = LayerUtilities.PlayerSafetyCollider; + spawnGO.layer = Layer.PlayerSafetyCollider; var spawnPoint = spawnGO.AddComponent(); spawnPoint._isShipSpawn = true; @@ -55,7 +55,7 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo Logger.LogVerbose("Overriding player spawn to be inside ship"); GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint"); playerSpawnGO.transform.parent = ship.transform; - playerSpawnGO.layer = LayerUtilities.PlayerSafetyCollider; + playerSpawnGO.layer = Layer.PlayerSafetyCollider; playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0); diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index 7028acda8..c76a02ac7 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -74,7 +74,7 @@ private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, S { var conversationZone = GeneralPropBuilder.MakeNew("ConversationZone", planetGO, sector, info, defaultParentPath: info.pathToAnimController); - conversationZone.layer = LayerUtilities.Interactible; + conversationZone.layer = Layer.Interactible; var sphere = conversationZone.AddComponent(); sphere.radius = info.radius; @@ -215,7 +215,7 @@ private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree var playerTrackingZone = new GameObject("PlayerTrackingZone"); playerTrackingZone.SetActive(false); - playerTrackingZone.layer = LayerUtilities.BasicEffectVolume; + playerTrackingZone.layer = Layer.BasicEffectVolume; playerTrackingZone.SetActive(false); var sphereCollider = playerTrackingZone.AddComponent(); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index b9e5be418..4cd1e19db 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -88,7 +88,7 @@ internal static void InitPrefabs() if (_shareStonePrefab == null) { GameObject stone = new GameObject("ShareStoneFallback"); - stone.layer = LayerUtilities.Interactible; + stone.layer = Layer.Interactible; stone.SetActive(false); SphereCollider sc = stone.AddComponent(); sc.center = Vector3.zero; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 8a7edc3c5..1ffe52548 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -112,7 +112,7 @@ public static string GetCustomSignalName(SignalName signalName) public static GameObject Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod) { var signalGO = GeneralPropBuilder.MakeNew($"Signal_{info.name}", planetGO, sector, info); - signalGO.layer = LayerUtilities.AdvancedEffectVolume; + signalGO.layer = Layer.AdvancedEffectVolume; var source = signalGO.AddComponent(); var owAudioSource = signalGO.AddComponent(); diff --git a/NewHorizons/Builder/ShipLog/RevealBuilder.cs b/NewHorizons/Builder/ShipLog/RevealBuilder.cs index e77581834..1e2d5a8b2 100644 --- a/NewHorizons/Builder/ShipLog/RevealBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RevealBuilder.cs @@ -93,7 +93,7 @@ private static void MakeTrigger(GameObject go, Sector sector, VolumesModule.Reve private static void MakeObservable(GameObject go, Sector sector, VolumesModule.RevealVolumeInfo info, IModBehaviour mod) { - go.layer = LayerUtilities.Interactible; + go.layer = Layer.Interactible; var sphere = go.AddComponent(); sphere.radius = info.radius; diff --git a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs index aa6231b71..c92b6520a 100644 --- a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs +++ b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs @@ -33,7 +33,7 @@ public static GameObject BuildSkySphere(StarSystemConfig.SkyboxModule module, IM var skySphere = new GameObject("Sky Sphere"); skySphere.transform.SetParent(skybox.transform, false); - skySphere.layer = LayerUtilities.Skybox; + skySphere.layer = Layer.Skybox; skySphere.transform.localScale = Vector3.one * 5f; BuildSkySphereFace(skySphere, "Right", Quaternion.Euler(0f, 90f, 0f), mesh, rightTex); @@ -56,7 +56,7 @@ public static GameObject BuildSkySphereFace(GameObject skySphere, string name, Q var go = new GameObject(name) { - layer = LayerUtilities.Skybox + layer = Layer.Skybox }; var mf = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs index 477d93230..3e2b723be 100644 --- a/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/AudioVolumeBuilder.cs @@ -19,7 +19,7 @@ public static class AudioVolumeBuilder public static AudioVolume Make(GameObject planetGO, Sector sector, VolumesModule.AudioVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("AudioVolume", planetGO, sector, info); - go.layer = LayerUtilities.AdvancedEffectVolume; + go.layer = Layer.AdvancedEffectVolume; var audioSource = go.AddComponent(); diff --git a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs index a6dfae3bc..5c64bb0a3 100644 --- a/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs @@ -16,7 +16,7 @@ public static class HazardVolumeBuilder public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("HazardVolume", planetGO, sector, info); - go.layer = LayerUtilities.BasicEffectVolume; + go.layer = Layer.BasicEffectVolume; var shape = go.AddComponent(); shape.radius = info.radius; @@ -51,7 +51,7 @@ public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody var detectorGO = new GameObject("ConstantFluidDetector"); detectorGO.transform.parent = go.transform; detectorGO.transform.localPosition = Vector3.zero; - detectorGO.layer = LayerUtilities.BasicDetector; + detectorGO.layer = Layer.BasicDetector; var detector = detectorGO.AddComponent(); detector._onlyDetectableFluid = water; detector._buoyancy.boundingRadius = 1; diff --git a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs index d2f1a6c89..c02f29671 100644 --- a/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/NotificationVolumeBuilder.cs @@ -19,7 +19,7 @@ public static class NotificationVolumeBuilder public static NHNotificationVolume Make(GameObject planetGO, Sector sector, VolumesModule.NotificationVolumeInfo info, IModBehaviour mod) { var go = GeneralPropBuilder.MakeNew("NotificationVolume", planetGO, sector, info); - go.layer = LayerUtilities.BasicEffectVolume; + go.layer = Layer.BasicEffectVolume; var shape = go.AddComponent(); shape.radius = info.radius; diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index ad0d9cf49..fbb5c8c07 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -12,7 +12,7 @@ public static class VanishVolumeBuilder public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VanishVolumeInfo info) where TVolume : VanishVolume { var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); - go.layer = LayerUtilities.BasicEffectVolume; + go.layer = Layer.BasicEffectVolume; var collider = go.AddComponent(); collider.isTrigger = true; diff --git a/NewHorizons/Builder/Volumes/VolumeBuilder.cs b/NewHorizons/Builder/Volumes/VolumeBuilder.cs index 4ace754c5..0a50d518e 100644 --- a/NewHorizons/Builder/Volumes/VolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VolumeBuilder.cs @@ -12,7 +12,7 @@ public static class VolumeBuilder public static TVolume Make(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too. { var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info); - go.layer = LayerUtilities.BasicEffectVolume; + go.layer = Layer.BasicEffectVolume; var shape = go.AddComponent(); shape.radius = info.radius; diff --git a/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs b/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs index f0c0a51f8..88392cb0a 100644 --- a/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs +++ b/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs @@ -21,7 +21,7 @@ public class AchievementObserveTrigger : MonoBehaviour, IObservable private void Reset() { - gameObject.layer = LayerUtilities.Interactible; + gameObject.layer = Layer.Interactible; } private void Awake() diff --git a/NewHorizons/Components/AddPhysics.cs b/NewHorizons/Components/AddPhysics.cs index 16810de08..683b5a3cd 100644 --- a/NewHorizons/Components/AddPhysics.cs +++ b/NewHorizons/Components/AddPhysics.cs @@ -39,7 +39,7 @@ private IEnumerator Start() var owRigidbody = bodyGo.AddComponent(); owRigidbody._simulateInSector = Sector; - bodyGo.layer = LayerUtilities.PhysicalDetector; + bodyGo.layer = Layer.PhysicalDetector; bodyGo.tag = "DynamicPropDetector"; // this collider is not included in groups. oh well bodyGo.AddComponent().radius = Radius; diff --git a/NewHorizons/Utility/OWUtilities/LayerUtilities.cs b/NewHorizons/Utility/OWUtilities/Layer.cs similarity index 98% rename from NewHorizons/Utility/OWUtilities/LayerUtilities.cs rename to NewHorizons/Utility/OWUtilities/Layer.cs index bfd5e7436..1b2c7240d 100644 --- a/NewHorizons/Utility/OWUtilities/LayerUtilities.cs +++ b/NewHorizons/Utility/OWUtilities/Layer.cs @@ -2,7 +2,7 @@ namespace NewHorizons.Utility.OWUtilities { - public static class LayerUtilities + public static class Layer { public static int Default = LayerMask.NameToLayer(nameof(Default)); public static int TransparentFX = LayerMask.NameToLayer(nameof(TransparentFX)); From b495b1ea2a258d5f282cc92ef09dc00ddb6c65df Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 21 Mar 2023 17:33:15 -0700 Subject: [PATCH 077/119] one of the layers has a space in it >:( --- NewHorizons/Utility/OWUtilities/Layer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Utility/OWUtilities/Layer.cs b/NewHorizons/Utility/OWUtilities/Layer.cs index 1b2c7240d..a9eae8bba 100644 --- a/NewHorizons/Utility/OWUtilities/Layer.cs +++ b/NewHorizons/Utility/OWUtilities/Layer.cs @@ -6,7 +6,7 @@ public static class Layer { public static int Default = LayerMask.NameToLayer(nameof(Default)); public static int TransparentFX = LayerMask.NameToLayer(nameof(TransparentFX)); - public static int IgnoreRaycast = LayerMask.NameToLayer(nameof(IgnoreRaycast)); + public static int IgnoreRaycast = LayerMask.NameToLayer("Ignore Raycast"); public static int Water = LayerMask.NameToLayer(nameof(Water)); public static int UI = LayerMask.NameToLayer(nameof(UI)); public static int PlayerSafetyCollider = LayerMask.NameToLayer(nameof(PlayerSafetyCollider)); From a88f3c16a8a2e6d44ea56bd268394c740c095fad Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 21 Mar 2023 17:44:50 -0700 Subject: [PATCH 078/119] use nullable values instead of separate keepAutoPlacement thing --- .../TranslatorText/TranslatorTextBuilder.cs | 14 +++++++------- NewHorizons/External/Modules/PropModule.cs | 16 ++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 4cf691044..4967b9c55 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -499,15 +499,15 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers var arcInfo = info.arcInfo[j]; var arc = arranger.spirals[j]; - if (arcInfo.keepAutoPlacement) continue; + if (arcInfo.position != null) arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); - if (arcInfo.position == null) arc.transform.localPosition = Vector3.zero; - else arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); + if (arcInfo.zRotation != null) arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.Value); - arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation); - - if (arcInfo.mirror) arc.transform.localScale = new Vector3(-1, 1, 1); - else arc.transform.localScale = new Vector3( 1, 1, 1); + if (arcInfo.mirror != null) + { + if (arcInfo.mirror.Value) arc.transform.localScale = new Vector3(-1, 1, 1); + else arc.transform.localScale = new Vector3(1, 1, 1); + } } // make an entry in the cache for all these spirals diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 5772cd265..639c361c9 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -590,17 +590,12 @@ public enum NomaiTextArcType } /// - /// Whether to skip modifying this spiral's placement, and instead keep the automatically determined placement. + /// Whether to flip the spiral from left-curling to right-curling or vice versa. If not specified, will use auto spiral generated value. /// - public bool keepAutoPlacement; + public bool? mirror; /// - /// Whether to flip the spiral from left-curling to right-curling or vice versa. - /// - public bool mirror; - - /// - /// The local position of this object on the wall. + /// The local position of this object on the wall. If not specified, will use auto spiral generated value. /// public MVector2 position; @@ -612,12 +607,13 @@ public enum NomaiTextArcType /// /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. /// + [Obsolete("only used in old nomai text")] [DefaultValue(-1)] public int variation = -1; /// - /// The z euler angle for this arc. + /// The z euler angle for this arc. If not specified, will use auto spiral generated value. /// - [Range(0f, 360f)] public float zRotation; + [Range(0f, 360f)] public float? zRotation; } [JsonObject] From 8d13f1e5e5cb802d38d8d568e0f1a0e335f289f8 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 21 Mar 2023 17:45:34 -0700 Subject: [PATCH 079/119] oops --- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 400170b67..5b8e91d43 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -704,9 +704,9 @@ internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObje if (arcInfo.position == null) arc.transform.localPosition = Vector3.zero; else arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); - arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation); + arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.GetValueOrDefault()); - if (arcInfo.mirror) arc.transform.localScale = new Vector3(-1, 1, 1); + if (arcInfo.mirror.GetValueOrDefault()) arc.transform.localScale = new Vector3(-1, 1, 1); } // Try auto I guess else From 0f248049280b6bd9b5ba56d6a99f57f1ba9e45da Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 22 Mar 2023 00:51:28 +0000 Subject: [PATCH 080/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 09f4f41de..bc6793b46 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1457,16 +1457,15 @@ "type": "object", "additionalProperties": false, "properties": { - "keepAutoPlacement": { - "type": "boolean", - "description": "Whether to skip modifying this spiral's placement, and instead keep the automatically determined placement." - }, "mirror": { - "type": "boolean", - "description": "Whether to flip the spiral from left-curling to right-curling or vice versa." + "type": [ + "boolean", + "null" + ], + "description": "Whether to flip the spiral from left-curling to right-curling or vice versa. If not specified, will use auto spiral generated value." }, "position": { - "description": "The local position of this object on the wall.", + "description": "The local position of this object on the wall. If not specified, will use auto spiral generated value.", "$ref": "#/definitions/MVector2" }, "type": { @@ -1474,15 +1473,12 @@ "default": "adult", "$ref": "#/definitions/NomaiTextArcType" }, - "variation": { - "type": "integer", - "description": "Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module.", - "format": "int32", - "default": -1 - }, "zRotation": { - "type": "number", - "description": "The z euler angle for this arc.", + "type": [ + "null", + "number" + ], + "description": "The z euler angle for this arc. If not specified, will use auto spiral generated value.", "format": "float", "maximum": 360.0, "minimum": 0.0 From 4085eb8effc6b8fe8e1b9b9ef3e357ddbed03a9c Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 21:11:02 -0500 Subject: [PATCH 081/119] Fix vessel merge null checks --- NewHorizons/External/Configs/StarSystemConfig.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 00281a494..c007787dc 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -270,12 +270,12 @@ public void Merge(StarSystemConfig otherConfig) respawnHere = respawnHere || otherConfig.respawnHere; startHere = startHere || otherConfig.startHere; - Vessel = Vessel == null ? otherConfig.Vessel : Vessel; - if (Vessel != null) + if (Vessel != null && otherConfig.Vessel != null) { Vessel.spawnOnVessel = Vessel.spawnOnVessel || otherConfig.Vessel.spawnOnVessel; Vessel.alwaysPresent = Vessel.alwaysPresent || otherConfig.Vessel.alwaysPresent; } + Vessel = Vessel == null ? otherConfig.Vessel : Vessel; entryPositions = Concatenate(entryPositions, otherConfig.entryPositions); curiosities = Concatenate(curiosities, otherConfig.curiosities); From 9aa436c60f1856e7fa55e5bcc6e62079197d407f Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 21:17:45 -0500 Subject: [PATCH 082/119] Vessel fixes --- .../External/Configs/StarSystemConfig.cs | 7 +++- NewHorizons/Handlers/VesselWarpHandler.cs | 34 ++++++++++++++++--- NewHorizons/Main.cs | 3 +- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index c007787dc..f3ffcf218 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -191,7 +191,7 @@ public class VesselModule public string promptFact; /// - /// Whether the vessel should spawn in this system even if it wasn't used to warp to it. + /// Whether the vessel should spawn in this system even if it wasn't used to warp to it. This will automatically power on the vessel. /// public bool alwaysPresent; @@ -205,6 +205,11 @@ public class VesselModule /// [DefaultValue(true)] public bool hasPhysics = true; + /// + /// Whether the vessel should have a zero-gravity volume around it that ignores any other sources of gravity, like the vessel works in Dark Bramble. + /// + public bool hasZeroGravityVolume; + /// /// The location that the vessel will warp to. /// diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 085f6a09f..2cc08a91a 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -27,19 +27,25 @@ public static void Initialize() VesselPrefab = Main.NHPrivateAssetBundle.LoadAsset("Vessel_Body"); } - public static bool IsVesselPresent() + public static bool IsVesselPresentAndActive() { var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; - var isDefaultSolarSystem = Instance.CurrentStarSystem == "SolarSystem"; - var vesselIsPresent = vesselConfig?.alwaysPresent ?? isDefaultSolarSystem; + var vesselIsPresent = vesselConfig?.alwaysPresent ?? false; return Instance.IsWarpingFromVessel || vesselIsPresent; } + public static bool IsVesselPresent() + { + var isDefaultSolarSystem = Instance.CurrentStarSystem == "SolarSystem"; + var isEyeOfTheUniverse = Instance.CurrentStarSystem == "EyeOfTheUniverse"; + return IsVesselPresentAndActive() || isDefaultSolarSystem || isEyeOfTheUniverse; + } + public static bool ShouldSpawnAtVessel() { var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; var shouldSpawnOnVessel = IsVesselPresent() && (vesselConfig?.spawnOnVessel ?? false); - return Instance.IsWarpingFromVessel || (IsVesselPresent() && shouldSpawnOnVessel); + return Instance.IsWarpingFromVessel || shouldSpawnOnVessel; } public static void LoadVessel() @@ -51,7 +57,7 @@ public static void LoadVessel() return; } - if (IsVesselPresent()) + if (IsVesselPresentAndActive()) _vesselSpawnPoint = Instance.CurrentStarSystem == "SolarSystem" ? UpdateVessel() : CreateVessel(); else _vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren(); @@ -182,9 +188,23 @@ public static EyeSpawnPoint CreateVessel() UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + var rfVolume = vesselObject.transform.Find("RFVolume"); + if (rfVolume != null) + { + GameObject.Destroy(rfVolume.gameObject); + } } vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody(); + if (system.Config.Vessel?.hasZeroGravityVolume ?? false) + { + var zeroGVolume = vesselObject.transform.Find("Sector_VesselBridge/Volumes_VesselBridge/ZeroGVolume"); + if (zeroGVolume != null) + { + GameObject.Destroy(zeroGVolume.gameObject); + } + } + vesselObject.SetActive(true); Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController)); @@ -274,6 +294,10 @@ public static void SetupWarpController(VesselWarpController vesselWarpController vesselWarpController._cageAnimator.OnTranslationComplete -= new TransformAnimator.AnimationEvent(vesselWarpController.OnCageAnimationComplete); vesselWarpController._cageAnimator.OnTranslationComplete += new TransformAnimator.AnimationEvent(vesselWarpController.OnCageAnimationComplete); } + + // Normally the power-on sound is 2D/global, we set it to 3D/local so it isn't audible if the player isn't nearby + vesselWarpController._audioSource.spatialBlend = 1f; + vesselWarpController._audioSource.rolloffMode = AudioRolloffMode.Linear; } } } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 390072a72..73f717cbb 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -146,8 +146,7 @@ public void ResetConfigs(bool resetTranslation = true) x = new int[5]{ 0,3,2,1,5 }, y = new int[5]{ 4,5,3,2,1 }, z = new int[5]{ 4,1,2,5,0 } - }, - alwaysPresent = true, + } } } }; From 0d8a454fb63e70c7f729c34be46a76c2a0f0df54 Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 22 Mar 2023 02:21:19 +0000 Subject: [PATCH 083/119] Updated Schemas --- NewHorizons/Schemas/star_system_schema.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 4ab0cdb8d..40d7e8f46 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -145,7 +145,7 @@ }, "alwaysPresent": { "type": "boolean", - "description": "Whether the vessel should spawn in this system even if it wasn't used to warp to it." + "description": "Whether the vessel should spawn in this system even if it wasn't used to warp to it. This will automatically power on the vessel." }, "spawnOnVessel": { "type": "boolean", @@ -156,6 +156,10 @@ "description": "Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.", "default": true }, + "hasZeroGravityVolume": { + "type": "boolean", + "description": "Whether the vessel should have a zero-gravity volume around it that ignores any other sources of gravity, like the vessel works in Dark Bramble." + }, "vesselSpawn": { "description": "The location that the vessel will warp to.", "$ref": "#/definitions/VesselInfo" From 420c91c67043b6a5147ed2396f0b415db0b0f09d Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 22:12:39 -0500 Subject: [PATCH 084/119] Defaults for hasPhysics and hasZeroGravityVolume --- NewHorizons/External/Configs/StarSystemConfig.cs | 8 ++++---- NewHorizons/Handlers/VesselWarpHandler.cs | 8 ++++++-- NewHorizons/Main.cs | 1 - 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index f3ffcf218..ecc1710f1 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -201,14 +201,14 @@ public class VesselModule public bool spawnOnVessel; /// - /// Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body. + /// Whether the vessel should have physics enabled. Defaults to false if parentBody is set, and true otherwise. /// - [DefaultValue(true)] public bool hasPhysics = true; + public bool? hasPhysics; /// - /// Whether the vessel should have a zero-gravity volume around it that ignores any other sources of gravity, like the vessel works in Dark Bramble. + /// Whether the vessel should have a zero-gravity volume around it. Defaults to false if parentBody is set, and true otherwise. /// - public bool hasZeroGravityVolume; + public bool? hasZeroGravityVolume; /// /// The location that the vessel will warp to. diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 2cc08a91a..922192f5e 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -177,7 +177,10 @@ public static EyeSpawnPoint CreateVessel() EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren(true); system.SpawnPoint = eyeSpawnPoint; - if (system.Config.Vessel?.hasPhysics ?? true) + var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody); + var hasPhysics = system.Config.Vessel?.hasPhysics ?? !hasParentBody; + + if (hasPhysics) { vesselObject.transform.parent = null; } @@ -196,7 +199,8 @@ public static EyeSpawnPoint CreateVessel() } vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody(); - if (system.Config.Vessel?.hasZeroGravityVolume ?? false) + var hasZeroGravityVolume = system.Config.Vessel?.hasZeroGravityVolume ?? !hasParentBody; + if (!hasZeroGravityVolume) { var zeroGVolume = vesselObject.transform.Find("Sector_VesselBridge/Volumes_VesselBridge/ZeroGVolume"); if (zeroGVolume != null) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 73f717cbb..d60f0e74f 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -366,7 +366,6 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) // If the vessel is forcing the player to spawn there, allow it to override IsWarpingFromVessel = VesselWarpHandler.ShouldSpawnAtVessel(); - Logger.LogWarning("Spawning from vessel: " + IsWarpingFromVessel); // Some builders have to be reset each loop SignalBuilder.Init(); From 0f9fd7e1b5c2b622e43825b5201abe019703675c Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Tue, 21 Mar 2023 22:14:47 -0500 Subject: [PATCH 085/119] Merge new settings --- NewHorizons/External/Configs/StarSystemConfig.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index ecc1710f1..514c393e8 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -279,6 +279,8 @@ public void Merge(StarSystemConfig otherConfig) { Vessel.spawnOnVessel = Vessel.spawnOnVessel || otherConfig.Vessel.spawnOnVessel; Vessel.alwaysPresent = Vessel.alwaysPresent || otherConfig.Vessel.alwaysPresent; + Vessel.hasPhysics = Vessel.hasPhysics ?? otherConfig.Vessel.hasPhysics; + Vessel.hasZeroGravityVolume = Vessel.hasZeroGravityVolume ?? otherConfig.Vessel.hasZeroGravityVolume; } Vessel = Vessel == null ? otherConfig.Vessel : Vessel; From 8d7201819cb69c252213a965dc2242ee070a831c Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 22 Mar 2023 03:14:49 +0000 Subject: [PATCH 086/119] Updated Schemas --- NewHorizons/Schemas/star_system_schema.json | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 40d7e8f46..f7d281b89 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -152,13 +152,18 @@ "description": "Whether to always spawn the player on the vessel, even if it wasn't used to warp to the system." }, "hasPhysics": { - "type": "boolean", - "description": "Whether the vessel should have physics enabled. This must be set to false for the vessel to stay attached to a parent body.", - "default": true + "type": [ + "boolean", + "null" + ], + "description": "Whether the vessel should have physics enabled. Defaults to false if parentBody is set, and true otherwise." }, "hasZeroGravityVolume": { - "type": "boolean", - "description": "Whether the vessel should have a zero-gravity volume around it that ignores any other sources of gravity, like the vessel works in Dark Bramble." + "type": [ + "boolean", + "null" + ], + "description": "Whether the vessel should have a zero-gravity volume around it. Defaults to false if parentBody is set, and true otherwise." }, "vesselSpawn": { "description": "The location that the vessel will warp to.", From 4a14101ba1dafe5e465b9fc5dd244055c7bd8c58 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 22 Mar 2023 00:07:53 -0400 Subject: [PATCH 087/119] Implement warp pads --- NewHorizons/Builder/Props/PropBuildManager.cs | 29 ++++ .../TranslatorText/TranslatorTextBuilder.cs | 10 +- NewHorizons/Builder/Props/WarpPadBuilder.cs | 126 ++++++++++++++++++ NewHorizons/External/Modules/PropModule.cs | 20 ++- .../Modules/WarpPad/NomaiWarpComputerInfo.cs | 9 ++ .../Modules/WarpPad/NomaiWarpPadInfo.cs | 10 ++ .../WarpPad/NomaiWarpPadReceiverInfo.cs | 24 ++++ .../WarpPad/NomaiWarpTransmitterInfo.cs | 19 +++ NewHorizons/Main.cs | 2 + NewHorizons/Utility/NewHorizonExtensions.cs | 5 + 10 files changed, 244 insertions(+), 10 deletions(-) create mode 100644 NewHorizons/Builder/Props/WarpPadBuilder.cs create mode 100644 NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs create mode 100644 NewHorizons/External/Modules/WarpPad/NomaiWarpPadInfo.cs create mode 100644 NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs create mode 100644 NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index 4758e43a4..e5781f7c9 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using UnityEngine; +using static NewHorizons.External.Modules.PropModule; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Props { @@ -235,6 +236,34 @@ public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, Ne } } } + if (config.Props.warpReceivers != null) + { + foreach (var warpReceiver in config.Props.warpReceivers) + { + try + { + WarpPadBuilder.Make(go, sector, warpReceiver); + } + catch (Exception ex) + { + Logger.LogError($"Couldn't make warp receiver [{warpReceiver.frequency}] for [{go.name}]:\n{ex}"); + } + } + } + if (config.Props.warpTransmitters != null) + { + foreach (var warpTransmitter in config.Props.warpTransmitters) + { + try + { + WarpPadBuilder.Make(go, sector, warpTransmitter); + } + catch (Exception ex) + { + Logger.LogError($"Couldn't make warp transmitter [{warpTransmitter.frequency}] for [{go.name}]:\n{ex}"); + } + } + } } } } diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 8b36a0a8b..05b1ca637 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -22,7 +22,7 @@ public static class TranslatorTextBuilder private static Material _adultArcMaterial; private static Material _childArcMaterial; private static GameObject _scrollPrefab; - private static GameObject _computerPrefab; + public static GameObject ComputerPrefab { get; private set; } private static GameObject _preCrashComputerPrefab; private static GameObject _cairnPrefab; private static GameObject _cairnVariantPrefab; @@ -77,10 +77,10 @@ internal static void InitPrefabs() if (_scrollPrefab == null) _scrollPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive().Rename("Prefab_NOM_Scroll").DontDestroyOnLoad(); - if (_computerPrefab == null) + if (ComputerPrefab == null) { - _computerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive().Rename("Prefab_NOM_Computer").DontDestroyOnLoad(); - _computerPrefab.transform.rotation = Quaternion.identity; + ComputerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive().Rename("Prefab_NOM_Computer").DontDestroyOnLoad(); + ComputerPrefab.transform.rotation = Quaternion.identity; } if (_preCrashComputerPrefab == null) @@ -206,7 +206,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra } case PropModule.NomaiTextType.Computer: { - var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info); + var computerObject = GeneralPropBuilder.MakeFromPrefab(ComputerPrefab, ComputerPrefab.name, planetGO, sector, info); var computer = computerObject.GetComponent(); computer.SetSector(sector); diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs new file mode 100644 index 000000000..ffe4600d5 --- /dev/null +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -0,0 +1,126 @@ +using Epic.OnlineServices.Presence; +using NewHorizons.External.Modules.WarpPad; +using NewHorizons.Handlers; +using NewHorizons.Utility; +using NewHorizons.Utility.OWMLUtilities; +using OWML.Utils; +using UnityEngine; + +namespace NewHorizons.Builder.Props +{ + public static class WarpPadBuilder + { + private static GameObject _detailedReceiverPrefab; + private static GameObject _receiverPrefab; + private static GameObject _transmitterPrefab; + + public static void InitPrefabs() + { + if (_detailedReceiverPrefab == null) + { + var thReceiverLamp = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Sector_NomaiCrater/Geometry_NomaiCrater/OtherComponentsGroup/Structure_NOM_WarpReceiver_TimberHearth_Lamp"); + var thReceiver = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Sector_NomaiCrater/Interactables_NomaiCrater/Prefab_NOM_WarpReceiver"); + + _detailedReceiverPrefab = new GameObject("NomaiWarpReceiver"); + + var detailedReceiver = thReceiver.InstantiateInactive(); + detailedReceiver.transform.parent = _detailedReceiverPrefab.transform; + detailedReceiver.transform.localPosition = Vector3.zero; + detailedReceiver.transform.localRotation = Quaternion.identity; + + var lamp = thReceiverLamp.InstantiateInactive(); + lamp.transform.parent = _detailedReceiverPrefab.transform; + lamp.transform.localPosition = thReceiver.transform.InverseTransformPoint(thReceiverLamp.transform.position); + lamp.transform.localRotation = thReceiver.transform.InverseTransformRotation(thReceiverLamp.transform.rotation); + + _detailedReceiverPrefab.SetActive(false); + lamp.SetActive(true); + detailedReceiver.SetActive(true); + + _detailedReceiverPrefab.DontDestroyOnLoad(); + + GameObject.Destroy(_detailedReceiverPrefab.GetComponentInChildren().gameObject); + } + + if (_receiverPrefab == null) + { + _receiverPrefab = SearchUtilities.Find("SunStation_Body/Sector_SunStation/Sector_WarpModule/Interactables_WarpModule/Prefab_NOM_WarpReceiver") + .InstantiateInactive() + .DontDestroyOnLoad(); + GameObject.Destroy(_receiverPrefab.GetComponentInChildren().gameObject); + } + + if (_transmitterPrefab == null) + { + _transmitterPrefab = SearchUtilities.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_SS/Interactables_Tower_SS/Tower_SS_VisibleFrom_TowerTwin/Prefab_NOM_WarpTransmitter") + .InstantiateInactive() + .DontDestroyOnLoad(); + GameObject.Destroy(_transmitterPrefab.GetComponentInChildren().gameObject); + } + } + + public static void Make(GameObject planetGO, Sector sector, NomaiWarpReceiverInfo info) + { + var receiverObject = GeneralPropBuilder.MakeFromPrefab(info.detailed ? _detailedReceiverPrefab : _receiverPrefab, "NomaiWarpReceiver", planetGO, sector, info); + + StreamingHandler.SetUpStreaming(receiverObject, sector); + + var receiver = receiverObject.GetComponentInChildren(); + + receiver._frequency = GetFrequency(info.frequency); + + receiver._alignmentTarget = planetGO?.transform; + + Locator.RegisterWarpReceiver(receiver); + + receiverObject.SetActive(true); + + if (info.computer != null) + { + CreateComputer(planetGO, sector, info.computer, receiver); + } + } + + public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitterInfo info) + { + var transmitterObject = GeneralPropBuilder.MakeFromPrefab(_transmitterPrefab, "NomaiWarpTransmitter", planetGO, sector, info); + + StreamingHandler.SetUpStreaming(transmitterObject, sector); + + var transmitter = transmitterObject.GetComponentInChildren(); + transmitter._frequency = GetFrequency(info.frequency); + + transmitter._alignmentWindow = info.alignmentWindow; + + transmitter.GetComponent().enabled = true; + + transmitterObject.SetActive(true); + } + + private static void CreateComputer(GameObject planetGO, Sector sector, NomaiWarpComputerLoggerInfo computerInfo, NomaiWarpReceiver receiver) + { + var computerObject = GeneralPropBuilder.MakeFromPrefab(TranslatorTextBuilder.ComputerPrefab, TranslatorTextBuilder.ComputerPrefab.name, planetGO, sector, computerInfo); + + var computer = computerObject.GetComponentInChildren(); + computer.SetSector(sector); + + Delay.FireOnNextUpdate(computer.ClearAllEntries); + + var computerLogger = computerObject.AddComponent(); + computerLogger._warpReceiver = receiver; + + StreamingHandler.SetUpStreaming(computerObject, sector); + + computerObject.SetActive(true); + } + + private static NomaiWarpPlatform.Frequency GetFrequency(string frequency) + { + if (!EnumUtils.TryParse(frequency, out var frequencyEnum)) + { + frequencyEnum = EnumUtilities.Create(frequency); + } + return frequencyEnum; + } + } +} diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 5772cd265..f22c5052d 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -1,12 +1,12 @@ - +using NewHorizons.External.Modules.VariableSize; +using NewHorizons.External.Modules.WarpPad; using NewHorizons.Utility; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System; -using NewHorizons.External.Modules.VariableSize; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; namespace NewHorizons.External.Modules { @@ -94,6 +94,16 @@ public class PropModule /// public RemoteInfo[] remotes; + /// + /// Add warp pad receivers to this planet. These are the warp pads you are sent to from Ash Twin. + /// + public NomaiWarpReceiverInfo[] warpReceivers; + + /// + /// Add warp pad transmitters to this planet. These are the warp pads seen on the Ash Twin. + /// + public NomaiWarpTransmitterInfo[] warpTransmitters; + [Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public VolumesModule.RevealVolumeInfo[] reveal; [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public VolumesModule.AudioVolumeInfo[] audioVolumes; diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs new file mode 100644 index 000000000..bd2bb6d75 --- /dev/null +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpComputerInfo.cs @@ -0,0 +1,9 @@ +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules.WarpPad +{ + [JsonObject] + public class NomaiWarpComputerLoggerInfo : GeneralPropInfo + { + } +} diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpPadInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpPadInfo.cs new file mode 100644 index 000000000..f4cd75153 --- /dev/null +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpPadInfo.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules.WarpPad +{ + [JsonObject] + public abstract class NomaiWarpPadInfo : GeneralPropInfo + { + public string frequency; + } +} diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs new file mode 100644 index 000000000..6680284c1 --- /dev/null +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpPadReceiverInfo.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; + +namespace NewHorizons.External.Modules.WarpPad +{ + [JsonObject] + public class NomaiWarpReceiverInfo : NomaiWarpPadInfo + { + /// + /// The body the transmitter must be aligned with to warp to this receiver. + /// Defaults to the body the receiver is on. + /// + public string alignmentTargetBody; + + /// + /// Will create a modern Nomai computer linked to this receiver. + /// + public NomaiWarpComputerLoggerInfo computer; + + /// + /// Set to true if you want to include Nomai ruin details around the warp pad. + /// + public bool detailed; + } +} diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs new file mode 100644 index 000000000..6e704f368 --- /dev/null +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using System.ComponentModel; + +namespace NewHorizons.External.Modules.WarpPad +{ + [JsonObject] + public class NomaiWarpTransmitterInfo : NomaiWarpPadInfo + { + /// + /// In degrees. Gives a margin of error for alignments. + /// + [DefaultValue(5f)] public float alignmentWindow = 5f; + + /// + /// Is this transmitter upsidedown? Means alignment will be checked facing the other way. + /// + public bool upsideDown = false; + } +} diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 390072a72..fe1ca4411 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -297,6 +297,8 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) ProjectionBuilder.InitPrefabs(); CloakBuilder.InitPrefab(); RaftBuilder.InitPrefab(); + + WarpPadBuilder.InitPrefabs(); } catch (Exception e) { diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index a00475c9c..ca3a2cf1e 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -188,6 +188,11 @@ public static GameObject InstantiateInactive(this GameObject original) return copy; } + public static GameObject Instantiate(this GameObject original) + { + return UnityEngine.Object.Instantiate(original); + } + public static T DontDestroyOnLoad(this T target) where T : UnityEngine.Object { UnityEngine.Object.DontDestroyOnLoad(target); From d7bc9fa930edec0765391d0130101e6d61fd693b Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 22 Mar 2023 04:11:15 +0000 Subject: [PATCH 088/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 141 +++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 09f4f41de..dafd0917e 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1088,6 +1088,20 @@ "items": { "$ref": "#/definitions/RemoteInfo" } + }, + "warpReceivers": { + "type": "array", + "description": "Add warp pad receivers to this planet. These are the warp pads you are sent to from Ash Twin.", + "items": { + "$ref": "#/definitions/NomaiWarpReceiverInfo" + } + }, + "warpTransmitters": { + "type": "array", + "description": "Add warp pad transmitters to this planet. These are the warp pads seen on the Ash Twin.", + "items": { + "$ref": "#/definitions/NomaiWarpTransmitterInfo" + } } } }, @@ -2395,6 +2409,133 @@ } } }, + "NomaiWarpReceiverInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "frequency": { + "type": "string" + }, + "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" + }, + "alignmentTargetBody": { + "type": "string", + "description": "The body the transmitter must be aligned with to warp to this receiver.\nDefaults to the body the receiver is on." + }, + "computer": { + "description": "Will create a modern Nomai computer linked to this receiver.", + "$ref": "#/definitions/NomaiWarpComputerLoggerInfo" + }, + "detailed": { + "type": "boolean", + "description": "Set to true if you want to include Nomai ruin details around the warp pad." + } + } + }, + "NomaiWarpComputerLoggerInfo": { + "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" + } + } + }, + "NomaiWarpTransmitterInfo": { + "type": "object", + "additionalProperties": false, + "properties": { + "frequency": { + "type": "string" + }, + "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" + }, + "alignmentWindow": { + "type": "number", + "description": "In degrees. Gives a margin of error for alignments.", + "format": "float", + "default": 5.0 + }, + "upsideDown": { + "type": "boolean", + "description": "Is this transmitter upsidedown? Means alignment will be checked facing the other way." + } + } + }, "ReferenceFrameModule": { "type": "object", "additionalProperties": false, From 4cd15cc8ae7a056e49b80cc8a34b785d3d67bc2c Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 22 Mar 2023 00:38:34 -0400 Subject: [PATCH 089/119] Add the platform from remote viewers around the base of warp pads --- NewHorizons/Builder/Props/WarpPadBuilder.cs | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index ffe4600d5..a7ef62400 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -13,9 +13,20 @@ public static class WarpPadBuilder private static GameObject _detailedReceiverPrefab; private static GameObject _receiverPrefab; private static GameObject _transmitterPrefab; + private static GameObject _platformContainerPrefab; public static void InitPrefabs() { + if (_platformContainerPrefab == null) + { + // Put this around the platforms without details + // Trifid is a Nomai ruins genius + _platformContainerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/Prefab_NOM_RemoteViewer/Structure_NOM_RemoteViewer") + .InstantiateInactive() + .DontDestroyOnLoad(); + _platformContainerPrefab.transform.localScale = new Vector3(0.85f, 3f, 0.85f); + } + if (_detailedReceiverPrefab == null) { var thReceiverLamp = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Sector_NomaiCrater/Geometry_NomaiCrater/OtherComponentsGroup/Structure_NOM_WarpReceiver_TimberHearth_Lamp"); @@ -48,6 +59,12 @@ public static void InitPrefabs() .InstantiateInactive() .DontDestroyOnLoad(); GameObject.Destroy(_receiverPrefab.GetComponentInChildren().gameObject); + + var structure = _platformContainerPrefab.Instantiate(); + structure.transform.parent = _receiverPrefab.transform; + structure.transform.localPosition = new Vector3(0, 0.8945f, 0); + structure.transform.localRotation = Quaternion.identity; + structure.SetActive(true); } if (_transmitterPrefab == null) @@ -56,6 +73,12 @@ public static void InitPrefabs() .InstantiateInactive() .DontDestroyOnLoad(); GameObject.Destroy(_transmitterPrefab.GetComponentInChildren().gameObject); + + var structure = _platformContainerPrefab.Instantiate(); + structure.transform.parent = _transmitterPrefab.transform; + structure.transform.localPosition = new Vector3(0, 0.8945f, 0); + structure.transform.localRotation = Quaternion.identity; + structure.SetActive(true); } } From 43873ea04a25ee0db092c3b61fd5e5b87271e088 Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Wed, 22 Mar 2023 10:03:08 -0500 Subject: [PATCH 090/119] Add Whiteboard (with optional scroll) to translatorText --- .../TranslatorText/TranslatorTextBuilder.cs | 92 +++++++++++++------ NewHorizons/External/Modules/PropModule.cs | 2 + 2 files changed, 68 insertions(+), 26 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 8b36a0a8b..51d987ef0 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -75,48 +75,44 @@ internal static void InitPrefabs() .sharedMaterial; } - if (_scrollPrefab == null) _scrollPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive().Rename("Prefab_NOM_Scroll").DontDestroyOnLoad(); + if (_scrollPrefab == null) + { + _scrollPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive().Rename("Prefab_NOM_Scroll").DontDestroyOnLoad(); + } if (_computerPrefab == null) { _computerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive().Rename("Prefab_NOM_Computer").DontDestroyOnLoad(); - _computerPrefab.transform.rotation = Quaternion.identity; } 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.transform.rotation = Quaternion.identity; } if (_cairnPrefab == null) { _cairnPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_Crossroads/Interactables_Crossroads/Trailmarkers/Prefab_NOM_BH_Cairn_Arc (1)").InstantiateInactive().Rename("Prefab_NOM_Cairn").DontDestroyOnLoad(); - _cairnPrefab.transform.rotation = Quaternion.identity; } if (_cairnVariantPrefab == null) { _cairnVariantPrefab = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Sector_NomaiMines/Interactables_NomaiMines/Prefab_NOM_TH_Cairn_Arc").InstantiateInactive().Rename("Prefab_NOM_Cairn").DontDestroyOnLoad(); - _cairnVariantPrefab.transform.rotation = Quaternion.identity; } if (_recorderPrefab == null) { _recorderPrefab = SearchUtilities.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive().Rename("Prefab_NOM_Recorder").DontDestroyOnLoad(); - _recorderPrefab.transform.rotation = Quaternion.identity; } if (_preCrashRecorderPrefab == null) { _preCrashRecorderPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/Interactables_CrashFragment/Prefab_NOM_Recorder").InstantiateInactive().Rename("Prefab_NOM_Recorder_Vessel").DontDestroyOnLoad(); - _preCrashRecorderPrefab.transform.rotation = Quaternion.identity; } if (_trailmarkerPrefab == null) { _trailmarkerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Sign").InstantiateInactive().Rename("Prefab_NOM_Trailmarker").DontDestroyOnLoad(); - _trailmarkerPrefab.transform.rotation = Quaternion.identity; } } @@ -124,13 +120,19 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra { InitPrefabs(); - var xmlPath = File.ReadAllText(Path.Combine(nhBody.Mod.ModHelper.Manifest.ModFolderPath, info.xmlFile)); + var xmlContent = !string.IsNullOrEmpty(info.xmlFile) ? File.ReadAllText(Path.Combine(nhBody.Mod.ModHelper.Manifest.ModFolderPath, info.xmlFile)) : null; + + if (xmlContent == null && info.type != PropModule.NomaiTextType.Whiteboard) + { + Logger.LogError($"Failed to create translator text because {nameof(info.xmlFile)} was not set to a valid text .xml file path"); + return null; + } switch (info.type) { case PropModule.NomaiTextType.Wall: { - var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; + var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlContent, nhBody).gameObject; nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info); if (info.normal != null) @@ -156,7 +158,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra { var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); - var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); + var nomaiWallText = MakeWallText(planetGO, sector, info, xmlContent, nhBody); nomaiWallText.transform.parent = customScroll.transform; nomaiWallText.transform.localPosition = Vector3.zero; nomaiWallText.transform.localRotation = Quaternion.identity; @@ -212,10 +214,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra computer.SetSector(sector); computer._location = EnumUtils.Parse(info.location.ToString()); - computer._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - computer._nomaiTextAsset = new TextAsset(xmlPath); + computer._dictNomaiTextData = MakeNomaiTextDict(xmlContent); + computer._nomaiTextAsset = new TextAsset(xmlContent); computer._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile); - AddTranslation(xmlPath); + AddTranslation(xmlContent); // Make sure the computer model is loaded StreamingHandler.SetUpStreaming(computerObject, sector); @@ -243,10 +245,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra computer.SetSector(sector); computer._location = EnumUtils.Parse(info.location.ToString()); - computer._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - computer._nomaiTextAsset = new TextAsset(xmlPath); + computer._dictNomaiTextData = MakeNomaiTextDict(xmlContent); + computer._nomaiTextAsset = new TextAsset(xmlContent); computer._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile); - AddTranslation(xmlPath); + AddTranslation(xmlContent); // Make fifth ring work var fifthRingObject = computerObject.FindChild("Props_NOM_Vessel_Computer 1/Props_NOM_Vessel_Computer_Effects (4)"); @@ -297,10 +299,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra nomaiWallText.SetSector(sector); nomaiWallText._location = EnumUtils.Parse(info.location.ToString()); - nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - nomaiWallText._nomaiTextAsset = new TextAsset(xmlPath); + nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlContent); + nomaiWallText._nomaiTextAsset = new TextAsset(xmlContent); nomaiWallText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile); - AddTranslation(xmlPath); + AddTranslation(xmlContent); // Make sure the computer model is loaded StreamingHandler.SetUpStreaming(cairnObject, sector); @@ -327,10 +329,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra nomaiText.SetSector(sector); nomaiText._location = EnumUtils.Parse(info.location.ToString()); - nomaiText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - nomaiText._nomaiTextAsset = new TextAsset(xmlPath); + nomaiText._dictNomaiTextData = MakeNomaiTextDict(xmlContent); + nomaiText._nomaiTextAsset = new TextAsset(xmlContent); nomaiText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile); - AddTranslation(xmlPath); + AddTranslation(xmlContent); recorderObject.SetActive(true); @@ -352,10 +354,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra nomaiWallText.SetSector(sector); nomaiWallText._location = EnumUtils.Parse(info.location.ToString()); - nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlPath); - nomaiWallText._nomaiTextAsset = new TextAsset(xmlPath); + nomaiWallText._dictNomaiTextData = MakeNomaiTextDict(xmlContent); + nomaiWallText._nomaiTextAsset = new TextAsset(xmlContent); nomaiWallText._nomaiTextAsset.name = Path.GetFileNameWithoutExtension(info.xmlFile); - AddTranslation(xmlPath); + AddTranslation(xmlContent); // Make sure the model is loaded StreamingHandler.SetUpStreaming(trailmarkerObject, sector); @@ -363,6 +365,44 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra return trailmarkerObject; } + case PropModule.NomaiTextType.Whiteboard: + { + var whiteboardInfo = new PropModule.DetailInfo() + { + alignRadial = info.alignRadial, + isRelativeToParent = info.isRelativeToParent, + parentPath = info.parentPath, + path = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/VisibleFrom_HangingCity/Props_NOM_Whiteboard (1)", + position = info.position, + rename = info.rename ?? "Props_NOM_Whiteboard", + rotation = info.rotation, + }; + var whiteboardObject = DetailBuilder.Make(planetGO, sector, whiteboardInfo); + + // Spawn a scroll and insert it into the whiteboard, but only if text is provided + if (!string.IsNullOrEmpty(info.xmlFile)) + { + var scrollSocket = whiteboardObject.GetComponentInChildren(); + + var scrollInfo = new PropModule.TranslatorTextInfo() + { + type = PropModule.NomaiTextType.Scroll, + arcInfo = info.arcInfo, + seed = info.seed, + xmlFile = info.xmlFile, + }; + + var scrollObject = Make(planetGO, sector, scrollInfo, nhBody); + var scrollItem = scrollObject.GetComponent(); + + Delay.FireOnNextUpdate(() => + { + scrollSocket.PlaceIntoSocket(scrollItem); + }); + } + + return whiteboardObject; + } default: Logger.LogError($"Unsupported NomaiText type {info.type}"); return null; diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 5772cd265..628110350 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -523,6 +523,8 @@ public enum NomaiTextType [EnumMember(Value = @"trailmarker")] Trailmarker = 7, [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, + + [EnumMember(Value = @"whiteboard")] Whiteboard = 9, } [JsonConverter(typeof(StringEnumConverter))] From 29630d19440d08c32962a24e235b9ecbf615a347 Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 22 Mar 2023 15:08:14 +0000 Subject: [PATCH 091/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 09f4f41de..6fcf66d1a 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1529,7 +1529,8 @@ "PreCrashRecorder", "PreCrashComputer", "Trailmarker", - "CairnVariant" + "CairnVariant", + "Whiteboard" ], "enum": [ "wall", @@ -1540,7 +1541,8 @@ "preCrashRecorder", "preCrashComputer", "trailmarker", - "cairnVariant" + "cairnVariant", + "whiteboard" ] }, "NomaiTextLocation": { From 094968187bf90f322710e63ad88c7da4c269fc5b Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Wed, 22 Mar 2023 13:36:03 -0500 Subject: [PATCH 092/119] Add isDefault flag to planet spawns --- NewHorizons/External/Modules/SpawnModule.cs | 4 ++++ NewHorizons/Handlers/PlanetCreationHandler.cs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index a73beb3f2..5e2d0377b 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -29,6 +29,10 @@ public class PlayerSpawnPoint : GeneralPropInfo { /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) /// public bool startWithSuit; + /// + /// Whether this planet's spawn point is the one the player will initially spawn at, if multiple spawn points exist. + /// + public bool isDefault; } [JsonObject] diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index b32dda4ed..7b7c1180d 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -454,7 +454,11 @@ public static GameObject GenerateStandardBody(NewHorizonsBody body, bool default if (body.Config.Spawn != null) { Logger.LogVerbose("Making spawn point"); - Main.SystemDict[body.Config.starSystem].SpawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody); + var spawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody); + if (Main.SystemDict[body.Config.starSystem].SpawnPoint == null || (body.Config.Spawn.playerSpawn?.isDefault ?? false)) + { + Main.SystemDict[body.Config.starSystem].SpawnPoint = spawnPoint; + } } if (body.Config.Orbit.showOrbitLine && !body.Config.Orbit.isStatic) From 5805908e6d121f6ef70671c6b4c3999ac6c2038c Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Wed, 22 Mar 2023 13:37:14 -0500 Subject: [PATCH 093/119] Fix vessel spawn overriding other spawns --- NewHorizons/Handlers/VesselWarpHandler.cs | 11 +++++++---- .../Patches/PlayerPatches/PlayerSpawnerPatches.cs | 10 +++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 922192f5e..dc4023f3c 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -45,7 +45,7 @@ public static bool ShouldSpawnAtVessel() { var vesselConfig = SystemDict[Instance.CurrentStarSystem].Config?.Vessel; var shouldSpawnOnVessel = IsVesselPresent() && (vesselConfig?.spawnOnVessel ?? false); - return Instance.IsWarpingFromVessel || shouldSpawnOnVessel; + return !Instance.IsWarpingFromShip && (Instance.IsWarpingFromVessel || shouldSpawnOnVessel); } public static void LoadVessel() @@ -174,9 +174,6 @@ public static EyeSpawnPoint CreateVessel() vesselObject.GetComponent()._labelID = (UITextType)TranslationHandler.AddUI("Vessel"); - EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren(true); - system.SpawnPoint = eyeSpawnPoint; - var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody); var hasPhysics = system.Config.Vessel?.hasPhysics ?? !hasParentBody; @@ -209,6 +206,12 @@ public static EyeSpawnPoint CreateVessel() } } + EyeSpawnPoint eyeSpawnPoint = vesselObject.GetComponentInChildren(true); + if (ShouldSpawnAtVessel()) + { + system.SpawnPoint = eyeSpawnPoint; + } + vesselObject.SetActive(true); Delay.FireOnNextUpdate(() => SetupWarpController(vesselWarpController)); diff --git a/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs b/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs index 80f814fbb..11bcc7c16 100644 --- a/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs +++ b/NewHorizons/Patches/PlayerPatches/PlayerSpawnerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Utility; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Patches.PlayerPatches @@ -15,12 +16,15 @@ public static bool PlayerSpawner_SpawnPlayer(PlayerSpawner __instance) Logger.LogWarning("Abort player spawn. Vessel will handle it."); return false; } - else + else if (Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint != null) { - Logger.LogVerbose("Player spawning"); + Logger.LogVerbose($"Player spawning at {Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint.transform.GetPath()}"); __instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint); - return true; + } else if (Main.Instance.CurrentStarSystem != "SolarSystem" && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") + { + Logger.LogWarning("No player spawn point set."); } + return true; } } } From f12be8c73ac70647ccadd351a125bfa2b6b9d87b Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 22 Mar 2023 18:41:33 +0000 Subject: [PATCH 094/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 09f4f41de..5cfcecf81 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2691,6 +2691,10 @@ "startWithSuit": { "type": "boolean", "description": "If you spawn on a planet with no oxygen, you probably want to set this to true ;;)" + }, + "isDefault": { + "type": "boolean", + "description": "Whether this planet's spawn point is the one the player will initially spawn at, if multiple spawn points exist." } } }, From c7632aa70ed3e28edf9b534fcb63824d1f6ca72b Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Wed, 22 Mar 2023 18:27:09 -0500 Subject: [PATCH 095/119] Pair up singularities after all planets have been built --- .../Builder/Body/SingularityBuilder.cs | 88 +++++++++---------- NewHorizons/Handlers/PlanetCreationHandler.cs | 2 + NewHorizons/Main.cs | 1 + 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 8f84e77fc..4ca159822 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -32,6 +32,7 @@ public static class SingularityBuilder public static readonly int Color1 = Shader.PropertyToID("_Color"); private static Dictionary _singularitiesByID; + private static List<(string, string)> _pairsToLink; private static Mesh _blackHoleMesh; private static GameObject _blackHoleAmbience; @@ -45,14 +46,8 @@ public static class SingularityBuilder private static GameObject _whiteHoleRulesetVolume; private static GameObject _whiteHoleVolume; - private static bool _isInit; - internal static void InitPrefabs() { - if (_isInit) return; - - _isInit = true; - if (_blackHoleProxyPrefab == null) _blackHoleProxyPrefab = SearchUtilities.Find(_blackHoleProxyPath).InstantiateInactive().Rename("BlackHoleSingularity").DontDestroyOnLoad(); if (_whiteHoleProxyPrefab == null) _whiteHoleProxyPrefab = SearchUtilities.Find(_whiteHoleProxyPath).InstantiateInactive().Rename("WhiteHoleSingularity").DontDestroyOnLoad(); @@ -72,13 +67,14 @@ internal static void InitPrefabs() if (_whiteHoleVolume == null) _whiteHoleVolume = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVolume").InstantiateInactive().Rename("WhiteHoleVolume").DontDestroyOnLoad(); } - public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityModule singularity) + public static void Init() { - InitPrefabs(); - - // If we've reloaded the first one will now be null so we have to refresh the list - if (_singularitiesByID?.Values?.FirstOrDefault() == null) _singularitiesByID = new Dictionary(); + _singularitiesByID = new Dictionary(); + _pairsToLink = new List<(string, string)>(); + } + public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityModule singularity) + { var horizonRadius = singularity.horizonRadius; var distortRadius = singularity.distortRadius != 0f ? singularity.distortRadius : horizonRadius * 2.5f; var pairedSingularity = singularity.pairedSingularity; @@ -95,51 +91,57 @@ public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetCo hasHazardVolume, singularity.targetStarSystem, singularity.curve, singularity.hasWarpEffects, singularity.renderQueueOverride, singularity.rename, singularity.parentPath, singularity.isRelativeToParent); var uniqueID = string.IsNullOrEmpty(singularity.uniqueID) ? config.name : singularity.uniqueID; + _singularitiesByID.Add(uniqueID, newSingularity); - - // Try to pair them - if (!string.IsNullOrEmpty(pairedSingularity) && newSingularity != null) + if (!string.IsNullOrEmpty(pairedSingularity)) { - if (_singularitiesByID.TryGetValue(pairedSingularity, out var pairedSingularityGO)) + if (polarity) { - switch (polarity) - { - case true: - PairSingularities(uniqueID, pairedSingularity, newSingularity, pairedSingularityGO); - break; - case false: - PairSingularities(pairedSingularity, uniqueID, pairedSingularityGO, newSingularity); - break; - } + _pairsToLink.Add((uniqueID, pairedSingularity)); + } + else + { + _pairsToLink.Add((pairedSingularity, uniqueID)); } } + } - public static void PairSingularities(string blackHoleID, string whiteHoleID, GameObject blackHole, GameObject whiteHole) + public static void PairAllSingularities() { - InitPrefabs(); - - if (blackHole == null || whiteHole == null) return; - - Logger.LogVerbose($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]"); - - var whiteHoleVolume = whiteHole.GetComponentInChildren(); - var blackHoleVolume = blackHole.GetComponentInChildren(); - - if (whiteHoleVolume == null || blackHoleVolume == null) + foreach (var pair in _pairsToLink) { - Logger.LogWarning($"[{blackHoleID}] and [{whiteHoleID}] do not have compatible polarities"); - return; + var (blackHoleID, whiteHoleID) = pair; + if (!_singularitiesByID.TryGetValue(blackHoleID, out GameObject blackHole)) + { + Logger.LogWarning($"Black hole [{blackHoleID}] is missing."); + break; + } + if (!_singularitiesByID.TryGetValue(whiteHoleID, out GameObject whiteHole)) + { + Logger.LogWarning($"White hole [{whiteHoleID}] is missing."); + break; + } + var whiteHoleVolume = whiteHole.GetComponentInChildren(); + var blackHoleVolume = blackHole.GetComponentInChildren(); + if (whiteHoleVolume == null || blackHoleVolume == null) + { + Logger.LogWarning($"Singularities [{blackHoleID}] and [{whiteHoleID}] do not have compatible polarities."); + break; + } + if (blackHoleVolume._whiteHole != null && blackHoleVolume._whiteHole != whiteHoleVolume) + { + Logger.LogWarning($"Black hole [{blackHoleID}] has already been linked!"); + break; + } + Logger.LogVerbose($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]"); + blackHoleVolume._whiteHole = whiteHoleVolume; } - - blackHoleVolume._whiteHole = whiteHoleVolume; } public static GameObject MakeSingularity(GameObject planetGO, Sector sector, Vector3 position, Vector3 rotation, bool polarity, float horizon, float distort, bool hasDestructionVolume, string targetStarSystem = null, TimeValuePair[] curve = null, bool warpEffects = true, int renderQueue = 2985, string rename = null, string parentPath = null, bool isRelativeToParent = false) { - InitPrefabs(); - // polarity true = black, false = white var info = new SingularityModule @@ -272,8 +274,6 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam public static MeshRenderer MakeSingularityGraphics(GameObject singularity, bool polarity, float horizon, float distort, int queue = 2985) { - InitPrefabs(); - var singularityRenderer = new GameObject(polarity ? "BlackHoleRenderer" : "WhiteHoleRenderer"); singularityRenderer.transform.parent = singularity.transform; singularityRenderer.transform.localPosition = Vector3.zero; @@ -296,8 +296,6 @@ public static MeshRenderer MakeSingularityGraphics(GameObject singularity, bool public static GameObject MakeSingularityProxy(GameObject rootObject, MVector3 position, bool polarity, float horizon, float distort, TimeValuePair[] curve = null, int queue = 2985) { - InitPrefabs(); - var singularityRenderer = MakeSingularityGraphics(rootObject, polarity, horizon, distort, queue); if (position != null) singularityRenderer.transform.localPosition = position; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 7b7c1180d..c6dd25dc9 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -131,6 +131,8 @@ public static void Init(List bodies) Logger.Log("Done loading bodies"); + SingularityBuilder.PairAllSingularities(); + // Events.FireOnNextUpdate(PlanetDestroyer.RemoveAllProxies); if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveStockPlanets(); diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 048525a8d..080bae406 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -376,6 +376,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode) AudioTypeHandler.Init(); InterferenceHandler.Init(); RemoteHandler.Init(); + SingularityBuilder.Init(); AtmosphereBuilder.Init(); BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray()); From 30ff6367efcffefe728e869c182e5bab9e754ecc Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 22 Mar 2023 22:38:53 -0400 Subject: [PATCH 096/119] Fix bad merge --- NewHorizons/Builder/Props/WarpPadBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index a7ef62400..f1afde449 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -1,4 +1,5 @@ using Epic.OnlineServices.Presence; +using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.External.Modules.WarpPad; using NewHorizons.Handlers; using NewHorizons.Utility; From 9c5982d9a4857d022f483e2edd94750c41f78dfb Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 22 Mar 2023 23:31:10 -0400 Subject: [PATCH 097/119] Use detail info instead --- NewHorizons/Builder/Props/WarpPadBuilder.cs | 15 ++++----------- NewHorizons/External/Modules/PropModule.cs | 10 ++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index f1afde449..e6ae0b427 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -1,7 +1,6 @@ -using Epic.OnlineServices.Presence; using NewHorizons.Builder.Props.TranslatorText; +using NewHorizons.External.Modules; using NewHorizons.External.Modules.WarpPad; -using NewHorizons.Handlers; using NewHorizons.Utility; using NewHorizons.Utility.OWMLUtilities; using OWML.Utils; @@ -85,9 +84,7 @@ public static void InitPrefabs() public static void Make(GameObject planetGO, Sector sector, NomaiWarpReceiverInfo info) { - var receiverObject = GeneralPropBuilder.MakeFromPrefab(info.detailed ? _detailedReceiverPrefab : _receiverPrefab, "NomaiWarpReceiver", planetGO, sector, info); - - StreamingHandler.SetUpStreaming(receiverObject, sector); + var receiverObject = DetailBuilder.Make(planetGO, sector, info.detailed ? _detailedReceiverPrefab : _receiverPrefab, new PropModule.DetailInfo(info)); var receiver = receiverObject.GetComponentInChildren(); @@ -107,9 +104,7 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpReceiverInf public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitterInfo info) { - var transmitterObject = GeneralPropBuilder.MakeFromPrefab(_transmitterPrefab, "NomaiWarpTransmitter", planetGO, sector, info); - - StreamingHandler.SetUpStreaming(transmitterObject, sector); + var transmitterObject = DetailBuilder.Make(planetGO, sector, _transmitterPrefab, new PropModule.DetailInfo(info)); var transmitter = transmitterObject.GetComponentInChildren(); transmitter._frequency = GetFrequency(info.frequency); @@ -123,7 +118,7 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitter private static void CreateComputer(GameObject planetGO, Sector sector, NomaiWarpComputerLoggerInfo computerInfo, NomaiWarpReceiver receiver) { - var computerObject = GeneralPropBuilder.MakeFromPrefab(TranslatorTextBuilder.ComputerPrefab, TranslatorTextBuilder.ComputerPrefab.name, planetGO, sector, computerInfo); + var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new PropModule.DetailInfo(computerInfo)); var computer = computerObject.GetComponentInChildren(); computer.SetSector(sector); @@ -133,8 +128,6 @@ private static void CreateComputer(GameObject planetGO, Sector sector, NomaiWarp var computerLogger = computerObject.AddComponent(); computerLogger._warpReceiver = receiver; - StreamingHandler.SetUpStreaming(computerObject, sector); - computerObject.SetActive(true); } diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index ede2eb5a3..539cab5d1 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -175,6 +175,16 @@ public class ScatterInfo [JsonObject] public class DetailInfo : GeneralPropInfo { + public DetailInfo() { } + + public DetailInfo(GeneralPropInfo info) + { + foreach (var prop in info.GetType().GetProperties()) + { + GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(info, null), null); + } + } + /// /// Relative filepath to an asset-bundle to load the prefab defined in `path` from /// From d847f13e8397121bcbce2fe111412e5ba0caf2ef Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 22 Mar 2023 23:46:40 -0400 Subject: [PATCH 098/119] Simplify calls to detail builder --- .../Builder/Body/BrambleDimensionBuilder.cs | 3 +-- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 18 ++----------- .../Builder/Props/ProjectionBuilder.cs | 21 ++-------------- NewHorizons/Builder/Props/RemoteBuilder.cs | 25 ++++--------------- .../TranslatorText/TranslatorTextBuilder.cs | 21 ++-------------- NewHorizons/External/Modules/PropModule.cs | 8 ++++++ 6 files changed, 20 insertions(+), 76 deletions(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 5ef9764db..fcbd1f872 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -104,8 +104,7 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject default: geometryPrefab = _hubGeometry; break; } - var detailInfo = new PropModule.DetailInfo(); - var geometry = DetailBuilder.Make(go, sector, geometryPrefab, detailInfo); + var geometry = DetailBuilder.Make(go, sector, geometryPrefab, new PropModule.DetailInfo()); var exitWarps = _exitWarps.InstantiateInactive(); var repelVolume = _repelVolume.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 5b8e91d43..19af1f49b 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -360,14 +360,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom } case PropModule.NomaiTextType.PreCrashComputer: { - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; - var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, detailInfo); + var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, new PropModule.DetailInfo(info)); computerObject.SetActive(false); var up = computerObject.transform.position - planetGO.transform.position; @@ -487,14 +480,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom case PropModule.NomaiTextType.Recorder: { var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); - var detailInfo = new PropModule.DetailInfo { - parentPath = info.parentPath, - rotation = info.rotation, - position = info.position, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; - var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo); + var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, new PropModule.DetailInfo(info)); recorderObject.SetActive(false); if (info.rotation == null) diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 19e1225ff..6bddf3036 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -202,16 +202,7 @@ public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector if (_visionTorchDetectorPrefab == null) return null; // spawn a trigger for the vision torch - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector", - scale = 2 - }; - var g = DetailBuilder.Make(planetGO, sector, _visionTorchDetectorPrefab, detailInfo); + var g = DetailBuilder.Make(planetGO, sector, _visionTorchDetectorPrefab, new DetailInfo(info) { scale = 2, rename = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector" }); if (g == null) { @@ -248,15 +239,7 @@ public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sec if (_standingVisionTorchPrefab == null) return null; // Spawn the torch itself - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; - var standingTorch = DetailBuilder.Make(planetGO, sector, _standingVisionTorchPrefab, detailInfo); + var standingTorch = DetailBuilder.Make(planetGO, sector, _standingVisionTorchPrefab, new DetailInfo(info)); if (standingTorch == null) { diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 4cd1e19db..98cf8534a 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -7,6 +7,7 @@ using System; using System.Linq; using UnityEngine; +using static NewHorizons.External.Modules.PropModule; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Props @@ -171,15 +172,7 @@ public static void Make(GameObject go, Sector sector, PropModule.RemoteInfo info public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.WhiteboardInfo info, NewHorizonsBody nhBody) { - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; - var whiteboard = DetailBuilder.Make(go, sector, _whiteboardPrefab, detailInfo); + var whiteboard = DetailBuilder.Make(go, sector, _whiteboardPrefab, new DetailInfo(info)); whiteboard.SetActive(false); var decalMat = new Material(_decalMaterial); @@ -196,7 +189,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer { var textInfo = info.nomaiText[i]; component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id); - var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.TranslatorTextInfo + var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new TranslatorTextInfo { arcInfo = textInfo.arcInfo, location = textInfo.location, @@ -205,7 +198,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer rename = textInfo.rename, rotation = Vector3.zero, seed = textInfo.seed, - type = PropModule.NomaiTextType.Wall, + type = NomaiTextType.Wall, xmlFile = textInfo.xmlFile }, nhBody).GetComponent(); wallText._showTextOnStart = false; @@ -219,15 +212,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.PlatformInfo info, IModBehaviour mod) { - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename - }; - var platform = DetailBuilder.Make(go, sector, _remoteCameraPlatformPrefab, detailInfo); + var platform = DetailBuilder.Make(go, sector, _remoteCameraPlatformPrefab, new DetailInfo(info)); platform.SetActive(false); var decalMat = new Material(_decalMaterial); diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 32ef0acb8..2c096bd86 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -229,16 +229,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra } case PropModule.NomaiTextType.PreCrashComputer: { - var detailInfo = new PropModule.DetailInfo() - { - position = info.position, - rotation = info.rotation, - parentPath = info.parentPath, - isRelativeToParent = info.isRelativeToParent, - alignRadial = info.alignRadial, - rename = info.rename - }; - var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, detailInfo); + var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, new PropModule.DetailInfo(info)); computerObject.SetActive(false); var computer = computerObject.GetComponent(); @@ -314,15 +305,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra case PropModule.NomaiTextType.Recorder: { var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); - var detailInfo = new PropModule.DetailInfo { - parentPath = info.parentPath, - rotation = info.rotation, - position = info.position, - isRelativeToParent = info.isRelativeToParent, - rename = info.rename, - alignRadial = info.alignRadial, - }; - var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo); + var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, new PropModule.DetailInfo(info)); recorderObject.SetActive(false); var nomaiText = recorderObject.GetComponentInChildren(); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 539cab5d1..309e8e538 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -185,6 +185,14 @@ public DetailInfo(GeneralPropInfo info) } } + public DetailInfo(GeneralPointPropInfo info) + { + foreach (var prop in info.GetType().GetProperties()) + { + GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(info, null), null); + } + } + /// /// Relative filepath to an asset-bundle to load the prefab defined in `path` from /// From 0c619e0fd1c4055603e04ac8582a1ef2f890ca51 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 23 Mar 2023 00:34:20 -0400 Subject: [PATCH 099/119] Fix warp pads --- NewHorizons/Builder/Props/GeneralPropBuilder.cs | 5 ----- NewHorizons/Builder/Props/WarpPadBuilder.cs | 6 +++++- NewHorizons/External/Modules/PropModule.cs | 14 ++------------ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index eae23d74d..41a3319ec 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -1,11 +1,6 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.OWUtilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index e6ae0b427..7494d70fb 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -5,6 +5,7 @@ using NewHorizons.Utility.OWMLUtilities; using OWML.Utils; using UnityEngine; +using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Props { @@ -84,7 +85,10 @@ public static void InitPrefabs() public static void Make(GameObject planetGO, Sector sector, NomaiWarpReceiverInfo info) { - var receiverObject = DetailBuilder.Make(planetGO, sector, info.detailed ? _detailedReceiverPrefab : _receiverPrefab, new PropModule.DetailInfo(info)); + var detailInfo = new PropModule.DetailInfo(info); + var receiverObject = DetailBuilder.Make(planetGO, sector, info.detailed ? _detailedReceiverPrefab : _receiverPrefab, detailInfo); + + Logger.Log($"Position is {detailInfo.position} was {info.position}"); var receiver = receiverObject.GetComponentInChildren(); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 309e8e538..8ed805bd1 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -3,6 +3,7 @@ using NewHorizons.Utility; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -177,20 +178,9 @@ public class DetailInfo : GeneralPropInfo { public DetailInfo() { } - public DetailInfo(GeneralPropInfo info) - { - foreach (var prop in info.GetType().GetProperties()) - { - GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(info, null), null); - } - } - public DetailInfo(GeneralPointPropInfo info) { - foreach (var prop in info.GetType().GetProperties()) - { - GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(info, null), null); - } + JsonConvert.PopulateObject(JsonConvert.SerializeObject(info), this); } /// From 31fb962f579cc983a654ee6acbb507847c76ded3 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 23 Mar 2023 00:39:58 -0400 Subject: [PATCH 100/119] Remove register warp receiver --- NewHorizons/Builder/Props/WarpPadBuilder.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index 7494d70fb..f106dc57e 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -96,8 +96,6 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpReceiverInf receiver._alignmentTarget = planetGO?.transform; - Locator.RegisterWarpReceiver(receiver); - receiverObject.SetActive(true); if (info.computer != null) From ad704d9bf600afa4699f16aaa4b727088a3c5cec Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 22 Mar 2023 22:13:49 -0700 Subject: [PATCH 101/119] TranslatorTextBuilder: dont do auto spiral if any property is specified --- .../TranslatorText/TranslatorTextBuilder.cs | 12 +++++----- NewHorizons/External/Modules/PropModule.cs | 22 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 2c096bd86..3c9ca9b07 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -522,14 +522,12 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers var arcInfo = info.arcInfo[j]; var arc = arranger.spirals[j]; - if (arcInfo.position != null) arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); - - if (arcInfo.zRotation != null) arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.Value); - - if (arcInfo.mirror != null) + if (arcInfo.position != null || arcInfo.zRotation != null || arcInfo.mirror != null) { - if (arcInfo.mirror.Value) arc.transform.localScale = new Vector3(-1, 1, 1); - else arc.transform.localScale = new Vector3(1, 1, 1); + var pos = (Vector2)(arcInfo.position ?? Vector2.zero); + arc.transform.localPosition = new Vector3(pos.x, pos.y, 0); + arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.GetValueOrDefault()); + arc.transform.localScale = arcInfo.mirror.GetValueOrDefault() ? new Vector3(-1, 1, 1) : new Vector3(1, 1, 1); } } diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 8ed805bd1..78b12b35d 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -610,30 +610,30 @@ public enum NomaiTextArcType } /// - /// Whether to flip the spiral from left-curling to right-curling or vice versa. If not specified, will use auto spiral generated value. + /// The type of text to display. /// - public bool? mirror; - + [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; + /// - /// The local position of this object on the wall. If not specified, will use auto spiral generated value. + /// The local position of this object on the wall. If specified, auto spiral will not touch this arc. /// public MVector2 position; /// - /// The type of text to display. + /// The z euler angle for this arc. If specified, auto spiral will not touch this arc. /// - [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; + [Range(0f, 360f)] public float? zRotation; /// - /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. + /// Whether to flip the spiral from left-curling to right-curling or vice versa. If specified, auto spiral will not touch this arc. /// - [Obsolete("only used in old nomai text")] - [DefaultValue(-1)] public int variation = -1; + public bool? mirror; /// - /// The z euler angle for this arc. If not specified, will use auto spiral generated value. + /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. /// - [Range(0f, 360f)] public float? zRotation; + [Obsolete("only used in old nomai text")] + [DefaultValue(-1)] public int variation = -1; } [JsonObject] From ad7ae299f229f6221d3482f5e067761fed150190 Mon Sep 17 00:00:00 2001 From: Ben C Date: Thu, 23 Mar 2023 05:17:36 +0000 Subject: [PATCH 102/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 50 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 6b56c515e..28d56ac29 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1471,45 +1471,31 @@ "type": "object", "additionalProperties": false, "properties": { - "mirror": { - "type": [ - "boolean", - "null" - ], - "description": "Whether to flip the spiral from left-curling to right-curling or vice versa. If not specified, will use auto spiral generated value." - }, - "position": { - "description": "The local position of this object on the wall. If not specified, will use auto spiral generated value.", - "$ref": "#/definitions/MVector2" - }, "type": { "description": "The type of text to display.", "default": "adult", "$ref": "#/definitions/NomaiTextArcType" }, + "position": { + "description": "The local position of this object on the wall. If specified, auto spiral will not touch this arc.", + "$ref": "#/definitions/MVector2" + }, "zRotation": { "type": [ "null", "number" ], - "description": "The z euler angle for this arc. If not specified, will use auto spiral generated value.", + "description": "The z euler angle for this arc. If specified, auto spiral will not touch this arc.", "format": "float", "maximum": 360.0, "minimum": 0.0 - } - } - }, - "MVector2": { - "type": "object", - "additionalProperties": false, - "properties": { - "x": { - "type": "number", - "format": "float" }, - "y": { - "type": "number", - "format": "float" + "mirror": { + "type": [ + "boolean", + "null" + ], + "description": "Whether to flip the spiral from left-curling to right-curling or vice versa. If specified, auto spiral will not touch this arc." } } }, @@ -1527,6 +1513,20 @@ "stranger" ] }, + "MVector2": { + "type": "object", + "additionalProperties": false, + "properties": { + "x": { + "type": "number", + "format": "float" + }, + "y": { + "type": "number", + "format": "float" + } + } + }, "NomaiTextType": { "type": "string", "description": "", From 3e681fea60ca4e28299289d7032b7c6f2b216729 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 22 Mar 2023 22:28:52 -0700 Subject: [PATCH 103/119] use better whiteboard --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 3c9ca9b07..338da77d6 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -355,7 +355,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra alignRadial = info.alignRadial, isRelativeToParent = info.isRelativeToParent, parentPath = info.parentPath, - path = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/VisibleFrom_HangingCity/Props_NOM_Whiteboard (1)", + path = "TimberHearth_Body/Sector_TH/Sector_NomaiMines/Interactables_NomaiMines/Props_NOM_Whiteboard/Props_NOM_Whiteboard (1)", position = info.position, rename = info.rename ?? "Props_NOM_Whiteboard", rotation = info.rotation, From 83d86ff4858e8a1f477fa1f45b94a4eda38a9f35 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 13:07:20 -0700 Subject: [PATCH 104/119] kill ignoresun entirely fuck it --- NewHorizons/Builder/Props/DetailBuilder.cs | 4 ++++ .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index e4e59795e..8ea3d9430 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -3,6 +3,7 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using System; using System.Collections.Generic; @@ -103,6 +104,9 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P var isTorch = prop.GetComponent() != null; isItem = false; + // IgnoreSun is just a shadow casting optimization for BH so we can get rid of it + if (go.layer == Layer.IgnoreSun) go.layer = Layer.Default; + foreach (var component in prop.GetComponentsInChildren(true)) { // Components can come through as null here (yes, really), diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 338da77d6..3c9ca9b07 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -355,7 +355,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra alignRadial = info.alignRadial, isRelativeToParent = info.isRelativeToParent, parentPath = info.parentPath, - path = "TimberHearth_Body/Sector_TH/Sector_NomaiMines/Interactables_NomaiMines/Props_NOM_Whiteboard/Props_NOM_Whiteboard (1)", + path = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/VisibleFrom_HangingCity/Props_NOM_Whiteboard (1)", position = info.position, rename = info.rename ?? "Props_NOM_Whiteboard", rotation = info.rotation, From f9d9733fccd3d947b33ee8300940c670e924ef81 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 13:30:48 -0700 Subject: [PATCH 105/119] oops --- 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 8ea3d9430..5cfa4ac6a 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -105,7 +105,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P isItem = false; // IgnoreSun is just a shadow casting optimization for BH so we can get rid of it - if (go.layer == Layer.IgnoreSun) go.layer = Layer.Default; + if (prop.layer == Layer.IgnoreSun) prop.layer = Layer.Default; foreach (var component in prop.GetComponentsInChildren(true)) { From 6e49af5abcac402607a1aeb0a56d628db4812b10 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 13:07:20 -0700 Subject: [PATCH 106/119] kill ignoresun entirely fuck it --- NewHorizons/Builder/Props/DetailBuilder.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 5cfa4ac6a..2b0b46f3a 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -279,8 +279,13 @@ private static bool FixUnsectoredComponent(Component component) private static void FixComponent(Component component, GameObject planetGO) { // Fix other components + // IgnoreSun is just a shadow casting optimization for BH so we can get rid of it + if (component is Transform && component.gameObject.layer == Layer.IgnoreSun) + { + component.gameObject.layer = Layer.Default; + } // I forget why this is here - if (component is GhostIK or GhostEffects) + else if (component is GhostIK or GhostEffects) { Component.DestroyImmediate(component); return; From 5f65bb5360f6d9c6831b1a15f75e8987233342e9 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 13:32:55 -0700 Subject: [PATCH 107/119] grrrrr --- NewHorizons/Builder/Props/DetailBuilder.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 2b0b46f3a..bb10ba295 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -104,9 +104,6 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P var isTorch = prop.GetComponent() != null; isItem = false; - // IgnoreSun is just a shadow casting optimization for BH so we can get rid of it - if (prop.layer == Layer.IgnoreSun) prop.layer = Layer.Default; - foreach (var component in prop.GetComponentsInChildren(true)) { // Components can come through as null here (yes, really), From b134e123892cb2591acfcb95ad38ad4884206159 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 13:37:33 -0700 Subject: [PATCH 108/119] use simplified call to detail info thing --- .../Builder/Props/TranslatorText/TranslatorTextBuilder.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 3c9ca9b07..49185247e 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -350,15 +350,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra } case PropModule.NomaiTextType.Whiteboard: { - var whiteboardInfo = new PropModule.DetailInfo() + var whiteboardInfo = new PropModule.DetailInfo(info) { - alignRadial = info.alignRadial, - isRelativeToParent = info.isRelativeToParent, - parentPath = info.parentPath, path = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/VisibleFrom_HangingCity/Props_NOM_Whiteboard (1)", - position = info.position, rename = info.rename ?? "Props_NOM_Whiteboard", - rotation = info.rotation, }; var whiteboardObject = DetailBuilder.Make(planetGO, sector, whiteboardInfo); From 97c869bd16c3c505a18f93d8fcd1c3d9000aec56 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 14:18:04 -0700 Subject: [PATCH 109/119] FireOnNextUpdate my beloved --- .../Props/TranslatorText/TranslatorTextBuilder.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 49185247e..213f3605a 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -1,3 +1,4 @@ +using HarmonyLib; using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; @@ -276,12 +277,16 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra cairnObject.SetActive(true); // Make it do the thing when it finishes being knocked over - foreach (var rock in cairnObject.GetComponent()._rocks) + // idk why, but sometimes stuff is null here, so just wait a frame to let it initialize + Delay.FireOnNextUpdate(() => { - rock._returning = false; - rock._owCollider.SetActivation(true); - rock.enabled = false; - } + foreach (var rock in cairnObject.GetComponent()._rocks) + { + rock._returning = false; + rock._owCollider.SetActivation(true); + rock.enabled = false; + } + }); // So we can actually knock it over cairnObject.GetComponent().enabled = true; From 572702bac070c01126ad2b2772c9faccdddc44d9 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 14:22:27 -0700 Subject: [PATCH 110/119] comment --- 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 bb10ba295..a280a4a3e 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -276,7 +276,7 @@ private static bool FixUnsectoredComponent(Component component) private static void FixComponent(Component component, GameObject planetGO) { // Fix other components - // IgnoreSun is just a shadow casting optimization for BH so we can get rid of it + // IgnoreSun is just a shadow casting optimization for caves and stuff so we can get rid of it if (component is Transform && component.gameObject.layer == Layer.IgnoreSun) { component.gameObject.layer = Layer.Default; From 687151c36bd1ea905667ec09ac5a63b5f490d881 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 16:00:41 -0700 Subject: [PATCH 111/119] potentially fix cull group map bug --- NewHorizons/Builder/Props/DetailBuilder.cs | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index a280a4a3e..c19407096 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -119,7 +119,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P { if (FixUnsectoredComponent(component)) continue; } - else FixSectoredComponent(component, sector, isTorch); + else FixSectoredComponent(component, sector, isTorch, detail.keepLoaded); FixComponent(component, go); } @@ -214,10 +214,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P /// /// 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 isTorch = false) + private static void FixSectoredComponent(Component component, Sector sector, bool isTorch, bool keepLoaded) { // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) if (component is ISectorGroup sectorGroup) @@ -225,6 +222,14 @@ private static void FixSectoredComponent(Component component, Sector sector, boo sectorGroup.SetSector(sector); } + // keepLoaded should remove existing groups + // renderers/colliders get enabled later so we dont have to do that here + if (keepLoaded && component is SectorCullGroup or SectorCollisionGroup or SectorLightsCullGroup) + { + Component.DestroyImmediate(component); + return; + } + // Not doing else if here because idk if any of the classes below implement ISectorGroup if (component is Sector s) @@ -235,6 +240,12 @@ private static void FixSectoredComponent(Component component, Sector sector, boo else if (component is SectorCullGroup sectorCullGroup) { sectorCullGroup._controllingProxy = null; + + // fixes sector cull group deactivating renderers on map view enter and fast foward + // TODO: does this actually work? what? how? + sectorCullGroup._inMapView = false; + sectorCullGroup._isFastForwarding = false; + sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false); } else if(component is SectoredMonoBehaviour behaviour) @@ -265,7 +276,7 @@ private static void FixSectoredComponent(Component component, Sector sector, boo /// private static bool FixUnsectoredComponent(Component component) { - if (component is FogLight or SectoredMonoBehaviour) + if (component is FogLight or SectoredMonoBehaviour or ISectorGroup) { GameObject.DestroyImmediate(component); return true; @@ -340,15 +351,6 @@ private static void FixComponent(Component component, GameObject planetGO) else if (component is Renderer renderer && component.gameObject.GetComponent() == null) renderer.enabled = true; else if(component is Shape shape) shape.enabled = true; - // fixes sector cull group deactivating renderers on map view enter and fast foward - // TODO: does this actually work? what? how? - else if(component is SectorCullGroup sectorCullGroup) - { - sectorCullGroup._inMapView = false; - sectorCullGroup._isFastForwarding = false; - sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false); - } - // If it's not a moving anglerfish make sure the anim controller is regular else if(component is AnglerfishAnimController && component.GetComponentInParent() == null) { From 9910323ebc02af10d0a35cb8431572ba3246acab Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 16:02:45 -0700 Subject: [PATCH 112/119] move this up so it returns early --- NewHorizons/Builder/Props/DetailBuilder.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index c19407096..d56aa17d0 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -216,12 +216,6 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P /// private static void FixSectoredComponent(Component component, Sector sector, bool isTorch, bool keepLoaded) { - // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) - if (component is ISectorGroup sectorGroup) - { - sectorGroup.SetSector(sector); - } - // keepLoaded should remove existing groups // renderers/colliders get enabled later so we dont have to do that here if (keepLoaded && component is SectorCullGroup or SectorCollisionGroup or SectorLightsCullGroup) @@ -229,6 +223,12 @@ private static void FixSectoredComponent(Component component, Sector sector, boo Component.DestroyImmediate(component); return; } + + // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) + if (component is ISectorGroup sectorGroup) + { + sectorGroup.SetSector(sector); + } // Not doing else if here because idk if any of the classes below implement ISectorGroup From b4340a93f71c20d22fd85b0ef442187f6182b01d Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 16:26:44 -0700 Subject: [PATCH 113/119] silly space --- 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 d56aa17d0..291201dd7 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -229,7 +229,7 @@ private static void FixSectoredComponent(Component component, Sector sector, boo { sectorGroup.SetSector(sector); } - + // Not doing else if here because idk if any of the classes below implement ISectorGroup if (component is Sector s) From 95aea5ebc47d7e6829bec2c2c837e45bd960a8fc Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 17:12:35 -0700 Subject: [PATCH 114/119] remove silly unused field --- .../External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs index 6e704f368..305283af6 100644 --- a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs @@ -10,10 +10,5 @@ public class NomaiWarpTransmitterInfo : NomaiWarpPadInfo /// In degrees. Gives a margin of error for alignments. /// [DefaultValue(5f)] public float alignmentWindow = 5f; - - /// - /// Is this transmitter upsidedown? Means alignment will be checked facing the other way. - /// - public bool upsideDown = false; } } From 9fdeea8e98670b69fb6b81e9ac40a7e3cdecf387 Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 24 Mar 2023 00:15:13 +0000 Subject: [PATCH 115/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 28d56ac29..f531c387a 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2527,10 +2527,6 @@ "description": "In degrees. Gives a margin of error for alignments.", "format": "float", "default": 5.0 - }, - "upsideDown": { - "type": "boolean", - "description": "Is this transmitter upsidedown? Means alignment will be checked facing the other way." } } }, From 6a97137cefdb91fb3009c62af575325c1a3cb6d6 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Thu, 23 Mar 2023 17:31:10 -0700 Subject: [PATCH 116/119] add it back and make it used --- NewHorizons/Builder/Props/WarpPadBuilder.cs | 2 ++ .../External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index f106dc57e..c4de76793 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -113,6 +113,8 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitter transmitter._alignmentWindow = info.alignmentWindow; + transmitter._upsideDown = info.flipAlignment; + transmitter.GetComponent().enabled = true; transmitterObject.SetActive(true); diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs index 305283af6..3a1dd55ca 100644 --- a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs @@ -10,5 +10,10 @@ public class NomaiWarpTransmitterInfo : NomaiWarpPadInfo /// In degrees. Gives a margin of error for alignments. /// [DefaultValue(5f)] public float alignmentWindow = 5f; + + /// + /// This makes the alignment happen if the destination planet is BELOW you rather than above. + /// + public bool flipAlignment; } } From 891a2e353d32304531974dae0668901bfab1be3f Mon Sep 17 00:00:00 2001 From: Ben C Date: Fri, 24 Mar 2023 00:37:22 +0000 Subject: [PATCH 117/119] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index f531c387a..b21da199d 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -2527,6 +2527,10 @@ "description": "In degrees. Gives a margin of error for alignments.", "format": "float", "default": 5.0 + }, + "flipAlignment": { + "type": "boolean", + "description": "This makes the alignment happen if the destination planet is BELOW you rather than above." } } }, From df41617c04df6a97ccdac5fc8a264de11d6d396e Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 23 Mar 2023 21:27:09 -0400 Subject: [PATCH 118/119] Set water to use Layer util --- NewHorizons/Builder/Body/WaterBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 452aa524c..fb0e25ecb 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -53,7 +53,7 @@ public static RadialFluidVolume Make(GameObject planetGO, Sector sector, OWRigid waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize); // Don't ignore sun when not under clouds - waterGO.layer = 0; + waterGO.layer = Layer.Default; Delay.FireOnNextUpdate(() => { if (planetGO.FindChild("Sector/SunOverride") != null) waterGO.layer = Layer.IgnoreSun; }); TessellatedSphereRenderer TSR = waterGO.AddComponent(); From 1b441d0c538fd58bafec8355d7b472b6c4f7f5ec Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 23 Mar 2023 22:40:55 -0400 Subject: [PATCH 119/119] Fix some warp exit stuff --- .../Builder/Props/GeneralPropBuilder.cs | 2 +- NewHorizons/Handlers/VesselWarpHandler.cs | 41 +++++-------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 41a3319ec..d80ca2457 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -76,7 +76,7 @@ public static class GeneralPropBuilder go.transform.position = pos; go.transform.rotation = rot; } - if (alignRadial) + if (alignRadial && planetGO != null) { var up = (go.transform.position - planetGO.transform.position).normalized; go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * rot; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index dc4023f3c..b298010fc 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -63,23 +63,6 @@ public static void LoadVessel() _vesselSpawnPoint = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension").GetComponentInChildren(); } - public static void OnReceiveWarpedBody(OWRigidbody warpedBody, NomaiWarpPlatform startPlatform, NomaiWarpPlatform targetPlatform) - { - bool isPlayer = warpedBody.CompareTag("Player"); - if (isPlayer) - { - Transform player_body = Locator.GetPlayerTransform(); - OWRigidbody s_rb = Locator.GetShipBody(); - OWRigidbody p_rb = Locator.GetPlayerBody(); - Vector3 newPos = player_body.position; - Vector3 offset = player_body.up * 10; - newPos += offset; - s_rb.SetPosition(newPos); - s_rb.SetRotation(player_body.transform.rotation); - s_rb.SetVelocity(p_rb.GetVelocity()); - } - } - public static void TeleportToVessel() { var playerSpawner = GameObject.FindObjectOfType(); @@ -162,16 +145,6 @@ public static EyeSpawnPoint CreateVessel() vesselWarpController._whiteHole = newWhiteHole.GetComponentInChildren(); vesselWarpController._whiteHoleOneShot = vesselWarpController._whiteHole.transform.parent.Find("WhiteHoleAudio_OneShot").GetComponent(); - vesselWarpController._targetWarpPlatform.OnReceiveWarpedBody += OnReceiveWarpedBody; - - var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false; - var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent; - var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, null, null, system.Config.Vessel?.warpExit, parentOverride: attachWarpExitToVessel ? warpExitParent : null); - if (attachWarpExitToVessel) - { - warpExit.transform.parent = warpExitParent; - } - vesselObject.GetComponent()._labelID = (UITextType)TranslationHandler.AddUI("Vessel"); var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody); @@ -194,6 +167,17 @@ public static EyeSpawnPoint CreateVessel() GameObject.Destroy(rfVolume.gameObject); } } + + var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false; + var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent; + + var planetGO = hasPhysics ? vesselObject.transform.parent.gameObject : null; + + var warpExit = GeneralPropBuilder.MakeFromExisting(vesselWarpController._targetWarpPlatform.gameObject, planetGO, null, system.Config.Vessel?.warpExit, parentOverride: attachWarpExitToVessel ? warpExitParent : null); + if (attachWarpExitToVessel) + { + warpExit.transform.parent = warpExitParent; + } vesselWarpController._targetWarpPlatform._owRigidbody = warpExit.GetAttachedOWRigidbody(); var hasZeroGravityVolume = system.Config.Vessel?.hasZeroGravityVolume ?? !hasParentBody; @@ -232,9 +216,6 @@ public static SpawnPoint UpdateVessel() VesselWarpController vesselWarpController = vectorSector.GetComponentInChildren(true); WarpController = vesselWarpController; - if (vesselWarpController._targetWarpPlatform != null) - vesselWarpController._targetWarpPlatform.OnReceiveWarpedBody += OnReceiveWarpedBody; - if (vesselWarpController._whiteHole == null) { GameObject whiteHole = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension/Sector_VesselBridge/Interactibles_VesselBridge/WhiteHole");