This commit is contained in:
Nick 2022-05-21 23:31:01 -04:00
commit 6bcc70d4bb
17 changed files with 143 additions and 98 deletions

View File

@ -9,19 +9,19 @@ namespace NewHorizons.Builder.Atmosphere
GameObject airGO = new GameObject("Air");
airGO.SetActive(false);
airGO.layer = 17;
airGO.transform.parent = sector?.transform ?? planetGO.transform;
airGO.transform.parent = sector?.transform ? sector.transform : planetGO.transform;
SphereCollider SC = airGO.AddComponent<SphereCollider>();
SC.isTrigger = true;
SC.radius = info.Scale;
SphereCollider sc = airGO.AddComponent<SphereCollider>();
sc.isTrigger = true;
sc.radius = info.Scale;
SimpleFluidVolume SFV = airGO.AddComponent<SimpleFluidVolume>();
SFV._layer = 5;
SFV._priority = 1;
SFV._density = 1.2f;
SFV._fluidType = FluidVolume.Type.AIR;
SFV._allowShipAutoroll = true;
SFV._disableOnStart = false;
SimpleFluidVolume sfv = airGO.AddComponent<SimpleFluidVolume>();
sfv._layer = 5;
sfv._priority = 1;
sfv._density = 1.2f;
sfv._fluidType = FluidVolume.Type.AIR;
sfv._allowShipAutoroll = true;
sfv._disableOnStart = false;
if (info.HasOxygen)
{
@ -30,10 +30,10 @@ namespace NewHorizons.Builder.Atmosphere
if (info.IsRaining)
{
VisorRainEffectVolume VREF = airGO.AddComponent<VisorRainEffectVolume>();
VREF._rainDirection = VisorRainEffectVolume.RainDirection.Radial;
VREF._layer = 0;
VREF._priority = 0;
var vref = airGO.AddComponent<VisorRainEffectVolume>();
vref._rainDirection = VisorRainEffectVolume.RainDirection.Radial;
vref._layer = 0;
vref._priority = 0;
AudioSource AS = airGO.AddComponent<AudioSource>();
AS.mute = false;
@ -49,10 +49,10 @@ namespace NewHorizons.Builder.Atmosphere
AS.spatialBlend = 0f;
AS.reverbZoneMix = 1f;
OWAudioSource OWAS = airGO.AddComponent<OWAudioSource>();
OWAS._audioLibraryClip = AudioType.GD_RainAmbient_LP;
OWAS.SetClipSelectionType(OWAudioSource.ClipSelectionOnPlay.RANDOM);
OWAS.SetTrack(OWAudioMixer.TrackName.Environment);
var owAudioSource = airGO.AddComponent<OWAudioSource>();
owAudioSource._audioLibraryClip = AudioType.GD_RainAmbient_LP;
owAudioSource.SetClipSelectionType(OWAudioSource.ClipSelectionOnPlay.RANDOM);
owAudioSource.SetTrack(OWAudioMixer.TrackName.Environment);
airGO.AddComponent<AudioVolume>();
}

View File

@ -4,6 +4,10 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class AtmosphereBuilder
{
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius");
private static readonly int OuterRadius = Shader.PropertyToID("_OuterRadius");
private static readonly int SkyColor = Shader.PropertyToID("_SkyColor");
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize)
{
GameObject atmoGO = new GameObject("Atmosphere");
@ -12,16 +16,15 @@ namespace NewHorizons.Builder.Atmosphere
if (atmosphereModule.UseAtmosphereShader)
{
GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"));
atmo.transform.parent = atmoGO.transform;
GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true);
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
atmo.transform.localScale = Vector3.one * atmosphereModule.Size * 1.2f;
foreach (var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>())
{
meshRenderer.material.SetFloat("_InnerRadius", atmosphereModule.Clouds != null ? atmosphereModule.Size : surfaceSize);
meshRenderer.material.SetFloat("_OuterRadius", atmosphereModule.Size * 1.2f);
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.ToColor());
meshRenderer.material.SetColor(SkyColor, atmosphereModule.AtmosphereTint.ToColor());
}
atmo.SetActive(true);

View File

@ -11,6 +11,11 @@ namespace NewHorizons.Builder.Atmosphere
private static Shader _sphereShader = null;
private static Material[] _gdCloudMaterials;
private static GameObject _lightningPrefab;
private static readonly int Color1 = Shader.PropertyToID("_Color");
private static readonly int TintColor = Shader.PropertyToID("_TintColor");
private static readonly int MainTex = Shader.PropertyToID("_MainTex");
private static readonly int RampTex = Shader.PropertyToID("_RampTex");
private static readonly int CapTex = Shader.PropertyToID("_CapTex");
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
{
@ -39,8 +44,8 @@ namespace NewHorizons.Builder.Atmosphere
var bottomTSRTempArray = new Material[2];
bottomTSRTempArray[0] = new Material(bottomTSRMaterials[0]);
bottomTSRTempArray[0].SetColor("_Color", bottomColor);
bottomTSRTempArray[0].SetColor("_TintColor", bottomColor);
bottomTSRTempArray[0].SetColor(Color1, bottomColor);
bottomTSRTempArray[0].SetColor(TintColor, bottomColor);
bottomTSRTempArray[1] = new Material(bottomTSRMaterials[1]);
@ -133,7 +138,7 @@ namespace NewHorizons.Builder.Atmosphere
public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod)
{
Color cloudTint = atmo.Clouds.Tint == null ? Color.white : atmo.Clouds.Tint.ToColor();
Color cloudTint = atmo.Clouds.Tint?.ToColor() ?? Color.white;
Texture2D image, cap, ramp;
@ -188,12 +193,12 @@ namespace NewHorizons.Builder.Atmosphere
foreach (var material in topMR.sharedMaterials)
{
material.SetColor("_Color", cloudTint);
material.SetColor("_TintColor", cloudTint);
material.SetColor(Color1, cloudTint);
material.SetColor(TintColor, cloudTint);
material.SetTexture("_MainTex", image);
material.SetTexture("_RampTex", ramp);
material.SetTexture("_CapTex", cap);
material.SetTexture(MainTex, image);
material.SetTexture(RampTex, ramp);
material.SetTexture(CapTex, cap);
}
if (atmo.Clouds.Unlit)

View File

@ -4,6 +4,8 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class VolumesBuilder
{
private static readonly int FogColor = Shader.PropertyToID("_FogColor");
public static void Make(GameObject planetGO, PlanetConfig config, float sphereOfInfluence)
{
var innerRadius = config.Base.SurfaceSize;
@ -42,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.ToColor32());
cloudMaterial.SetColor(FogColor, config.Atmosphere.Clouds.Tint.ToColor32());
}
ER._cloudMaterial = cloudMaterial;

View File

@ -8,6 +8,10 @@ namespace NewHorizons.Builder.Body
{
public static class FunnelBuilder
{
private static readonly int FogColor = Shader.PropertyToID("_FogColor");
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
private static readonly int HeightScale = Shader.PropertyToID("_HeightScale");
private enum FunnelType
{
SAND,
@ -76,7 +80,7 @@ namespace NewHorizons.Builder.Body
materials[i] = new Material(waterMaterials[i]);
if (module.Tint != null)
{
materials[i].SetColor("_FogColor", module.Tint.ToColor());
materials[i].SetColor(FogColor, module.Tint.ToColor());
}
}
@ -123,7 +127,7 @@ namespace NewHorizons.Builder.Body
if (module.Tint != null)
{
lavaMaterial.SetColor("_EmissionColor", module.Tint.ToColor());
lavaMaterial.SetColor(EmissionColor, module.Tint.ToColor());
}
proxyGO.GetComponentInChildren<MeshRenderer>().material = lavaMaterial;
@ -131,13 +135,13 @@ namespace NewHorizons.Builder.Body
if (funnelType == FunnelType.LAVA)
{
lavaMaterial.SetFloat("_HeightScale", 0);
lavaMaterial.SetFloat(HeightScale, 0);
AddDestructionVolumes(fluidVolume, DeathType.Lava);
}
else if (funnelType == FunnelType.STAR)
{
lavaMaterial.renderQueue = 2999;
lavaMaterial.SetFloat("_HeightScale", 100000);
lavaMaterial.SetFloat(HeightScale, 100000);
AddDestructionVolumes(fluidVolume, DeathType.Energy);
}

View File

@ -43,9 +43,11 @@ namespace NewHorizons.Builder.Body
//if (PlanetShader == null) PlanetShader = Shader.Find("Standard");
var cubeSphereMR = cubeSphere.AddComponent<MeshRenderer>();
cubeSphereMR.material = new Material(PlanetShader);
cubeSphereMR.material.name = textureMap.name;
cubeSphereMR.material.mainTexture = textureMap;
var material = cubeSphereMR.material;
material = new Material(PlanetShader);
cubeSphereMR.material = material;
material.name = textureMap.name;
material.mainTexture = textureMap;
var cubeSphereMC = cubeSphere.AddComponent<MeshCollider>();
cubeSphereMC.sharedMesh = mesh;

View File

@ -6,6 +6,9 @@ namespace NewHorizons.Builder.Body
{
public static class LavaBuilder
{
private static readonly int HeightScale = Shader.PropertyToID("_HeightScale");
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, LavaModule module)
{
var heightScale = module.Size;
@ -28,8 +31,8 @@ namespace NewHorizons.Builder.Body
var lavaSphere = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform);
lavaSphere.transform.localScale = Vector3.one;
lavaSphere.transform.name = "LavaSphere";
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat("_HeightScale", heightScale);
if (module.Tint != null) lavaSphere.GetComponent<MeshRenderer>().material.SetColor("_EmissionColor", module.Tint.ToColor());
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
if (module.Tint != null) lavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.Tint.ToColor());
var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>();
sectorCullGroup.SetSector(sector);
@ -40,8 +43,8 @@ namespace NewHorizons.Builder.Body
var proxyLavaSphere = moltenCoreProxy.transform.Find("LavaSphere (1)");
proxyLavaSphere.transform.localScale = Vector3.one;
proxyLavaSphere.name = "LavaSphere_Proxy";
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat("_HeightScale", heightScale);
if (module.Tint != null) proxyLavaSphere.GetComponent<MeshRenderer>().material.SetColor("_EmissionColor", module.Tint.ToColor());
proxyLavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
if (module.Tint != null) proxyLavaSphere.GetComponent<MeshRenderer>().material.SetColor(EmissionColor, module.Tint.ToColor());
var sectorProxy = moltenCoreProxy.GetComponent<SectorProxy>();
sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() };

View File

@ -19,6 +19,12 @@ namespace NewHorizons.Builder.Body
private static readonly string _blackHolePath = "TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity";
private static readonly string _whiteHolePath = "TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_CT/Prefab_NOM_WarpTransmitter/WhiteHole/WhiteHoleSingularity";
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
private static readonly int Radius = Shader.PropertyToID("_Radius");
private static readonly int MaxDistortRadius = Shader.PropertyToID("_MaxDistortRadius");
private static readonly int MassScale = Shader.PropertyToID("_MassScale");
private static readonly int DistortFadeDist = Shader.PropertyToID("_DistortFadeDist");
private static readonly int Color1 = Shader.PropertyToID("_Color");
public static void Make(GameObject planetGO, NewHorizonsBody body)
@ -71,7 +77,7 @@ 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.ToColor());
if (body.Config.Lava.Tint != null) material.SetColor(EmissionColor, body.Config.Lava.Tint.ToColor());
sphere.GetComponent<MeshRenderer>().material = material;
}
if (body.Config.Water != null)
@ -185,10 +191,10 @@ namespace NewHorizons.Builder.Body
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
meshRenderer.material = new Material(blackHoleShader);
meshRenderer.material.SetFloat("_Radius", size * 0.4f);
meshRenderer.material.SetFloat("_MaxDistortRadius", size * 0.95f);
meshRenderer.material.SetFloat("_MassScale", 1);
meshRenderer.material.SetFloat("_DistortFadeDist", size * 0.55f);
meshRenderer.material.SetFloat(Radius, size * 0.4f);
meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f);
meshRenderer.material.SetFloat(MassScale, 1);
meshRenderer.material.SetFloat(DistortFadeDist, size * 0.55f);
blackHoleRender.SetActive(true);
}
@ -210,10 +216,10 @@ namespace NewHorizons.Builder.Body
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
meshRenderer.material = new Material(whiteHoleShader);
meshRenderer.sharedMaterial.SetFloat("_Radius", size * 0.4f);
meshRenderer.sharedMaterial.SetFloat("_DistortFadeDist", size);
meshRenderer.sharedMaterial.SetFloat("_MaxDistortRadius", size * 2.8f);
meshRenderer.sharedMaterial.SetColor("_Color", new Color(1.88f, 1.88f, 1.88f, 1f));
meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f);
meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size);
meshRenderer.sharedMaterial.SetFloat(MaxDistortRadius, size * 2.8f);
meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f));
whiteHoleRenderer.SetActive(true);
}

