Game.UI.InGame.DummyHumanSection
Assembly: Game
Namespace: Game.UI.InGame
Type: class
Base: InfoSectionBase
Summary:
UI info section used by the in-game UI to display information about "dummy humans" — i.e., residents that do not have a corresponding Citizen entity. When the currently selected entity is a Resident whose m_Citizen == Entity.Null, this section becomes visible and exposes the origin (owner of the current vehicle, if any) and the vehicle destination as JSON properties. The section reads component data from the ECS EntityManager and uses the game's name system to bind readable names for entities.
Fields
-
private Entity originEntity { get; set; }
Stores the origin entity for the currently inspected dummy human (typically the Owner of the CurrentVehicle). When no origin is available this is Entity.Null. It is reset during Reset() and updated in OnProcess(). -
private Entity destinationEntity { get; set; }
Stores the destination entity for the currently inspected dummy human's vehicle. When no destination is available this is Entity.Null. It is reset during Reset() and updated in OnProcess().
Properties
protected override string group => "DummyHumanSection"
Identifier for the UI group this info section belongs to. InfoSectionBase uses this to categorize/locate the section in the UI system.
Constructors
[Preserve] public DummyHumanSection()
Default constructor. Marked with [Preserve] to avoid being stripped by code-stripping tooling. No custom initialization logic beyond base constructor behavior.
Methods
-
protected override void Reset()
Resets internal state by setting originEntity and destinationEntity to Entity.Null. Called by the base class lifecycle when the section should clear its stored data. -
private bool Visible()
Returns true when the section should be visible: checks if the currently selectedEntity has a Resident component and that resident's m_Citizen is Entity.Null (indicating a "dummy human"). Otherwise returns false. This is used by OnUpdate to set the visible flag. -
[Preserve] protected override void OnUpdate()
Lifecycle update method invoked by the UI system. Calls Visible() and assigns its result to base.visible so the UI shows or hides this section accordingly. Marked with [Preserve] to prevent stripping. -
protected override void OnProcess()
Called during processing to collect runtime data for display. If the selectedEntity has a CurrentVehicle component, this method: - obtains the vehicle entity from the CurrentVehicle component,
- reads the Owner component from that vehicle to determine the originEntity,
-
obtains the destinationEntity via VehicleUIUtils.GetDestination(EntityManager, vehicle). If no CurrentVehicle component is present, originEntity/destinationEntity remain unchanged or null (depending on Reset/previous state).
-
public override void OnWriteProperties(IJsonWriter writer)
Serializes the section's properties into JSON. Writes four properties: - "origin" — if originEntity != Entity.Null, m_NameSystem.BindName(writer, originEntity) is used to write a human-readable name; otherwise writes null.
- "originEntity" — writes the raw originEntity value or null.
- "destination" — if destinationEntity != Entity.Null, m_NameSystem.BindName(writer, destinationEntity) is used to write a human-readable name; otherwise writes null.
- "destinationEntity" — writes the raw destinationEntity value or null. This method allows the UI frontend or debugging tools to receive both display names and raw entity ids.
Notes: - The class makes use of the EntityManager and component types like Resident, CurrentVehicle, and Owner from the game's ECS. It assumes InfoSectionBase provides access to selectedEntity, base.EntityManager, base.visible, and m_NameSystem. - [Preserve] attributes are applied to methods/constructors that are invoked reflectively or by external systems to ensure they are not removed by build optimizers.
Usage Example
// The UI framework normally constructs and manages this section. Example of the kind of calls it performs:
[Preserve]
protected override void OnUpdate()
{
base.visible = Visible(); // as implemented in DummyHumanSection
}
// Example: forcing a properties write (normally called by UI/serialization pipeline)
var section = new DummyHumanSection();
// The section is tied to the InfoSectionBase lifecycle and relies on selectedEntity and EntityManager
// For demonstration, assume those are already set by the UI framework and OnProcess was called:
section.OnProcess();
using (var writer = new JsonStringWriter()) // hypothetical IJsonWriter implementation
{
section.OnWriteProperties(writer);
string json = writer.ToString();
// json will contain: origin, originEntity, destination, destinationEntity
}