Game.Creatures.GroupCreature
Assembly: Assembly-CSharp
Namespace: Game.Creatures
Type: struct
Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable
Summary: GroupCreature is a simple buffer element used by the ECS to represent a reference to a creature Entity that belongs to a group. It implements IBufferElementData so instances can be stored in a DynamicBuffer on a "group" entity, and implements IEmptySerializable to cooperate with the game's Colossal serialization system. The struct is blittable and suitable for use in jobs and DOTS ECS contexts.
Fields
public Unity.Entities.Entity m_Creature
Holds the Entity reference for a creature that is part of the group. When stored in a DynamicBufferon a group entity, each element's m_Creature points to one member creature entity.
Properties
- This type defines no properties. It only exposes a single public field.
Constructors
public GroupCreature(Unity.Entities.Entity creature)
Constructs a GroupCreature buffer element and initializes m_Creature with the provided Entity. Useful when adding new elements to a DynamicBuffer.
Methods
- This struct declares no methods beyond the generated value-type members. Any behavior is provided by ECS systems that read/write the buffer.
Usage Example
// Example: adding a creature entity to a group's DynamicBuffer<GroupCreature>
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// assume groupEntity and creatureEntity are valid Entity instances
Entity groupEntity = /* created elsewhere */;
Entity creatureEntity = /* created elsewhere */;
// Add or get the buffer that stores group members
var buffer = entityManager.AddBuffer<Game.Creatures.GroupCreature>(groupEntity);
// Add the creature to the group's buffer
buffer.Add(new Game.Creatures.GroupCreature(creatureEntity));
// Iterating the buffer to process members
for (int i = 0; i < buffer.Length; i++)
{
Entity member = buffer[i].m_Creature;
// operate on member...
}
Additional notes:
- Use DynamicBuffer