Game.SchoolSeeker
Assembly:
Namespace: Game.Citizens
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: A lightweight ECS component that marks an entity (typically a citizen) as seeking a school. It stores a simple integer level (m_Level) used by game logic to determine which school level/type the citizen is looking for. Implements ISerializable so the value is persisted by the game's serialization system, and IQueryTypeParameter so it can be used in entity queries.
Fields
public int m_Level
Holds the numeric school level or category the entity is seeking. The concrete interpretation (e.g., primary/secondary/college or priority weight) is determined by surrounding game logic. This value is serialized and deserialized by the implemented ISerializable methods.
Properties
- None
This struct exposes its data via the public field m_Level rather than properties.
Constructors
- Implicit default constructor (public SchoolSeeker())
As a C# struct, SchoolSeeker has an implicit parameterless constructor which initializes m_Level to 0. If you need a different default, construct with an explicit initializer: new SchoolSeeker { m_Level = X }.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Level value to the provided writer so the component's state can be saved. This method is invoked by the game's serialization pipeline. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads m_Level from the provided reader to restore the component's state during load operations.
Both methods are simple and only (de)serialize the single integer field.
Usage Example
// Add the component to an entity with a specific school level
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity citizen = /* obtain or create entity */;
entityManager.AddComponentData(citizen, new SchoolSeeker { m_Level = 1 });
// Example of manual serialization call (normally handled by the engine)
var seeker = new SchoolSeeker { m_Level = 2 };
// TWriter would be provided by the game's serialization system in practice
// seeker.Serialize(writer);
// Example of reading back (normally handled by the engine)
// seeker.Deserialize(reader);