From cb1c3891fa7267da7833fdd8d6185fd6245d6692 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 24 May 2022 10:36:38 -0700 Subject: [PATCH] revert color thing --- .../Builder/Atmosphere/AtmosphereBuilder.cs | 2 +- .../Builder/Atmosphere/CloudsBuilder.cs | 6 +++--- NewHorizons/Builder/Atmosphere/FogBuilder.cs | 6 +++--- .../Builder/Atmosphere/VolumesBuilder.cs | 2 +- NewHorizons/Builder/Body/FunnelBuilder.cs | 4 ++-- NewHorizons/Builder/Body/LavaBuilder.cs | 4 ++-- NewHorizons/Builder/Body/ProcGenBuilder.cs | 2 +- NewHorizons/Builder/Body/ProxyBuilder.cs | 6 +++--- NewHorizons/Builder/Body/SandBuilder.cs | 4 ++-- NewHorizons/Builder/Body/StarBuilder.cs | 18 +++++++++--------- NewHorizons/Builder/Body/WaterBuilder.cs | 6 +++--- .../Builder/Orbital/OrbitlineBuilder.cs | 8 ++++---- NewHorizons/Builder/Props/ProjectionBuilder.cs | 2 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 4 ++-- NewHorizons/Builder/Props/VolcanoBuilder.cs | 4 ++-- NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 10 +++++----- .../Builder/ShipLog/RumorModeBuilder.cs | 4 ++-- .../SizeControllers/StarEvolutionController.cs | 4 ++-- NewHorizons/Utility/MColor.cs | 3 +++ 19 files changed, 51 insertions(+), 48 deletions(-) diff --git a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs index 67de6b32..c60ae6a3 100644 --- a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs @@ -24,7 +24,7 @@ namespace NewHorizons.Builder.Atmosphere meshRenderer.material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize); meshRenderer.material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f); if (atmosphereModule.atmosphereTint != null) - meshRenderer.material.SetColor(SkyColor, atmosphereModule.atmosphereTint); + 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 d9e4b63f..8363f36a 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -42,7 +42,7 @@ namespace NewHorizons.Builder.Atmosphere // If they set a colour apply it to all the materials else keep the default QM one if (atmo.clouds.tint != null) { - var bottomColor = atmo.clouds.tint; + var bottomColor = atmo.clouds.tint.ToColor(); var bottomTSRTempArray = new Material[2]; @@ -121,7 +121,7 @@ namespace NewHorizons.Builder.Atmosphere for(int i = 0; i < atmo.clouds.lightningGradient.Length; i++) { var pair = atmo.clouds.lightningGradient[i]; - gradient[i] = new GradientColorKey(pair.tint, pair.time); + gradient[i] = new GradientColorKey(pair.tint.ToColor(), pair.time); } lightningGenerator._lightColor.colorKeys = gradient; @@ -140,7 +140,7 @@ namespace NewHorizons.Builder.Atmosphere public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod) { - Color cloudTint = atmo.clouds.tint ?? Color.white; + Color cloudTint = atmo.clouds.tint?.ToColor() ?? Color.white; Texture2D image, cap, ramp; diff --git a/NewHorizons/Builder/Atmosphere/FogBuilder.cs b/NewHorizons/Builder/Atmosphere/FogBuilder.cs index 06a83f14..b521ede5 100644 --- a/NewHorizons/Builder/Atmosphere/FogBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/FogBuilder.cs @@ -33,9 +33,9 @@ namespace NewHorizons.Builder.Atmosphere PFC.fogRadius = atmo.fogSize; PFC.fogDensity = atmo.fogDensity; PFC.fogExponent = 1f; - PFC.fogColorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint); + PFC.fogColorRampTexture = atmo.fogTint == null ? _ramp : ImageUtilities.TintImage(_ramp, atmo.fogTint.ToColor()); PFC.fogColorRampIntensity = 1f; - PFC.fogTint = atmo.fogTint; + PFC.fogTint = atmo.fogTint.ToColor(); GameObject lodFogGO = new GameObject("LODFogSphere"); lodFogGO.SetActive(false); @@ -47,7 +47,7 @@ namespace NewHorizons.Builder.Atmosphere MeshRenderer lodMR = lodFogGO.AddComponent(); lodMR.material = new Material(brambleLODFog.GetComponent().material); - lodMR.material.color = atmo.fogTint; + lodMR.material.color = atmo.fogTint.ToColor(); lodMR.material.renderQueue = 1000; /* diff --git a/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs b/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs index e5dfc508..6a960870 100644 --- a/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs @@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Atmosphere var cloudMaterial = new Material(gdRuleset._cloudMaterial); if (config.Atmosphere?.clouds?.tint != null) { - cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint); + cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint.ToColor32()); } ER._cloudMaterial = cloudMaterial; diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index 3f6b22ec..5f9ccd93 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -70,7 +70,7 @@ namespace NewHorizons.Builder.Body materials[i] = new Material(waterMaterials[i]); if (module.tint != null) { - materials[i].SetColor(FogColor, module.tint); + materials[i].SetColor(FogColor, module.tint.ToColor()); } } @@ -117,7 +117,7 @@ namespace NewHorizons.Builder.Body if (module.tint != null) { - lavaMaterial.SetColor(EmissionColor, module.tint); + lavaMaterial.SetColor(EmissionColor, module.tint.ToColor()); } proxyGO.GetComponentInChildren().material = lavaMaterial; diff --git a/NewHorizons/Builder/Body/LavaBuilder.cs b/NewHorizons/Builder/Body/LavaBuilder.cs index fde7cbe0..9d2f40df 100644 --- a/NewHorizons/Builder/Body/LavaBuilder.cs +++ b/NewHorizons/Builder/Body/LavaBuilder.cs @@ -32,7 +32,7 @@ namespace NewHorizons.Builder.Body lavaSphere.transform.localScale = Vector3.one; lavaSphere.transform.name = "LavaSphere"; lavaSphere.GetComponent().material.SetFloat(HeightScale, heightScale); - if (module.tint != null) lavaSphere.GetComponent().material.SetColor(EmissionColor, module.tint); + if (module.tint != null) lavaSphere.GetComponent().material.SetColor(EmissionColor, module.tint.ToColor()); var sectorCullGroup = lavaSphere.GetComponent(); sectorCullGroup.SetSector(sector); @@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Body proxyLavaSphere.transform.localScale = Vector3.one; proxyLavaSphere.name = "LavaSphere_Proxy"; proxyLavaSphere.GetComponent().material.SetFloat(HeightScale, heightScale); - if (module.tint != null) proxyLavaSphere.GetComponent().material.SetColor(EmissionColor, module.tint); + if (module.tint != null) proxyLavaSphere.GetComponent().material.SetColor(EmissionColor, module.tint.ToColor()); var sectorProxy = moltenCoreProxy.GetComponent(); sectorProxy._renderers = new List { proxyLavaSphere.GetComponent() }; diff --git a/NewHorizons/Builder/Body/ProcGenBuilder.cs b/NewHorizons/Builder/Body/ProcGenBuilder.cs index af85572d..af13da22 100644 --- a/NewHorizons/Builder/Body/ProcGenBuilder.cs +++ b/NewHorizons/Builder/Body/ProcGenBuilder.cs @@ -27,7 +27,7 @@ namespace NewHorizons.Builder.Body var cubeSphereMR = icosphere.AddComponent(); cubeSphereMR.material = new Material(Shader.Find("Standard")); - cubeSphereMR.material.color = module.color != null ? module.color : Color.white; + cubeSphereMR.material.color = module.color != null ? module.color.ToColor() : Color.white; var cubeSphereMC = icosphere.AddComponent(); cubeSphereMC.sharedMesh = mesh; diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 64f8fcd0..33510c62 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -77,18 +77,18 @@ namespace NewHorizons.Builder.Body if (realSize < body.Config.Lava.size) realSize = body.Config.Lava.size; var material = new Material(lavaMaterial); - if (body.Config.Lava.tint != null) material.SetColor(EmissionColor, body.Config.Lava.tint); + if (body.Config.Lava.tint != null) material.SetColor(EmissionColor, body.Config.Lava.tint.ToColor()); sphere.GetComponent().material = material; } if (body.Config.Water != null) { - var colour = body.Config.Water.tint ?? Color.blue; + var colour = body.Config.Water.tint?.ToColor() ?? Color.blue; AddColouredSphere(newProxy, body.Config.Water.size, body.Config.Water.Curve, colour); if (realSize < body.Config.Water.size) realSize = body.Config.Water.size; } if (body.Config.Sand != null) { - var colour = body.Config.Sand.Tint ?? Color.yellow; + var colour = body.Config.Sand.Tint?.ToColor() ?? Color.yellow; AddColouredSphere(newProxy, body.Config.Sand.Size, body.Config.Sand.Curve, colour); if (realSize < body.Config.Sand.Size) realSize = body.Config.Sand.Size; } diff --git a/NewHorizons/Builder/Body/SandBuilder.cs b/NewHorizons/Builder/Body/SandBuilder.cs index a6037315..261a3434 100644 --- a/NewHorizons/Builder/Body/SandBuilder.cs +++ b/NewHorizons/Builder/Body/SandBuilder.cs @@ -24,8 +24,8 @@ namespace NewHorizons.Builder.Body new Material(sandMaterials[1]) }; GameObject.Destroy(oldMR); - sandMR.sharedMaterials[0].color = module.Tint; - sandMR.sharedMaterials[1].color = module.Tint; + sandMR.sharedMaterials[0].color = module.Tint.ToColor32(); + sandMR.sharedMaterials[1].color = module.Tint.ToColor32(); } 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 82e379e6..29de1a84 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -43,13 +43,13 @@ namespace NewHorizons.Builder.Body var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent(); if (starModule.tint != null) { - fog.fogTint = starModule.tint; + fog.fogTint = starModule.tint.ToColor(); sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one; foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren()) { - lod.material.SetColor(SkyColor, starModule.tint); - lod.material.SetColor(AtmosFar, starModule.tint); - lod.material.SetColor(AtmosNear, starModule.tint); + lod.material.SetColor(SkyColor, starModule.tint.ToColor()); + lod.material.SetColor(AtmosFar, starModule.tint.ToColor()); + lod.material.SetColor(AtmosNear, starModule.tint.ToColor()); lod.material.SetFloat(InnerRadius, starModule.size); lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio); } @@ -91,7 +91,7 @@ namespace NewHorizons.Builder.Body light.range *= Mathf.Sqrt(starModule.solarLuminosity); Color lightColour = light.color; - if (starModule.lightTint != null) lightColour = starModule.lightTint; + if (starModule.lightTint != null) lightColour = starModule.lightTint.ToColor(); light.color = lightColour; ambientLight.color = lightColour; @@ -183,7 +183,7 @@ namespace NewHorizons.Builder.Body if (starModule.tint != null) { - var flareTint = starModule.tint; + var flareTint = starModule.tint.ToColor(); var emitter = solarFlareEmitter.GetComponent(); emitter.tint = flareTint; foreach (var controller in solarFlareEmitter.GetComponentsInChildren()) @@ -201,7 +201,7 @@ namespace NewHorizons.Builder.Body { TessellatedSphereRenderer surface = sunSurface.GetComponent(); - var colour = starModule.tint; + var colour = starModule.tint.ToColor(); var sun = GameObject.Find("Sun_Body"); var mainSequenceMaterial = sun.GetComponent().GetValue("_startSurfaceMaterial"); @@ -217,7 +217,7 @@ namespace NewHorizons.Builder.Body if (starModule.endTint != null) { - var endColour = starModule.endTint; + var endColour = starModule.endTint.ToColor(); darkenedColor = new Color(endColour.r * mod, endColour.g * mod, endColour.b * mod); } @@ -239,7 +239,7 @@ namespace NewHorizons.Builder.Body if (starModule.supernovaTint != null) { - var colour = starModule.supernovaTint; + var colour = starModule.supernovaTint.ToColor(); var supernovaMaterial = new Material(supernova._supernovaMaterial); var ramp = ImageUtilities.LerpGreyscaleImage(ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Effects_SUN_Supernova_d.png"), Color.white, colour); diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index bf0aaa12..acca5a7d 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -40,8 +40,8 @@ namespace NewHorizons.Builder.Body tempArray[i] = new Material(GDSharedMaterials[i]); if (module.tint != null) { - tempArray[i].color = module.tint; - tempArray[i].SetColor("_FogColor", module.tint); + tempArray[i].color = module.tint.ToColor(); + tempArray[i].SetColor("_FogColor", module.tint.ToColor()); } } @@ -85,7 +85,7 @@ namespace NewHorizons.Builder.Body if (module.tint != null) { - var adjustedColour = (Color)module.tint / 4f; + var adjustedColour = module.tint.ToColor() / 4f; adjustedColour.a = adjustedColour.a * 4f; fogGO.GetComponent().material.color = adjustedColour; } diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index d86fc9e2..dc2a0232 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -57,13 +57,13 @@ namespace NewHorizons.Builder.Orbital } var color = Color.white; - if (config.Orbit.tint != null) color = config.Orbit.tint; - else if (config.Star != null) color = config.Star.tint; - else if (config.Atmosphere?.clouds?.tint != null) color = config.Atmosphere.clouds.tint; + if (config.Orbit.tint != null) color = config.Orbit.tint.ToColor32(); + else if (config.Star != null) color = config.Star.tint.ToColor32(); + else if (config.Atmosphere?.clouds?.tint != null) color = config.Atmosphere.clouds.tint.ToColor32(); else if (config.Singularity != null) color = new Color(1f, 0.5f, 1f); else if (config.Water != null) color = new Color(0.5f, 0.5f, 1f); else if (config.Lava != null) color = new Color(1f, 0.5f, 0.5f); - else if (config.Atmosphere != null && config.Atmosphere.fogTint != null) color = config.Atmosphere.fogTint; + else if (config.Atmosphere != null && config.Atmosphere.fogTint != null) color = config.Atmosphere.fogTint.ToColor32(); var fade = isMoon; diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 2a5bd451..4b111c86 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -185,7 +185,7 @@ namespace NewHorizons.Builder.Props var ambientLight = new SlideAmbientLightModule(); ambientLight._intensity = slideInfo.ambientLightIntensity; ambientLight._range = slideInfo.ambientLightRange; - ambientLight._color = slideInfo.ambientLightColor; + ambientLight._color = slideInfo.ambientLightColor.ToColor(); ambientLight._spotIntensityMod = slideInfo.spotIntensityMod; modules.Add(ambientLight); } diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 8377a9d4..730790b5 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -148,7 +148,7 @@ namespace NewHorizons.Builder.Props if (info.tint != null) { - ApplyTint(tornadoGO, info.tint, false, downwards); + ApplyTint(tornadoGO, info.tint.ToColor(), false, downwards); } if (info.wanderRate != 0) @@ -205,7 +205,7 @@ namespace NewHorizons.Builder.Props if (info.tint != null) { - ApplyTint(hurricaneGO, info.tint, true, false); + ApplyTint(hurricaneGO, info.tint.ToColor(), true, false); } if (info.wanderRate != 0) diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index ef649ddf..a9e04b51 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -50,8 +50,8 @@ namespace NewHorizons.Builder.Props meteor.transform.localScale = Vector3.one * info.scale; var mat = meteor.GetComponentInChildren().material; - mat.SetColor(Color1, info.stoneTint ?? defaultStoneTint); - mat.SetColor(EmissionColor, info.lavaTint ?? defaultLavaTint); + mat.SetColor(Color1, info.stoneTint?.ToColor() ?? defaultStoneTint); + mat.SetColor(EmissionColor, info.lavaTint?.ToColor() ?? defaultLavaTint); var detectors = meteor.transform.Find("ConstantDetectors").gameObject; GameObject.Destroy(detectors.GetComponent()); diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index 7b8102a1..feb17183 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -521,10 +521,10 @@ namespace NewHorizons.Builder.ShipLog } var starColor = body.Config?.Star?.tint; - if (starColor != null) return starColor; + if (starColor != null) return starColor.ToColor(); var atmoColor = body.Config.Atmosphere?.atmosphereTint; - if (body.Config.Atmosphere?.clouds != null && atmoColor != null) return atmoColor; + if (body.Config.Atmosphere?.clouds != null && atmoColor != null) return atmoColor.ToColor(); if (body.Config?.HeightMap?.textureMap != null) { @@ -538,13 +538,13 @@ namespace NewHorizons.Builder.ShipLog } var waterColor = body.Config.Water?.tint; - if (waterColor != null) return waterColor; + if (waterColor != null) return waterColor.ToColor(); var lavaColor = body.Config.Lava?.tint; - if (lavaColor != null) return lavaColor; + if (lavaColor != null) return lavaColor.ToColor(); var sandColor = body.Config.Sand?.Tint; - if (sandColor != null) return sandColor; + if (sandColor != null) return sandColor.ToColor(); } catch (Exception) { diff --git a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs index f2b14b76..23c50ea2 100644 --- a/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/RumorModeBuilder.cs @@ -31,8 +31,8 @@ namespace NewHorizons.Builder.ShipLog { CuriosityName newName = (CuriosityName)8 + _rawNameToCuriosityName.Count; _rawNameToCuriosityName.Add(newColor.id, newName); - _curiosityColors.Add(newName, newColor.color); - _curiosityHighlightColors.Add(newName, newColor.highlightColor); + _curiosityColors.Add(newName, newColor.color.ToColor()); + _curiosityHighlightColors.Add(newName, newColor.highlightColor.ToColor()); } } } diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index 30d5194c..4468b948 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -71,7 +71,7 @@ namespace NewHorizons.Components.SizeControllers } else { - _startColour = StartColour; + _startColour = StartColour.ToColor(); _startSurfaceMaterial.color = _startColour; } @@ -82,7 +82,7 @@ namespace NewHorizons.Components.SizeControllers } else { - _endColour = EndColour; + _endColour = EndColour.ToColor(); _endSurfaceMaterial.color = _endColour; } diff --git a/NewHorizons/Utility/MColor.cs b/NewHorizons/Utility/MColor.cs index 4e949478..9bb81358 100644 --- a/NewHorizons/Utility/MColor.cs +++ b/NewHorizons/Utility/MColor.cs @@ -39,6 +39,9 @@ namespace NewHorizons.Utility [DefaultValue(255f)] public int a; + public Color32 ToColor32() => new Color32((byte)r, (byte)g, (byte)b, (byte)a); + + public Color ToColor() => new Color(r / 255f, g / 255f, b / 255f, a / 255f); public static implicit operator Color(MColor c) => new Color(c.r / 255f, c.g / 255f, c.b / 255f, c.a / 255f); } }