Skip to content

Game.Prefabs.CreatureData

Assembly:
Assembly-CSharp (typical for Unity game/mod assemblies; replace with the correct assembly if different)
Namespace: Game.Prefabs

Type:
struct

Base:
IComponentData, IQueryTypeParameter

Summary:
Component data struct used by the ECS to represent simple metadata for a creature prefab: which activities the creature supports and its gender. Intended to be attached to entities representing creature prefabs so systems can query and react based on supported activities and gender. ActivityMask and GenderMask are bitmask/enum-like types (flags) used to represent multiple possible values compactly.


Fields

  • public ActivityMask m_SupportedActivities
    Bitmask/flags describing which activities this creature supports (for example: walking, eating, sleeping, etc.). Systems can test bits in this mask to determine if a creature can perform or be assigned particular activities.

  • public GenderMask m_Gender
    Mask or enum value indicating the creature's gender (for example: Male, Female, Other, or combinations if represented as flags). Used for gender-specific logic in AI, spawning, or animation selection.

Properties

  • None
    This struct exposes only public fields and does not define properties. Use the fields directly when reading or writing component data.

Constructors

  • public CreatureData()
    Default value-type constructor (auto-generated). Initialize fields inline when creating an instance, e.g.: new CreatureData { m_SupportedActivities = ActivityMask.None, m_Gender = GenderMask.Unknown }

Methods

  • None
    This component is a plain data container (POD) with no methods. All behavior should be implemented in systems that read/write this component.

Usage Example

// Add component to an existing entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var creatureComponent = new CreatureData
{
    m_SupportedActivities = ActivityMask.Walk | ActivityMask.Eat, // example flags
    m_Gender = GenderMask.Male
};
entityManager.AddComponentData(someCreatureEntity, creatureComponent);

// Query in a system (example using SystemBase)
protected override void OnUpdate()
{
    Entities
        .WithAll<CreatureData>()
        .ForEach((ref CreatureData creature) =>
        {
            // Check if creature supports a specific activity
            if ((creature.m_SupportedActivities & ActivityMask.Eat) != 0)
            {
                // schedule or assign eating task
            }

            // Inspect gender
            if (creature.m_Gender == GenderMask.Female)
            {
                // do gender-specific logic
            }
        }).ScheduleParallel();
}

Notes: - Replace ActivityMask/GenderMask values with the actual enum/flag members defined in the project. - As a plain IComponentData, this struct should remain small and trivially copyable for ECS performance.