284 lines
4.1 KiB
C#
284 lines
4.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace CTS
|
|
{
|
|
[Serializable]
|
|
public class CTSWeatherManager : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private float m_snowPower;
|
|
|
|
[SerializeField]
|
|
private float m_snowMinHeight;
|
|
|
|
[SerializeField]
|
|
private float m_rainPower;
|
|
|
|
[SerializeField]
|
|
private float m_maxRainSmoothness = 15f;
|
|
|
|
[SerializeField]
|
|
private bool m_seasonalTintActive = true;
|
|
|
|
[SerializeField]
|
|
private float m_season;
|
|
|
|
[SerializeField]
|
|
private Color m_winterTint = Color.white;
|
|
|
|
[SerializeField]
|
|
private Color m_springTint = new Color(0.7372549f, 1f, 0.5882353f);
|
|
|
|
[SerializeField]
|
|
private Color m_summerTint = new Color(1f, 37f / 51f, 32f / 85f);
|
|
|
|
[SerializeField]
|
|
private Color m_autumnTint = Color.white;
|
|
|
|
private bool m_somethingChanged = true;
|
|
|
|
public float SnowPower
|
|
{
|
|
get
|
|
{
|
|
return m_snowPower;
|
|
}
|
|
set
|
|
{
|
|
if (m_snowPower != value)
|
|
{
|
|
m_snowPower = Mathf.Clamp01(value);
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public float SnowMinHeight
|
|
{
|
|
get
|
|
{
|
|
return m_snowMinHeight;
|
|
}
|
|
set
|
|
{
|
|
if (m_snowMinHeight != value)
|
|
{
|
|
m_snowMinHeight = value;
|
|
if (m_snowMinHeight < 0f)
|
|
{
|
|
m_snowMinHeight = 0f;
|
|
}
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public float RainPower
|
|
{
|
|
get
|
|
{
|
|
return m_rainPower;
|
|
}
|
|
set
|
|
{
|
|
if (m_rainPower != value)
|
|
{
|
|
m_rainPower = Mathf.Clamp01(value);
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public float MaxRainSmoothness
|
|
{
|
|
get
|
|
{
|
|
return m_maxRainSmoothness;
|
|
}
|
|
set
|
|
{
|
|
if (m_maxRainSmoothness != value)
|
|
{
|
|
m_maxRainSmoothness = Mathf.Clamp(value, 0f, 30f);
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool SeasonalTintActive
|
|
{
|
|
get
|
|
{
|
|
return m_seasonalTintActive;
|
|
}
|
|
set
|
|
{
|
|
if (m_seasonalTintActive != value)
|
|
{
|
|
m_seasonalTintActive = value;
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public float Season
|
|
{
|
|
get
|
|
{
|
|
return m_season;
|
|
}
|
|
set
|
|
{
|
|
if (m_season == value)
|
|
{
|
|
return;
|
|
}
|
|
m_season = Mathf.Clamp(value, 0f, 3.9999f);
|
|
if (m_seasonalTintActive)
|
|
{
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Color WinterTint
|
|
{
|
|
get
|
|
{
|
|
return m_winterTint;
|
|
}
|
|
set
|
|
{
|
|
if (!(m_winterTint != value))
|
|
{
|
|
return;
|
|
}
|
|
m_winterTint = value;
|
|
if (m_seasonalTintActive)
|
|
{
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Color SpringTint
|
|
{
|
|
get
|
|
{
|
|
return m_springTint;
|
|
}
|
|
set
|
|
{
|
|
if (!(m_springTint != value))
|
|
{
|
|
return;
|
|
}
|
|
m_springTint = value;
|
|
if (m_seasonalTintActive)
|
|
{
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Color SummerTint
|
|
{
|
|
get
|
|
{
|
|
return m_summerTint;
|
|
}
|
|
set
|
|
{
|
|
if (!(m_summerTint != value))
|
|
{
|
|
return;
|
|
}
|
|
m_summerTint = value;
|
|
if (m_seasonalTintActive)
|
|
{
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Color AutumnTint
|
|
{
|
|
get
|
|
{
|
|
return m_autumnTint;
|
|
}
|
|
set
|
|
{
|
|
if (!(m_autumnTint != value))
|
|
{
|
|
return;
|
|
}
|
|
m_autumnTint = value;
|
|
if (m_seasonalTintActive)
|
|
{
|
|
m_somethingChanged = true;
|
|
if (!Application.isPlaying)
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
BroadcastUpdates();
|
|
}
|
|
|
|
private void BroadcastUpdates()
|
|
{
|
|
if (m_somethingChanged)
|
|
{
|
|
CTSSingleton<CTSTerrainManager>.Instance.BroadcastWeatherUpdate(this);
|
|
m_somethingChanged = false;
|
|
}
|
|
}
|
|
}
|
|
}
|