Skip to content

Game.UI.InGame.EducationInfoviewUISystem

Assembly: Game (runtime assembly containing game systems; equivalent to Assembly-CSharp in usual modding setups)
Namespace: Game.UI.InGame

Type: class

Base: InfoviewUISystemBase

Summary:
EducationInfoviewUISystem is a UI system used by the in-game "Education" infoview. It gathers education-related statistics (population education levels, student counts, eligible students, and school capacities), runs Burst-compiled IJobChunk jobs to compute these aggregates on the ECS world, and exposes the results through UI bindings (RawValueBinding / ValueBinding / GetterValueBinding). The system maintains an internal NativeArray (m_Results) to accumulate results from several jobs, updates UI bindings every frame in PerformUpdate, and computes availability indicators for each education tier (elementary → university). It relies on multiple EntityQuery definitions and reads various component lookups (citizens, households, school data, installed upgrades, city modifiers, etc.).


Fields

  • private enum Result
    Enum used as indexes into m_Results to identify stored counts (Uneducated, ElementaryEducated, HighSchoolEducated, ... , UniversityCapacity).

  • private SimulationSystem m_SimulationSystem
    Reference to the SimulationSystem used to get the current simulation frame index.

  • private CitySystem m_CitySystem
    Reference to the CitySystem used to get the city entity and its buffers (city modifiers, service fees).

  • private RawValueBinding m_EducationData
    Raw binding used to provide detailed education distribution data (5-slice pie chart) to the infoview UI.

  • private ValueBinding<int> m_ElementaryStudents, m_HighSchoolStudents, m_CollegeStudents, m_UniversityStudents
    Simple integer bindings exposing current student counts for each tier.

  • private ValueBinding<int> m_ElementaryEligible, m_HighSchoolEligible, m_CollegeEligible, m_UniversityEligible
    Integer bindings exposing the number of citizens eligible (or expected) to enter each education tier.

  • private ValueBinding<int> m_ElementaryCapacity, m_HighSchoolCapacity, m_CollegeCapacity, m_UniversityCapacity
    Integer bindings exposing student capacity per tier (sum of capacities of relevant school prefabs, combining installed upgrades if present).

  • private GetterValueBinding<IndicatorValue> m_ElementaryAvailability, m_HighSchoolAvailability, m_CollegeAvailability, m_UniversityAvailability
    Getter bindings that compute an IndicatorValue (availability/shortage indicator) from capacity and eligible counts.

  • private EntityQuery m_HouseholdQuery
    Query used to iterate households and their citizens for education level counts.

  • private EntityQuery m_SchoolQuery
    Query used to iterate school buildings and their student buffers / efficiencies for student & capacity counting.

  • private EntityQuery m_SchoolModifiedQuery
    Query used to detect when a school building was created/updated/deleted (affects Modified property).

  • private EntityQuery m_EligibleQuery
    Query used to iterate citizens eligible for entering education (citizen components + UpdateFrame) and calculate entering probabilities.

  • private EntityQuery m_TimeDataQuery
    (Internal query assigned via __AssignQueries; used to fetch TimeData singleton when scheduling eligibility job.)

  • private NativeArray<int> m_Results
    Native array of length 17 (as used in this system) used to accumulate intermediate and final counts: education distribution, eligible counts, student counts, capacities, etc. Allocated with Allocator.Persistent and disposed in OnDestroy — important to avoid leaks.

  • private TypeHandle __TypeHandle
    Compiler-generated structure that caches ComponentTypeHandle/BufferTypeHandle/ComponentLookup/BufferLookup used by the jobs.

  • private EntityQuery __query_607537787_0, __query_607537787_1, __query_607537787_2
    Compiler-generated EntityQuery instances used to fetch singletons like EconomyParameterData, EducationParameterData and TimeData.

  • Several nested Burst-compiled job structs:

  • UpdateEducationDataJob (IJobChunk) — iterates households and household citizens to count living citizens by education level and accumulates results into m_Results[0..4].
  • UpdateStudentCountsJob (IJobChunk) — iterates school buildings, checks efficiency & installed upgrades, sums student buffer lengths and prefab student capacities into m_Results (student counts and capacities per tier).
  • UpdateEligibilityJob (IJobChunk) — iterates citizens to estimate how many will attempt to enter each tier (applies entering probability functions and city modifiers; uses economy/education/time singletons and building/household lookups).

