2021-07-18 04:03:43 +00:00
|
|
|
|
using SanAndreasUnity.Behaviours.World;
|
2020-05-31 17:07:22 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using SanAndreasUnity.UI;
|
|
|
|
|
|
2021-07-18 04:03:43 +00:00
|
|
|
|
namespace SanAndreasUnity.Settings
|
|
|
|
|
{
|
|
|
|
|
public class WorldSettings : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private static WorldSettings Singleton { get; set; }
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
2021-07-18 04:03:43 +00:00
|
|
|
|
private float _drawDistanceToApply = 0f;
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
2022-01-12 02:25:17 +00:00
|
|
|
|
public const string DrawDistanceSerializationName = "max_draw_distance";
|
|
|
|
|
|
2021-07-18 04:03:43 +00:00
|
|
|
|
private OptionsWindow.FloatInput m_maxDrawDistanceInput = new OptionsWindow.FloatInput
|
|
|
|
|
{
|
2022-01-12 02:25:17 +00:00
|
|
|
|
serializationName = DrawDistanceSerializationName,
|
2020-05-31 17:07:22 +00:00
|
|
|
|
description = "Max draw distance",
|
2021-07-18 04:03:43 +00:00
|
|
|
|
minValue = WorldManager.MinMaxDrawDistance,
|
|
|
|
|
maxValue = WorldManager.MaxMaxDrawDistance,
|
|
|
|
|
getValue = () => WorldManager.Singleton.MaxDrawDistance,
|
|
|
|
|
setValue = value => { Singleton.OnDrawDistanceChanged(value); },
|
|
|
|
|
persistType = OptionsWindow.InputPersistType.OnStart,
|
2020-05-31 17:07:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-01-12 01:17:50 +00:00
|
|
|
|
public float overridenMaxDrawDistance = 0f;
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
|
|
|
|
|
void Awake ()
|
|
|
|
|
{
|
2021-07-18 04:03:43 +00:00
|
|
|
|
Singleton = this;
|
|
|
|
|
|
2022-01-12 01:17:50 +00:00
|
|
|
|
if (this.overridenMaxDrawDistance > 0f)
|
|
|
|
|
m_maxDrawDistanceInput.maxValue = this.overridenMaxDrawDistance;
|
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
|
OptionsWindow.RegisterInputs ("WORLD", m_maxDrawDistanceInput);
|
2019-06-22 21:01:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-18 04:03:43 +00:00
|
|
|
|
void OnDrawDistanceChanged(float newValue)
|
2019-06-22 21:01:50 +00:00
|
|
|
|
{
|
2021-07-18 04:03:43 +00:00
|
|
|
|
this.CancelInvoke(nameof(ChangeDrawDistanceDelayed));
|
|
|
|
|
_drawDistanceToApply = newValue;
|
|
|
|
|
this.Invoke(nameof(ChangeDrawDistanceDelayed), 0.2f);
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-18 04:03:43 +00:00
|
|
|
|
void ChangeDrawDistanceDelayed()
|
|
|
|
|
{
|
|
|
|
|
WorldManager.Singleton.MaxDrawDistance = _drawDistanceToApply;
|
|
|
|
|
}
|
2020-05-31 17:07:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|