Game.TrainObjectData
Assembly: Assembly-CSharp (game)
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable
Summary:
TrainObjectData is a small ECS component/marker struct that stores two Unity.Entities.EntityArchetype references used by the train prefab system. These archetypes represent the controller entities for a moving train and for a stopped train respectively. The struct is intended to be attached as component data to an entity that needs quick access to the proper controller archetypes when spawning or switching train controllers.
Fields
-
public Unity.Entities.EntityArchetype m_ControllerArchetype
Holds the archetype used to create controller entities for a moving/active train (the running controller). -
public Unity.Entities.EntityArchetype m_StoppedControllerArchetype
Holds the archetype used to create controller entities for a stopped/inactive train (the stopped controller).
Properties
This type defines no properties.
Constructors
public TrainObjectData()
Structs have an implicit parameterless constructor that zero-initializes fields. In typical usage you create and assign both archetype fields explicitly after creating the relevant archetypes via an EntityManager.
Methods
This struct declares no methods. It only implements marker/contract interfaces (IComponentData, IQueryTypeParameter, IEmptySerializable) and stores archetype references.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Example: creating archetypes and assigning them to TrainObjectData
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// Create controller archetypes (example component types — replace with actual train controller components)
var movingControllerArchetype = entityManager.CreateArchetype(
typeof(Translation),
typeof(Rotation),
typeof(TrainControllerComponent) // hypothetical component
);
var stoppedControllerArchetype = entityManager.CreateArchetype(
typeof(Translation),
typeof(Rotation),
typeof(StoppedTrainControllerComponent) // hypothetical component
);
// Create TrainObjectData and set archetypes
var trainObjectData = new TrainObjectData
{
m_ControllerArchetype = movingControllerArchetype,
m_StoppedControllerArchetype = stoppedControllerArchetype
};
// Assuming you have an entity that should hold this data:
Entity trainPrefabEntity = entityManager.CreateEntity();
entityManager.AddComponentData(trainPrefabEntity, trainObjectData);
Notes: - EntityArchetype values are created once (or cached) and reused to efficiently instantiate controller entities at runtime. - Because this is an IComponentData struct, it can be queried and read/written from ECS systems. The IEmptySerializable marker indicates custom serialization behavior used by the game's serialization pipeline.