Game.Prefabs.ChirpData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
ChirpData is a small ECS component that carries data required for creating or identifying "chirp" prefabs in the game. It stores a cached archetype used when instantiating chirp entities, a flags field for configurable behavior, and an Entity reference to the account that produced the chirp. The struct is intended to be attached to prefab or manager entities and read by systems that spawn or manage chirps.
Fields
-
public EntityArchetype m_Archetype
Stores the EntityArchetype representing the components/layout used for spawned chirp entities. Systems that create chirps can cache and reuse this to avoid recreating archetypes repeatedly. -
public ChirpDataFlags m_Flags
A bitmask/enum describing options or states for this chirp prefab (e.g., persistence, visibility, networked behavior). The exact members are defined in the ChirpDataFlags enum elsewhere in the codebase. -
public Entity m_ChirperAccount
Entity reference to the account (player, AI, or system) that originated the chirp. Used for ownership, attribution, or permission checks. Entity.Null indicates no owner.
Properties
- This type does not define any C# properties. It is a plain IComponentData struct with public fields.
Constructors
public ChirpData()
Default parameterless constructor (struct default). Fields are value-initialized: m_Archetype set to default(EntityArchetype), m_Flags to default(ChirpDataFlags), and m_ChirperAccount to Entity.Null (or default Entity). When creating instances, explicitly set fields to the intended values.
Methods
- This type does not declare any methods. It is used purely as a data container for ECS systems.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Example: create a prefab entity and attach ChirpData to it
void CreateChirpPrefab(EntityManager entityManager, Entity chirperAccount)
{
// Create or obtain an archetype suitable for a chirp entity.
// Replace the component types below with the real components used by chirps.
EntityArchetype chirpArchetype = entityManager.CreateArchetype(
typeof(Translation), typeof(Rotation), /* ... other chirp components ... */);
// Create a prefab or manager entity to hold the ChirpData
Entity prefabEntity = entityManager.CreateEntity();
entityManager.AddComponentData(prefabEntity, new ChirpData
{
m_Archetype = chirpArchetype,
m_Flags = ChirpDataFlags.None, // choose appropriate flags
m_ChirperAccount = chirperAccount
});
}
// Example: reading ChirpData inside a system
public partial struct ChirpSpawnSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
// Iterate over entities that have ChirpData
var em = state.EntityManager;
state.Entities.ForEach((ref ChirpData data) =>
{
if (data.m_ChirperAccount != Entity.Null)
{
// Use data.m_Archetype to create instances, inspect flags, etc.
}
}).Schedule();
}
}
Notes: - Implementing IQueryTypeParameter allows this type to be referenced in compile-time query constructs (e.g., using Entities/EntityQuery APIs). - Keep in mind ECS data layout rules: store only data required at runtime. If you merely need to reference a prefab instance, consider storing an Entity prefab instead of an archetype depending on how instances are created in your systems.