using Unity.Entities;
using Unity.MegaCity.UI;
using static Unity.Entities.SystemAPI;
namespace Unity.MegaCity.Gameplay
{
///
/// Updates Control Settings based on the Settings UI
///
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
public partial struct UpdateControlSettingsSystem : ISystem
{
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate();
}
public void OnUpdate(ref SystemState state)
{
if (UIControlSettings.Instance == null || !UIControlSettings.Instance.ShouldUpdate)
return;
var controlSettings = GetSingletonRW().ValueRW;
controlSettings.MouseSensitivity = UIControlSettings.Instance.MouseSensitivity;
controlSettings.InverseLookHorizontal = UIControlSettings.Instance.InverseLookHorizontal;
controlSettings.InverseLookVertical = UIControlSettings.Instance.InverseLookVertical;
UIControlSettings.Instance.ShouldUpdate = false;
SetSingleton(controlSettings);
}
}
}