Game.Prefabs.HelicopterPrefab
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: AircraftPrefab
Summary:
HelicopterPrefab is a prefab class used by Cities: Skylines 2 to configure helicopter-type aircraft. It exposes tuning parameters (speeds, accelerations and sway factors) and wires up entity component data for runtime use. During Initialize it populates a HelicopterData component (converting units where appropriate) and the class declares which components/archetypes it requires. The mod tag enumeration includes the helicopter type (from HelicopterType) in addition to any tags provided by the base prefab.
Fields
-
public float m_FlyingMaxSpeed = 250f
Maximum flying speed expressed in km/h in the prefab. Note: during initialization this value is converted to m/s (divided by 3.6) before being stored into HelicopterData.m_FlyingMaxSpeed. -
public float m_FlyingAcceleration = 10f
Linear acceleration used by the helicopter (units preserved as-is into HelicopterData.m_FlyingAcceleration). -
public float m_FlyingAngularAcceleration = 10f
Angular acceleration expressed in degrees per second^2 in the prefab. During Initialize it is converted to radians (using math.radians) before being stored into HelicopterData.m_FlyingAngularAcceleration. -
public float m_AccelerationSwayFactor = 0.5f
Factor controlling how much acceleration affects visual or physics sway; passed directly into HelicopterData.m_AccelerationSwayFactor. -
public float m_VelocitySwayFactor = 0.7f
Velocity sway tuning value stored on HelicopterData as a per-m/s factor. In Initialize this prefab value is divided by the (converted) flying max speed so the stored value is normalized relative to speed.
Properties
public override IEnumerable<string> modTags { get; }
Returns enumerable of mod tags for this prefab. It yields all base.modTags and then adds a string representation of the HelicopterType returned by GetHelicopterType(). Useful for categorizing or filtering prefabs by helicopter type.
Constructors
public HelicopterPrefab()
Default constructor (no explicit constructor declared in source). Field initializers provide default tuning values shown above.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds all component types required by this prefab. Calls base.GetPrefabComponents(components) and then addsComponentType.ReadWrite<HelicopterData>()
. This tells the prefab system that instantiated entities will include HelicopterData. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds ECS archetype components needed at entity creation. Calls base.GetArchetypeComponents(components) and then addsComponentType.ReadWrite<Helicopter>()
. Ensures the entity archetype includes the Helicopter tag/component. -
public override void Initialize(EntityManager entityManager, Entity entity)
Initializes the entity's HelicopterData component using prefab fields: - Sets m_HelicopterType = GetHelicopterType().
- Converts m_FlyingMaxSpeed from km/h to m/s (divides by 3.6) and assigns to HelicopterData.m_FlyingMaxSpeed.
- Copies m_FlyingAcceleration into HelicopterData.m_FlyingAcceleration.
- Converts m_FlyingAngularAcceleration from degrees to radians (math.radians) and assigns to HelicopterData.m_FlyingAngularAcceleration.
- Copies m_AccelerationSwayFactor.
- Normalizes m_VelocitySwayFactor by dividing by the converted FlyingMaxSpeed and stores into HelicopterData.m_VelocitySwayFactor.
-
Writes the filled HelicopterData to the entity via entityManager.SetComponentData(entity, componentData).
-
protected virtual HelicopterType GetHelicopterType()
Returns the HelicopterType for this prefab. The base implementation returns HelicopterType.Helicopter. Override this in derived prefab classes to provide different helicopter types (the return value is also added to the prefab's modTags).
Usage Example
// Example subclass that defines a different helicopter type and adjusts defaults
[ExcludeGeneratedModTag]
[ComponentMenu("Vehicles/", new Type[] { })]
public class MedicalHelicopterPrefab : HelicopterPrefab
{
public MedicalHelicopterPrefab()
{
// override defaults defined in base prefab
m_FlyingMaxSpeed = 220f; // km/h, will be converted to m/s during Initialize
m_FlyingAcceleration = 12f;
m_FlyingAngularAcceleration = 14f; // degrees per second^2, converted to radians
}
protected override HelicopterType GetHelicopterType()
{
return HelicopterType.Medical;
}
}
Notes and tips: - Be aware of unit conversions performed in Initialize: max speed (km/h -> m/s) and angular acceleration (degrees -> radians). If you edit the prefab fields, adjust for those conversions. - Adding or changing modTags can help your prefab be discoverable by systems that filter prefabs by mod tags. The prefab automatically appends the helicopter type string. - Ensure your prefab adds the corresponding ECS components (HelicopterData and Helicopter) via the GetPrefabComponents/GetArchetypeComponents hooks so entities are created with the correct data.