Game.Serialization.HotspotFrameSystem
Assembly: Game (runtime / Assembly-CSharp)
Namespace: Game.Serialization
Type: public class HotspotFrameSystem
Base: GameSystemBase
Summary:
HotspotFrameSystem is a compiler-generated ECS system that initializes per-entity InterpolatedTransform components and HotspotFrame dynamic buffers from a WeatherPhenomenon component. It schedules a Burst-compiled IJobChunk (HotspotFrameJob) to run in parallel over an EntityQuery containing WeatherPhenomenon (read-only), InterpolatedTransform, and HotspotFrame buffer components. The job constructs an InterpolatedTransform from each WeatherPhenomenon and fills each HotspotFrame buffer with four HotspotFrame instances created from the WeatherPhenomenon. The system uses cached TypeHandle structs and InternalCompilerInterface helpers to obtain Component/Buffer type handles for job safety and performance. The class is marked CompilerGenerated and has [Preserve] attributes on lifecycle methods (intended for internal/auto-generated use within the game's ECS pipeline).
Fields
-
private EntityQuery m_Query
Holds the EntityQuery used by the system. The query selects entities that have a HotspotFrame dynamic buffer, an InterpolatedTransform component, and a read-only WeatherPhenomenon component. The system calls RequireForUpdate(m_Query) so it only updates when matching entities exist. -
private TypeHandle __TypeHandle
A private nested struct instance used to cache ComponentTypeHandle<...> and BufferTypeHandle<...> values for use in jobs. The TypeHandle stores read-only and read-write handles for WeatherPhenomenon, InterpolatedTransform, and HotspotFrame buffer and provides an __AssignHandles method to initialize them from a SystemState.
Properties
- None exposed by this system.
Constructors
public HotspotFrameSystem()
Default (empty) constructor. The system relies on OnCreate / OnCreateForCompiler to initialize query and cached type handles.
Methods
protected override void OnCreate()
Called when the system is created. It builds the EntityQuery:- ComponentType.ReadWrite
() - ComponentType.ReadWrite
() -
ComponentType.ReadOnly
()
Then calls RequireForUpdate(m_Query) so the system only runs when matching entities exist. -
protected override void OnUpdate()
Creates and populates a HotspotFrameJob instance with component/buffer type handles obtained through InternalCompilerInterface.GetComponentTypeHandle / GetBufferTypeHandle, then schedules the job in parallel using JobChunkExtensions.ScheduleParallel, wiring its JobHandle to base.Dependency. -
protected override void OnCreateForCompiler()
Compiler-time helper called to assign queries and component handles used by generated code. It calls __AssignQueries and TypeHandle.__AssignHandles with the SystemState reference. Present to support generated code workflows. -
private void __AssignQueries(ref SystemState state)
A small method used by the generated system to assign queries (here it constructs and disposes an EntityQueryBuilder with Allocator.Temp). Present to satisfy the generated setup pattern. -
private struct TypeHandle.__AssignHandles(ref SystemState state)
Initializes cached handles: - Gets a read-only ComponentTypeHandle
- Gets a ComponentTypeHandle
(read-write) -
Gets a BufferTypeHandle
(read-write) These cached handles are then used to build the job data on each update. -
private struct HotspotFrameJob : IJobChunk
(nested) - Attributes: [BurstCompile] (the job is Burst-compiled for performance)
- Fields:
ComponentTypeHandle<WeatherPhenomenon> m_WeatherPhenomenonType
(ReadOnly)ComponentTypeHandle<InterpolatedTransform> m_InterpolatedTransformType
BufferTypeHandle<HotspotFrame> m_HotspotFrameType
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
For each entity in the chunk:- Reads the WeatherPhenomenon value.
- Constructs a new InterpolatedTransform from that WeatherPhenomenon and writes it into the InterpolatedTransform component array.
- Gets the HotspotFrame dynamic buffer for the entity, calls ResizeUninitialized(4) and fills the buffer with 4 HotspotFrame instances constructed from the WeatherPhenomenon.
The job implements IJobChunk.Execute explicitly and calls the local Execute to satisfy the interface.
Notes / Implementation details: - The job uses ResizeUninitialized to set buffer length to 4 without initializing memory first, then immediately assigns each element. - The use of InternalCompilerInterface methods and the CompilerGenerated attribute indicate this system is produced/assisted by the compiler or source generator patterns used in this codebase. - The v128 chunkEnabledMask param and useEnabledMask bool are present to support enabled-mask processing in IJobChunk (used by Unity's job system). - All job scheduling is done with base.Dependency to maintain correct job dependencies with other systems.
Usage Example
// Simplified illustration of what the generated system does in OnCreate and OnUpdate:
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
m_Query = GetEntityQuery(
ComponentType.ReadWrite<HotspotFrame>(),
ComponentType.ReadWrite<InterpolatedTransform>(),
ComponentType.ReadOnly<WeatherPhenomenon>());
RequireForUpdate(m_Query);
}
[Preserve]
protected override void OnUpdate()
{
var jobData = new HotspotFrameJob {
m_WeatherPhenomenonType = InternalCompilerInterface.GetComponentTypeHandle(ref __TypeHandle.__Game_Events_WeatherPhenomenon_RO_ComponentTypeHandle, ref base.CheckedStateRef),
m_InterpolatedTransformType = InternalCompilerInterface.GetComponentTypeHandle(ref __TypeHandle.__Game_Rendering_InterpolatedTransform_RW_ComponentTypeHandle, ref base.CheckedStateRef),
m_HotspotFrameType = InternalCompilerInterface.GetBufferTypeHandle(ref __TypeHandle.__Game_Events_HotspotFrame_RW_BufferTypeHandle, ref base.CheckedStateRef)
};
base.Dependency = JobChunkExtensions.ScheduleParallel(jobData, m_Query, base.Dependency);
}
If you want, I can also: - Expand the example into a minimal custom system that mimics this behavior for testing, or - Document the related component types (WeatherPhenomenon, InterpolatedTransform, HotspotFrame) if you provide their definitions.