mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix variable star atmo size, atmo colours, sand sphere size
This commit is contained in:
parent
4b080250c3
commit
8e502f2c28
@ -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);
|
||||
|
||||
@ -35,7 +35,7 @@ namespace NewHorizons.Builder.Body
|
||||
var owrb = funnelGO.AddComponent<OWRigidbody>();
|
||||
var alignment = funnelGO.AddComponent<AlignWithTargetBody>();
|
||||
|
||||
funnelGO.AddComponent<InitialMotion>();
|
||||
//funnelGO.AddComponent<InitialMotion>();
|
||||
|
||||
var matchMotion = funnelGO.AddComponent<MatchInitialMotion>();
|
||||
matchMotion.SetBodyToMatch(rigidbody);
|
||||
|
||||
@ -102,7 +102,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
if (ring.Curve != null)
|
||||
{
|
||||
var levelController = ringGO.AddComponent<RingSizeController>();
|
||||
var levelController = ringGO.AddComponent<SizeController>();
|
||||
var curve = new AnimationCurve();
|
||||
foreach (var pair in ring.Curve)
|
||||
{
|
||||
|
||||
@ -58,7 +58,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
sandGO.transform.parent = go.transform;
|
||||
sandGO.transform.localPosition = Vector3.zero;
|
||||
sandGO.transform.localScale = Vector3.one * module.Size;
|
||||
sandGO.transform.localScale = Vector3.one * module.Size * 2f;
|
||||
|
||||
sandGO.SetActive(true);
|
||||
}
|
||||
|
||||
@ -9,11 +9,14 @@ using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using NewHorizons.Components;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class StarBuilder
|
||||
{
|
||||
public const float OuterRadiusRatio = 1.5f;
|
||||
|
||||
private static Texture2D _colorOverTime;
|
||||
public static StarController Make(GameObject body, Sector sector, StarModule starModule)
|
||||
{
|
||||
@ -70,17 +73,23 @@ namespace NewHorizons.Builder.Body
|
||||
PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
|
||||
if (starModule.Tint != null)
|
||||
{
|
||||
fog.fogTint = starModule.Tint.ToColor32();
|
||||
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one * (starModule.Size + 1000) / starModule.Size;
|
||||
fog.fogTint = starModule.Tint.ToColor();
|
||||
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one * (starModule.Size * OuterRadiusRatio);
|
||||
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);
|
||||
lod.material.SetFloat("_OuterRadius", starModule.Size * OuterRadiusRatio);
|
||||
}
|
||||
}
|
||||
fog.transform.localScale = Vector3.one;
|
||||
fog.fogRadius = starModule.Size * 1.2f;
|
||||
fog.fogRadius = starModule.Size * OuterRadiusRatio;
|
||||
if(starModule.Curve != null)
|
||||
{
|
||||
var controller = sunAtmosphere.AddComponent<StarAtmosphereSizeController>();
|
||||
controller.scaleCurve = starModule.ToAnimationCurve();
|
||||
controller.initialSize = starModule.Size;
|
||||
}
|
||||
}
|
||||
|
||||
var ambientLightGO = GameObject.Instantiate(GameObject.Find("Sun_Body/AmbientLight_SUN"), starGO.transform);
|
||||
@ -131,7 +140,7 @@ namespace NewHorizons.Builder.Body
|
||||
surface.sharedMaterial.color = adjustedColour;
|
||||
|
||||
Color.RGBToHSV(adjustedColour, out float H, out float S, out float V);
|
||||
var darkenedColor = Color.HSVToRGB(H, S, V * 0.125f);
|
||||
var darkenedColor = Color.HSVToRGB(H, S, V * 0.05f);
|
||||
surface.sharedMaterial.SetTexture("_ColorRamp", ImageUtilities.LerpGreyscaleImage(_colorOverTime, adjustedColour, darkenedColor));
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class RingSizeController : MonoBehaviour
|
||||
{
|
||||
public AnimationCurve scaleCurve;
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
float num = scaleCurve.Evaluate(TimeLoop.GetMinutesElapsed());
|
||||
base.transform.localScale = new Vector3(num, num, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
NewHorizons/Components/SizeController.cs
Normal file
21
NewHorizons/Components/SizeController.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class SizeController : MonoBehaviour
|
||||
{
|
||||
public AnimationCurve scaleCurve;
|
||||
public float CurrentScale { get; private set; }
|
||||
|
||||
protected void FixedUpdate()
|
||||
{
|
||||
CurrentScale = scaleCurve.Evaluate(TimeLoop.GetMinutesElapsed());
|
||||
base.transform.localScale = new Vector3(CurrentScale, CurrentScale, CurrentScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
NewHorizons/Components/StarAtmosphereSizeController.cs
Normal file
34
NewHorizons/Components/StarAtmosphereSizeController.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using NewHorizons.Builder.Body;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class StarAtmosphereSizeController : SizeController
|
||||
{
|
||||
private PlanetaryFogController fog;
|
||||
public float initialSize;
|
||||
private MeshRenderer[] atmosphereRenderers;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
fog = GetComponentInChildren<PlanetaryFogController>();
|
||||
atmosphereRenderers = transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>();
|
||||
}
|
||||
|
||||
protected new void FixedUpdate()
|
||||
{
|
||||
base.FixedUpdate();
|
||||
fog.fogRadius = initialSize * CurrentScale * StarBuilder.OuterRadiusRatio;
|
||||
foreach (var lod in atmosphereRenderers)
|
||||
{
|
||||
lod.material.SetFloat("_InnerRadius", initialSize * CurrentScale);
|
||||
lod.material.SetFloat("_OuterRadius", initialSize * CurrentScale * StarBuilder.OuterRadiusRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.External.VariableSize
|
||||
{
|
||||
@ -15,5 +16,15 @@ namespace NewHorizons.External.VariableSize
|
||||
public float Time { get; set; }
|
||||
public float Value { get; set; }
|
||||
}
|
||||
|
||||
public AnimationCurve ToAnimationCurve(float size = 1f)
|
||||
{
|
||||
var curve = new AnimationCurve();
|
||||
foreach (var pair in this.Curve)
|
||||
{
|
||||
curve.AddKey(new Keyframe(pair.Time, size * pair.Value));
|
||||
}
|
||||
return curve;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user