Game.UI.InGame.CitizenSection
Assembly: (not specified in source)
Namespace: Game.UI.InGame
Type: class
Base: InfoSectionBase
Summary:
CitizenSection is a UI info section used in the in-game inspector / info panel to display details about a specific citizen entity. It queries and caches various citizen-related entities and keys (household, residence, workplace, school, education, age, wealth, etc.), requires the global CitizenHappinessParameterData for some calculations, decides whether it should be visible for the currently selected entity, and serializes the collected information into JSON via an IJsonWriter. It also resolves the current destination (transport target) for the citizen when present.
Fields
private Unity.Entities.EntityQuery m_HappinessParameterQuery
Holds an EntityQuery for reading the CitizenHappinessParameterData singleton. This query is created in OnCreate and required for update so the section has access to the happiness parameter data.
Properties
-
protected override string group => "CitizenSection"
Identifier string for the info section group used by the UI system. -
private CitizenKey citizenKey { get; set; }
Type of citizen (e.g., regular citizen, commuter, tourist). Determined from the household type in OnProcess. -
private CitizenStateKey stateKey { get; set; }
Key representing the citizen's current state (derived via CitizenUIUtils). -
private Unity.Entities.Entity householdEntity { get; set; }
Household entity for the citizen (Entity.Null if none). -
private Unity.Entities.Entity residenceEntity { get; set; }
Residence building/entity for the citizen (Entity.Null if none). -
private CitizenResidenceKey residenceKey { get; set; }
Residence type key (derived from the citizen's residence). -
private Unity.Entities.Entity workplaceEntity { get; set; }
Workplace entity where the citizen works (Entity.Null if none). -
private Unity.Entities.Entity companyEntity { get; set; }
Company entity associated with the workplace; used for naming the workplace in output. -
private CitizenWorkplaceKey workplaceKey { get; set; }
Workplace type key. -
private CitizenOccupationKey occupationKey { get; set; }
Citizen occupation key (job occupation). -
private CitizenJobLevelKey jobLevelKey { get; set; }
Job level key of the citizen. -
private Unity.Entities.Entity schoolEntity { get; set; }
School entity the citizen attends (Entity.Null if none). -
private int schoolLevel { get; set; }
Numerical school level (set by GetSchoolEntity helper). -
private CitizenEducationKey educationKey { get; set; }
Citizen education key. -
private CitizenAgeKey ageKey { get; set; }
Citizen age category key. -
private HouseholdWealthKey wealthKey { get; set; }
Household wealth key (derived via CitizenUIUtils and happiness parameters). -
private Unity.Entities.Entity destinationEntity { get; set; }
Resolved destination entity (transport target, owner target, outside connection, or Entity.Null).
Constructors
public CitizenSection()
Default constructor. Marked with [Preserve] in source. No additional runtime initialization beyond the base constructor; OnCreate performs required setup.
Methods
-
[Preserve] protected override void OnCreate() : System.Void
Creates and stores an EntityQuery for CitizenHappinessParameterData and registers it with RequireForUpdate so the system updates when the singleton is available. Calls base.OnCreate(). -
protected override void Reset() : System.Void
Clears cached entity references: householdEntity, residenceEntity, workplaceEntity, schoolEntity, destinationEntity are all set to Entity.Null. -
private bool Visible() : System.Boolean
Returns true when the currently selected entity has both a HouseholdMember and a Citizen component; this determines whether the section should be visible for the selected entity. -
[Preserve] protected override void OnUpdate() : System.Void
Sets base.visible according to the Visible() result. Called each update. -
protected override void OnProcess() : System.Void
Primary processing method that reads the Citizen component from the selected entity and uses various CitizenUIUtils helpers to populate the section properties: - Determines household, citizenKey (normal/commuter/tourist), wealthKey (using happiness params).
- Gets stateKey, residenceEntity and residenceKey, workplaceEntity/companyEntity/workplaceKey, schoolEntity/schoolLevel, occupationKey, jobLevelKey, ageKey, educationKey.
- Resolves current destination via GetDestination().
-
Adds a "Male" tooltip tag if the citizen has the male flag in their state.
-
private Unity.Entities.Entity GetDestination() : System.Entity
Resolves the citizen's current destination by inspecting the CurrentTransport component on the selected entity: - If a Divert component is present, checks its Purpose and uses Divert.m_Target for certain purposes (Safety, Shopping, SendMail).
- Otherwise checks Target.m_Target.
- If target has an OutsideConnection component, returns that.
- If target has an Owner component, returns Owner.m_Owner.
-
If target entity exists, returns it; otherwise returns Entity.Null.
-
public override void OnWriteProperties(IJsonWriter writer) : System.Void
Serializes the collected properties to the provided IJsonWriter. For entity references, it writes either null or uses m_NameSystem.BindName(writer, entity) to bind a human-readable name; it also writes the raw entity id for "*Entity" properties. Enum keys are written as their string names via Enum.GetName.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Set up the query for citizen happiness parameters and require it for updates
m_HappinessParameterQuery = GetEntityQuery(ComponentType.ReadOnly<CitizenHappinessParameterData>());
RequireForUpdate(m_HappinessParameterQuery);
}
Additional notes: - This class depends on many game-specific types and helper utilities: Citizen, HouseholdMember, CitizenUIUtils, CurrentTransport, Divert, Target, Owner, m_NameSystem, TooltipTags, and the EntityManager available from the base InfoSectionBase. - It uses Unity.Entities.Entity for referencing entities and relies on the ECS component queries/patterns typical in Cities: Skylines 2 modding.