From 21a9643b9ec13aa67bd787cd88e1ba916c256901 Mon Sep 17 00:00:00 2001 From: ZygZagGaming <46930418+ZygZagGaming@users.noreply.github.com> Date: Wed, 11 Dec 2024 12:29:16 -0500 Subject: [PATCH] Allowed planets to decide if they change SolarSystemRadius --- NewHorizons/External/Configs/PlanetConfig.cs | 5 +++++ NewHorizons/Handlers/PlanetCreationHandler.cs | 12 ++++++------ NewHorizons/Schemas/body_schema.json | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 81dd162a..ea9a7a39 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -52,6 +52,11 @@ namespace NewHorizons.External.Configs /// public bool destroy; + /// + /// `true` if you want the map zoom speed to adjust to this planet's orbit + /// + public bool adjustZoomSpeed = true; + /// /// A list of paths to child GameObjects to destroy on this planet /// diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 60d3bded..3e4efbad 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -413,7 +413,7 @@ namespace NewHorizons.Handlers AstroObjectLocator.RegisterCustomAstroObject(ao); // Now that we're done move the planet into place - SetPositionFromVector(go, body.Config.Orbit.staticPosition); + SetPositionFromVector(go, body.Config.Orbit.staticPosition, body.Config.adjustZoomSpeed); NHLogger.LogVerbose($"Finished creating Bramble Dimension [{body.Config.name}]"); @@ -500,7 +500,7 @@ namespace NewHorizons.Handlers // Now that we're done move the planet into place if (body.Config.Orbit?.staticPosition != null) { - SetPositionFromVector(go, body.Config.Orbit.staticPosition); + SetPositionFromVector(go, body.Config.Orbit.staticPosition, body.Config.adjustZoomSpeed); } else { @@ -920,15 +920,15 @@ namespace NewHorizons.Handlers var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume()); var pos = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialPosition + primaryBody.transform.position; - SetPositionFromVector(go, pos); + SetPositionFromVector(go, pos, true); } else { - SetPositionFromVector(go, Vector3.zero); + SetPositionFromVector(go, Vector3.zero, true); } } - public static void SetPositionFromVector(GameObject go, Vector3 position) + public static void SetPositionFromVector(GameObject go, Vector3 position, bool adjustZoomSpeed) { var rb = go.GetAttachedOWRigidbody(); if (rb) @@ -960,7 +960,7 @@ namespace NewHorizons.Handlers // Uses the ratio of the interlopers furthest point to what the base game considers the edge of the solar system var distanceToCenter = go.transform.position.magnitude / (24000 / 30000f); - if (distanceToCenter > SolarSystemRadius) + if (distanceToCenter > SolarSystemRadius && adjustZoomSpeed) { SolarSystemRadius = distanceToCenter; } diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 6b011cc4..a652accb 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -31,6 +31,11 @@ "type": "boolean", "description": "`true` if you want to delete this planet" }, + "adjustZoomSpeed": { + "type": "boolean", + "description": "`true` if you want the map zoom speed to adjust to fit this planet's orbit", + "default": true + }, "removeChildren": { "type": "array", "description": "A list of paths to child GameObjects to destroy on this planet",