Game.MultipleUnitTrainCarPrefab
Assembly:
Assembly-CSharp (default Unity game assembly)
Namespace:
Game.Prefabs
Type:
class
Base:
TrainPrefab
Summary:
MultipleUnitTrainCarPrefab is a prefab class used with Unity's ECS for a train car that is part of a multiple-unit train. It extends TrainPrefab and, when queried for ECS components, adds TrainCarriageData and MultipleUnitTrainData as writable components. The class is annotated with ComponentMenu("Vehicles/") so it appears under that menu in the Unity editor.
Fields
- (none declared)
This class declares no instance fields.
Properties
- (none declared)
There are no properties defined by this class.
Constructors
public MultipleUnitTrainCarPrefab()
No explicit constructor is defined in the source; the default parameterless constructor is used.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Overrides TrainPrefab.GetPrefabComponents. It calls the base implementation then adds two component types to the provided HashSet:- ComponentType.ReadWrite
() - ComponentType.ReadWrite
() This ensures that entities created from this prefab include those writable components in their archetype.
Additional notes: - Uses Unity.Entities.ComponentType to describe component requirements for the prefab. - Intended to be used during prefab/component collection when building entity archetypes for train cars in an ECS-based implementation.
Usage Example
// Example of how the prefab contributes components to an archetype collection
var components = new HashSet<Unity.Entities.ComponentType>();
var prefab = new MultipleUnitTrainCarPrefab();
prefab.GetPrefabComponents(components);
// 'components' now contains TrainCarriageData and MultipleUnitTrainData (as ReadWrite)
// which can be used when creating an EntityArchetype or when configuring entity creation.