Game.UI.InGame.ActionsSection
Assembly: Assembly-CSharp (game/client assembly)
Namespace: Game.UI.InGame
Type: class
Base: InfoSectionBase
Summary:
ActionsSection implements the "Actions" area of the in-game selected-info UI. It inspects the currently selected prefab/entity and exposes/updates UI bindings and triggers for common actions such as focus, follow, move, delete, toggle policies (including out-of-service and emptying), editing lots, and toggling traffic route visibility. The section hooks into many core systems (tool systems, policy UI, traffic routes, audio, life path / follow, prefab/policy lookup and initialization) to implement the behavior for those actions and to update UI state (value bindings and raw bindings) each frame.
Fields
-
private ToolSystem m_ToolSystem
Reference to the global ToolSystem used to change and query active tools. -
private AreaToolSystem m_AreaToolSystem
Reference to the area/lot editing tool system used for editing lots. -
private DefaultToolSystem m_DefaultToolSystem
Reference to the default tool system to return to when disabling other tools. -
private ObjectToolSystem m_ObjectToolSystem
Reference to the object tool system used for moving objects. -
private UIInitializeSystem m_UIInitializeSystem
Used to access initial UI configuration data such as available policies. -
private PoliciesUISystem m_PoliciesUISystem
Used to open/set policy UI on a selected entity. -
private LifePathEventSystem m_LifePathEventSystem
Used for following/unfollowing citizens (life path functionality). -
private GamePanelUISystem m_GamePanelUISystem
Used to open game panels (e.g., LifePathPanel) when following. -
private TrafficRoutesSystem m_TrafficRoutesSystem
Used to toggle route visibility and query route visibility state. -
private AudioManager m_AudioManager
Used to play UI sounds (e.g., bulldoze/delete). -
private EntityQuery m_SoundQuery
EntityQuery to access ToolUXSoundSettingsData singleton for UI sound ids. -
private EntityQuery m_RouteConfigQuery
EntityQuery to access RouteConfigurationData singleton for route visualization prefabs. -
private PolicyPrefab m_RouteOutOfServicePolicy
Cached PolicyPrefab reference for "Route Out of Service" policy (filled on game load). -
private PolicyPrefab m_BuildingOutOfServicePolicy
Cached PolicyPrefab reference for building out-of-service policy. -
private PolicyPrefab m_EmptyingPolicy
Cached PolicyPrefab reference for emptying policy. -
private AreaPrefab m_LotPrefab
If the selected prefab is part of an area/lot, this holds the corresponding AreaPrefab (used to enable lot editing). -
private bool m_EditingLot
Internal flag tracking whether lot editing is active for this section. -
private Color32[] m_TrafficRouteColors
Cached colors for traffic route visualizations (initialized from route config). -
private ValueBinding<bool> m_MovingBinding
UI binding that exposes whether the object move tool is active. -
private ValueBinding<bool> m_EditingLotBinding
UI binding that exposes whether the lot editing tool is active. -
private ValueBinding<bool> m_TrafficRoutesVisibleBinding
UI binding exposing whether traffic route visualization is currently visible. -
private ValueBinding<Color32[]> m_TrafficRouteColorsBinding
UI binding exposing the colors used for traffic route visualization. -
private RawValueBinding m_MoveableObjectName
Raw binding used to write the name of the object being moved (when object move tool is active).
Properties
-
protected override string group => "ActionsSection"
UI binding group identifier used for all bindings created by this section. -
public bool editingLot => m_EditingLot
Public read-only accessor exposing whether the lot editing mode is currently enabled for this section. -
protected override bool displayForDestroyedObjects => true
Indicates the section should be displayed for destroyed objects. -
protected override bool displayForOutsideConnections => true
Indicates the section should be displayed for outside connections. -
protected override bool displayForUnderConstruction => true
Indicates the section should be displayed for under-construction entities. -
protected override bool displayForUpgrades => true
Indicates the section should be displayed for upgrade entities. -
private bool focusable { get; set; }
Internal state used to drive the "focus" UI control. -
private bool focusing { get; set; }
Internal state indicating whether the selected entity is currently being focused. -
private bool following { get; set; }
Internal state used for UI follow button. -
private bool followable { get; set; }
Whether current selection can be followed (e.g., citizen). -
private bool moveable { get; set; }
Whether the current selection can be moved. -
private bool deletable { get; set; }
Whether the current selection can be deleted. -
private bool disabled { get; set; }
Whether the current selection is in a disabled/inactive state. -
private bool disableable { get; set; }
Whether the current selection supports toggling disabled/inactive state. -
private bool hasTutorial { get; set; }
Reserved/internal flag for tutorial availability (not used extensively in this class). -
private bool emptying { get; set; }
Whether the current building is currently in the "emptying" state. -
private bool emptiable { get; set; }
Whether the current selection can be set to emptying (e.g., garbage facility long term storage). -
private bool hasLotTool { get; set; }
Whether a lot editing tool is available for the current selection. -
private bool hasTrafficRoutes { get; set; }
Whether traffic routes are relevant for the current selection.
Constructors
public ActionsSection()
Default constructor. Typical initialization is done in OnCreate; the constructor itself does no special work beyond instantiation.
Methods
-
protected override void Reset()
Resets all temporary per-selection boolean flags and clears the cached lot prefab. Called by the base InfoSection lifecycle to clear state before processing a new selection. -
[Preserve] protected override void OnCreate()
Initializes references to many game systems via World.GetOrCreateSystemManaged<...>(), prepares entity queries, registers event handlers and creates UI bindings/triggers: - Hooks ToolSystem.EventToolChanged to OnToolChanged.
- Adds trigger bindings: "focus", "toggleMove", "follow", "delete", "toggle", "toggleEmptying", "toggleLotTool", "toggleTrafficRoutes".
-
Adds value/raw bindings: moving, editingLot, moveableObjectName, trafficRouteColors, trafficRoutesVisible. This method is where the section wires itself into the UI binding system and the game's systems.
-
private void OnToggleTrafficRoutes()
Toggles m_TrafficRoutesSystem.routesVisible and marks the info UI dirty so the UI updates. -
private void BindObjectName(IJsonWriter binder)
Raw binder callback used to supply the name of the object currently being moved. Writes the selected entity's name when the ObjectToolSystem is active and in Move mode; otherwise writes null. -
private void OnToolChanged(ToolBaseSystem tool)
Tool-change event handler. Updates internal flags and UI bindings when the active tool changes. Ensures editingLot is cleared if the tool is not the AreaToolSystem, updates moving and editingLot bindings and updates the moveable object name binding. -
private void OnToggleLotTool()
Toggles lot-editing mode: if already editing, switches back to default tool; if not editing and a lot prefab is available, sets the area tool's prefab, marks editing mode, and activates the area tool. -
protected override void OnGameLoaded(Context serializationContext)
During game load it iterates UI-initialized policy prefabs to locate and cache policy prefabs for "Route Out of Service", "Out of Service" (building), and "Empty". These prefabs are used when toggling policies from this section. -
private void OnToggle()
Handles the "toggle" trigger (used for toggling out-of-service policies). Chooses which policy to toggle depending on selection type: route out-of-service for routes/transport lines, building out-of-service for buildings and service upgrades. -
private void OnToggleEmptying()
Sets the Emptying policy on the selected info (uses cached m_EmptyingPolicy). -
private void OnDelete()
Requests the selected entity to be deleted: plays the appropriate UI sound (bulldoze for buildings, delete-entity otherwise) and adds a Deleted component to the entity via the EndFrameBarrier's command buffer. -
private void OnFocus()
Toggles camera focus on the selected entity. If not currently focusing, focus is set to the selected entity; if already focusing, focus is cleared (Entity.Null). -
private void OnToggleMove()
Starts or stops object move mode: if the selection is moveable and the object tool is already active it resets to default tool; otherwise it tells the ObjectToolSystem to start moving the selected entity and activates the object tool. -
private void OnFollow()
Handles following/unfollowing of citizens. If currently not followed, instructs LifePathEventSystem to follow the citizen and opens the LifePathPanel; if already followed, unfollows the citizen. Marks the info UI as dirty afterwards so UI updates. -
[Preserve] protected override void OnUpdate()
Called each frame update by the InfoSection lifecycle. Sets the section's visible flag based on whether a valid selectedEntity exists (visible only if an entity is selected). -
protected override void OnProcess()
Main per-selection processing method. Inspects the selected entity and its prefab to compute and set all of the internal boolean flags used by the UI (focusable, focusing, moveable, followable, deletable, disabled, disableable, emptying, emptiable, hasLotTool, hasTrafficRoutes). Also detects lot prefabs from areas or attached parent areas, initializes route visualization colors once (from RouteConfigurationData), and updates traffic route visibility binding. This method contains the bulk of the selection-dependent logic used to enable/disable UI controls. -
public override void OnWriteProperties(IJsonWriter writer)
Writes the computed boolean states and other flags into the JSON writer for the UI layer (exposed properties such as focusable, moveable, deletable, disabled, hasLotTool, hasTrafficRoutes, etc.). Called by the UI binding system when serializing the section state to the UI.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Typical initialization done by ActionsSection: grab required systems and add bindings.
// Example: cache the tool system and ensure tool-change handler is registered
m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
// The class already adds trigger/value bindings and registers OnToolChanged in its OnCreate.
}