From 6a35123c48b098d6384853aae0d7264e3223f25c Mon Sep 17 00:00:00 2001 From: "Nick J. Connors" Date: Sun, 23 Jan 2022 03:49:22 -0500 Subject: [PATCH] Changed MColor32 to MColor --- .../Builder/Atmosphere/AtmosphereBuilder.cs | 2 +- .../Builder/Atmosphere/CloudsBuilder.cs | 4 +- NewHorizons/Builder/Atmosphere/FogBuilder.cs | 6 +-- .../Builder/Body/AsteroidBeltBuilder.cs | 2 +- NewHorizons/Builder/Body/FunnelBuilder.cs | 50 +++++++++++-------- NewHorizons/Builder/Body/ProcGenBuilder.cs | 2 +- NewHorizons/Builder/Body/SandBuilder.cs | 4 +- NewHorizons/Builder/Body/StarBuilder.cs | 10 ++-- NewHorizons/Builder/Body/WaterBuilder.cs | 2 +- .../Builder/Orbital/OrbitlineBuilder.cs | 8 +-- NewHorizons/External/AtmosphereModule.cs | 6 +-- NewHorizons/External/BaseModule.cs | 2 +- NewHorizons/External/OrbitModule.cs | 2 +- NewHorizons/External/ProcGenModule.cs | 2 +- .../External/VariableSize/FunnelModule.cs | 2 +- .../External/VariableSize/LavaModule.cs | 2 +- .../External/VariableSize/SandModule.cs | 2 +- .../External/VariableSize/StarModule.cs | 6 +-- .../External/VariableSize/WaterModule.cs | 2 +- NewHorizons/Utility/MColor.cs | 22 ++++++++ NewHorizons/Utility/MColor32.cs | 22 -------- 21 files changed, 85 insertions(+), 75 deletions(-) create mode 100644 NewHorizons/Utility/MColor.cs delete mode 100644 NewHorizons/Utility/MColor32.cs diff --git a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs index 6ec91e61..2457c32c 100644 --- a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs @@ -23,7 +23,7 @@ namespace NewHorizons.Atmosphere meshRenderer.material.SetFloat("_InnerRadius", atmosphereModule.Cloud != null ? atmosphereModule.Size : surfaceSize); meshRenderer.material.SetFloat("_OuterRadius", atmosphereModule.Size * 1.2f); if(atmosphereModule.AtmosphereTint != null) - meshRenderer.material.SetColor("_SkyColor", atmosphereModule.AtmosphereTint.ToColor32()); + meshRenderer.material.SetColor("_SkyColor", atmosphereModule.AtmosphereTint.ToColor()); } atmo.SetActive(true); diff --git a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs index 0dfcaeb7..34170e84 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -30,7 +30,7 @@ namespace NewHorizons.Atmosphere return; } - Color cloudTint = atmo.CloudTint == null ? Color.white : (Color)atmo.CloudTint.ToColor32(); + Color cloudTint = atmo.CloudTint == null ? Color.white : (Color)atmo.CloudTint.ToColor(); GameObject cloudsMainGO = new GameObject(); cloudsMainGO.SetActive(false); @@ -90,7 +90,7 @@ namespace NewHorizons.Atmosphere var bottomTSRTempArray = new Material[bottomTSRMaterials.Length]; // It's a bit too green - var bottomColor = atmo.CloudTint.ToColor32(); + var bottomColor = atmo.CloudTint.ToColor(); bottomColor.g = (byte)(bottomColor.g * 0.5f); for (int i = 0; i < bottomTSRMaterials.Length; i++) { diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index 96f8ed37..65dc7903 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -38,12 +38,12 @@ namespace NewHorizons.Atmosphere PFC.fogExponent = 1f; PFC.fogColorRampTexture = dbPlanetaryFogController.fogColorRampTexture; PFC.fogColorRampIntensity = 1f; - var adjustedColour = atmo.FogTint.ToColor32(); + var adjustedColour = atmo.FogTint.ToColor(); adjustedColour.r = (byte)(adjustedColour.r * atmo.FogDensity); adjustedColour.g = (byte)(adjustedColour.g * atmo.FogDensity); adjustedColour.b = (byte)(adjustedColour.b * atmo.FogDensity); adjustedColour.a = (byte)(adjustedColour.a * atmo.FogDensity); - PFC.fogTint = atmo.FogTint.ToColor32(); + PFC.fogTint = atmo.FogTint.ToColor(); GameObject lodFogGO = new GameObject("LODFogSphere"); lodFogGO.SetActive(false); @@ -55,7 +55,7 @@ namespace NewHorizons.Atmosphere MeshRenderer lodMR = lodFogGO.AddComponent(); lodMR.material = new Material(brambleLODFog.GetComponent().material); - lodMR.material.color = atmo.FogTint.ToColor32(); + lodMR.material.color = atmo.FogTint.ToColor(); lodMR.material.renderQueue = 1000; /* diff --git a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs index ab2b20ce..e84dc57f 100644 --- a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs +++ b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs @@ -55,7 +55,7 @@ namespace NewHorizons.Builder.Body {"ProcGen", new Dictionary() { {"Scale", size }, - {"Color", new MColor32(126, 94, 73, 255) } + {"Color", new MColor(126, 94, 73, 255) } } } }; diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index 12902bce..7ccff241 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -77,33 +77,43 @@ namespace NewHorizons.Builder.Body GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); - var waterMaterial = GameObject.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent().material; - proxyGO.GetComponentInChildren().material = waterMaterial; - geoGO.GetComponentInChildren().material = waterMaterial; + var waterMaterials = GameObject.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent().materials; + proxyGO.GetComponentInChildren().materials = waterMaterials; + geoGO.GetComponentInChildren().materials = waterMaterials; + + //TODO: Material inside + + //TODO: do the effect in water effect break; case FunnelType.LAVA: - sfv._fluidType = FluidVolume.Type.PLASMA; - - GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); - - var lavaMaterial = GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent().material; - proxyGO.GetComponentInChildren().material = lavaMaterial; - geoGO.GetComponentInChildren().material = lavaMaterial; - - AddDestructionVolumes(fluidVolume); - - break; case FunnelType.STAR: sfv._fluidType = FluidVolume.Type.PLASMA; GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); - var starMaterial = GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent().material; - proxyGO.GetComponentInChildren().material = starMaterial; - geoGO.GetComponentInChildren().material = starMaterial; + var lavaMaterial = new Material(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent().material); + lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f); + lavaMaterial.mainTextureScale = new Vector2(1f, 3f); - AddDestructionVolumes(fluidVolume); + if(module.Tint != null) + { + lavaMaterial.SetColor("_EmissionColor", module.Tint.ToColor()); + } + + proxyGO.GetComponentInChildren().material = lavaMaterial; + geoGO.GetComponentInChildren().material = lavaMaterial; + + if (funnelType == FunnelType.LAVA) + { + lavaMaterial.SetFloat("_HeightScale", 0); + AddDestructionVolumes(fluidVolume, DeathType.Lava); + } + else if (funnelType == FunnelType.STAR) + { + lavaMaterial.SetFloat("_HeightScale", 1000); + AddDestructionVolumes(fluidVolume, DeathType.Energy); + } break; } @@ -150,7 +160,7 @@ namespace NewHorizons.Builder.Body alignment.SetUsePhysicsToRotate(true); } - private static void AddDestructionVolumes(GameObject go) + private static void AddDestructionVolumes(GameObject go, DeathType deathType) { // Gotta put destruction volumes on the children reeeeeeeeee foreach (Transform child in go.transform) @@ -165,7 +175,7 @@ namespace NewHorizons.Builder.Body child.gameObject.AddComponent(); var destructionVolume = child.gameObject.AddComponent(); - destructionVolume._deathType = DeathType.Lava; + destructionVolume._deathType = deathType; } } } diff --git a/NewHorizons/Builder/Body/ProcGenBuilder.cs b/NewHorizons/Builder/Body/ProcGenBuilder.cs index e53e76d7..94ae60e6 100644 --- a/NewHorizons/Builder/Body/ProcGenBuilder.cs +++ b/NewHorizons/Builder/Body/ProcGenBuilder.cs @@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Body var cubeSphereMR = icosphere.AddComponent(); cubeSphereMR.material = new Material(Shader.Find("Standard")); - cubeSphereMR.material.color = module.Color.ToColor32(); + cubeSphereMR.material.color = module.Color.ToColor(); var cubeSphereMC = icosphere.AddComponent(); cubeSphereMC.sharedMesh = mesh; diff --git a/NewHorizons/Builder/Body/SandBuilder.cs b/NewHorizons/Builder/Body/SandBuilder.cs index 5e5874e2..30a85b8a 100644 --- a/NewHorizons/Builder/Body/SandBuilder.cs +++ b/NewHorizons/Builder/Body/SandBuilder.cs @@ -29,8 +29,8 @@ namespace NewHorizons.Builder.Body new Material(sandMaterials[1]) }; GameObject.Destroy(oldMR); - sandMR.sharedMaterials[0].color = module.Tint.ToColor32(); - sandMR.sharedMaterials[1].color = module.Tint.ToColor32(); + sandMR.sharedMaterials[0].color = module.Tint.ToColor(); + sandMR.sharedMaterials[1].color = module.Tint.ToColor(); } var collider = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform); diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 7d2018eb..b9d0648f 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -70,11 +70,11 @@ namespace NewHorizons.Builder.Body PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent(); if (starModule.Tint != null) { - fog.fogTint = starModule.Tint.ToColor32(); + fog.fogTint = starModule.Tint.ToColor(); sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one * (starModule.Size + 1000) / starModule.Size; foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren()) { - lod.material.SetColor("_SkyColor", starModule.Tint.ToColor32()); + lod.material.SetColor("_SkyColor", starModule.Tint.ToColor()); lod.material.SetFloat("_InnerRadius", starModule.Size); lod.material.SetFloat("_OuterRadius", starModule.Size * 3f / 2f); } @@ -103,7 +103,7 @@ namespace NewHorizons.Builder.Body Light ambientLight = ambientLightGO.GetComponent(); Color lightColour = light.color; - if (starModule.LightTint != null) lightColour = starModule.LightTint.ToColor32(); + if (starModule.LightTint != null) lightColour = starModule.LightTint.ToColor(); if (lightColour == null && starModule.Tint != null) { // Lighten it a bit @@ -119,7 +119,7 @@ namespace NewHorizons.Builder.Body if(starModule.Tint != null) { - var colour = starModule.Tint.ToColor32(); + var colour = starModule.Tint.ToColor(); var sun = GameObject.Find("Sun_Body"); var mainSequenceMaterial = sun.GetComponent().GetValue("_startSurfaceMaterial"); @@ -132,7 +132,7 @@ namespace NewHorizons.Builder.Body } if(starModule.SolarFlareTint != null) - solarFlareEmitter.GetComponent().tint = starModule.SolarFlareTint.ToColor32(); + solarFlareEmitter.GetComponent().tint = starModule.SolarFlareTint.ToColor(); starGO.transform.localPosition = Vector3.zero; starGO.transform.localScale = starModule.Size * Vector3.one; diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 34ed30f0..cd2ba69c 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -38,7 +38,7 @@ namespace NewHorizons.Builder.Body tempArray[i] = new Material(GDSharedMaterials[i]); if (module.Tint != null) { - tempArray[i].color = module.Tint.ToColor32(); + tempArray[i].color = module.Tint.ToColor(); } } diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index aeaff924..dfee8b05 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -35,13 +35,13 @@ namespace NewHorizons.Builder.Orbital orbitLine = orbitGO.AddComponent(); var color = Color.white; - if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor32(); - else if (config.Star != null) color = config.Star.Tint.ToColor32(); - else if (config.Atmosphere != null && config.Atmosphere.CloudTint != null) color = config.Atmosphere.CloudTint.ToColor32(); + if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor(); + else if (config.Star != null) color = config.Star.Tint.ToColor(); + else if (config.Atmosphere != null && config.Atmosphere.CloudTint != null) color = config.Atmosphere.CloudTint.ToColor(); else if (config.Base.BlackHoleSize != 0 || config.Singularity != null) color = new Color(1f, 0.5f, 1f); else if (config.Base.WaterSize != 0) color = new Color(0.5f, 0.5f, 1f); else if (config.Base.LavaSize != 0) color = new Color(1f, 0.5f, 0.5f); - else if (config.Atmosphere != null && config.Atmosphere.FogTint != null) color = config.Atmosphere.FogTint.ToColor32(); + else if (config.Atmosphere != null && config.Atmosphere.FogTint != null) color = config.Atmosphere.FogTint.ToColor(); var fade = isMoon; if (config.Base.IsSatellite) diff --git a/NewHorizons/External/AtmosphereModule.cs b/NewHorizons/External/AtmosphereModule.cs index 16ee6e71..d9b716ec 100644 --- a/NewHorizons/External/AtmosphereModule.cs +++ b/NewHorizons/External/AtmosphereModule.cs @@ -10,18 +10,18 @@ namespace NewHorizons.External public class AtmosphereModule : Module { public float Size { get; set; } - public MColor32 CloudTint { get; set; } + public MColor CloudTint { get; set; } public string Cloud { get; set; } public string CloudCap { get; set; } public string CloudRamp { get; set; } public bool UseBasicCloudShader { get; set; } - public MColor32 FogTint { get; set; } + public MColor FogTint { get; set; } public float FogDensity { get; set; } public float FogSize { get; set; } public bool HasRain { get; set; } public bool HasSnow { get; set; } public bool HasOxygen { get; set; } public bool HasAtmosphere { get; set; } - public MColor32 AtmosphereTint { get; set; } + public MColor AtmosphereTint { get; set; } } } diff --git a/NewHorizons/External/BaseModule.cs b/NewHorizons/External/BaseModule.cs index 85cf6dda..1b9f9f78 100644 --- a/NewHorizons/External/BaseModule.cs +++ b/NewHorizons/External/BaseModule.cs @@ -25,6 +25,6 @@ namespace NewHorizons.External public float BlackHoleSize { get; set; } public float LavaSize { get; set; } public float WaterSize { get; set; } - public MColor32 WaterTint { get; set; } + public MColor WaterTint { get; set; } } } diff --git a/NewHorizons/External/OrbitModule.cs b/NewHorizons/External/OrbitModule.cs index 69184052..5e005f2a 100644 --- a/NewHorizons/External/OrbitModule.cs +++ b/NewHorizons/External/OrbitModule.cs @@ -22,6 +22,6 @@ namespace NewHorizons.External public bool IsTidallyLocked { get; set; } public bool ShowOrbitLine { get; set; } = true; public bool IsStatic { get; set; } - public MColor32 Tint { get; set; } + public MColor Tint { get; set; } } } diff --git a/NewHorizons/External/ProcGenModule.cs b/NewHorizons/External/ProcGenModule.cs index e4e738e5..45813262 100644 --- a/NewHorizons/External/ProcGenModule.cs +++ b/NewHorizons/External/ProcGenModule.cs @@ -10,6 +10,6 @@ namespace NewHorizons.External public class ProcGenModule : Module { public float Scale { get; set; } - public MColor32 Color { get; set; } + public MColor Color { get; set; } } } diff --git a/NewHorizons/External/VariableSize/FunnelModule.cs b/NewHorizons/External/VariableSize/FunnelModule.cs index cba7de4b..33039ae3 100644 --- a/NewHorizons/External/VariableSize/FunnelModule.cs +++ b/NewHorizons/External/VariableSize/FunnelModule.cs @@ -11,6 +11,6 @@ namespace NewHorizons.External.VariableSize { public string Target { get; set; } public string Type { get; set; } = "Sand"; - public MColor32 Tint { get; set; } + public MColor Tint { get; set; } } } diff --git a/NewHorizons/External/VariableSize/LavaModule.cs b/NewHorizons/External/VariableSize/LavaModule.cs index 4fcd3ac8..0b393504 100644 --- a/NewHorizons/External/VariableSize/LavaModule.cs +++ b/NewHorizons/External/VariableSize/LavaModule.cs @@ -10,6 +10,6 @@ namespace NewHorizons.External.VariableSize public class LavaModule : VariableSizeModule { public float Size { get; set; } - public MColor32 Tint { get; set; } + public MColor Tint { get; set; } } } diff --git a/NewHorizons/External/VariableSize/SandModule.cs b/NewHorizons/External/VariableSize/SandModule.cs index 9b790db2..1dd9bfec 100644 --- a/NewHorizons/External/VariableSize/SandModule.cs +++ b/NewHorizons/External/VariableSize/SandModule.cs @@ -10,6 +10,6 @@ namespace NewHorizons.External.VariableSize public class SandModule : VariableSizeModule { public float Size { get; set; } - public MColor32 Tint { get; set; } + public MColor Tint { get; set; } } } diff --git a/NewHorizons/External/VariableSize/StarModule.cs b/NewHorizons/External/VariableSize/StarModule.cs index d2dc23e3..7808f880 100644 --- a/NewHorizons/External/VariableSize/StarModule.cs +++ b/NewHorizons/External/VariableSize/StarModule.cs @@ -10,9 +10,9 @@ namespace NewHorizons.External.VariableSize 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 MColor Tint { get; set; } + public MColor SolarFlareTint { get; set; } + public MColor LightTint { get; set; } public float SolarLuminosity { get; set; } = 1f; public bool HasAtmosphere { get; set; } = true; } diff --git a/NewHorizons/External/VariableSize/WaterModule.cs b/NewHorizons/External/VariableSize/WaterModule.cs index f2d1b740..937cd63d 100644 --- a/NewHorizons/External/VariableSize/WaterModule.cs +++ b/NewHorizons/External/VariableSize/WaterModule.cs @@ -10,6 +10,6 @@ namespace NewHorizons.External.VariableSize public class WaterModule : VariableSizeModule { public float Size { get; set; } - public MColor32 Tint { get; set; } + public MColor Tint { get; set; } } } diff --git a/NewHorizons/Utility/MColor.cs b/NewHorizons/Utility/MColor.cs new file mode 100644 index 00000000..99885ab4 --- /dev/null +++ b/NewHorizons/Utility/MColor.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace NewHorizons.Utility +{ + public class MColor + { + public MColor(int r, int g, int b, int a) + { + R = r; + G = g; + B = b; + A = a; + } + + public int R { get; } + public int G { get; } + public int B { get; } + public int A { get; } + + public Color ToColor() => new Color(R / 255, G / 255, B / 255, A / 255); + } +} diff --git a/NewHorizons/Utility/MColor32.cs b/NewHorizons/Utility/MColor32.cs deleted file mode 100644 index 525e9cdc..00000000 --- a/NewHorizons/Utility/MColor32.cs +++ /dev/null @@ -1,22 +0,0 @@ -using UnityEngine; - -namespace NewHorizons.Utility -{ - public class MColor32 - { - public MColor32(byte r, byte g, byte b, byte a) - { - R = r; - G = g; - B = b; - A = a; - } - - public byte R { get; } - public byte G { get; } - public byte B { get; } - public byte A { get; } - - public Color32 ToColor32() => new Color32(R, G, B, A); - } -}