mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Allow planets to choose whether they're factored into changing map zoom speed (#1000)
## Minor features - Allow planets to choose whether they're factored into changing map zoom speed
This commit is contained in:
commit
6093e10492
7
NewHorizons/External/Configs/PlanetConfig.cs
vendored
7
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -52,6 +52,13 @@ namespace NewHorizons.External.Configs
|
||||
/// </summary>
|
||||
public bool destroy;
|
||||
|
||||
/// <summary>
|
||||
/// Do we track the position of this body when calculating the solar system radius?
|
||||
/// `true` if you want the map zoom speed, map panning distance/speed, map camera farclip plane,
|
||||
/// and autopilot-returning-to-solar-system to adjust to this planet's orbit
|
||||
/// </summary>
|
||||
[DefaultValue(true)] public bool trackForSolarSystemRadius = true;
|
||||
|
||||
/// <summary>
|
||||
/// A list of paths to child GameObjects to destroy on this planet
|
||||
/// </summary>
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using Epic.OnlineServices;
|
||||
using NewHorizons.Builder.Atmosphere;
|
||||
using NewHorizons.Builder.Body;
|
||||
using NewHorizons.Builder.General;
|
||||
@ -413,7 +412,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.trackForSolarSystemRadius);
|
||||
|
||||
NHLogger.LogVerbose($"Finished creating Bramble Dimension [{body.Config.name}]");
|
||||
|
||||
@ -500,11 +499,11 @@ 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.trackForSolarSystemRadius);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
|
||||
UpdatePosition(go, body.Config.Orbit, primaryBody, ao, body.Config.trackForSolarSystemRadius);
|
||||
}
|
||||
|
||||
// Have to do this after setting position
|
||||
@ -858,7 +857,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
|
||||
// Move the primary
|
||||
UpdatePosition(go, body.Config.Orbit, primary, newAO);
|
||||
UpdatePosition(go, body.Config.Orbit, primary, newAO, body.Config.trackForSolarSystemRadius);
|
||||
|
||||
for (int i = 0; i < children.Count(); i++)
|
||||
{
|
||||
@ -911,6 +910,12 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
|
||||
public static void UpdatePosition(GameObject go, IOrbitalParameters orbit, AstroObject primaryBody, AstroObject secondaryBody)
|
||||
{
|
||||
// Keeping old method signature because its the kind of method I think something somewhere might call
|
||||
UpdatePosition(go, orbit, primaryBody, secondaryBody, true);
|
||||
}
|
||||
|
||||
public static void UpdatePosition(GameObject go, IOrbitalParameters orbit, AstroObject primaryBody, AstroObject secondaryBody, bool trackForSolarSystemRadius)
|
||||
{
|
||||
NHLogger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
|
||||
|
||||
@ -920,15 +925,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, trackForSolarSystemRadius);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPositionFromVector(go, Vector3.zero);
|
||||
SetPositionFromVector(go, Vector3.zero, trackForSolarSystemRadius);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetPositionFromVector(GameObject go, Vector3 position)
|
||||
public static void SetPositionFromVector(GameObject go, Vector3 position, bool trackForSolarSystemRadius)
|
||||
{
|
||||
var rb = go.GetAttachedOWRigidbody();
|
||||
if (rb)
|
||||
@ -960,7 +965,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 && trackForSolarSystemRadius)
|
||||
{
|
||||
SolarSystemRadius = distanceToCenter;
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user