Game.Prefabs.PetData
Assembly: Assembly-CSharp (or the mod/game assembly that defines Game.Prefabs)
Namespace: Game.Prefabs
Type: public struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
PetData is a lightweight ECS component that stores a pet classification for an entity (for example, the species or category of a pet). It's a blittable value type intended to be attached to Entities so systems can read or filter by pet type. The field is typically an enum (PetType) defined elsewhere in the codebase; ensure PetType is a blittable enum to keep this component safe for DOTS usage.
Fields
public PetType m_Type
Holds the pet's type/category. Usually an enum (e.g., Dog, Cat, Bird). Default value is the enum default (usually the 0-value) if the struct is default-constructed. The "m_" prefix follows the codebase naming convention.
Properties
- This type defines no properties.
The component exposes a raw field only (m_Type). Use the field directly when reading/writing in jobs or systems.
Constructors
public PetData()
Structs get a default parameterless constructor that initializes m_Type to the default enum value. You can also construct with an object initializer:new PetData { m_Type = PetType.Dog }
Methods
- This type defines no methods.
Being a plain IComponentData, behavior is implemented in systems that read/write this component.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Add the component to an entity
var pet = new PetData { m_Type = PetType.Dog };
entityManager.AddComponentData(entity, pet);
// Read or modify in a system (example using Entities.ForEach style)
Entities
.WithAll<PetData>()
.ForEach((ref PetData petData) =>
{
if (petData.m_Type == PetType.Cat)
{
// do cat-specific logic
}
}).Run();
Additional notes: - Because PetData implements IComponentData, it is intended for use with Unity's DOTS/ECS systems and jobs. Keep the component small and blittable. - IQueryTypeParameter allows the type to be used in query declarations/filters; check your Entities API version for exact query usage patterns.