View File

@ -16,6 +16,7 @@ namespace NewHorizons.Builder.Body
public static Shader RingShader1Pixel;
public static Shader UnlitRingShader;
public static Shader UnlitRingShader1Pixel;
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius");
public static GameObject Make(GameObject planetGO, Sector sector, RingModule ring, IModBehaviour mod)
{
@ -105,7 +106,7 @@ namespace NewHorizons.Builder.Body
if (texture.width == 1)
{
mat = new Material(ring.Unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
mat.SetFloat("_InnerRadius", 0);
mat.SetFloat(InnerRadius, 0);
}
ringMR.receiveShadows = !ring.Unlit;

View File

@ -16,6 +16,11 @@ namespace NewHorizons.Builder.Body
private static Shader blackHoleShader = null;
private static Shader whiteHoleShader = null;
private static readonly int Radius = Shader.PropertyToID("_Radius");
private static readonly int MaxDistortRadius = Shader.PropertyToID("_MaxDistortRadius");
private static readonly int MassScale = Shader.PropertyToID("_MassScale");
private static readonly int DistortFadeDist = Shader.PropertyToID("_DistortFadeDist");
private static readonly int Color1 = Shader.PropertyToID("_Color");
public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config)
{
@ -96,10 +101,10 @@ namespace NewHorizons.Builder.Body
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
if (blackHoleShader == null) blackHoleShader = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshRenderer>().sharedMaterial.shader;
meshRenderer.material = new Material(blackHoleShader);
meshRenderer.material.SetFloat("_Radius", size * 0.4f);
meshRenderer.material.SetFloat("_MaxDistortRadius", size * 0.95f);
meshRenderer.material.SetFloat("_MassScale", 1);
meshRenderer.material.SetFloat("_DistortFadeDist", size * 0.55f);
meshRenderer.material.SetFloat(Radius, size * 0.4f);
meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f);
meshRenderer.material.SetFloat(MassScale, 1);
meshRenderer.material.SetFloat(DistortFadeDist, size * 0.55f);
if (makeAudio)
{
@ -167,11 +172,11 @@ namespace NewHorizons.Builder.Body
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
if (whiteHoleShader == null) whiteHoleShader = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshRenderer>().sharedMaterial.shader;
meshRenderer.material = new Material(whiteHoleShader);
meshRenderer.sharedMaterial.SetFloat("_Radius", size * 0.4f);
meshRenderer.sharedMaterial.SetFloat("_DistortFadeDist", size);
meshRenderer.sharedMaterial.SetFloat("_MaxDistortRadius", size * 2.8f);
meshRenderer.sharedMaterial.SetFloat("_MassScale", -1);
meshRenderer.sharedMaterial.SetColor("_Color", new Color(1.88f, 1.88f, 1.88f, 1f));
meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f);
meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size);
meshRenderer.sharedMaterial.SetFloat(MaxDistortRadius, size * 2.8f);
meshRenderer.sharedMaterial.SetFloat(MassScale, -1);
meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f));
var ambientLight = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/AmbientLight_WH"));
ambientLight.transform.parent = whiteHole.transform;

