Rename sphereOfInfluence to soiOverride

This commit is contained in:
Nick 2022-06-15 14:06:34 -04:00
parent df66d4ef8d
commit e833512bda
5 changed files with 255 additions and 250 deletions

View File

@ -18,7 +18,7 @@ namespace NewHorizons.Builder.General
// To let you actually orbit things the way you would expect we cap this at 4x the diameter if its not a star or black hole (this is what giants deep has) // To let you actually orbit things the way you would expect we cap this at 4x the diameter if its not a star or black hole (this is what giants deep has)
if (config.Star == null && config.Singularity == null) gravityRadius = Mathf.Min(gravityRadius, 4 * config.Base.surfaceSize); if (config.Star == null && config.Singularity == null) gravityRadius = Mathf.Min(gravityRadius, 4 * config.Base.surfaceSize);
else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.surfaceSize); else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.surfaceSize);
if (config.Base.sphereOfInfluence != 0f) gravityRadius = config.Base.sphereOfInfluence; if (config.Base.soiOverride != 0f) gravityRadius = config.Base.soiOverride;
var gravityGO = new GameObject("GravityWell"); var gravityGO = new GameObject("GravityWell");
gravityGO.transform.parent = planetGO.transform; gravityGO.transform.parent = planetGO.transform;

View File

@ -57,7 +57,7 @@ namespace NewHorizons.Builder.Orbital
// Other stuff to make the fake barycenter not interact with anything in any way // Other stuff to make the fake barycenter not interact with anything in any way
fakeMassConfig.name = config.name + "_FakeBarycenterMass"; fakeMassConfig.name = config.name + "_FakeBarycenterMass";
fakeMassConfig.Base.sphereOfInfluence = 0; fakeMassConfig.Base.soiOverride = 0;
fakeMassConfig.Base.hasMapMarker = false; fakeMassConfig.Base.hasMapMarker = false;
fakeMassConfig.ReferenceFrame.hideInMap = true; fakeMassConfig.ReferenceFrame.hideInMap = true;

View File

