Skip to content

Game.EffectData

Assembly:
Assembly-CSharp (Unity project default)

Namespace:
Game.Prefabs

Type:
struct EffectData

Base:
IComponentData, IQueryTypeParameter

Summary:
Component data used to describe a spawnable effect prefab in the game's ECS. Contains an EntityArchetype to define the entity layout used when creating effect instances, a set of flags describing when/how the effect should play (EffectCondition), and a boolean controlling whether the effect should be culled for the owning entity (owner culling). This struct is intended to be attached to entities or used as a query parameter to drive effect instantiation and lifetime management inside systems.


Fields

  • public Unity.Entities.EntityArchetype m_Archetype
    Archetype describing the set of components that should be used when instantiating the effect entity. Typically created via EntityManager.CreateArchetype and used with EntityManager.CreateEntity or similar APIs to spawn the runtime effect.

  • public EffectCondition m_Flags
    Flags (likely an enum) that control when and how the effect is applied. This typically encodes conditions such as visibility checks, trigger types, or other effect-specific behaviours. (EffectCondition is defined elsewhere in the codebase.)

  • public bool m_OwnerCulling
    When true, the effect should be culled/hidden for the owning entity (for example, to avoid showing a local player's own special effect). When false, the effect is shown to the owner as well.

Properties

  • None declared on this struct. (Being a plain public struct, it only exposes the public fields above.)

Constructors

  • No explicit constructors are declared.
    The struct uses the default value-type constructor provided by C#. Initialize fields via object initializer or by setting them directly.

Methods

  • No methods are declared on this struct. It is a plain data container used by systems and entity managers.

Usage Example

// Example usage inside a ComponentSystem or SystemBase to register an archetype and attach EffectData to an entity.
protected override void OnCreate()
{
    base.OnCreate();

    // Create an archetype for the effect entities (components here are examples; replace with real ones).
    var effectArchetype = EntityManager.CreateArchetype(
        typeof(Unity.Transforms.LocalToWorld),
        typeof(SomeEffectComponent),
        typeof(Unity.Rendering.RenderMesh)
    );

    // Configure the EffectData for a prefab or manager entity
    var effectData = new EffectData
    {
        m_Archetype = effectArchetype,
        m_Flags = EffectCondition.VisibleToAll, // example flag value; replace with actual enum member
        m_OwnerCulling = true
    };

    // Create an entity to hold the effect metadata (or attach to a prefab/manager entity)
    var metaEntity = EntityManager.CreateEntity();
    EntityManager.AddComponentData(metaEntity, effectData);

    // Later, to spawn an effect instance, use the saved archetype:
    var instance = EntityManager.CreateEntity(effectData.m_Archetype);
    // Initialize instance components as needed...
}