Skip to content

Game.Prefabs.TrainEngineData

Assembly: Assembly-CSharp (game/mod assembly; actual assembly may vary)
Namespace: Game.Prefabs

Type: struct

Base: Implements IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
TrainEngineData is a small ECS component used to store a minimum and maximum engine count for a train prefab. It is a plain, blittable value type (uses Unity.Mathematics.int2) and is suitable for use with Unity's Entities (ECS) systems and serialization expected by the game.


Fields

  • public int2 m_Count
    Holds the engine count range as a Unity.Mathematics.int2: m_Count.x is the minimum engine count and m_Count.y is the maximum engine count. There is no built-in runtime validation in this type (e.g., no enforcement that x <= y), so callers should ensure values are sensible.

Properties

  • (none)
    This struct exposes no properties; the data is stored in the public field m_Count.

Constructors

  • public TrainEngineData(int minCount, int maxCount)
    Initializes the component by packing the provided minCount and maxCount into m_Count (int2(minCount, maxCount)).

Methods

  • (none)
    The struct defines no methods. Behaviorally it is a passive data container used by ECS systems and queries. It implements IEmptySerializable to satisfy the game's serialization patterns and IQueryTypeParameter for use in query APIs.

Usage Example

// Create an instance with a min/max engine count
var engineData = new TrainEngineData(1, 4);

// Example: add to an entity using an EntityManager (Entities API)
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = entityManager.CreateEntity(typeof(TrainEngineData));
entityManager.SetComponentData(entity, engineData);

// In systems you can read the values:
public void SomeSystemMethod(ref TrainEngineData data)
{
    int minEngines = data.m_Count.x;
    int maxEngines = data.m_Count.y;
    // use or validate counts as needed
}

Notes and recommendations: - Because there is no validation, prefer to ensure minCount <= maxCount when constructing instances. - As an IComponentData struct, this type is suitable for large-scale batch processing inside ECS systems and should remain lightweight. - The int2 type comes from Unity.Mathematics (x = min, y = max).