Game.Prefabs.MultipleUnitTrainCarriageInfo
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: System.Object
Summary:
Represents a configuration entry for a carriage that can be attached to a multiple-unit train prefab. This serializable container ties a carriage prefab to a direction and a min/max count range, and is typically used by multiple-unit train prefabs to describe optional or repeated carriage units that are spawned as part of a composite train. Useful for modders who need to add or modify how train carriages are assembled at runtime or in prefab definitions.
Fields
-
public MultipleUnitTrainCarPrefab m_Carriage
Holds a reference to the carriage prefab to be used/instantiated for this entry. This is the prefab object that will be spawned as a carriage when the multiple-unit train is constructed. Can be null if not assigned; mod code should validate before use. -
public VehicleCarriageDirection m_Direction
Specifies the carriage direction/orientation relative to the parent unit. Determines how the carriage is placed/rotated when attached to the train. Values come from the VehicleCarriageDirection enum (direction semantics depend on the game's enum definition — typically front/back or left/right relative to the unit). Ensure you use the correct enum member when creating or editing entries. -
public int m_MinCount
Minimum number of carriages of this type to include. Used when the game or prefab logic decides how many instances of this carriage to attach. Should be >= 0. Modders should ensure this value is consistent with m_MaxCount. -
public int m_MaxCount
Maximum number of carriages of this type to include. Used with m_MinCount to form a valid range. Should be >= m_MinCount. If m_MaxCount < m_MinCount, prefab logic may behave unexpectedly — validate or clamp values in your code.
Properties
- This class defines public fields only and does not expose any C# properties.
Constructors
public MultipleUnitTrainCarriageInfo()
Default parameterless constructor (compiler-provided). Initializes the instance with default field values: reference fields null and integer fields set to 0. When creating instances in code, populate fields explicitly and validate ranges as needed.
Methods
- This class does not declare any methods. It is a simple data container (POCO/struct-like class) intended for serialization and runtime consumption by other systems.
Usage Example
// Create and configure a carriage info entry for a multiple-unit train prefab
var carriageInfo = new Game.Prefabs.MultipleUnitTrainCarriageInfo
{
m_Carriage = someCarriagePrefab, // assign a valid MultipleUnitTrainCarPrefab reference
m_Direction = VehicleCarriageDirection.Back, // example enum value — use the appropriate member
m_MinCount = 1,
m_MaxCount = 3
};
// Validate before using
if (carriageInfo.m_Carriage == null)
throw new InvalidOperationException("Carriage prefab must be assigned.");
if (carriageInfo.m_MinCount < 0)
carriageInfo.m_MinCount = 0;
if (carriageInfo.m_MaxCount < carriageInfo.m_MinCount)
carriageInfo.m_MaxCount = carriageInfo.m_MinCount;
// Add carriageInfo to your multiple-unit train prefab configuration or use it when spawning carriages.
Notes for modders: - Because the class is marked [Serializable], it is intended to be used in serialized prefab data. When editing saved prefabs or creating new ones, ensure prefab references remain valid and that enum values match expected semantics. - Always validate m_MinCount/m_MaxCount ranges in editor tools or runtime code to avoid unexpected behavior when the game spawns carriages.