Game.TelecomPreviewSystem
Assembly:
Game (inferred)
Namespace:
Game.Tools
Type:
class
Base:
CellMapSystem
Summary:
TelecomPreviewSystem is an ECS system used by the tools layer to build and update a preview map of telecom coverage for telecom facilities. It queries density (citizens/employees) and facility entities, gathers required data (terrain height, city data, prefab/component lookups) and schedules a TelecomCoverageJob to compute coverage into the CellMap
Fields
-
private struct TypeHandle
TypeHandle is a private nested struct that stores ComponentTypeHandle, BufferTypeHandle and ComponentLookup/BufferLookup instances for all component types the system's job needs (Transform, PropertyRenter, TelecomFacility, Efficiency buffer, PrefabRef, Temp, InstalledUpgrade buffer, HouseholdCitizen buffer, Employee buffer, ObjectGeometryData, TelecomFacilityData and CityModifier buffers). It provides a single method __AssignHandles(ref SystemState) which acquires all of these handles from the SystemState. This is used to obtain the correct handles for the job respecting batching and the current system state. -
private TerrainSystem m_TerrainSystem
Reference to the TerrainSystem obtained from the world. Used to get terrain height data and to register CPU height readers for job synchronization. -
private CitySystem m_CitySystem
Reference to the CitySystem obtained from the world. The job uses m_CitySystem.City to include city-level data in coverage calculations. -
private EntityQuery m_DensityQuery
EntityQuery selecting density-related buffers (HouseholdCitizen or Employee) while excluding Temp and Deleted. Used to gather density chunks for the coverage job. -
private EntityQuery m_FacilityQuery
EntityQuery selecting telecom facility entities (TelecomFacility + Transform + PrefabRef) excluding service upgrades, hidden or deleted entities. Used to gather facility chunks for the coverage job. -
private EntityQuery m_ModifiedQuery
EntityQuery selecting telecom facility entities that have either Updated or Deleted set. This query drives when a recompute is required (or the system will recompute if forced). -
private bool m_ForceUpdate
Flag indicating the next update should recompute coverage even if no modified entities are detected. Set to true on start running. -
private NativeArray<TelecomStatus> m_Status
NativeArray used to store telecom status per facility. Allocated with Allocator.Persistent (initially length 0 here) and disposed on system destruction. Passed into the scheduled TelecomCoverageJob. -
private TypeHandle __TypeHandle
Instance of the private TypeHandle struct used to cache component type/lookup handles for scheduling the job.
Properties
public int2 TextureSize { get; }
Returns the preview texture size as an int2. In this implementation it returns new int2(128, 128). This value is used when CreateTextures(128) is called on creation to prepare the preview textures.
Constructors
public TelecomPreviewSystem()
Default constructor. The system does its initialization in OnCreate.
Methods
[Preserve] protected override void OnCreate()
Initializes the system:- Calls base.OnCreate().
- Gets TerrainSystem and CitySystem from the World.
- Constructs three EntityQueries: m_DensityQuery, m_FacilityQuery and m_ModifiedQuery to select density and facility entities and detect modifications.
- Allocates m_Status as a NativeArray
with length 0 using Allocator.Persistent. - Calls CreateTextures(128) to create the preview textures (method provided by base CellMapSystem).
-
Prepares the system to schedule the TelecomCoverageJob during updates.
-
[Preserve] protected override void OnDestroy()
Cleans up resources: - Disposes m_Status.
-
Calls base.OnDestroy().
-
[Preserve] protected override void OnStartRunning()
Called when the system starts running. Sets m_ForceUpdate = true so the first update after start will force a recompute of the coverage map. -
[Preserve] protected override void OnUpdate()
Main update loop. If m_ModifiedQuery indicates facility updates/deletes or m_ForceUpdate is true: - Resets m_ForceUpdate.
- Builds archetype chunk lists for density and facility queries asynchronously.
- Obtains the map via GetMap(readOnly: false, out dependencies).
- Constructs and schedules a TelecomCoverageSystem.TelecomCoverageJob, filling many job fields (density chunks, facility chunks, terrain height data, city data, preview flag, telemetry/status arrays, component type handles and lookups).
- Combines dependencies and base.Dependency, disposes chunk lists with the job handle, registers the job as a CPU height reader with TerrainSystem, calls AddWriter(jobHandle) and updates base.Dependency to the scheduled job handle.
-
The job computes and writes telecom coverage into the map.
-
[MethodImpl(MethodImplOptions.AggressiveInlining)] private void __AssignQueries(ref SystemState state)
Internal helper used by the compiler-generated OnCreateForCompiler path. In this file it creates and immediately disposes a temporary EntityQueryBuilder (placeholder/no-op). -
protected override void OnCreateForCompiler()
Used by the code-generation/compilation flow: - Calls base.OnCreateForCompiler().
-
Invokes __AssignQueries(ref base.CheckedStateRef) and __TypeHandle.__AssignHandles(ref base.CheckedStateRef) to prepare cached query and type handle data used by the generated job scheduling code.
-
[MethodImpl(MethodImplOptions.AggressiveInlining)] public void __AssignHandles(ref SystemState state)
(on TypeHandle)
Acquires all required ComponentTypeHandle, BufferTypeHandle, ComponentLookup and BufferLookup instances from the provided SystemState (via state.GetComponentTypeHandle / GetBufferTypeHandle / GetComponentLookup / GetBufferLookup) and stores them in the TypeHandle fields for later use when scheduling the job.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// The system prepares its internal data and textures in OnCreate.
// You can read the preview texture size via the TextureSize property:
var size = TextureSize; // int2(128,128)
}
Notes and implementation details:
- The system relies on a TelecomCoverageJob defined elsewhere (TelecomCoverageSystem.TelecomCoverageJob). That job performs the per-chunk coverage computation and writes into the CellMap