diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index c453dfea..8c1025bc 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.Files; +using OWML.Common; using UnityEngine; namespace NewHorizons.Builder.Atmosphere { @@ -35,7 +36,7 @@ namespace NewHorizons.Builder.Atmosphere if (_dbImpostorMaterials == null) _dbImpostorMaterials = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD").GetComponent().sharedMaterials.MakePrefabMaterials(); } - public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo) + public static PlanetaryFogController Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod) { InitPrefabs(); @@ -58,7 +59,10 @@ namespace NewHorizons.Builder.Atmosphere PFC.lodFadeDistance = PFC.fogRadius * 0.5f; PFC.fogDensity = atmo.fogDensity; PFC.fogExponent = 1f; - var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + var colorRampTexture = + atmo.fogRampPath != null ? ImageUtilities.GetTexture(mod, atmo.fogRampPath) : + atmo.fogTint != null ? ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()) : + _ramp; PFC.fogColorRampTexture = colorRampTexture; PFC.fogColorRampIntensity = 1f; if (atmo.fogTint != null) @@ -78,7 +82,7 @@ namespace NewHorizons.Builder.Atmosphere return PFC; } - public static Renderer MakeProxy(GameObject proxyGO, AtmosphereModule atmo) + public static Renderer MakeProxy(GameObject proxyGO, AtmosphereModule atmo, IModBehaviour mod) { InitPrefabs(); @@ -94,7 +98,10 @@ namespace NewHorizons.Builder.Atmosphere MR.materials = _dbImpostorMaterials; MR.allowOcclusionWhenDynamic = true; - var colorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); + var colorRampTexture = + atmo.fogRampPath != null ? ImageUtilities.GetTexture(mod, atmo.fogRampPath) : + atmo.fogTint != null ? ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()) : + _ramp; if (atmo.fogTint != null) { MR.material.SetColor(Tint, atmo.fogTint.ToColor()); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 0f87a90a..c788c3b2 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -120,7 +120,7 @@ namespace NewHorizons.Builder.Body if (body.Config.Atmosphere.fogSize != 0) { - fog = FogBuilder.MakeProxy(proxy, body.Config.Atmosphere); + fog = FogBuilder.MakeProxy(proxy, body.Config.Atmosphere, body.Mod); fogCurveMaxVal = body.Config.Atmosphere.fogDensity; } diff --git a/NewHorizons/External/Modules/AtmosphereModule.cs b/NewHorizons/External/Modules/AtmosphereModule.cs index b1f563ac..675ed837 100644 --- a/NewHorizons/External/Modules/AtmosphereModule.cs +++ b/NewHorizons/External/Modules/AtmosphereModule.cs @@ -46,7 +46,7 @@ namespace NewHorizons.External.Modules /// /// How dense the fog is, if you put fog. /// - [Range(0f, 1f)] public float fogDensity; + [Range(0f, double.MaxValue)] public float fogDensity; /// /// Radius of fog sphere, independent of the atmosphere. This has to be set for there to be fog. @@ -57,6 +57,12 @@ namespace NewHorizons.External.Modules /// Colour of fog on the planet, if you put fog. /// public MColor fogTint; + + /// + /// Relative filepath to the fog color ramp texture, if you put fog. + /// x axis is angle to sun (left at midnight, right at noon), y axis is distance to camera (close at bottom, far at top). + /// + public string fogRampPath; /// /// Lets you survive on the planet without a suit. diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index 5899b658..f8af3fa1 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -29,7 +29,7 @@ namespace NewHorizons.External.Modules /// /// Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0). /// - public MVector3? offset; + public MVector3 offset; } [JsonObject] diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 6a3647d6..983c8e98 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -652,7 +652,7 @@ namespace NewHorizons.Handlers if (body.Config.Atmosphere.fogSize != 0) { - fog = FogBuilder.Make(go, sector, body.Config.Atmosphere); + fog = FogBuilder.Make(go, sector, body.Config.Atmosphere, body.Mod); } atmosphere = AtmosphereBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize).GetComponentInChildren(); diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index e58bdc83..8974ffde 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -345,7 +345,6 @@ "type": "number", "description": "How dense the fog is, if you put fog.", "format": "float", - "maximum": 1.0, "minimum": 0.0 }, "fogSize": { @@ -358,6 +357,10 @@ "description": "Colour of fog on the planet, if you put fog.", "$ref": "#/definitions/MColor" }, + "fogRampPath": { + "type": "string", + "description": "Relative filepath to the fog color ramp texture, if you put fog.\nx axis is angle to sun (left at midnight, right at noon), y axis is distance to camera (close at bottom, far at top)." + }, "hasOxygen": { "type": "boolean", "description": "Lets you survive on the planet without a suit." @@ -3050,14 +3053,7 @@ "properties": { "offset": { "description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/definitions/MVector3" - } - ] + "$ref": "#/definitions/MVector3" }, "rotation": { "description": "Rotation of the object", @@ -3102,14 +3098,7 @@ "properties": { "offset": { "description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/definitions/MVector3" - } - ] + "$ref": "#/definitions/MVector3" }, "rotation": { "description": "Rotation of the object",