Skip to content

Game.TrainBogieFrameSystem

Assembly:
Most likely Assembly-CSharp (game runtime assembly). If you extract from the game's managed assemblies the type is in the game's main assembly.
Namespace: Game.Serialization

Type: class

Base: GameSystemBase

Summary:
TrainBogieFrameSystem is an ECS system that populates/updates the TrainBogieFrame dynamic buffer on train entities from their TrainCurrentLane component. It schedules a Burst-compiled IJobChunk (BogieFrameJob) to run in parallel over matching chunks. The job resizes each TrainBogieFrame buffer to 4 elements and writes the front and rear lane IDs (taken from TrainCurrentLane.m_Front.m_Lane and TrainCurrentLane.m_Rear.m_Lane) into each buffer element. The system requires entities that have a TrainBogieFrame buffer and a TrainCurrentLane component and will not run unless such entities are present.


Fields

  • private EntityQuery m_Query
    Used to select entities that contain a TrainBogieFrame buffer (read/write) and a TrainCurrentLane component (read-only). The query is created during OnCreate and passed to the job scheduler in OnUpdate.

  • private TypeHandle __TypeHandle
    Holds component / buffer / shared-component type handles used by the job. The nested TypeHandle struct stores the SharedComponentTypeHandle, a read-only ComponentTypeHandle, and a buffer-type BufferTypeHandle. The __AssignHandles method populates those handles from a SystemState.

  • private struct BogieFrameJob (nested)
    Burst-compiled IJobChunk implementation that reads TrainCurrentLane data and writes TrainBogieFrame buffers. Fields:

  • SharedComponentTypeHandle<UpdateFrame> m_UpdateFrameType (readonly) — acquired but not used in the job body; likely present for chunk filtering or future use.
  • ComponentTypeHandle<TrainCurrentLane> m_TrainCurrentLaneType (readonly) — used to read per-entity TrainCurrentLane data.
  • BufferTypeHandle<TrainBogieFrame> m_TrainBogieFrameType — used to access and write dynamic TrainBogieFrame buffers.

The job iterates entities in a chunk, resizes each entity's TrainBogieFrame buffer to length 4, and sets each element's m_FrontLane and m_RearLane from the corresponding TrainCurrentLane.

  • private struct TypeHandle (nested)
    Container for the specific component/buffer/shared-component handles and an inline initializer (__AssignHandles) to bind them from a SystemState.

Properties

  • None (no public properties are declared on this type)

Constructors

  • public TrainBogieFrameSystem()
    Default parameterless constructor. The system also has OnCreate/OnCreateForCompiler overrides to initialize queries and assign handles.

Methods

  • protected override void OnCreate()
    Creates and configures the EntityQuery for entities with a TrainBogieFrame buffer (read/write) and a TrainCurrentLane component (read-only). Calls RequireForUpdate(m_Query) so the system runs only when matching entities exist.

  • protected override void OnUpdate()
    Builds a BogieFrameJob with the appropriate component/buffer/shared-component type handles (obtained via InternalCompilerInterface and the stored __TypeHandle). Schedules the job in parallel over m_Query using JobChunkExtensions.ScheduleParallel and updates base.Dependency with the returned JobHandle. This is where the TrainBogieFrame buffers are updated each frame.

  • protected override void OnCreateForCompiler()
    Helper invoked by the generated/system compilation path; it calls __AssignQueries and binds type handles via __TypeHandle.__AssignHandles(ref base.CheckedStateRef). Ensures the system is properly wired when compiled/stripped.

  • private void __AssignQueries(ref SystemState state)
    Generated helper; currently only constructs an EntityQueryBuilder(Allocator.Temp).Dispose(); in this decompiled form. In normal ECS code this would be where queries are assigned; here it is present for compiler compatibility.

  • private struct TypeHandle.__AssignHandles(ref SystemState state)
    Assigns the SharedComponentTypeHandle, the read-only ComponentTypeHandle, and the BufferTypeHandle from the provided SystemState.

  • BogieFrameJob.Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
    Main job logic: obtains the native array of TrainCurrentLane components and the buffer accessor for TrainBogieFrame. For each entity in the chunk it:

  • Reads TrainCurrentLane for that entity.
  • Resizes the TrainBogieFrame dynamic buffer to 4 elements (ResizeUninitialized(4)).
  • Fills all elements (0..3) with a TrainBogieFrame whose m_FrontLane is trainCurrentLane.m_Front.m_Lane and m_RearLane is trainCurrentLane.m_Rear.m_Lane.

The job also implements the explicit IJobChunk.Execute wrapper that forwards to the strongly typed Execute method.

Notes / Behavior details: - The job is Burst-compiled ([BurstCompile]) for performance. - The UpdateFrame shared component handle is acquired but not referenced inside Execute — it may be used implicitly for chunk filtering or intended for future extension. - Buffer resize is unconditional to length 4; any previous data is discarded/overwritten. - The system uses parallel chunk scheduling, so it expects job-safe reads/writes.

Usage Example

// This system is created by the ECS runtime; typical usage is to rely on the system running automatically.
// Example of the important OnCreate logic replicated below:

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // build a query that finds entities with the TrainBogieFrame buffer and TrainCurrentLane component
    m_Query = GetEntityQuery(
        ComponentType.ReadWrite<TrainBogieFrame>(),
        ComponentType.ReadOnly<TrainCurrentLane>()
    );
    RequireForUpdate(m_Query);
}

// The system's OnUpdate schedules a Burst IJobChunk (BogieFrameJob) that updates the TrainBogieFrame buffers
// with lane ids copied from TrainCurrentLane for each train entity.

Additional notes: - Because this system resizes and writes train bogie buffers every update, modifying the buffer length or format elsewhere must be compatible with the expected size (4) and element layout (TrainBogieFrame with m_FrontLane/m_RearLane fields). - If you need to extend or change behavior (for example store per-bogie offsets or timestamps), update the BogieFrameJob to fill different fields and ensure the buffer type matches.