Skip to content

Game.Agents.JobSeeker

Assembly:
Namespace: Game.Agents

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: JobSeeker is a lightweight ECS component that tags an agent as a job seeker and stores two small pieces of state: - m_Level: a byte representing the job/education level or tier of the seeker. - m_Outside: a byte used as a boolean-like flag indicating whether the agent is from outside the city/region. The component implements ISerializable to control what is persisted; only m_Level is serialized. It can be used in queries (IQueryTypeParameter) and as typical Unity.Entities IComponentData.


Fields

  • public byte m_Level Represents the job/education level/tier of the job seeker. Range 0–255 (byte). This field is the only one written to the game's serializer by the component's Serialize implementation.

  • public byte m_Outside A byte used effectively as a boolean flag indicating if the agent comes from outside (e.g., commuter/outsider). Note: this field is not serialized by this type's ISerializable implementation, so its value will not be persisted / restored by the provided Serialize/Deserialize methods.

Properties

  • (none)

Constructors

  • (implicit) default struct constructor As a struct there is no explicit constructor defined; you can initialize it using object initializer syntax or by assignment. Example: new JobSeeker { m_Level = 2, m_Outside = 0 }.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Serializes the component state into the provided writer. Implementation writes only m_Level: writer.Write(m_Level); This means m_Outside is omitted from persistence; if you need to persist that flag you must modify the Serialize/Deserialize implementations.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Deserializes component state from the provided reader. Implementation reads only m_Level: reader.Read(out m_Level); m_Outside is left untouched by deserialization.

Usage Example

// Add component to an entity
var jobSeeker = new Game.Agents.JobSeeker {
    m_Level = 3,     // e.g. skilled worker
    m_Outside = 0    // local resident
};
entityManager.AddComponentData(entity, jobSeeker);

// Query example (pseudo-code using Entities API)
Entities
    .WithAll<Game.Agents.JobSeeker>()
    .ForEach((ref Game.Agents.JobSeeker seeker) => {
        // use seeker.m_Level and seeker.m_Outside
    }).Run();