Skip to content

Game.Prefabs.ResidentData

Assembly:
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
ResidentData is a small ECS component (plain value type) used to attach age information to resident entities. It stores an AgeMask value (defined elsewhere in the codebase) that encodes one or more age groups for the resident. As a struct implementing IComponentData it is blittable and suitable for use in Burst-compiled jobs and Entity queries; implementing IQueryTypeParameter indicates it can be used as a typed parameter in query APIs.


Fields

  • public AgeMask m_Age
    Stores the resident's age mask. AgeMask is a bitmask/enum-like type defined elsewhere that represents age groups (e.g., child/teen/adult/senior) or combinations thereof. This field is the component payload.

Properties

  • This component defines no properties. It exposes a single public field (m_Age).

Constructors

  • public ResidentData()
    Structs have an implicit parameterless constructor. You can also initialize with an initializer syntax, e.g. new ResidentData { m_Age = someMask }.

Methods

  • This struct defines no methods.

Usage Example

// Create and add the component to an existing entity
var resident = new ResidentData { m_Age = AgeMask.Adult }; // AgeMask.* values defined elsewhere
entityManager.AddComponentData(entity, resident);

// Example with EntityCommandBuffer (for use in jobs/systems deferring structural changes)
var residentComp = new ResidentData { m_Age = AgeMask.Adult | AgeMask.Senior };
commandBuffer.AddComponent(entityInCommandBuffer, residentComp);

// Querying in a system (pseudo-example)
Entities
    .WithAll<ResidentData>()
    .ForEach((Entity e, ref ResidentData rd) =>
    {
        // read or modify rd.m_Age
    }).Schedule();