Skip to content

Game.Prefabs.HouseholdPetData

Assembly: Assembly-CSharp (typical)
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
Component data that represents a household pet's type for use with Unity ECS. This struct stores a single PetType value which systems can read or write to determine or modify the kind of pet associated with an entity (e.g., Dog, Cat). The PetType enum is defined elsewhere in the codebase.


Fields

  • public PetType m_Type
    The pet type stored on the component. Use this field to determine what kind of pet the entity represents (for example PetType.Dog, PetType.Cat). This is a plain value field and part of the component data, so reads/writes should respect ECS access patterns (e.g., access via Entities.ForEach, ComponentDataFromEntity, or EntityManager).

Properties

  • This type has no properties.

Constructors

  • public HouseholdPetData()
    Structs have an implicit parameterless constructor that initializes m_Type to the default value of PetType (usually the first enum value). You can also initialize using an object initializer: new HouseholdPetData { m_Type = PetType.Dog }

Methods

  • This type defines no methods.

Usage Example

// Add the component to an entity via EntityManager
var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, new HouseholdPetData { m_Type = PetType.Dog });

// Query in a system
Entities
    .ForEach((ref HouseholdPetData pet) =>
    {
        if (pet.m_Type == PetType.Cat)
        {
            // do something for cats
        }
    })
    .Schedule();

{{ This component is lightweight and intended for identifying pet types on entities. Because it implements IComponentData, store and access it using ECS-safe patterns. The IQueryTypeParameter implementation allows using the type in query descriptions when supported. }}