Properties

  • protected override bool Active
    Returns whether the system should be considered active. The system is active if base.Active is true OR any of its UI bindings are active (checks many of the ValueBinding/RawValueBinding/GetterValueBinding .active flags). This lets the system avoid work when the education infoview isn't in use.

  • protected override bool Modified
    Returns true when the m_SchoolModifiedQuery is non-empty (i.e., when a school building has been created/updated/deleted). Used to indicate the infoview needs updating if school data changed.

Constructors

  • public EducationInfoviewUISystem()
    Default (compiler-generated) constructor. Initialization is done in OnCreate.

Methods

  • [Preserve] protected override void OnCreate()
    Sets up the system: gets SimulationSystem and CitySystem references; declares RequireForUpdate for EconomyParameterData and TimeData; builds EntityQueries used by the system; registers UI bindings (RawValueBinding, ValueBinding, GetterValueBinding); allocates m_Results as a Persistent NativeArray.

Notes: - Bindings registered here are: - Raw "educationData" (pie chart distribution) - integer counts for students, eligible and capacities per tier - availability getters that compute IndicatorValue from capacity & eligible

  • [Preserve] protected override void OnDestroy()
    Disposes m_Results and calls base.OnDestroy. Always dispose the Persistent NativeArray to avoid memory leaks.

  • protected override void PerformUpdate()
    Main per-frame update: resets m_Results, runs UpdateStudentCounts and UpdateEligibility (both schedule and complete job work), updates the Raw education data (UpdateEducationData), updates the ValueBinding integers from m_Results indices (student counts, capacities, eligible counts), and calls Update on each availability getter to compute IndicatorValues.

  • private void ResetResults()
    Zeroes all entries in m_Results before each frame's aggregation.

  • private void UpdateEducationData(IJsonWriter binder)
    Schedules and completes UpdateEducationDataJob against m_HouseholdQuery to count citizens by education level, then writes a five-slice pie chart data structure (InfoviewsUIUtils.UpdateFiveSlicePieChartData) into the provided binder using m_Results[0..4].

  • private void UpdateStudentCounts()
    Schedules and completes UpdateStudentCountsJob against m_SchoolQuery to sum active students and capacities across schools (takes into account building efficiency and installed upgrades) and accumulates results into m_Results.

  • private void UpdateEligibility()
    Schedules and completes UpdateEligibilityJob against m_EligibleQuery. The job fetches singletons (EconomyParameterData, EducationParameterData, TimeData) and uses city modifiers / service fees to estimate the numbers of eligible students per education tier, accumulating results into m_Results[5..8].

  • private IndicatorValue UpdateElementaryAvailability()
    Returns IndicatorValue.Calculate(m_ElementaryCapacity.value, m_ElementaryEligible.value). IndicatorValue encodes whether capacity is sufficient or not and is used by the UI (green/yellow/red indicators).

  • private IndicatorValue UpdateHighSchoolAvailability()
    Same as above for high school.

  • private IndicatorValue UpdateCollegeAvailability()
    Same as above for college.

  • private IndicatorValue UpdateUniversityAvailability()
    Same as above for university.

  • [MethodImpl(MethodImplOptions.AggressiveInlining)] private void __AssignQueries(ref SystemState state)
    Compiler-generated helper that builds the internal queries used to fetch singletons (EconomyParameterData, EducationParameterData, TimeData). Called from OnCreateForCompiler.

  • protected override void OnCreateForCompiler()
    Compiler hook that calls __AssignQueries and assigns component handles from __TypeHandle.

  • Nested job structs also contain their Execute implementations (IJobChunk.Execute wrappers); these are Burst-compiled for performance.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // The system registers UI bindings and allocates its native buffers in OnCreate.
    // If you subclass this system (rare for mods), ensure you call base.OnCreate() so bindings are registered.
    // Example: log that the education infoview system was created (useful when debugging mod interactions).
    Debug.Log("EducationInfoviewUISystem created");
}

Additional notes for modders: - This system performs heavy work via Burst IJobChunk jobs and uses Persistent NativeArray for aggregation; if you modify or copy this pattern, remember to dispose persistent allocations in OnDestroy. - The jobs rely on many component lookups and buffer lookups — altering related component definitions or archetypes may require matching changes to the jobs' type handles. - The availability indicators are computed from capacity vs eligible counts; capacity accounts for installed upgrades via UpgradeUtils.CombineStats in UpdateStudentCountsJob. - The system completes scheduled jobs immediately (Complete()) before updating UI bindings — this simplifies UI consistency at the cost of potentially blocking the main thread for the duration of the jobs. If you change scheduling behavior, ensure UI bindings see consistent aggregated data.