Skip to content

Game.UI.InGame.SelectedInfoUISystem

Assembly:
Namespace: Game.UI.InGame

Type: public class

Base: UISystemBase

Summary:
SelectedInfoUISystem is the in-game UI system responsible for managing the "selected info" panel: tracking the currently selected entity/prefab/route, calculating and exposing the selected world position, maintaining UI bindings for sections (top/middle/bottom/title/developer/tooltip/etc.), and handling camera follow behavior for selected entities. It collects and updates multiple ISectionSource subsections, coordinates binding updates to the UI, and provides helpers to obtain a display position for many kinds of entity targets (interpolated transforms, relatives, nodes, curves, routes, labels, etc.). It also integrates with ToolSystem, PrefabSystem and CameraUpdateSystem to react to tools, prefabs and camera changes.


Fields

  • private const string kGroup = "selectedInfo"
    Name of the JSON/UI binding group used by this system.

  • public static OrbitCameraController s_CameraController
    Static reference to the orbit camera controller used for following selected entities (set on game load).

  • private float3 m_SelectedPosition
    Current world position (float3) of the selected entity used for UI placement.

  • private Entity m_SelectedEntity
    The currently selected entity (Entity.Null when none).

  • private Entity m_SelectedPrefab
    Prefab entity reference corresponding to the selected entity (Entity.Null when none).

  • private Entity m_SelectedRoute
    Optional currently selected route entity (updated via binding and setter).

  • private Entity m_LastSelectedEntity
    Previously selected entity, tracked to detect selection changes.

  • private EntityQuery m_TransportConfigQuery
    EntityQuery used to obtain the transport UI configuration singleton prefab.

  • private List<ISectionSource> m_TopSections
    List of top-section sources included in the selected info panel.

  • private List<ISectionSource> m_MiddleSections
    List of middle-section sources included in the selected info panel.

  • private List<ISectionSource> m_BottomSections
    List of bottom-section sources included in the selected info panel.

  • private TitleSection m_TitleSection
    Title section system instance responsible for the ID/title of the selected item.

  • private DeveloperSection m_DeveloperSection
    Developer/debug info section instance.

  • private LineVisualizerSection m_LineVisualizerSection
    Line visualizer section instance (used for transport lines and similar).

  • private HouseholdSidebarSection m_HouseholdSidebarSection
    Household sidebar section instance (household-related UI).

  • private DebugUISystem m_DebugUISystem
    Reference to the DebugUISystem (used to check whether developer info should be shown).

  • private ToolSystem m_ToolSystem
    Reference to ToolSystem (used to get current selection, selectedIndex, and infomode changes).

  • private PrefabSystem m_PrefabSystem
    Reference to PrefabSystem used for retrieving prefab data and singletons.

  • private CameraUpdateSystem m_CameraUpdateSystem
    Reference to CameraUpdateSystem used when starting/stopping camera follow.

  • private ValueBinding<Entity> m_SelectedEntityBinding
    UI binding for the selected entity value exposed to the UI.

  • private ValueBinding<Entity> m_SelectedTrailerControllerBinding
    UI binding used to expose a trailer controller or related entity for the selection.

  • private ValueBinding<string> m_SelectedUITagBinding
    UI binding exposing the selected prefab's UI tag string.

  • private GetterValueBinding<Entity> m_SelectedRouteBinding
    Getter binding that returns the currently set selectedRoute field.

  • private ValueBinding<bool> m_ActiveSelectionBinding
    UI binding that indicates whether there is an active selection.

  • private RawValueBinding m_TopSectionsBinding
    Raw binding that serializes the top sections for the UI.

  • private RawValueBinding m_MiddleSectionsBinding
    Raw binding that serializes the middle sections for the UI.

  • private RawValueBinding m_BottomSectionsBinding
    Raw binding that serializes the bottom sections for the UI.

  • private RawValueBinding m_IDSectionBinding
    Raw binding that writes the title/ID section to the UI.

  • private RawValueBinding m_LineVisualizerSectionBinding
    Raw binding that writes the line visualizer section.

  • private RawValueBinding m_DeveloperSectionBinding
    Raw binding that conditionally writes the developer section (or null).

  • private RawValueBinding m_HouseholdSidebarSectionBinding
    Raw binding that writes the household sidebar section.

  • private ValueBinding<float2> m_PositionBinding
    UI binding that exposes the selected world position converted to viewport coordinates.

  • private RawValueBinding m_TooltipTagsBinding
    Raw binding that writes tooltip tag strings for the selection.

  • private bool m_BindingsDirty
    Flag indicating that bindings need to be re-pushed to the UI.

  • private UIUpdateState m_UpdateState
    Internal update state used to trigger periodic UI refreshes even if entity components did not change.

