mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Rearranged modules to support variable size over time
This commit is contained in:
parent
eb00d9589f
commit
09a1d8a120
@ -1,4 +1,5 @@
|
||||
using OWML.Utils;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using OWML.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -11,13 +12,13 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class LavaBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody rb, float lavaSize)
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody rb, LavaModule module)
|
||||
{
|
||||
var moltenCore = new GameObject("MoltenCore");
|
||||
moltenCore.SetActive(false);
|
||||
moltenCore.transform.parent = body.transform;
|
||||
moltenCore.transform.localPosition = Vector3.zero;
|
||||
moltenCore.transform.localScale = Vector3.one * lavaSize;
|
||||
moltenCore.transform.localScale = Vector3.one * module.Radius;
|
||||
|
||||
var lavaSphere = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform);
|
||||
lavaSphere.transform.localScale = Vector3.one;
|
||||
|
||||
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.External.VariableSize;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
|
||||
18
NewHorizons/Builder/Body/SandBuilder.cs
Normal file
18
NewHorizons/Builder/Body/SandBuilder.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using NewHorizons.External.VariableSize;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class SandBuilder
|
||||
{
|
||||
public static void Make(GameObject go, Sector sector, OWRigidbody rb, SandModule module)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.External.VariableSize;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
@ -26,7 +27,6 @@ namespace NewHorizons.Builder.Body
|
||||
sunSurface.transform.localScale = Vector3.one;
|
||||
sunSurface.name = "Surface";
|
||||
|
||||
//var sunLight = GameObject.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight"), sunGO.transform);
|
||||
var sunLight = new GameObject();
|
||||
sunLight.transform.parent = starGO.transform;
|
||||
sunLight.transform.localPosition = Vector3.zero;
|
||||
@ -61,12 +61,26 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
sunAudio.name = "Audio_Star";
|
||||
|
||||
/*
|
||||
if(starModule.HasAtmosphere)
|
||||
{
|
||||
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), starGO.transform);
|
||||
sunAtmosphere.transform.localPosition = Vector3.zero;
|
||||
sunAtmosphere.transform.localScale = Vector3.one;
|
||||
sunAtmosphere.name = "Atmosphere_Star";
|
||||
*/
|
||||
PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
|
||||
if (starModule.Tint != null)
|
||||
{
|
||||
fog.fogTint = starModule.Tint.ToColor32();
|
||||
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one * (starModule.Size + 1000) / starModule.Size;
|
||||
foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
lod.material.SetColor("_SkyColor", starModule.Tint.ToColor32());
|
||||
lod.material.SetFloat("_InnerRadius", starModule.Size);
|
||||
lod.material.SetFloat("_OuterRadius", starModule.Size + 1000);
|
||||
}
|
||||
}
|
||||
fog.fogRadius = starModule.Size * 1.2f;
|
||||
}
|
||||
|
||||
var ambientLightGO = GameObject.Instantiate(GameObject.Find("Sun_Body/AmbientLight_SUN"), starGO.transform);
|
||||
ambientLightGO.transform.localPosition = Vector3.zero;
|
||||
@ -84,7 +98,6 @@ namespace NewHorizons.Builder.Body
|
||||
deathVolume.GetComponent<SphereCollider>().radius = 1f;
|
||||
deathVolume.name = "DestructionVolume";
|
||||
|
||||
//PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
|
||||
TessellatedSphereRenderer surface = sunSurface.GetComponent<TessellatedSphereRenderer>();
|
||||
Light ambientLight = ambientLightGO.GetComponent<Light>();
|
||||
|
||||
@ -103,12 +116,11 @@ namespace NewHorizons.Builder.Body
|
||||
light.color = lightColour;
|
||||
ambientLight.color = lightColour;
|
||||
|
||||
//fog.fogRadius = starModule.Size * 1.2f;
|
||||
if(starModule.Tint != null)
|
||||
{
|
||||
var colour = starModule.Tint.ToColor32();
|
||||
//sunLightController.sunColor = colour;
|
||||
//fog.fogTint = colour;
|
||||
|
||||
|
||||
var sun = GameObject.Find("Sun_Body");
|
||||
var mainSequenceMaterial = sun.GetComponent<SunController>().GetValue<Material>("_startSurfaceMaterial");
|
||||
@ -118,16 +130,6 @@ namespace NewHorizons.Builder.Body
|
||||
var mod = 8f * starModule.SolarLuminosity / 255f;
|
||||
surface.sharedMaterial.color = new Color(colour.r * mod, colour.g * mod, colour.b * mod);
|
||||
surface.sharedMaterial.SetTexture("_ColorRamp", ImageUtilities.TintImage(_colorOverTime, colour));
|
||||
|
||||
/*
|
||||
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one * (starModule.Size + 1000)/starModule.Size;
|
||||
foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
|
||||
{
|
||||
lod.material.SetColor("_SkyColor", colour);
|
||||
lod.material.SetFloat("_InnerRadius", starModule.Size);
|
||||
lod.material.SetFloat("_OuterRadius", starModule.Size + 1000);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if(starModule.SolarFlareTint != null)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using NewHorizons.External;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using OWML.Utils;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
@ -7,9 +8,9 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class WaterBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody rb, IPlanetConfig config)
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody rb, WaterModule module)
|
||||
{
|
||||
var waterSize = config.Base.WaterSize;
|
||||
var waterSize = module.Radius;
|
||||
|
||||
GameObject waterGO = new GameObject("Water");
|
||||
waterGO.SetActive(false);
|
||||
@ -28,9 +29,9 @@ namespace NewHorizons.Builder.Body
|
||||
for(int i = 0; i < GDSharedMaterials.Length; i++)
|
||||
{
|
||||
tempArray[i] = new Material(GDSharedMaterials[i]);
|
||||
if (config.Base.WaterTint != null)
|
||||
if (module.Tint != null)
|
||||
{
|
||||
tempArray[i].color = config.Base.WaterTint.ToColor32();
|
||||
tempArray[i].color = module.Tint.ToColor32();
|
||||
}
|
||||
}
|
||||
// TODO: Make water module
|
||||
|
||||
6
NewHorizons/External/BaseModule.cs
vendored
6
NewHorizons/External/BaseModule.cs
vendored
@ -15,10 +15,7 @@ namespace NewHorizons.External
|
||||
public string GravityFallOff { get; set; } = "linear";
|
||||
public float SurfaceSize { get; set; }
|
||||
public float SphereOfInfluence { get; set; }
|
||||
public float WaterSize { get; set; }
|
||||
public MColor32 WaterTint { get; set; }
|
||||
public float GroundSize { get; set; }
|
||||
public float LavaSize { get; set; }
|
||||
public bool HasCometTail { get; set; }
|
||||
public bool HasReferenceFrame { get; set; } = true;
|
||||
public bool CenterOfSolarSystem { get; set; } = false;
|
||||
@ -26,5 +23,8 @@ namespace NewHorizons.External
|
||||
|
||||
// Old, see SingularityModule instead
|
||||
public float BlackHoleSize { get; set; }
|
||||
public float LavaSize { get; set; }
|
||||
public float WaterSize { get; set; }
|
||||
public MColor32 WaterTint { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
6
NewHorizons/External/IPlanetConfig.cs
vendored
6
NewHorizons/External/IPlanetConfig.cs
vendored
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using NewHorizons.Utility;
|
||||
|
||||
namespace NewHorizons.External
|
||||
{
|
||||
@ -21,5 +22,8 @@ namespace NewHorizons.External
|
||||
SpawnModule Spawn { get; }
|
||||
SignalModule Signal { get; }
|
||||
SingularityModule Singularity { get; }
|
||||
LavaModule Lava { get; }
|
||||
SandModule Sand { get; }
|
||||
WaterModule Water { get; }
|
||||
}
|
||||
}
|
||||
|
||||
6
NewHorizons/External/PlanetConfig.cs
vendored
6
NewHorizons/External/PlanetConfig.cs
vendored
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@ -24,6 +25,9 @@ namespace NewHorizons.External
|
||||
public SpawnModule Spawn { get; set; }
|
||||
public SignalModule Signal { get; set; }
|
||||
public SingularityModule Singularity { get; set; }
|
||||
public LavaModule Lava { get; set; }
|
||||
public WaterModule Water { get; set; }
|
||||
public SandModule Sand { get; set; }
|
||||
|
||||
public PlanetConfig(Dictionary<string, object> dict)
|
||||
{
|
||||
|
||||
15
NewHorizons/External/VariableSize/LavaModule.cs
vendored
Normal file
15
NewHorizons/External/VariableSize/LavaModule.cs
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class LavaModule : VariableSizeModule
|
||||
{
|
||||
public float Radius { get; set; }
|
||||
public MColor32 Tint { get; set; }
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class RingModule : Module
|
||||
public class RingModule : VariableSizeModule
|
||||
{
|
||||
public float InnerRadius { get; set; }
|
||||
public float OuterRadius { get; set; }
|
||||
15
NewHorizons/External/VariableSize/SandModule.cs
vendored
Normal file
15
NewHorizons/External/VariableSize/SandModule.cs
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class SandModule : VariableSizeModule
|
||||
{
|
||||
public float Radius { get; set; }
|
||||
public MColor32 Tint { get; set; }
|
||||
}
|
||||
}
|
||||
@ -5,9 +5,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class SingularityModule : Module
|
||||
public class SingularityModule : VariableSizeModule
|
||||
{
|
||||
public float Size;
|
||||
public string PairedSingularity;
|
||||
@ -5,14 +5,15 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class StarModule : Module
|
||||
public class StarModule : VariableSizeModule
|
||||
{
|
||||
public float Size { get; set; } = 2000f;
|
||||
public MColor32 Tint { get; set; }
|
||||
public MColor32 SolarFlareTint { get; set; }
|
||||
public MColor32 LightTint { get; set; }
|
||||
public float SolarLuminosity { get; set; } = 1f;
|
||||
public bool HasAtmosphere { get; set; } = true;
|
||||
}
|
||||
}
|
||||
19
NewHorizons/External/VariableSize/VariableSizeModule.cs
vendored
Normal file
19
NewHorizons/External/VariableSize/VariableSizeModule.cs
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class VariableSizeModule : Module
|
||||
{
|
||||
public TimeValuePair[] Curve { get; set; }
|
||||
|
||||
public class TimeValuePair
|
||||
{
|
||||
public float Time { get; set; }
|
||||
public float Value { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
15
NewHorizons/External/VariableSize/WaterModule.cs
vendored
Normal file
15
NewHorizons/External/VariableSize/WaterModule.cs
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
public class WaterModule : VariableSizeModule
|
||||
{
|
||||
public float Radius { get; set; }
|
||||
public MColor32 Tint { get; set; }
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ using NewHorizons.Builder.Orbital;
|
||||
using NewHorizons.Builder.Props;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.External;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using NewHorizons.OrbitalPhysics;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
@ -506,11 +507,31 @@ namespace NewHorizons
|
||||
if (body.Config.Base.HasCometTail)
|
||||
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||
|
||||
// Backwards compatability
|
||||
if (body.Config.Base.LavaSize != 0)
|
||||
LavaBuilder.Make(go, sector, rb, body.Config.Base.LavaSize);
|
||||
{
|
||||
var lava = new LavaModule();
|
||||
lava.Radius = body.Config.Base.LavaSize;
|
||||
LavaBuilder.Make(go, sector, rb, lava);
|
||||
}
|
||||
|
||||
if (body.Config.Lava != null)
|
||||
LavaBuilder.Make(go, sector, rb, body.Config.Lava);
|
||||
|
||||
// Backwards compatability
|
||||
if (body.Config.Base.WaterSize != 0)
|
||||
WaterBuilder.Make(go, sector, rb, body.Config);
|
||||
{
|
||||
var water = new WaterModule();
|
||||
water.Radius = body.Config.Base.WaterSize;
|
||||
water.Tint = body.Config.Base.WaterTint;
|
||||
WaterBuilder.Make(go, sector, rb, water);
|
||||
}
|
||||
|
||||
if (body.Config.Water != null)
|
||||
WaterBuilder.Make(go, sector, rb, body.Config.Water);
|
||||
|
||||
if (body.Config.Sand != null)
|
||||
SandBuilder.Make(go, sector, rb, body.Config.Sand);
|
||||
|
||||
if (body.Config.Atmosphere != null)
|
||||
{
|
||||
|
||||
@ -54,50 +54,11 @@
|
||||
"default": 0,
|
||||
"description": "An override for the radius of the planet's gravitational sphere of influence. Optional"
|
||||
},
|
||||
"waterSize": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"description": "Sea level for the planet. Optional"
|
||||
},
|
||||
"waterTint": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"R": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"G": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"B": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"A": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"groundSize": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"description": "Radius of the a simple sphere used as the ground for the planet. If you want to use more complex terrain, leave this as 0."
|
||||
},
|
||||
"lavaSize": {
|
||||
"type": "number",
|
||||
"default": 0,
|
||||
"description": "Radius of a sphere of lava. Optional."
|
||||
},
|
||||
"hasCometTail": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
@ -585,6 +546,10 @@
|
||||
"minimum": 0,
|
||||
"description": "Relative strenght of the light compared to the sun",
|
||||
"default": 1
|
||||
},
|
||||
"hasAtmosphere": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -891,6 +856,110 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Water": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"radius": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"tint": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"R": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"G": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"B": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"A": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"curve": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"time": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
},
|
||||
"value": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Lava": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"radius": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"curve": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"time": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
},
|
||||
"value": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Sand": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"radius": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"curve": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"time": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
},
|
||||
"value": {
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user