Game.UI.InGame.ToolbarBottomUISystem
Assembly:
Assembly-CSharp (inferred — actual assembly name may vary)
Namespace:
Game.UI.InGame
Type:
class
Base:
UISystemBase
Summary:
A UI system responsible for the bottom toolbar in-game. It sets up data bindings for city-related UI elements (city name, money, population, trend thresholds, unlimited money toggle, etc.), reads configuration prefab data via the PrefabSystem, and updates those bindings each frame. Integrates with city systems (city configuration, statistics, budget, and general city data) and uses Unity.Entities EntityQuery to require the toolbar configuration data.
Fields
-
private const string kGroup
Constant string used as the UI binding group identifier ("toolbarBottom"). -
private PrefabSystem m_PrefabSystem
Reference to the game's PrefabSystem used to fetch UI configuration prefabs. -
private CityConfigurationSystem m_CityConfigurationSystem
Reference to the system that stores city configuration data (e.g., city name, unlimited money). -
private ICityStatisticsSystem m_CityStatisticsSystem
Reference to the city statistics system, used to obtain historical statistic samples for trend/delta calculations. -
private CitySystem m_CitySystem
Reference to the CitySystem (holds city entity and runtime city state like money amount). -
private ICityServiceBudgetSystem m_CityServiceBudgetSystem
Reference to the service/budget system used to obtain money delta information. -
private GetterValueBinding<string> m_CityNameBinding
Getter binding for the city name shown on the toolbar. Bound to "toolbarBottom", "cityName". -
private GetterValueBinding<int> m_MoneyBinding
Getter binding for the current money amount ("toolbarBottom", "money"). -
private GetterValueBinding<int> m_MoneyDeltaBinding
Getter binding for money delta/trend ("toolbarBottom", "moneyDelta"), uses m_CityServiceBudgetSystem.GetMoneyDelta. -
private GetterValueBinding<int> m_PopulationBinding
Getter binding for current population ("toolbarBottom", "population"). -
private GetterValueBinding<int> m_PopulationDeltaBinding
Getter binding for population delta/trend ("toolbarBottom", "populationDelta"). -
private GetterValueBinding<bool> m_UnlimitedMoneyBinding
Getter binding for unlimited money toggle ("toolbarBottom", "unlimitedMoney"). -
private UIToolbarBottomConfigurationPrefab m_ToolbarBottomConfigurationPrefab
Cached prefab of the toolbar bottom configuration (holds threshold values for trends). -
private EntityQuery m_ToolbarBottomConfigurationQuery
EntityQuery used in RequireForUpdate to ensure a toolbar configuration exists. -
private TypeHandle __TypeHandle
Compiler-generated type handle struct instance used for DOTS/system handle assignment. -
private EntityQuery __query_2118611066_0
Compiler-generated EntityQuery used to fetch the singleton entity to obtain the UIToolbarBottomConfigurationPrefab. -
private struct TypeHandle
(nested, sequential size 1)
Contains a single method __AssignHandles(ref SystemState) used by the compiler to assign handles. It is a compiler-generated helper.
Properties
- None (no public properties are defined on this type).
Constructors
public ToolbarBottomUISystem()
Default public constructor with [Preserve] attribute present on the class and constructor; no custom constructor logic beyond what the base class provides.
Methods
protected override void OnCreate()
Initializes system references (PrefabSystem, CityConfigurationSystem, CityStatisticsSystem, CitySystem, CityServiceBudgetSystem), builds the EntityQuery for UIToolbarBottomConfigurationData, registers multiple GetterValueBinding and TriggerBinding instances for the toolbar UI, and calls RequireForUpdate(m_ToolbarBottomConfigurationQuery). Bindings include:- cityName (string) — getter uses cityName from CityConfigurationSystem (falls back to empty string).
- money (int) — getter returns m_CitySystem.moneyAmount.
- moneyDelta (int) — getter uses m_CityServiceBudgetSystem.GetMoneyDelta.
- unlimitedMoney (bool) — getter returns CityConfigurationSystem.unlimitedMoney.
- population (int) — getter uses GetPopulation().
- populationDelta (int) — getter uses GetPopulationDelta().
- populationTrendThresholds and moneyTrendThresholds (float2) — read from the configuration prefab thresholds.
-
setCityName (trigger) — TriggerBinding that calls SetCityName(string).
-
private int GetPopulation()
Returns current population by checking the city entity for a Population component and returning its m_Population; returns 0 if the component is absent. -
private int GetPopulationDelta()
Computes a population delta value for the toolbar trend display: - Reads Population component if present.
- Obtains the Population statistic data array from m_CityStatisticsSystem.
- If there are no samples, returns the current population.
- Otherwise interpolates between the last two statistic samples using an interpolant t computed from sample frame index and modulus 8192, then computes difference between current population and the interpolated statistic value.
- The result is scaled by 32/24 (i.e., multiplied by 32 and divided by 24) before returning.
-
Implementation uses Mathf.RoundToInt and math.lerp.
-
private void SetCityName(string name)
Sets m_CityConfigurationSystem.cityName to the provided name and updates the city name binding. -
protected override void OnUpdate()
Updates all registered bindings each frame: m_CityNameBinding, m_MoneyBinding, m_PopulationBinding, m_MoneyDeltaBinding, m_PopulationDeltaBinding, m_UnlimitedMoneyBinding. Lazily loads the UIToolbarBottomConfigurationPrefab if not already cached by getting the singleton entity via the compiler-generated __query_2118611066_0 and fetching the prefab from m_PrefabSystem. -
private void __AssignQueries(ref SystemState state)
Compiler-generated helper that builds the EntityQuery __query_2118611066_0 for UIToolbarBottomConfigurationData with the IncludeSystems option. Called from OnCreateForCompiler. -
protected override void OnCreateForCompiler()
Compiler helper that calls __AssignQueries and __TypeHandle.__AssignHandles using the checked state reference. This is part of source-generated/system-generated wiring for ECS. -
private void TypeHandle.__AssignHandles(ref SystemState state)
Compiler-generated (empty in code) method for assigning handles — present to satisfy generated code structure.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Resolve systems
m_PrefabSystem = base.World.GetOrCreateSystemManaged<PrefabSystem>();
m_CityConfigurationSystem = base.World.GetOrCreateSystemManaged<CityConfigurationSystem>();
m_CityStatisticsSystem = base.World.GetOrCreateSystemManaged<CityStatisticsSystem>();
m_CitySystem = base.World.GetOrCreateSystemManaged<CitySystem>();
m_CityServiceBudgetSystem = base.World.GetOrCreateSystemManaged<CityServiceBudgetSystem>();
// Create bindings for the UI toolbar
AddBinding(m_CityNameBinding = new GetterValueBinding<string>("toolbarBottom", "cityName", () => m_CityConfigurationSystem.cityName ?? ""));
AddBinding(m_MoneyBinding = new GetterValueBinding<int>("toolbarBottom", "money", () => m_CitySystem.moneyAmount));
AddBinding(m_MoneyDeltaBinding = new GetterValueBinding<int>("toolbarBottom", "moneyDelta", m_CityServiceBudgetSystem.GetMoneyDelta));
AddBinding(m_UnlimitedMoneyBinding = new GetterValueBinding<bool>("toolbarBottom", "unlimitedMoney", () => m_CityConfigurationSystem.unlimitedMoney));
AddBinding(m_PopulationBinding = new GetterValueBinding<int>("toolbarBottom", "population", GetPopulation));
AddBinding(m_PopulationDeltaBinding = new GetterValueBinding<int>("toolbarBottom", "populationDelta", GetPopulationDelta));
// Require the toolbar configuration prefab data to be present for this system to run
RequireForUpdate(m_ToolbarBottomConfigurationQuery);
}
Notes and implementation details: - The system integrates Unity.Entities (DOTS) patterns: uses EntityQuery, SystemState, and GetOrCreateSystemManaged to locate other managed systems. - Trend thresholds (float2: medium and high) are read from UIToolbarBottomConfigurationPrefab when first needed and exposed via bindings for UI to use. - Population delta computation uses historical statistic samples with interpolation and a scaling factor (32/24) — keep that in mind if changing statistics sampling frequency or interpretation. - The code contains compiler-generated queries and type handle plumbing to work with the Entities source-generation / conversion pipeline; those members (__query_..., TypeHandle) are not intended for manual modification.