Skip to content

Game.Creatures.GroupMember

Assembly: Assembly-CSharp.dll
Namespace: Game.Creatures

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a creature group member component that stores a reference to the group's leader Entity. Designed for use with Unity's ECS (Unity.Entities) and Colossal's serialization system so the leader reference can be saved/loaded with the component.


Fields

  • public Unity.Entities.Entity m_Leader
    Holds the Entity that acts as this member's leader. This is the key piece of data for grouping creatures. When a GroupMember is constructed with a leader Entity, this field is initialized accordingly. If not set explicitly, it will have the default Entity value (Entity.Null).

Properties

  • None

Constructors

  • public GroupMember(Unity.Entities.Entity leader)
    Initializes a GroupMember instance and sets m_Leader to the provided leader Entity. Note that as a C# struct there is also an implicit parameterless default constructor which yields default values (m_Leader == Entity.Null).

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the leader Entity to the provided writer using writer.Write(m_Leader). Used by the Colossal.Serialization.Entities system to persist this component's leader reference.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the leader Entity from the provided reader into m_Leader using reader.Read(out m_Leader). Used by the Colossal.Serialization.Entities system to restore this component's leader reference.

Usage Example

// Create or obtain Entities and an EntityManager (or SystemBase.EntityManager)
Entity leader = /* obtain leader Entity */;
Entity memberEntity = entityManager.CreateEntity();

// Add the GroupMember component to an entity, pointing to the leader
entityManager.AddComponentData(memberEntity, new GroupMember(leader));

// Read the component back
GroupMember gm = entityManager.GetComponentData<GroupMember>(memberEntity);
Entity currentLeader = gm.m_Leader;

// Serialization example (pseudo, depends on actual writer/reader usage in your mod)
var writer = /* obtain a TWriter implementing IWriter */;
gm.Serialize(writer);

// Deserialization example
GroupMember loaded = default;
var reader = /* obtain a TReader implementing IReader */;
loaded.Deserialize(reader);
// now loaded.m_Leader contains the deserialized leader Entity