revert color thing

This commit is contained in:
JohnCorby 2022-05-24 10:36:38 -07:00
parent 497e1f5a38
commit cb1c3891fa
19 changed files with 51 additions and 48 deletions

View File

@ -24,7 +24,7 @@ namespace NewHorizons.Builder.Atmosphere
meshRenderer.material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize); meshRenderer.material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize);
meshRenderer.material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f); meshRenderer.material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f);
if (atmosphereModule.atmosphereTint != null) if (atmosphereModule.atmosphereTint != null)
meshRenderer.material.SetColor(SkyColor, atmosphereModule.atmosphereTint); meshRenderer.material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor());
} }
atmo.SetActive(true); atmo.SetActive(true);

View File

@ -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 they set a colour apply it to all the materials else keep the default QM one
if (atmo.clouds.tint != null) if (atmo.clouds.tint != null)
{ {
var bottomColor = atmo.clouds.tint; var bottomColor = atmo.clouds.tint.ToColor();
var bottomTSRTempArray = new Material[2]; var bottomTSRTempArray = new Material[2];
@ -121,7 +121,7 @@ namespace NewHorizons.Builder.Atmosphere
for(int i = 0; i < atmo.clouds.lightningGradient.Length; i++) for(int i = 0; i < atmo.clouds.lightningGradient.Length; i++)
{ {
var pair = atmo.clouds.lightningGradient[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; lightningGenerator._lightColor.colorKeys = gradient;
@ -140,7 +140,7 @@ namespace NewHorizons.Builder.Atmosphere
public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod) 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; Texture2D image, cap, ramp;

View File

@ -33,9 +33,9 @@ namespace NewHorizons.Builder.Atmosphere
PFC.fogRadius = atmo.fogSize; PFC.fogRadius = atmo.fogSize;
PFC.fogDensity = atmo.fogDensity; PFC.fogDensity = atmo.fogDensity;
PFC.fogExponent = 1f; 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.fogColorRampIntensity = 1f;
PFC.fogTint = atmo.fogTint; PFC.fogTint = atmo.fogTint.ToColor();
GameObject lodFogGO = new GameObject("LODFogSphere"); GameObject lodFogGO = new GameObject("LODFogSphere");
lodFogGO.SetActive(false); lodFogGO.SetActive(false);
@ -47,7 +47,7 @@ namespace NewHorizons.Builder.Atmosphere
MeshRenderer lodMR = lodFogGO.AddComponent<MeshRenderer>(); MeshRenderer lodMR = lodFogGO.AddComponent<MeshRenderer>();
lodMR.material = new Material(brambleLODFog.GetComponent<MeshRenderer>().material); lodMR.material = new Material(brambleLODFog.GetComponent<MeshRenderer>().material);
lodMR.material.color = atmo.fogTint; lodMR.material.color = atmo.fogTint.ToColor();
lodMR.material.renderQueue = 1000; lodMR.material.renderQueue = 1000;
/* /*

View File

@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Atmosphere
var cloudMaterial = new Material(gdRuleset._cloudMaterial); var cloudMaterial = new Material(gdRuleset._cloudMaterial);
if (config.Atmosphere?.clouds?.tint != null) if (config.Atmosphere?.clouds?.tint != null)
{ {
cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint); cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint.ToColor32());
} }
ER._cloudMaterial = cloudMaterial; ER._cloudMaterial = cloudMaterial;

View File

@ -70,7 +70,7 @@ namespace NewHorizons.Builder.Body
materials[i] = new Material(waterMaterials[i]); materials[i] = new Material(waterMaterials[i]);
if (module.tint != null) 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) if (module.tint != null)
{ {
lavaMaterial.SetColor(EmissionColor, module.tint); lavaMaterial.SetColor(EmissionColor, module.tint.ToColor());
} }
proxyGO.GetComponentInChildren<MeshRenderer>().material = lavaMaterial; proxyGO.GetComponentInChildren<MeshRenderer>().material = lavaMaterial;

View File

@ -32,7 +32,7 @@ namespace NewHorizons.Builder.Body
lavaSphere.transform.localScale = Vector3.one; lavaSphere.transform.localScale = Vector3.one;
lavaSphere.transform.name = "LavaSphere"; lavaSphere.transform.name = "LavaSphere";
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale); lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
if (module.tint != null) lavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.tint); if (module.tint != null) lavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.tint.ToColor());
var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>(); var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>();
sectorCullGroup.SetSector(sector); sectorCullGroup.SetSector(sector);
@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Body
proxyLavaSphere.transform.localScale = Vector3.one; proxyLavaSphere.transform.localScale = Vector3.one;
proxyLavaSphere.name = "LavaSphere_Proxy"; proxyLavaSphere.name = "LavaSphere_Proxy";
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale); proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
if (module.tint != null) proxyLavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.tint); if (module.tint != null) proxyLavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.tint.ToColor());
var sectorProxy = moltenCoreProxy.GetComponent<SectorProxy>(); var sectorProxy = moltenCoreProxy.GetComponent<SectorProxy>();
sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() }; sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() };

View File

@ -27,7 +27,7 @@ namespace NewHorizons.Builder.Body
var cubeSphereMR = icosphere.AddComponent<MeshRenderer>(); var cubeSphereMR = icosphere.AddComponent<MeshRenderer>();
cubeSphereMR.material = new Material(Shader.Find("Standard")); 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<MeshCollider>(); var cubeSphereMC = icosphere.AddComponent<MeshCollider>();
cubeSphereMC.sharedMesh = mesh; cubeSphereMC.sharedMesh = mesh;

View File

@ -77,18 +77,18 @@ namespace NewHorizons.Builder.Body
if (realSize < body.Config.Lava.size) realSize = body.Config.Lava.size; if (realSize < body.Config.Lava.size) realSize = body.Config.Lava.size;
var material = new Material(lavaMaterial); 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<MeshRenderer>().material = material; sphere.GetComponent<MeshRenderer>().material = material;
} }
if (body.Config.Water != null) 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); AddColouredSphere(newProxy, body.Config.Water.size, body.Config.Water.Curve, colour);
if (realSize < body.Config.Water.size) realSize = body.Config.Water.size; if (realSize < body.Config.Water.size) realSize = body.Config.Water.size;
} }
if (body.Config.Sand != null) 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); AddColouredSphere(newProxy, body.Config.Sand.Size, body.Config.Sand.Curve, colour);
if (realSize < body.Config.Sand.Size) realSize = body.Config.Sand.Size; if (realSize < body.Config.Sand.Size) realSize = body.Config.Sand.Size;
} }

View File

@ -24,8 +24,8 @@ namespace NewHorizons.Builder.Body
new Material(sandMaterials[1]) new Material(sandMaterials[1])
}; };
GameObject.Destroy(oldMR); GameObject.Destroy(oldMR);
sandMR.sharedMaterials[0].color = module.Tint; sandMR.sharedMaterials[0].color = module.Tint.ToColor32();
sandMR.sharedMaterials[1].color = module.Tint; sandMR.sharedMaterials[1].color = module.Tint.ToColor32();
} }
var collider = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform); var collider = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform);

View File

@ -43,13 +43,13 @@ namespace NewHorizons.Builder.Body
var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>(); var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
if (starModule.tint != null) if (starModule.tint != null)
{ {
fog.fogTint = starModule.tint; fog.fogTint = starModule.tint.ToColor();
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one; sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one;
foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>()) foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
{ {
lod.material.SetColor(SkyColor, starModule.tint); lod.material.SetColor(SkyColor, starModule.tint.ToColor());
lod.material.SetColor(AtmosFar, starModule.tint); lod.material.SetColor(AtmosFar, starModule.tint.ToColor());
lod.material.SetColor(AtmosNear, starModule.tint); lod.material.SetColor(AtmosNear, starModule.tint.ToColor());
lod.material.SetFloat(InnerRadius, starModule.size); lod.material.SetFloat(InnerRadius, starModule.size);
lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio); lod.material.SetFloat(OuterRadius, starModule.size * OuterRadiusRatio);
} }
@ -91,7 +91,7 @@ namespace NewHorizons.Builder.Body
light.range *= Mathf.Sqrt(starModule.solarLuminosity); light.range *= Mathf.Sqrt(starModule.solarLuminosity);
Color lightColour = light.color; Color lightColour = light.color;
if (starModule.lightTint != null) lightColour = starModule.lightTint; if (starModule.lightTint != null) lightColour = starModule.lightTint.ToColor();
light.color = lightColour; light.color = lightColour;
ambientLight.color = lightColour; ambientLight.color = lightColour;
@ -183,7 +183,7 @@ namespace NewHorizons.Builder.Body
if (starModule.tint != null) if (starModule.tint != null)
{ {
var flareTint = starModule.tint; var flareTint = starModule.tint.ToColor();
var emitter = solarFlareEmitter.GetComponent<SolarFlareEmitter>(); var emitter = solarFlareEmitter.GetComponent<SolarFlareEmitter>();
emitter.tint = flareTint; emitter.tint = flareTint;
foreach (var controller in solarFlareEmitter.GetComponentsInChildren<SolarFlareController>()) foreach (var controller in solarFlareEmitter.GetComponentsInChildren<SolarFlareController>())
@ -201,7 +201,7 @@ namespace NewHorizons.Builder.Body
{ {
TessellatedSphereRenderer surface = sunSurface.GetComponent<TessellatedSphereRenderer>(); TessellatedSphereRenderer surface = sunSurface.GetComponent<TessellatedSphereRenderer>();
var colour = starModule.tint; var colour = starModule.tint.ToColor();
var sun = GameObject.Find("Sun_Body"); var sun = GameObject.Find("Sun_Body");
var mainSequenceMaterial = sun.GetComponent<SunController>().GetValue<Material>("_startSurfaceMaterial"); var mainSequenceMaterial = sun.GetComponent<SunController>().GetValue<Material>("_startSurfaceMaterial");
@ -217,7 +217,7 @@ namespace NewHorizons.Builder.Body
if (starModule.endTint != null) 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); darkenedColor = new Color(endColour.r * mod, endColour.g * mod, endColour.b * mod);
} }
@ -239,7 +239,7 @@ namespace NewHorizons.Builder.Body
if (starModule.supernovaTint != null) if (starModule.supernovaTint != null)
{ {
var colour = starModule.supernovaTint; var colour = starModule.supernovaTint.ToColor();
var supernovaMaterial = new Material(supernova._supernovaMaterial); var supernovaMaterial = new Material(supernova._supernovaMaterial);
var ramp = ImageUtilities.LerpGreyscaleImage(ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Effects_SUN_Supernova_d.png"), Color.white, colour); var ramp = ImageUtilities.LerpGreyscaleImage(ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Effects_SUN_Supernova_d.png"), Color.white, colour);

View File

@ -40,8 +40,8 @@ namespace NewHorizons.Builder.Body
tempArray[i] = new Material(GDSharedMaterials[i]); tempArray[i] = new Material(GDSharedMaterials[i]);
if (module.tint != null) if (module.tint != null)
{ {
tempArray[i].color = module.tint; tempArray[i].color = module.tint.ToColor();
tempArray[i].SetColor("_FogColor", module.tint); tempArray[i].SetColor("_FogColor", module.tint.ToColor());
} }
} }
@ -85,7 +85,7 @@ namespace NewHorizons.Builder.Body
if (module.tint != null) if (module.tint != null)
{ {
var adjustedColour = (Color)module.tint / 4f; var adjustedColour = module.tint.ToColor() / 4f;
adjustedColour.a = adjustedColour.a * 4f; adjustedColour.a = adjustedColour.a * 4f;
fogGO.GetComponent<MeshRenderer>().material.color = adjustedColour; fogGO.GetComponent<MeshRenderer>().material.color = adjustedColour;
} }

View File

@ -57,13 +57,13 @@ namespace NewHorizons.Builder.Orbital
} }
var color = Color.white; var color = Color.white;
if (config.Orbit.tint != null) color = config.Orbit.tint; if (config.Orbit.tint != null) color = config.Orbit.tint.ToColor32();
else if (config.Star != null) color = config.Star.tint; else if (config.Star != null) color = config.Star.tint.ToColor32();
else if (config.Atmosphere?.clouds?.tint != null) color = config.Atmosphere.clouds.tint; 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.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.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.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; var fade = isMoon;

View File

@ -185,7 +185,7 @@ namespace NewHorizons.Builder.Props
var ambientLight = new SlideAmbientLightModule(); var ambientLight = new SlideAmbientLightModule();
ambientLight._intensity = slideInfo.ambientLightIntensity; ambientLight._intensity = slideInfo.ambientLightIntensity;
ambientLight._range = slideInfo.ambientLightRange; ambientLight._range = slideInfo.ambientLightRange;
ambientLight._color = slideInfo.ambientLightColor; ambientLight._color = slideInfo.ambientLightColor.ToColor();
ambientLight._spotIntensityMod = slideInfo.spotIntensityMod; ambientLight._spotIntensityMod = slideInfo.spotIntensityMod;
modules.Add(ambientLight); modules.Add(ambientLight);
} }

View File

@ -148,7 +148,7 @@ namespace NewHorizons.Builder.Props
if (info.tint != null) if (info.tint != null)
{ {
ApplyTint(tornadoGO, info.tint, false, downwards); ApplyTint(tornadoGO, info.tint.ToColor(), false, downwards);
} }
if (info.wanderRate != 0) if (info.wanderRate != 0)
@ -205,7 +205,7 @@ namespace NewHorizons.Builder.Props
if (info.tint != null) if (info.tint != null)
{ {
ApplyTint(hurricaneGO, info.tint, true, false); ApplyTint(hurricaneGO, info.tint.ToColor(), true, false);
} }
if (info.wanderRate != 0) if (info.wanderRate != 0)

View File

@ -50,8 +50,8 @@ namespace NewHorizons.Builder.Props
meteor.transform.localScale = Vector3.one * info.scale; meteor.transform.localScale = Vector3.one * info.scale;
var mat = meteor.GetComponentInChildren<MeshRenderer>().material; var mat = meteor.GetComponentInChildren<MeshRenderer>().material;
mat.SetColor(Color1, info.stoneTint ?? defaultStoneTint); mat.SetColor(Color1, info.stoneTint?.ToColor() ?? defaultStoneTint);
mat.SetColor(EmissionColor, info.lavaTint ?? defaultLavaTint); mat.SetColor(EmissionColor, info.lavaTint?.ToColor() ?? defaultLavaTint);
var detectors = meteor.transform.Find("ConstantDetectors").gameObject; var detectors = meteor.transform.Find("ConstantDetectors").gameObject;
GameObject.Destroy(detectors.GetComponent<ConstantForceDetector>()); GameObject.Destroy(detectors.GetComponent<ConstantForceDetector>());

View File

@ -521,10 +521,10 @@ namespace NewHorizons.Builder.ShipLog
} }
var starColor = body.Config?.Star?.tint; var starColor = body.Config?.Star?.tint;
if (starColor != null) return starColor; if (starColor != null) return starColor.ToColor();
var atmoColor = body.Config.Atmosphere?.atmosphereTint; 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) if (body.Config?.HeightMap?.textureMap != null)
{ {
@ -538,13 +538,13 @@ namespace NewHorizons.Builder.ShipLog
} }
var waterColor = body.Config.Water?.tint; var waterColor = body.Config.Water?.tint;
if (waterColor != null) return waterColor; if (waterColor != null) return waterColor.ToColor();
var lavaColor = body.Config.Lava?.tint; var lavaColor = body.Config.Lava?.tint;
if (lavaColor != null) return lavaColor; if (lavaColor != null) return lavaColor.ToColor();
var sandColor = body.Config.Sand?.Tint; var sandColor = body.Config.Sand?.Tint;
if (sandColor != null) return sandColor; if (sandColor != null) return sandColor.ToColor();
} }
catch (Exception) catch (Exception)
{ {

View File

@ -31,8 +31,8 @@ namespace NewHorizons.Builder.ShipLog
{ {
CuriosityName newName = (CuriosityName)8 + _rawNameToCuriosityName.Count; CuriosityName newName = (CuriosityName)8 + _rawNameToCuriosityName.Count;
_rawNameToCuriosityName.Add(newColor.id, newName); _rawNameToCuriosityName.Add(newColor.id, newName);
_curiosityColors.Add(newName, newColor.color); _curiosityColors.Add(newName, newColor.color.ToColor());
_curiosityHighlightColors.Add(newName, newColor.highlightColor); _curiosityHighlightColors.Add(newName, newColor.highlightColor.ToColor());
} }
} }
} }

View File

@ -71,7 +71,7 @@ namespace NewHorizons.Components.SizeControllers
} }
else else
{ {
_startColour = StartColour; _startColour = StartColour.ToColor();
_startSurfaceMaterial.color = _startColour; _startSurfaceMaterial.color = _startColour;
} }
@ -82,7 +82,7 @@ namespace NewHorizons.Components.SizeControllers
} }
else else
{ {
_endColour = EndColour; _endColour = EndColour.ToColor();
_endSurfaceMaterial.color = _endColour; _endSurfaceMaterial.color = _endColour;
} }

View File

@ -39,6 +39,9 @@ namespace NewHorizons.Utility
[DefaultValue(255f)] [DefaultValue(255f)]
public int a; 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); public static implicit operator Color(MColor c) => new Color(c.r / 255f, c.g / 255f, c.b / 255f, c.a / 255f);
} }
} }