Changed MColor32 to MColor

This commit is contained in:
Nick J. Connors 2022-01-23 03:49:22 -05:00
parent 6c32b3c7a2
commit 6a35123c48
21 changed files with 85 additions and 75 deletions

View File

@ -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);

View File

@ -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++)
{

View File

@ -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<MeshRenderer>();
lodMR.material = new Material(brambleLODFog.GetComponent<MeshRenderer>().material);
lodMR.material.color = atmo.FogTint.ToColor32();
lodMR.material.color = atmo.FogTint.ToColor();
lodMR.material.renderQueue = 1000;
/*

View File

@ -55,7 +55,7 @@ namespace NewHorizons.Builder.Body
{"ProcGen", new Dictionary<string, object>()
{
{"Scale", size },
{"Color", new MColor32(126, 94, 73, 255) }
{"Color", new MColor(126, 94, 73, 255) }
}
}
};

View File

@ -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<MeshRenderer>().material;
proxyGO.GetComponentInChildren<MeshRenderer>().material = waterMaterial;
geoGO.GetComponentInChildren<MeshRenderer>().material = waterMaterial;
var waterMaterials = GameObject.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent<MeshRenderer>().materials;
proxyGO.GetComponentInChildren<MeshRenderer>().materials = waterMaterials;
geoGO.GetComponentInChildren<MeshRenderer>().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<MeshRenderer>().material;
proxyGO.GetComponentInChildren<MeshRenderer>().material = lavaMaterial;
geoGO.GetComponentInChildren<MeshRenderer>().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<MeshRenderer>().material;
proxyGO.GetComponentInChildren<MeshRenderer>().material = starMaterial;
geoGO.GetComponentInChildren<MeshRenderer>().material = starMaterial;
var lavaMaterial = new Material(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().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<MeshRenderer>().material = lavaMaterial;
geoGO.GetComponentInChildren<MeshRenderer>().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<OWCapsuleCollider>();
var destructionVolume = child.gameObject.AddComponent<DestructionVolume>();
destructionVolume._deathType = DeathType.Lava;
destructionVolume._deathType = deathType;
}
}
}

View File

@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Body
var cubeSphereMR = icosphere.AddComponent<MeshRenderer>();
cubeSphereMR.material = new Material(Shader.Find("Standard"));
cubeSphereMR.material.color = module.Color.ToColor32();
cubeSphereMR.material.color = module.Color.ToColor();
var cubeSphereMC = icosphere.AddComponent<MeshCollider>();
cubeSphereMC.sharedMesh = mesh;

View File

@ -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);

View File

@ -70,11 +70,11 @@ namespace NewHorizons.Builder.Body
PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
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<MeshRenderer>())
{
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<Light>();
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<SunController>().GetValue<Material>("_startSurfaceMaterial");
@ -132,7 +132,7 @@ namespace NewHorizons.Builder.Body
}
if(starModule.SolarFlareTint != null)
solarFlareEmitter.GetComponent<SolarFlareEmitter>().tint = starModule.SolarFlareTint.ToColor32();
solarFlareEmitter.GetComponent<SolarFlareEmitter>().tint = starModule.SolarFlareTint.ToColor();
starGO.transform.localPosition = Vector3.zero;
starGO.transform.localScale = starModule.Size * Vector3.one;

View File

@ -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();
}
}

View File

@ -35,13 +35,13 @@ namespace NewHorizons.Builder.Orbital
orbitLine = orbitGO.AddComponent<TrackingOrbitLine>();
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)

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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;
}

View File

@ -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; }
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}