Skip to content

Game.InfoSectionBase

Assembly: Game
Namespace: Game.UI.InGame

Type: abstract class

Base: UISystemBase, ISectionSource, IJsonWritable

Summary:
Base class for in-game information UI sections. Manages lifecycle and visibility of a section (including rules for destroyed objects, outside connections, under construction, and upgrades), maintains "dirty" state and tooltip lists, integrates with core systems (NameSystem, PrefabSystem, EndFrameBarrier, SelectedInfoUISystem), and provides JSON serialization support for active sections. Derived types must implement reset/processing and property writing logic.


Fields

  • protected bool m_Dirty
    Marks the section as needing an update. Set by RequestUpdate() and checked during PerformUpdate().

  • protected NameSystem m_NameSystem
    Cached reference to the NameSystem obtained on creation.

  • protected PrefabSystem m_PrefabSystem
    Cached reference to the PrefabSystem obtained on creation.

  • protected EndFrameBarrier m_EndFrameBarrier
    Cached reference to the EndFrameBarrier system obtained on creation.

  • protected SelectedInfoUISystem m_InfoUISystem
    Cached reference to the SelectedInfoUISystem that provides selected entity/prefab info.

Properties

  • public override GameMode gameMode => GameMode.Game
    Indicates this UI system is for the main game mode.

  • public bool visible { get; protected set; }
    Whether the section is enabled to be shown; derived classes can set visibility.

  • protected virtual bool displayForDestroyedObjects => false
    Whether to display the section for destroyed entities. Can be overridden.

  • protected virtual bool displayForOutsideConnections => false
    Whether to display the section for outside connection entities. Can be overridden.

  • protected virtual bool displayForUnderConstruction => false
    Whether to display the section for entities under construction. Can be overridden.

  • protected virtual bool displayForUpgrades => false
    Whether to display the section for entities which are being upgraded. Can be overridden.

  • protected abstract string group { get; }
    Abstract property that derived classes must provide to identify the section group (written to JSON).

  • protected List<string> tooltipKeys { get; set; }
    List of tooltip key strings collected during update; initialized in OnCreate.

  • protected List<string> tooltipTags { get; set; }
    List of tooltip tags collected during update; initialized in OnCreate.

  • protected virtual Entity selectedEntity => m_InfoUISystem.selectedEntity
    The currently selected entity provided by SelectedInfoUISystem; can be overridden.

  • protected virtual Entity selectedPrefab => m_InfoUISystem.selectedPrefab
    The currently selected prefab provided by SelectedInfoUISystem; can be overridden.

  • protected bool Destroyed => base.EntityManager.HasComponent<Destroyed>(selectedEntity)
    True if the selected entity has a Destroyed component.

  • protected bool OutsideConnection => base.EntityManager.HasComponent<Game.Objects.OutsideConnection>(selectedEntity)
    True if the selected entity is an outside connection.

  • protected bool UnderConstruction
    True if the selected entity has an UnderConstruction component and its m_NewPrefab equals Entity.Null (implementation checks component.m_NewPrefab).

  • protected bool Upgrade => base.EntityManager.HasComponent<ServiceUpgradeData>(selectedPrefab)
    True if the selected prefab has a ServiceUpgradeData component (indicates an upgrade target).

Constructors

  • protected InfoSectionBase()
    Default protected constructor (no extra logic beyond base).

Methods

  • [Preserve] protected override void OnCreate()
    Initializes internal lists and caches system references:
  • Creates tooltipKeys and tooltipTags lists.
  • Retrieves NameSystem, PrefabSystem, EndFrameBarrier, and SelectedInfoUISystem from the World.

  • protected abstract void Reset()
    Derived classes must reset their internal state before an update cycle.

  • protected abstract void OnProcess()
    Derived classes must implement processing logic executed when the section is visible during PerformUpdate().

  • public abstract void OnWriteProperties(IJsonWriter writer)
    Derived classes must serialize section-specific properties into the provided IJsonWriter.

  • public void RequestUpdate()
    Marks the section dirty (m_Dirty = true) causing it to be updated on the next PerformUpdate().

  • private bool Visible()
    Determines whether the section should be processed/written based on visible flag and the various display* rules (Destroyed, OutsideConnection, UnderConstruction, Upgrade). Returns true if allowed.

  • protected virtual void OnPreUpdate()
    Hook for derived classes to run code just before an update begins. Default implementation does nothing.

  • public void PerformUpdate()
    Main update entry called by the UI system:

  • Calls OnPreUpdate().
  • If m_Dirty is set:

    • Clears m_Dirty and tooltip lists.
    • Calls Reset().
    • Calls Update() (inherited from base/system framework).
    • If Visible() returns true, calls OnProcess() to populate UI/tooltip data.
  • public void Write(IJsonWriter writer)
    Writes section data to JSON if Visible(). Format produced:

  • TypeBegin(full type name)
  • property "group" -> group
  • property "tooltipKeys" -> array of tooltipKeys
  • property "tooltipTags" -> array of tooltipTags
  • calls OnWriteProperties(writer)
  • TypeEnd() If not visible, writes a JSON null.

  • protected bool TryGetComponentWithUpgrades<T>(Entity entity, Entity prefab, out T data) where T : unmanaged, IComponentData, ICombineData<T>
    Helper that attempts to obtain a combined component (including upgrade logic) for an entity/prefab via UpgradeUtils.TryGetCombinedComponent.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    tooltipKeys = new List<string>();
    tooltipTags = new List<string>();
    m_NameSystem = base.World.GetOrCreateSystemManaged<NameSystem>();
    m_PrefabSystem = base.World.GetOrCreateSystemManaged<PrefabSystem>();
    m_EndFrameBarrier = base.World.GetOrCreateSystemManaged<EndFrameBarrier>();
    m_InfoUISystem = base.World.GetOrCreateSystemManaged<SelectedInfoUISystem>();
}