Game.Simulation.TelecomFacilityAISystem
Assembly: Game
Namespace: Game.Simulation
Type: class
Base: GameSystemBase
Summary:
A game system that periodically updates TelecomFacility entities to mark them as having coverage. It schedules a Burst-compiled IJobChunk (TelecomFacilityTickJob) that iterates TelecomFacility components in matching entities and sets the HasCoverage flag on each. The system is optimized with an EntityQuery restricting processing to prefab telecom facilities that are not temporary, destroyed or deleted, and it exposes compiler-generated helpers for component type handles and query assignment used by the DOTS/ECS build pipeline.
Fields
-
private EntityQuery m_BuildingQuery
Used to select TelecomFacility entities to process. Constructed in OnCreate to match entities with a TelecomFacility component and a PrefabRef, excluding Temp, Destroyed and Deleted tags. Also passed to RequireForUpdate so the system only runs when matching entities exist. -
private TypeHandle __TypeHandle
Compiler-generated container for component type handles used by the scheduled job. It holds a ComponentTypeHandleand provides an __AssignHandles(ref SystemState) helper to initialize the handle from the current SystemState.
Properties
- This system defines no public properties.
Constructors
public TelecomFacilityAISystem()
Default constructor. Marked with Preserve attribute in the source; acts as the usual ECS system constructor and relies on OnCreate/OnCreateForCompiler to initialize runtime and compiler-time state.
Methods
-
public override int GetUpdateInterval(SystemUpdatePhase phase)
Returns the system's update interval (256). This indicates the system is intended to run every 256 ticks/frames for the given update phase. -
public override int GetUpdateOffset(SystemUpdatePhase phase)
Returns the system's update offset (208). Used to stagger execution relative to other systems in the same phase. -
[Preserve] protected override void OnCreate()
Initializes runtime query data. Builds m_BuildingQuery with: - Required: ReadOnly
, ReadOnly -
Excluded: Temp, Destroyed, Deleted
Calls RequireForUpdate(m_BuildingQuery) to prevent updates when no matching entities exist. -
[Preserve] protected override void OnUpdate()
Schedules the TelecomFacilityTickJob with ScheduleParallel using the m_BuildingQuery. The job's TelecomFacility component type handle is obtained via InternalCompilerInterface.GetComponentTypeHandle(...) using the compiler-generated __TypeHandle entry. The returned JobHandle is stored back into base.Dependency. -
private void __AssignQueries(ref SystemState state)
Compiler helper invoked from OnCreateForCompiler. In the decompiled source this creates and immediately disposes a temporary EntityQueryBuilder; in a built environment this method is a placeholder used by code generation to assign queries. -
protected override void OnCreateForCompiler()
Compiler-time initialization hook that: - Calls __AssignQueries(ref base.CheckedStateRef)
-
Calls __TypeHandle.__AssignHandles(ref base.CheckedStateRef)
These set up the component type handles and any compiler-only state required for scheduling jobs. -
Nested:
TelecomFacilityTickJob
(private, [BurstCompile], implements IJobChunk) - Fields:
public ComponentTypeHandle<Game.Buildings.TelecomFacility> m_TelecomFacilityType
— component handle used to access TelecomFacility components in a chunk.
- Execute behavior:
- For each TelecomFacility in the chunk, sets the HasCoverage flag: value.m_Flags |= TelecomFacilityFlags.HasCoverage; then writes the component back to the native array.
-
The job is Burst compiled and scheduled in parallel for improved performance.
-
Nested:
TypeHandle
(private struct) - Field:
public ComponentTypeHandle<Game.Buildings.TelecomFacility> __Game_Buildings_TelecomFacility_RW_ComponentTypeHandle
- Method:
public void __AssignHandles(ref SystemState state)
— initializes the component type handle via state.GetComponentTypeHandle().
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Build the query to process TelecomFacility prefabs only (exclude Temp/Destroyed/Deleted)
m_BuildingQuery = GetEntityQuery(
ComponentType.ReadOnly<Game.Buildings.TelecomFacility>(),
ComponentType.ReadOnly<PrefabRef>(),
ComponentType.Exclude<Temp>(),
ComponentType.Exclude<Destroyed>(),
ComponentType.Exclude<Deleted>());
RequireForUpdate(m_BuildingQuery);
}
[Preserve]
protected override void OnUpdate()
{
// Prepare and schedule the Burst-compiled chunk job that sets the HasCoverage flag
JobHandle dependency = JobChunkExtensions.ScheduleParallel(new TelecomFacilityTickJob
{
m_TelecomFacilityType = InternalCompilerInterface.GetComponentTypeHandle(
ref __TypeHandle.__Game_Buildings_TelecomFacility_RW_ComponentTypeHandle,
ref base.CheckedStateRef)
}, m_BuildingQuery, base.Dependency);
base.Dependency = dependency;
}
Notes: - The job uses IJobChunk and is Burst-compiled for performance; it modifies component data in-place. - Update interval and offset (256 and 208) control how often and when relative to the update phase this system runs. Adjusting those values affects scheduling frequency.