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