Skip to content

Game.Creatures.OwnedCreature

Assembly: Assembly-CSharp
Namespace: Game.Creatures

Type: struct

Base: System.ValueType, Unity.Entities.IBufferElementData, System.IEquatable, Colossal.Serialization.Entities.IEmptySerializable

Summary: Represents a buffer element that holds a reference to a creature entity owned by some other entity (e.g., an owner/parent entity). Marked with [InternalBufferCapacity(0)] so the buffer has no inline capacity and element storage is allocated out-of-line. The struct implements IEquatable for fast comparisons and IBufferElementData so it can be stored in a DynamicBuffer on an entity.


Fields

  • public Unity.Entities.Entity m_Creature Holds the Entity handle that identifies the owned creature. This is the primary data carried by the buffer element and is used to refer to the creature entity within ECS operations and queries. Equality and hash code are based on this field.

Properties

  • This struct exposes no properties. It only contains the public field m_Creature.

Constructors

  • public OwnedCreature(Entity creature) Constructs a new OwnedCreature buffer element containing the provided creature entity. Use this to add entries into a DynamicBuffer or to construct values for comparisons.

Methods

  • public bool Equals(OwnedCreature other) Implements IEquatable. Returns true when the m_Creature Entity value equals the other.m_Creature Entity value. Useful for quick comparisons in collections or buffer operations.

  • public override int GetHashCode() Returns the hash code of the contained Entity (m_Creature). Matches the equality semantics so the struct can be used in hashed containers consistently.

Usage Example

// Example: add a creature entity to an owner's OwnedCreature buffer
// (inside a SystemBase or otherwise with access to EntityManager)

Entity ownerEntity = /* some owner entity */;
Entity creatureEntity = /* some creature entity */;

// ensure the owner has the buffer (AddBuffer will add the DynamicBuffer if missing)
var buffer = EntityManager.GetBuffer<Game.Creatures.OwnedCreature>(ownerEntity);
buffer.Add(new Game.Creatures.OwnedCreature(creatureEntity));

// Later you can iterate:
foreach (var owned in buffer)
{
    Entity e = owned.m_Creature;
    // operate on creature entity e
}