48 lines
868 B
C#
48 lines
868 B
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using _Data.Variabales.DayWeather;
|
|
|
|
public class LightGroupController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private List<Light> lights;
|
|
|
|
[SerializeField]
|
|
private AnimationCurve lightCurve;
|
|
|
|
[SerializeField]
|
|
private ScriptableTimeDayVariable timeOfDay;
|
|
|
|
private bool isEnabled;
|
|
|
|
private void Awake()
|
|
{
|
|
timeOfDay.OnValueChanged += TimeOfDayOnOnValueChanged;
|
|
TimeOfDayOnOnValueChanged(timeOfDay.Value);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
timeOfDay.OnValueChanged -= TimeOfDayOnOnValueChanged;
|
|
}
|
|
|
|
private void TimeOfDayOnOnValueChanged(float obj)
|
|
{
|
|
float num = lightCurve.Evaluate(timeOfDay.Value);
|
|
SetLights(!(num <= 0f));
|
|
}
|
|
|
|
private void SetLights(bool isOn)
|
|
{
|
|
if (isEnabled == isOn)
|
|
{
|
|
return;
|
|
}
|
|
foreach (Light light in lights)
|
|
{
|
|
light.enabled = isOn;
|
|
}
|
|
isEnabled = isOn;
|
|
}
|
|
}
|