Skip to content

Game.ClimatePanelSystem

Assembly: Game
Namespace: Game.UI.Editor

Type: class

Base: EditorPanelSystemBase

Summary:
ClimatePanelSystem is an editor UI system that implements the climate editor panel used by the in-game editor. It ties together Prefab, Climate, WindSimulation, Planetary and Tool systems to present and edit ClimatePrefab data (seasons, temperature/precipitation/other curves, latitude/longitude, etc.). It also manages the inspector UI generation, handles built-in vs custom prefab editing (duplication), and temporarily activates a wind infoview when the user manipulates wind direction in the editor.


Fields

  • private PrefabSystem m_PrefabSystem
    Handles access to game prefabs. Used to query and add ClimatePrefab and InfoviewPrefab instances.

  • private ClimateSystem m_ClimateSystem
    Reference to the ClimateSystem that stores the currently-active climate entity and climate simulation state.

  • private WindSimulationSystem m_WindSimulationSystem
    Provides wind simulation access (constant wind vector and methods to set wind).

  • private PlanetarySystem m_PlanetarySystem
    Used to set planetary parameters such as latitude and longitude based on the edited climate prefab.

  • private EntityQuery m_ClimateQuery
    (Declared but not populated in this class) Intended for queries related to climate entities if needed.

  • private EntityQuery m_ClimateSeasonQuery
    (Declared but not populated here) Intended for season-related entity queries.

  • private EntityQuery m_UpdatedQuery
    (Declared but not populated here) Intended for queries of updated entities.

  • private SeasonsField.SeasonCurves m_SeasonsCurves
    Local cache of season curve arrays (temperature, precipitation, cloudiness, aurora, fog) that drive the seasons UI and editing.

  • private EntityQuery m_RenderQuery
    (Declared but not populated here) Presumably for render/visualization-related entities.

  • private ToolSystem m_ToolSystem
    Reference to ToolSystem used to switch infoviews/infomodes when previewing wind direction.

  • private InfoviewPrefab m_WindInfoview
    Cached InfoviewPrefab used to temporarily display wind information (the class looks up the "AirPollution" infoview and uses it to show wind direction).

  • private double m_LastWindDirection
    Tracks the last wind direction value (used to detect changes).

  • private int m_LastClimateHash
    Cached hash of the currently loaded climate to detect changes.

  • private int m_InfoviewCooldown
    Cooldown counter used to control infoview toggling (internal UI handling detail).

  • private EditorSection m_InspectorSection
    Top-level inspector section used to place generated inspector widgets for the selected climate prefab.

  • private EditorGenerator m_Generator
    Helper used to generate inspector widgets for a prefab's serialized members.

  • private Coroutine m_DelayedInfomodeReset
    Coroutine handle used to delay reset of the previously active infoview after showing wind preview.

  • private InfoviewPrefab m_PreviousInfoview
    Cached previous infoview to restore after wind preview completes.

  • private EntityQuery m_AllInfoviewQuery
    EntityQuery that finds all prefabs with InfoviewData; used to locate the wind infoview prefab.

  • private TypeHandle __TypeHandle
    Internal compiler-generated struct used to store ComponentTypeHandles for efficient archetype chunk reading in GetWindInfoView. See nested TypeHandle.

  • private struct TypeHandle
    Contains a ComponentTypeHandle and method __AssignHandles to fill it from a SystemState. Used by compiler-generated OnCreateForCompiler / GetWindInfoView to read PrefabData arrays.

Properties

  • private ClimatePrefab currentClimate { get; set; }
    Private property that resolves the ClimatePrefab for m_ClimateSystem.currentClimate (returns null if the entity does not exist). Setting this property writes the climate entity into m_ClimateSystem.currentClimate and triggers RebuildInspector().

  • private double windDirection { get; set; }
    Private property for reading and setting the editor wind direction. The getter computes the compass degrees from WindSimulationSystem.constantWind. The setter converts degrees to a direction vector, calls WindSimulationSystem.SetWind, switches the tool infoview to the wind infoview and activates the corresponding infomode, and starts a coroutine to restore the previous infoview after a short delay.

  • IEnumerable<ClimateSystem.SeasonInfo> SeasonsField.IAdapter.seasons { get; set; }
    Explicit interface implementation for SeasonsField.IAdapter. Gets/sets the currentClimate.m_Seasons array (converting to/from IEnumerable for the UI adapter). Used by the seasons UI widget to read/write season entries.

  • SeasonsField.SeasonCurves SeasonsField.IAdapter.curves { get; set; }
    Explicit interface implementation used by the seasons UI to get/set the cached season curves (temperature, precipitation, cloudiness, aurora, fog).

  • public Entity selectedSeason { get; set; }
    Public property exposing the currently selected season entity in the editor (used by external UI logic to track the selection).

