Skip to content

Game.UI.InGame.TitleSection

Assembly: Assembly-CSharp
Namespace: Game.UI.InGame

Type: class TitleSection

Base: InfoSectionBase

Summary:
UI info section used in the in-game HUD that displays and manages the "title" area for a selected entity (name, icon and rename actions). It retrieves an instance icon via the ImageSystem, exposes rename handling (binding a rename trigger), and provides localized virtual keyboard locale keys based on the selected entity type. The class is intended to be created and updated by the game's UI systems and interacts with NameSystem, ImageSystem, and the InfoUISystem.


Fields

  • private ImageSystem m_ImageSystem
    Used to fetch instance icons for the currently selected entity/prefab. Initialized in OnCreate using the ECS World to obtain or create the ImageSystem.

  • private string icon { get; set; }
    A private auto-property (annotated [CanBeNull]) that stores the icon identifier for the selected entity instance. It is cleared in Reset() and set during OnProcess().

Properties

  • protected override string group { get; }
    Returns the group identifier for this section. Constant value is "TitleSection". Used when creating bindings (e.g., rename trigger).

  • protected override bool displayForDestroyedObjects { get; }
    Overrides to true — the section is displayed even for destroyed objects.

  • protected override bool displayForOutsideConnections { get; }
    Overrides to true — the section is displayed for outside connection entities.

  • protected override bool displayForUnderConstruction { get; }
    Overrides to true — the section is displayed for entities under construction.

  • protected override bool displayForUpgrades { get; }
    Overrides to true — the section is displayed for upgrade-related entities.

  • [CanBeNull] private string icon { get; set; }
    (Repeated here as a property) Holds the cached icon string for writing out to the UI. Nullable.

Constructors

  • public TitleSection()
    Default parameterless constructor. Marked with [Preserve] attribute on lifecycle methods; construction itself is trivial and relies on OnCreate for initialization.

Methods

  • [Preserve] protected override void OnCreate()
    Initializes the section. Calls base.OnCreate(), obtains the ImageSystem from the World (GetOrCreateSystemManaged), and adds a rename trigger binding: AddBinding(new TriggerBinding(group, "renameEntity", OnRename))

  • protected override void Reset()
    Resets section state between uses. Clears the cached icon (sets icon = null).

  • private void OnRename(string newName)
    Handler invoked when the rename trigger is fired from the UI. Sets a custom name for the selected entity via the NameSystem and requests the UI system to update: m_NameSystem.SetCustomName(selectedEntity, newName); m_InfoUISystem.RequestUpdate();

  • [Preserve] protected override void OnUpdate()
    Called each frame/update. Sets this.visible = selectedEntity != Entity.Null so the section is visible only when there is a selected entity.

  • protected override void OnProcess()
    Per-process update where the instance icon for the selected entity/prefab is retrieved: icon = m_ImageSystem.GetInstanceIcon(selectedEntity, selectedPrefab);

  • public override void OnWriteProperties(IJsonWriter writer)
    Writes JSON properties consumed by the UI for this section:

  • "name" — binds name via m_NameSystem.BindName(writer, selectedEntity)
  • "vkName" — binds virtual keyboard name via m_NameSystem.BindNameForVirtualKeyboard(writer, selectedEntity)
  • "vkLocaleKey" — writes the locale key returned by GetVirtualKeyboardLocaleKey(EntityManager, selectedEntity)
  • "icon" — writes the cached icon string or null

  • public static string GetVirtualKeyboardLocaleKey(EntityManager entityManager, Entity entity)
    Returns a locale key string used to select the virtual keyboard name type based on entity components. Mapping implemented:

  • Building -> "BuildingName"
  • Tree -> "PlantName"
  • Citizen -> "CitizenName"
  • Vehicle -> "VehicleName"
  • Animal -> "AnimalName"
  • TransportLine -> "LineName"
  • Aggregate -> "RoadName"
  • District -> "DistrictName"
  • default -> "ObjectName"

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // get or create the ImageSystem used to fetch instance icons
    m_ImageSystem = base.World.GetOrCreateSystemManaged<ImageSystem>();

    // add a trigger binding so the UI can call "renameEntity" with a string
    AddBinding(new TriggerBinding<string>(group, "renameEntity", OnRename));
}