Game.UI.Editor.EditorBottomBarUISystem
Assembly: Game
Namespace: Game.UI.Editor
Type: class
Base: UISystemBase
Summary:
Provides the UI system that drives the editor bottom bar controls (time of day, date and cloudiness) for the Editor game mode. It exposes bindings for the UI to read current values (with snapping) and trigger bindings to set or reset overrides on the underlying simulation systems (PlanetarySystem and ClimateSystem). The system retrieves these simulation systems from the world and ensures state is cleaned up when the system stops running. Uses the "editorBottomBar" binding group for all UI bindings. Marked methods use the [Preserve] attribute so they aren't stripped by linking.
Fields
-
private static readonly string kGroup
Group name used for all UI bindings created by this system ("editorBottomBar"). Use this when referencing or adding UI bindings related to the editor bottom bar. -
private ClimateSystem m_ClimateSystem
Reference to the ClimateSystem retrieved from the world. Used to read and override climate-related values like current date and cloudiness. -
private PlanetarySystem m_PlanetarySystem
Reference to the PlanetarySystem retrieved from the world. Used to read and override time-of-day values.
Properties
-
public override GameMode gameMode { get; }
Returns GameMode.Editor — the system is active for the editor game mode. -
private float m_NormalizedTimeBindingValue { get; }
Computed (private) property that returns the planetary system's normalizedTime snapped to 0.01 increments using MathUtils.Snap. This is used for the UI update binding so the UI doesn't update excessively for tiny changes. -
private float m_NormalizedDateBindingValue { get; }
Computed (private) property that returns the climate system's currentDate snapped to 0.01 increments. Used for the UI update binding for the date field.
Constructors
public EditorBottomBarUISystem()
Default constructor. Marked with [Preserve] attribute on the OnCreate and constructor in source to avoid stripping. No special initialization logic beyond what OnCreate performs.
Methods
protected override void OnCreate()
Initializes the system: retrieves ClimateSystem and PlanetarySystem from the world, registers update bindings and trigger bindings with the UI binding group:- Update bindings (GetterValueBinding
) for: - "timeOfDay" -> m_NormalizedTimeBindingValue
- "date" -> m_NormalizedDateBindingValue
- "cloudiness" -> m_ClimateSystem.cloudiness
-
Trigger bindings to handle UI actions:
- "setTimeOfDay" (float) -> SetTimeOfDay
- "resetTimeOfDay" -> ResetTimeOfDay
- "setDate" (float) -> SetDate
- "resetDate" -> ResetDate
- "setCloudiness" (float) -> SetCloudiness
- "resetCloudiness" -> ResetCloudiness
Marked with [Preserve].
-
protected override void OnStopRunning()
Called when the system stops running. Clears any overrides applied by this system: - m_PlanetarySystem.overrideTime = false
- m_ClimateSystem.currentDate.overrideState = false
-
m_ClimateSystem.cloudiness.overrideState = false
-
private void SetTimeOfDay(float time)
Sets planetary override: enables overrideTime on PlanetarySystem and sets normalizedTime to the provided value. -
private void ResetTimeOfDay()
Disables PlanetarySystem.overrideTime to return to normal time progression. -
private void SetDate(float date)
Sets m_ClimateSystem.currentDate.overrideValue to the provided date (enables override value without toggling overrideState directly here — the overrideState usage is handled elsewhere). -
private void ResetDate()
Disables the currentDate override by setting m_ClimateSystem.currentDate.overrideState = false. -
private void SetCloudiness(float cloudiness)
Sets m_ClimateSystem.cloudiness.overrideValue to the provided cloudiness (similarly manages the override value). -
private void ResetCloudiness()
Disables cloudiness override by setting m_ClimateSystem.cloudiness.overrideState = false.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
m_ClimateSystem = base.World.GetOrCreateSystemManaged<ClimateSystem>();
m_PlanetarySystem = base.World.GetOrCreateSystemManaged<PlanetarySystem>();
AddUpdateBinding(new GetterValueBinding<float>(kGroup, "timeOfDay", () => m_NormalizedTimeBindingValue));
AddUpdateBinding(new GetterValueBinding<float>(kGroup, "date", () => m_NormalizedDateBindingValue));
AddUpdateBinding(new GetterValueBinding<float>(kGroup, "cloudiness", () => m_ClimateSystem.cloudiness));
AddBinding(new TriggerBinding<float>(kGroup, "setTimeOfDay", SetTimeOfDay));
AddBinding(new TriggerBinding(kGroup, "resetTimeOfDay", ResetTimeOfDay));
AddBinding(new TriggerBinding<float>(kGroup, "setDate", SetDate));
AddBinding(new TriggerBinding(kGroup, "resetDate", ResetDate));
AddBinding(new TriggerBinding<float>(kGroup, "setCloudiness", SetCloudiness));
AddBinding(new TriggerBinding(kGroup, "resetCloudiness", ResetCloudiness));
}
Additional notes: - The system uses snapping (0.01) before updating UI to reduce update churn in bindings. - Reset methods ensure that any manual overrides applied via the UI are cleared when appropriate (either via UI reset actions or when the system stops running). - When modding, ensure you access the same binding keys ("editorBottomBar" group and the exact binding names) if you want to interact with or extend the same UI elements.