Skip to content

Game.Effects.EnabledEffectData

Assembly:
Assembly-CSharp (typical for Cities: Skylines 2 game code / mods)
Namespace: Game.Effects

Type: struct

Base: System.ValueType

Summary: Lightweight data container used to represent an enabled/active effect in the ECS-based effect system. Instances of EnabledEffectData are attached to entities (as a component-like data struct) to tell the effect system which effect prefab to instantiate or update, where to place it, and how it should behave (scale, rotation, intensity, scheduling). This struct is intended to be processed by effect systems/systems groups that spawn, update and remove runtime visual or audio effects.


Fields

  • public Entity m_Owner Owner entity that requested or owns the effect. Can be used to follow the owner, to query owner-specific state, or to resolve lifetime/cleanup when the owner is destroyed.

  • public Entity m_Prefab Entity that represents the effect prefab to instantiate (usually an entity pointing to a visual/audio effect archetype). The effect system will use this prefab to create the runtime effect instance.

  • public int m_EffectIndex Index identifying which sub-effect or variation inside the prefab should be used. Useful when one prefab contains multiple effect entries and you need to select a specific one.

  • public EnabledEffectFlags m_Flags Flags controlling behavior of the enabled effect (looping, follow-owner, single-shot, networked, etc.). See the EnabledEffectFlags enum definition for exact flag values and semantics. This field is used by effect systems to modify spawn/update logic.

  • public float3 m_Position Position where the effect should be placed. Interpreted in the coordinate space expected by the effect system (usually world-space). If the effect follows an owner, this can be treated as a local offset.

  • public float3 m_Scale Scale to apply to the spawned effect. Allows scaling of visual/audio intensity or size.

  • public quaternion m_Rotation Rotation/orientation for the spawned effect. Used to orient directional effects correctly when instantiated.

  • public float m_Intensity Intensity multiplier for the effect (used for audio volume, particle emission rate, brightness, etc., depending on the effect implementation).

  • public float m_NextTime Next scheduled time for the effect to update, re-trigger, or expire. Typically used by systems that schedule periodic updates or delayed playback.

Properties

  • None
    This struct contains public fields only and exposes no properties.

Constructors

  • public EnabledEffectData()
    Default parameterless constructor (value-type default). All fields will have their default values (Entity = default, numeric types = 0, quaternion = identity if explicitly set otherwise default, etc.). For convenience and clarity, create and initialize instances with an object initializer or helper factory.

Suggested helper constructor (example — not present in original source):

public EnabledEffectData(Entity owner, Entity prefab, int effectIndex,
                         EnabledEffectFlags flags, float3 position,
                         quaternion rotation, float3 scale, float intensity, float nextTime)
{
    m_Owner = owner;
    m_Prefab = prefab;
    m_EffectIndex = effectIndex;
    m_Flags = flags;
    m_Position = position;
    m_Rotation = rotation;
    m_Scale = scale;
    m_Intensity = intensity;
    m_NextTime = nextTime;
}

Methods

  • None
    This type is a plain data container with no methods. Behavior and lifecycle are handled by separate systems that read and act on EnabledEffectData.

Usage Example

// Example: Add an enabled effect component to an entity using EntityManager
var enabledEffect = new EnabledEffectData
{
    m_Owner = ownerEntity,
    m_Prefab = effectPrefabEntity,
    m_EffectIndex = 0,
    m_Flags = EnabledEffectFlags.None, // or EnabledEffectFlags.Loop | EnabledEffectFlags.FollowOwner
    m_Position = new float3(0f, 1.5f, 0f), // world position or local offset
    m_Rotation = quaternion.identity,
    m_Scale = new float3(1f, 1f, 1f),
    m_Intensity = 1.0f,
    m_NextTime = 0f // immediate
};

entityManager.AddComponentData(targetEntity, enabledEffect);

// Effect system will read EnabledEffectData from targetEntity and spawn/update the effect accordingly.

Notes: - Check the EnabledEffectFlags enum in the codebase to understand available flags and their effects. - The effect lifetime and cleanup are typically handled by the effect system; ensure you set flags or update m_NextTime appropriately for one-shot vs. looping effects. - When using with Unity ECS, ensure the target entity has the correct archetype/components expected by the effect system (for example marker components or tag components).