@ -1,250 +1,252 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.VariableSize;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NewHorizons.External.Configs namespace NewHorizons.External.Configs
{ {
/// <summary> /// <summary>
/// Describes a body to generate /// Describes a body to generate
/// </summary> /// </summary>
[JsonObject(Title = "Celestial Body")] [JsonObject(Title = "Celestial Body")]
public class PlanetConfig public class PlanetConfig
{ {
/// <summary> /// <summary>
/// Generate asteroids around this body /// Generate asteroids around this body
/// </summary> /// </summary>
public AsteroidBeltModule AsteroidBelt; public AsteroidBeltModule AsteroidBelt;
/// <summary> /// <summary>
/// Describes this Body's atmosphere /// Describes this Body's atmosphere
/// </summary> /// </summary>
public AtmosphereModule Atmosphere; public AtmosphereModule Atmosphere;
/// <summary> /// <summary>
/// Base Properties of this Body /// Base Properties of this Body
/// </summary> /// </summary>
public BaseModule Base; public BaseModule Base;
/// <summary> /// <summary>
/// Set to a higher number if you wish for this body to be built sooner /// Set to a higher number if you wish for this body to be built sooner
/// </summary> /// </summary>
[DefaultValue(-1)] public int buildPriority = -1; [DefaultValue(-1)] public int buildPriority = -1;
/// <summary> /// <summary>
/// Should this planet ever be shown on the title screen? /// Should this planet ever be shown on the title screen?
/// </summary> /// </summary>
public bool canShowOnTitle = true; public bool canShowOnTitle = true;
#region Obsolete #region Obsolete
[Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] [Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")]
public string[] childrenToDestroy; public string[] childrenToDestroy;
#endregion Obsolete #endregion Obsolete
/// <summary> /// <summary>
/// Add a cloaking field to this planet /// Add a cloaking field to this planet
/// </summary> /// </summary>
public CloakModule Cloak; public CloakModule Cloak;
/// <summary> /// <summary>
/// `true` if you want to delete this planet /// `true` if you want to delete this planet
/// </summary> /// </summary>
public bool destroy; public bool destroy;
/// <summary> /// <summary>
/// Make this body into a focal point (barycenter) /// Make this body into a focal point (barycenter)
/// </summary> /// </summary>
public FocalPointModule FocalPoint; public FocalPointModule FocalPoint;
/// <summary> /// <summary>
/// Add funnel from this planet to another /// Add funnel from this planet to another
/// </summary> /// </summary>
public FunnelModule Funnel; public FunnelModule Funnel;
/// <summary> /// <summary>
/// Generate the surface of this planet using a heightmap /// Generate the surface of this planet using a heightmap
/// </summary> /// </summary>
public HeightMapModule HeightMap; public HeightMapModule HeightMap;
/// <summary> /// <summary>
/// Does this config describe a quantum state of a custom planet defined in another file? /// Does this config describe a quantum state of a custom planet defined in another file?
/// </summary> /// </summary>
public bool isQuantumState; public bool isQuantumState;
/// <summary> /// <summary>
/// Add lava to this planet /// Add lava to this planet
/// </summary> /// </summary>
public LavaModule Lava; public LavaModule Lava;
/// <summary> /// <summary>
/// Unique name of your planet /// Unique name of your planet
/// </summary> /// </summary>
[Required] [Required]
public string name; public string name;
/// <summary> /// <summary>
/// Describes this Body's orbit (or lack there of) /// Describes this Body's orbit (or lack there of)
/// </summary> /// </summary>
public OrbitModule Orbit; public OrbitModule Orbit;
/// <summary> /// <summary>
/// Procedural Generation /// Procedural Generation
/// </summary> /// </summary>
public ProcGenModule ProcGen; public ProcGenModule ProcGen;
/// <summary> /// <summary>
/// Spawn various objects on this body /// Spawn various objects on this body
/// </summary> /// </summary>
public PropModule Props; public PropModule Props;
/// <summary> /// <summary>
/// Reference frame properties of this body /// Reference frame properties of this body
/// </summary> /// </summary>
public ReferenceFrameModule ReferenceFrame; public ReferenceFrameModule ReferenceFrame;
/// <summary> /// <summary>
/// A list of paths to child GameObjects to destroy on this planet /// A list of paths to child GameObjects to destroy on this planet
/// </summary> /// </summary>
public string[] removeChildren; public string[] removeChildren;
/// <summary> /// <summary>
/// Creates a ring around the planet /// Creates a ring around the planet
/// </summary> /// </summary>
public RingModule Ring; public RingModule Ring;
/// <summary> /// <summary>
/// Add sand to this planet /// Add sand to this planet
/// </summary> /// </summary>
public SandModule Sand; public SandModule Sand;
/// <summary> /// <summary>
/// Add ship log entries to this planet and describe how it looks in map mode /// Add ship log entries to this planet and describe how it looks in map mode
/// </summary> /// </summary>
public ShipLogModule ShipLog; public ShipLogModule ShipLog;
/// <summary> /// <summary>
/// Add signals that can be heard via the signal-scope to this planet /// Add signals that can be heard via the signal-scope to this planet
/// </summary> /// </summary>
public SignalModule Signal; public SignalModule Signal;
/// <summary> /// <summary>
/// Add a black or white hole to this planet /// Add a black or white hole to this planet
/// </summary> /// </summary>
public SingularityModule Singularity; public SingularityModule Singularity;
/// <summary> /// <summary>
/// Spawn the player at this planet /// Spawn the player at this planet
/// </summary> /// </summary>
public SpawnModule Spawn; public SpawnModule Spawn;
/// <summary> /// <summary>
/// Make this body a star /// Make this body a star
/// </summary> /// </summary>
public StarModule Star; public StarModule Star;
/// <summary> /// <summary>
/// Unique star system containing your planet /// Unique star system containing your planet
/// </summary> /// </summary>
[DefaultValue("SolarSystem")] public string starSystem = "SolarSystem"; [DefaultValue("SolarSystem")] public string starSystem = "SolarSystem";
/// <summary> /// <summary>
/// Version of New Horizons this config is using (Doesn't do anything) /// Version of New Horizons this config is using (Doesn't do anything)
/// </summary> /// </summary>
public string version; public string version;
/// <summary> /// <summary>
/// Add water to this planet /// Add water to this planet
/// </summary> /// </summary>
public WaterModule Water; public WaterModule Water;
public PlanetConfig() public PlanetConfig()
{ {
// Always have to have a base module // Always have to have a base module
if (Base == null) Base = new BaseModule(); if (Base == null) Base = new BaseModule();
if (Orbit == null) Orbit = new OrbitModule(); if (Orbit == null) Orbit = new OrbitModule();
if (ShipLog == null) ShipLog = new ShipLogModule(); if (ShipLog == null) ShipLog = new ShipLogModule();
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule(); if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
} }
public void MigrateAndValidate() public void MigrateAndValidate()
{ {
// Validate // Validate
if (Base.centerOfSolarSystem) Orbit.isStatic = true; if (Base.centerOfSolarSystem) Orbit.isStatic = true;
if (Atmosphere?.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; if (Atmosphere?.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true;
// Backwards compatability // Backwards compatability
// Should be the only place that obsolete things are referenced // Should be the only place that obsolete things are referenced
#pragma warning disable 612, 618 #pragma warning disable 612, 618
if (Base.waterSize != 0) if (Base.waterSize != 0)
Water = new WaterModule Water = new WaterModule
{ {
size = Base.waterSize, size = Base.waterSize,
tint = Base.waterTint tint = Base.waterTint
}; };
if (Base.lavaSize != 0) if (Base.lavaSize != 0)
Lava = new LavaModule Lava = new LavaModule
{ {
size = Base.lavaSize size = Base.lavaSize
}; };
if (Base.blackHoleSize != 0) if (Base.blackHoleSize != 0)
Singularity = new SingularityModule Singularity = new SingularityModule
{ {
type = SingularityModule.SingularityType.BlackHole, type = SingularityModule.SingularityType.BlackHole,
size = Base.blackHoleSize size = Base.blackHoleSize
}; };
if (Base.isSatellite) Base.showMinimap = false; if (Base.isSatellite) Base.showMinimap = false;
if (!Base.hasReferenceFrame) ReferenceFrame.hideInMap = true; if (!Base.hasReferenceFrame) ReferenceFrame.hideInMap = true;
if (childrenToDestroy != null) removeChildren = childrenToDestroy; if (childrenToDestroy != null) removeChildren = childrenToDestroy;
if (Base.cloakRadius != 0) if (Base.cloakRadius != 0)
Cloak = new CloakModule Cloak = new CloakModule
{ {
radius = Base.cloakRadius radius = Base.cloakRadius
}; };
if (Base.hasAmbientLight) Base.ambientLight = 0.5f; if (Base.hasAmbientLight) Base.ambientLight = 0.5f;
if (Atmosphere != null) if (Atmosphere != null)
{ {
if (!string.IsNullOrEmpty(Atmosphere.cloud)) if (!string.IsNullOrEmpty(Atmosphere.cloud))
Atmosphere.clouds = new AtmosphereModule.CloudInfo Atmosphere.clouds = new AtmosphereModule.CloudInfo
{ {
outerCloudRadius = Atmosphere.size, outerCloudRadius = Atmosphere.size,
innerCloudRadius = Atmosphere.size * 0.9f, innerCloudRadius = Atmosphere.size * 0.9f,
tint = Atmosphere.cloudTint, tint = Atmosphere.cloudTint,
texturePath = Atmosphere.cloud, texturePath = Atmosphere.cloud,
capPath = Atmosphere.cloudCap, capPath = Atmosphere.cloudCap,
rampPath = Atmosphere.cloudRamp, rampPath = Atmosphere.cloudRamp,
fluidType = Atmosphere.fluidType, fluidType = Atmosphere.fluidType,
useBasicCloudShader = Atmosphere.useBasicCloudShader, useBasicCloudShader = Atmosphere.useBasicCloudShader,
unlit = !Atmosphere.shadowsOnClouds unlit = !Atmosphere.shadowsOnClouds
}; };
// Validate // Validate
if (Atmosphere.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; if (Atmosphere.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true;
// Former is obsolete, latter is to validate // Former is obsolete, latter is to validate
if (Atmosphere.hasAtmosphere || Atmosphere.atmosphereTint != null) if (Atmosphere.hasAtmosphere || Atmosphere.atmosphereTint != null)
Atmosphere.useAtmosphereShader = true; Atmosphere.useAtmosphereShader = true;
// useBasicCloudShader is obsolete // useBasicCloudShader is obsolete
if (Atmosphere.clouds != null && Atmosphere.clouds.useBasicCloudShader) if (Atmosphere.clouds != null && Atmosphere.clouds.useBasicCloudShader)
Atmosphere.clouds.cloudsPrefab = CloudPrefabType.Basic; Atmosphere.clouds.cloudsPrefab = CloudPrefabType.Basic;
} }
if (Props?.tornados != null) if (Props?.tornados != null)
foreach (var tornado in Props.tornados) foreach (var tornado in Props.tornados)
if (tornado.downwards) if (tornado.downwards)
tornado.type = PropModule.TornadoInfo.TornadoType.Downwards; tornado.type = PropModule.TornadoInfo.TornadoType.Downwards;
}
} if (Base.sphereOfInfluence != 0f) Base.soiOverride = Base.sphereOfInfluence;
}
}
} }

View File

@ -69,7 +69,7 @@ namespace NewHorizons.External.Modules
/// <summary> /// <summary>
/// An override for the radius of the planet's gravitational sphere of influence. Optional /// An override for the radius of the planet's gravitational sphere of influence. Optional
/// </summary> /// </summary>
public float sphereOfInfluence; public float soiOverride;
/// <summary> /// <summary>
/// The acceleration due to gravity felt as the surfaceSize. Timber Hearth has 12 for reference /// The acceleration due to gravity felt as the surfaceSize. Timber Hearth has 12 for reference
@ -112,6 +112,9 @@ namespace NewHorizons.External.Modules
[Obsolete("CloakRadius is deprecated, please use CloakModule instead")] [Obsolete("CloakRadius is deprecated, please use CloakModule instead")]
public float cloakRadius; public float cloakRadius;
[Obsolete("SphereOfInfluence is deprecated, please use soiOverride instead")]
public float sphereOfInfluence;
#endregion Obsolete #endregion Obsolete
} }
} }

View File

@ -365,7 +365,7 @@ namespace NewHorizons.Handlers
{ {
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.size : 0f; var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.size : 0f;
float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.surfaceSize * 2f); float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.surfaceSize * 2f);
var overrideSOI = body.Config.Base.sphereOfInfluence; var overrideSOI = body.Config.Base.soiOverride;
if (overrideSOI != 0) sphereOfInfluence = overrideSOI; if (overrideSOI != 0) sphereOfInfluence = overrideSOI;
return sphereOfInfluence; return sphereOfInfluence;
} }