View File

@ -11,6 +11,12 @@ namespace NewHorizons.Builder.Body
{
public const float OuterRadiusRatio = 1.5f;
private static Texture2D _colorOverTime;
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp");
private static readonly int SkyColor = Shader.PropertyToID("_SkyColor");
private static readonly int AtmosFar = Shader.PropertyToID("_AtmosFar");
private static readonly int AtmosNear = Shader.PropertyToID("_AtmosNear");
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius");
private static readonly int OuterRadius = Shader.PropertyToID("_OuterRadius");
public static StarController Make(GameObject planetGO, Sector sector, StarModule starModule)
{
@ -40,11 +46,11 @@ namespace NewHorizons.Builder.Body
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one;
foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
{
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);
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);
}
}
fog.transform.localScale = Vector3.one;
@ -85,15 +91,6 @@ namespace NewHorizons.Builder.Body
Color lightColour = light.color;
if (starModule.LightTint != null) lightColour = starModule.LightTint.ToColor();
if (lightColour == null && starModule.Tint != null)
{
// Lighten it a bit
var r = Mathf.Clamp01(starModule.Tint.R * 1.5f);
var g = Mathf.Clamp01(starModule.Tint.G * 1.5f);
var b = Mathf.Clamp01(starModule.Tint.B * 1.5f);
lightColour = new Color(r, g, b);
}
if (lightColour != null) light.color = (Color)lightColour;
light.color = lightColour;
ambientLight.color = lightColour;
@ -218,7 +215,7 @@ namespace NewHorizons.Builder.Body
darkenedColor = new Color(endColour.r * mod, endColour.g * mod, endColour.b * mod);
}
surface.sharedMaterial.SetTexture("_ColorRamp", ImageUtilities.LerpGreyscaleImage(_colorOverTime, adjustedColour, darkenedColor));
surface.sharedMaterial.SetTexture(ColorRamp, ImageUtilities.LerpGreyscaleImage(_colorOverTime, adjustedColour, darkenedColor));
}
return starGO;
@ -240,7 +237,7 @@ namespace NewHorizons.Builder.Body
var supernovaMaterial = new Material(supernova._supernovaMaterial);
var ramp = ImageUtilities.LerpGreyscaleImage(ImageUtilities.GetTexture(Main.Instance, "AssetBundle/Effects_SUN_Supernova_d.png"), Color.white, colour);
supernovaMaterial.SetTexture("_ColorRamp", ramp);
supernovaMaterial.SetTexture(ColorRamp, ramp);
supernova._supernovaMaterial = supernovaMaterial;
// Motes