Properties

  • public override GameMode gameMode => GameMode.Game
    Indicates this system runs in Game mode (not Editor mode).

  • public float3 selectedPosition => m_SelectedPosition
    Public getter for the currently computed selected world position.

  • public Entity selectedEntity => m_SelectedEntity
    Public getter for the currently selected entity.

  • public Entity selectedPrefab => m_SelectedPrefab
    Public getter for the prefab entity associated with the selection.

  • public Entity selectedRoute
    get: returns m_SelectedRoute
    set: sets m_SelectedRoute and updates the selected route binding
    Binding-backed property for the selected route entity used by some UI sections.

  • public Action<Entity, Entity, float3> eventSelectionChanged { get; set; }
    Event invoked when the selection changes. Parameters: (newSelectedEntity, selectedPrefab, selectedPosition).

  • public List<TooltipTags> tooltipTags { get; set; }
    List of tooltip tag enums/strings collected by sections for the current selection.

Constructors

  • public SelectedInfoUISystem()
    Default constructor. The class also has [Preserve] attributes on lifecycle methods and the constructor for IL2CPP/linker preservation.

Methods

  • protected override void OnCreate()
    Initializes the system, creates and registers section sources, sets up bindings (value/getter/raw/trigger bindings), acquires references to DebugUISystem, ToolSystem, PrefabSystem and CameraUpdateSystem, prepares the update state and hooks the tool-changed event. This is where the top/middle/bottom sections and title/line/household/developer sections are added.

  • private void OnToolChanged(ToolBaseSystem obj)
    Callback for tool changes — forces a UI update state refresh.

  • protected override void OnDestroy()
    Removes camera follow callback if present and performs base cleanup.

  • public void AddTopSection(ISectionSource section)
    Adds a section to the top section list.

  • public void AddMiddleSection(ISectionSource section)
    Adds a section to the middle section list.

  • public void AddBottomSection(ISectionSource section)
    Adds a section to the bottom section list.

  • public void AddDeveloperInfo(ISubsectionSource subsection)
    Adds a developer subsection into the DeveloperSection instance.

  • private void AddSections(List<ISectionSource> topSections, List<ISectionSource> sections, List<ISectionSource> bottomSections)
    Internal helper that resolves and adds many built-in section systems (notifications, status, description, residents, vehicles, services, actions, etc.) to the provided lists. Called during OnCreate.

  • protected override void OnGameLoaded(Context serializationContext)
    Called when the game finishes loading. Acquires the orbit camera controller from CameraUpdateSystem and sets camera mode and follow callback depending on current mode (Game vs Editor).

  • private void OnCameraStoppedFollowing()
    Callback invoked when the orbit camera stops following an entity; it calls StopFollowing().

  • private void StartFollowing(Entity entity)
    Sets the orbit camera to follow the provided entity (if it exists and is not already followed) and switches the active camera controller.

  • private void StopFollowing()
    Stops orbit camera following and restores the gameplay camera controller as active.

  • public void RequestUpdate()
    Forces the internal UI update state to refresh on the next OnUpdate.

  • public void SetDirty()
    Marks bindings dirty so the UI will be re-serialized next update.

  • protected override void OnUpdate()
    Main update loop that refreshes selection, updates bindings (selected entity, trailer controller, UI tag, active selection), handles selection-changed events, marks bindings dirty based on changes or update state, updates the various sections and the selection screen position.

  • private void RefreshSelection()
    Retrieves the current selection from ToolSystem, resolves prefab via PrefabRef, filters selection (icons, residents, pets, etc.), and computes the selected position/bounds using TryGetPosition. Sets m_SelectedEntity, m_SelectedPrefab and m_SelectedPosition accordingly, or clears them.

  • private bool TryGetSelection(out Entity entity)
    Reads the selected entity from ToolSystem; returns whether there is a selection.

  • private void FilterSelection(ref Entity entity, ref Entity prefab)
    Performs selection filtering and normalization — e.g., if the clicked entity is an icon it finds the owner, if the entity is a resident/pet it selects the underlying citizen/pet prefab, and updates the selection in the ToolSystem.

  • public void SetSelection(Entity entity)
    Programmatically sets the selection via ToolSystem (if different from current selected entity).

  • public void SetRoutesVisible()
    Enables the transport routes infomode if a transport config exists and that infomode isn't already active.

  • private void ResetRouteVisibility()
    Disables the routes infomode when selection changes away.

  • private bool TryGetTransportConfig(out UITransportConfigurationPrefab config)
    Attempts to read a singleton UI transport configuration prefab via m_TransportConfigQuery and PrefabSystem.

  • private void SetBindingsDirty()
    Requests updates on all section sources and sets the m_BindingsDirty flag so that raw bindings will be re-serialized to the UI.

  • private void UpdateSections()
    If there is a selection, clears tooltipTags, performs update on title, household sidebar, line visualizer and all registered sections, conditionally updates developer section, and if bindings are dirty triggers UpdateSectionBindings.

  • private void UpdateSectionBindings()
    Pushes the raw/value bindings for tooltip tags, title, developer, top/middle/bottom sections and household sidebar.

  • private void UpdatePosition()
    Converts selectedPosition (world) to viewport position using Camera.main.WorldToViewportPoint and updates the m_PositionBinding.

  • private void OnClearSelection()
    Clears the current selection (sets selection to Entity.Null).

  • private void OnSelect(Entity entity)
    Trigger binding handler invoked by UI to select an entity. If the entity exists and is not a TrafficAccident, it sets selection; otherwise it starts following (for certain event entities).

  • private void OnSetSelectedRoute(Entity entity)
    Trigger binding handler that sets the selectedRoute property.

  • public void Focus(Entity entity)
    Public API to start or stop camera following of the provided entity. Null stops following.

  • public static bool TryGetPosition(Entity entity, EntityManager entityManager, ref int elementIndex, out Entity location, out float3 position, out Bounds3 bounds, out quaternion rotation, bool reinterpolate = false)
    General-purpose helper that resolves a display location and computes a transform/position for a wide variety of entity types: interpolated transform frames, Relative, object transform, route waypoints, label aggregates, geometry, icon positions, net nodes, curves. Returns true if a position could be determined.

  • private static Game.Objects.Transform GetInterpolatedPosition(Entity entity, EntityManager entityManager, DynamicBuffer<TransformFrame> transformFrames, bool reinterpolate, out Bounds3 bounds)
    Calculates an interpolated transform for animated objects either via stored InterpolatedTransform (if near camera and not reinterpolating) or by computing between TransformFrame entries and then returns object position/bounds.

  • private static Game.Objects.Transform GetRelativePosition(Entity entity, EntityManager entityManager, Relative relative, bool reinterpolate, out Bounds3 bounds)
    Computes world transform for entities that have a Relative component (local-to-owner transform) by resolving the owner interpolated/object transform then converting local to world.

  • private static bool IsNearCamera(Entity entity, EntityManager entityManager)
    Checks pre-culling data to determine if an entity is flagged as NearCamera (optimizes whether to use existing interpolated transform).

  • private static Game.Objects.Transform GetObjectPosition(Entity entity, EntityManager entityManager, Game.Objects.Transform transform, out Bounds3 bounds)
    Computes bounds for a transform using prefab geometry data if available, returns the given transform.

  • private static float3 GetNodePosition(Entity entity, EntityManager entityManager, Game.Net.Node node, out Bounds3 bounds, out quaternion rotation)
    Gets node position and rotation; accounts for default surface height override when NetGeometryData exists on the prefab.

  • private static float3 GetCurvePosition(Entity entity, EntityManager entityManager, Curve curve, out Bounds3 bounds, out quaternion rotation)
    Gets a mid-curve position and tangent-based rotation for curves and optionally adjusts bounds by NetGeometryData.

  • private static float3 GetRoutePosition(EntityManager entityManager, DynamicBuffer<RouteWaypoint> routeWaypoints)
    Chooses the waypoint position in a route that is closest to camera pivot (used to place route labels/selection near camera).

  • private static float3 GetAggregatePosition(DynamicBuffer<LabelPosition> labelPositions, ref int selectedIndex)
    Chooses a label position for aggregated labels (like multiple sub-elements) preferring the currently selected element index or the closest label to camera and updating the element index.

  • private static void FilterPositionTarget(ref Entity entity, EntityManager entityManager)
    Normalizes the location target used by TryGetPosition by unwrapping TargetElement buffers, CurrentTransport, Unspawned proxies, lane/current-lane types, current building/property/hotel/houshold redirections, etc. Many game-specific cases are handled so UI can find a visible object for selection.

  • private static void FilterPositionTarget(out Entity entity, Entity location, EntityManager entityManager)
    Overload used to find the underlying Game.Objects.Object or outside connection sub-object for a given location, walking Owner chain and subobjects to find an appropriate display entity.

  • private void WriteDeveloperSection(IJsonWriter binder)
    Writes the developer section contents only if developer info is visible, otherwise writes null.

  • private void WriteSections(List<ISectionSource> list, IJsonWriter binder)
    Serializes an array of ISectionSource entries to the provided IJsonWriter.

  • private void WriteTooltipFlags(IJsonWriter writer)
    Serializes the tooltipTags list of enums/strings into a JSON array for the UI.

Usage Example

// Example: set selection and focus camera on an entity (e.g. from another system or mod)
var selectedInfo = World.GetOrCreateSystemManaged<Game.UI.InGame.SelectedInfoUISystem>();
Entity someEntity = /* obtain entity */;
selectedInfo.SetSelection(someEntity);
selectedInfo.Focus(someEntity);

// Force the UI to refresh for the current selection
selectedInfo.RequestUpdate();

If you want a specific section or method documented in more detail (parameters, return values, example inputs/outputs), tell me which one and I will expand it.