Skip to content

Game.Prefabs.HelicopterData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
HelicopterData is a component-style struct used by the game's ECS prefab system to store helicopter-specific runtime parameters. It contains the helicopter type and various motion parameters (max speed, accelerations and sway factors) used by helicopter movement and physics logic. The struct is serializable via the Colossal.Serialization interfaces so it can be saved/loaded with prefab data and used as a query-type parameter in ECS systems.


Fields

  • public HelicopterType m_HelicopterType
    Type/category of the helicopter (enum). Determines behaviour/profile specific to that helicopter variant.

  • public float m_FlyingMaxSpeed
    Maximum forward speed while flying (typically in game units per second).

  • public float m_FlyingAcceleration
    Linear acceleration while flying (units per second squared).

  • public float m_FlyingAngularAcceleration
    Angular acceleration used for turning/rotational responsiveness (radians or degrees per second squared depending on consumer expectations).

  • public float m_AccelerationSwayFactor
    Multiplier applied to acceleration to produce sway effects (used to create visual/physical sway during thrust changes).

  • public float m_VelocitySwayFactor
    Multiplier applied to velocity to produce sway effects (used to create ongoing tilt/sway from movement).

Properties

  • None (the struct exposes public fields; no C# properties are declared).

Constructors

  • public HelicopterData()
    Default value-type constructor implicit for structs. All fields default to their default values (enum default and zeros for floats). Use an initializer to set meaningful values.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the struct data to the provided writer in the following order: HelicopterType (as byte), m_FlyingMaxSpeed, m_FlyingAcceleration, m_FlyingAngularAcceleration, m_AccelerationSwayFactor, m_VelocitySwayFactor. Used by the game's serialization pipeline to persist prefab/component data.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads data from the provided reader in the same order as Serialize: reads a byte for HelicopterType, then reads the float values into the corresponding fields, and finally assigns the HelicopterType from the read byte. Used when loading prefab/component data.

Usage Example

// Create and initialize a HelicopterData instance (e.g. when constructing a prefab)
HelicopterData data = new HelicopterData
{
    m_HelicopterType = HelicopterType.Medical,
    m_FlyingMaxSpeed = 40f,
    m_FlyingAcceleration = 10f,
    m_FlyingAngularAcceleration = 5f,
    m_AccelerationSwayFactor = 0.6f,
    m_VelocitySwayFactor = 0.3f
};

// Example: attaching to an entity/prefab in an ECS context
// entityManager.AddComponentData(entity, data);

// Serialization usage is handled by the engine's IWriter/IReader implementations.
// The Serialize/Deserialize methods ensure the same read/write order so data round-trips correctly.