View File

@ -9,6 +9,9 @@ namespace NewHorizons.Builder.Body
{
public static class WaterBuilder
{
private static readonly int Radius = Shader.PropertyToID("_Radius");
private static readonly int Radius2 = Shader.PropertyToID("_Radius2");
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module)
{
var waterSize = module.Size;
@ -101,8 +104,8 @@ namespace NewHorizons.Builder.Body
}
else
{
fogGO.GetComponent<MeshRenderer>().material.SetFloat("_Radius", module.Size);
fogGO.GetComponent<MeshRenderer>().material.SetFloat("_Radius2", module.Size / 2f);
fogGO.GetComponent<MeshRenderer>().material.SetFloat(Radius, module.Size);
fogGO.GetComponent<MeshRenderer>().material.SetFloat(Radius2, module.Size / 2f);
}
// TODO: make LOD work

View File

@ -12,6 +12,8 @@ namespace NewHorizons.Builder.Props
{
private static GameObject _slideReelPrefab;
private static GameObject _autoPrefab;
private static readonly int EmissionMap = Shader.PropertyToID("_EmissionMap");
public static void Make(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
{
if (info.type == "autoProjector") MakeAutoProjector(go, sector, info, mod);
@ -90,9 +92,9 @@ namespace NewHorizons.Builder.Props
// Now put together the textures into a 4x4 thing for the materials
var reelTexture = ImageUtilities.MakeReelTexture(textures);
slidesBack.material.mainTexture = reelTexture;
slidesBack.material.SetTexture("_EmissionMap", reelTexture);
slidesBack.material.SetTexture(EmissionMap, reelTexture);
slidesFront.material.mainTexture = reelTexture;
slidesFront.material.SetTexture("_EmissionMap", reelTexture);
slidesFront.material.SetTexture(EmissionMap, reelTexture);
slideReelObj.SetActive(true);
}
@ -147,7 +149,7 @@ namespace NewHorizons.Builder.Props
// Change the picture on the lens
var lens = projectorObj.transform.Find("Spotlight/Prop_IP_SingleSlideProjector/Projector_Lens").GetComponent<MeshRenderer>();
lens.materials[1].mainTexture = slideCollection.slides[0]._textureOverride;
lens.materials[1].SetTexture("_EmissionMap", slideCollection.slides[0]._textureOverride);
lens.materials[1].SetTexture(EmissionMap, slideCollection.slides[0]._textureOverride);
projectorObj.SetActive(true);
}

View File

@ -16,6 +16,11 @@ namespace NewHorizons.Builder.Props
private static Texture2D _mainTexture;
private static Texture2D _detailTexture;
private static readonly int DetailColor = Shader.PropertyToID("_DetailColor");
private static readonly int TintColor = Shader.PropertyToID("_TintColor");
private static readonly int DetailTex = Shader.PropertyToID("_DetailTex");
private static readonly int MainTex = Shader.PropertyToID("_MainTex");
private static readonly int FresnelColor = Shader.PropertyToID("_FresnelColor");
public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, bool hasClouds)
{
@ -226,14 +231,14 @@ namespace NewHorizons.Builder.Props
foreach (var renderer in go.GetComponentsInChildren<Renderer>())
{
renderer.material.SetColor("_DetailColor", colour);
renderer.material.SetColor("_TintColor", colour);
renderer.material.SetColor(DetailColor, colour);
renderer.material.SetColor(TintColor, colour);
if (renderer.material.name.Contains(materialName))
{
renderer.material.SetTexture("_DetailTex", detailTexture);
renderer.material.SetTexture("_MainTex", mainTexture);
renderer.material.SetColor("_FresnelColor", colour);
renderer.material.SetTexture(DetailTex, detailTexture);
renderer.material.SetTexture(MainTex, mainTexture);
renderer.material.SetColor(FresnelColor, colour);
}
else
{

View File

@ -7,6 +7,8 @@ namespace NewHorizons.Builder.Props
{
private static Color defaultStoneTint = new Color(0.07450981f, 0.07450981f, 0.07450981f);
private static Color defaultLavaTint = new Color(4.594794f, 0.3419145f, 0f, 1f);
private static readonly int Color1 = Shader.PropertyToID("_Color");
private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");
public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info)
{
@ -48,8 +50,8 @@ namespace NewHorizons.Builder.Props
meteor.transform.localScale = Vector3.one * info.scale;
var mat = meteor.GetComponentInChildren<MeshRenderer>().material;
mat.SetColor("_Color", info.stoneTint == null ? defaultStoneTint : info.stoneTint.ToColor());
mat.SetColor("_EmissionColor", info.lavaTint == null ? defaultLavaTint : info.lavaTint.ToColor());
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<ConstantForceDetector>());

View File

@ -12,7 +12,7 @@ namespace NewHorizons.Components
// Temporary solution that i will never get rid of
transform.position = anchor.position;
float num = scaleCurve == null ? 1f : scaleCurve.Evaluate(TimeLoop.GetMinutesElapsed());
float num = scaleCurve?.Evaluate(TimeLoop.GetMinutesElapsed()) ?? 1f;
var dist = (transform.position - target.position).magnitude;
transform.localScale = new Vector3(num, num, dist / 500f);

View File

@ -7,14 +7,19 @@ namespace NewHorizons.Components
{
public void Awake()
{
var config = new PlanetConfig();
config.Base.SurfaceSize = 10f;
var config = new PlanetConfig
{
Base =
{
SurfaceSize = 10f
}
};
var detector = base.transform.GetComponentInChildren<DynamicForceDetector>();
var ao = base.GetComponent<AstroObject>();
var newDetector = DetectorBuilder.Make(base.gameObject, ao.GetAttachedOWRigidbody(), ao.GetPrimaryBody(), ao, config);
var detector = transform.GetComponentInChildren<DynamicForceDetector>();
var ao = GetComponent<AstroObject>();
var newDetector = DetectorBuilder.Make(gameObject, ao.GetAttachedOWRigidbody(), ao.GetPrimaryBody(), ao, config);
newDetector.transform.parent = detector.transform.parent;
GameObject.Destroy(detector);
Destroy(detector);
}
}
}