Constructors

  • public ClimatePanelSystem()
    Parameterless constructor. Marked with [Preserve] in the source to avoid stripping. Typical ECS managed-system constructor — initialization of fields happens in OnCreate.

Methods

  • protected override void OnCreate()
    Initializes the editor system: resolves managed systems (PrefabSystem, ClimateSystem, ToolSystem, WindSimulationSystem, PlanetarySystem), constructs the AllInfoview query, locates the wind infoview prefab via GetWindInfoView(), sets the panel title, creates an EditorGenerator and builds the top-level inspector UI structure (a scrollable EditorSection). Called by the ECS lifecycle when the system is created.

  • protected override void OnValueChanged(IWidget widget)
    Called when a widget value changes. If the currently selected climate is not builtin, it rebuilds the prefab's curves (climatePrefab.RebuildCurves()) and pushes latitude/longitude values into PlanetarySystem.

  • protected override void OnGameLoaded(Context serializationContext)
    Handles map load/new map events; if the context purpose is LoadMap or NewMap, RebuildInspector() is called to refresh UI based on loaded data.

  • private void RebuildInspector()
    (Internal) Regenerates the inspector UI widgets for the currentClimate. Creates a prefab picker at the top, shows a prompt and "Create custom climate" button when the selected climate is builtin (which calls Duplicate), uses EditorGenerator to build member widgets for the climate prefab, and disables editing of builtin prefab fields.

  • private void Duplicate()
    Creates a clone of the currently selected climate prefab via PrefabBase.Clone(), registers it with PrefabSystem.AddPrefab, and sets it as the currentClimate so the inspector updates to the newly created custom prefab.

  • private IEnumerator DisableInfomode()
    Coroutine that waits for 1 second then restores the previously active infoview on ToolSystem and clears the delayed reset handle. Used to temporarily show the wind infoview, then revert back.

  • private void GetWindInfoView()
    Scans all prefabs with InfoviewData via m_AllInfoviewQuery, reads PrefabData from archetype chunks, and finds the InfoviewPrefab whose name is "AirPollution" (used as the wind infoview in the editor). Caches it into m_WindInfoview.

  • public void RebuildCurves()
    Public helper that invokes RebuildCurves() on the current climate prefab and then copies its arrays into m_SeasonsCurves fields (m_Temperature, m_Precipitation, m_Cloudiness, m_Aurora, m_Fog). Used to refresh the curve cache consumed by the seasons UI.

  • private void __AssignQueries(ref SystemState state)
    Compiler-generated stub for entity query assignment. Currently constructs and disposes an EntityQueryBuilder(Allocator.Temp) — no runtime queries assigned in this method for this class.

  • protected override void OnCreateForCompiler()
    Compiler-assisted OnCreate hook that calls __AssignQueries and populates the TypeHandle component type handles. Used by the IL2CPP/Entities compiler path.

  • [Preserve] public ClimatePanelSystem()
    The constructor is marked Preserve to avoid stripping; the constructor itself does not perform heavy initialization — OnCreate does.

Usage Example

// Example: minimal setup inside the system's OnCreate override.
// This mirrors what the system does to initialize its dependencies and the inspector.
[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_PrefabSystem = World.GetOrCreateSystemManaged<PrefabSystem>();
    m_ClimateSystem = World.GetOrCreateSystemManaged<ClimateSystem>();
    m_ToolSystem = World.GetOrCreateSystemManaged<ToolSystem>();
    m_WindSimulationSystem = World.GetOrCreateSystemManaged<WindSimulationSystem>();
    m_PlanetarySystem = World.GetOrCreateSystemManaged<PlanetarySystem>();

    // Find wind infoview and build initial inspector UI
    m_AllInfoviewQuery = GetEntityQuery(ComponentType.ReadOnly<PrefabData>(), ComponentType.ReadOnly<InfoviewData>());
    GetWindInfoView();
    title = "Editor.CLIMATE_SETTINGS";
    RebuildInspector();
}

Notes and tips: - Built-in climate prefabs are protected from in-place editing in the inspector; use the "Create custom climate" button (Duplicate) to produce a modifiable copy. - Wind previewing temporarily switches the active infoview and infomode; this is reverted automatically after a short delay. - RebuildCurves synchronizes the prefab curve arrays into the SeasonsField.SeasonCurves instance used by the seasons UI.