Skip to content

Game.Citizens.SchoolSeekerCooldown

Assembly: Assembly-CSharp (Cities: Skylines 2)
Namespace: Game.Citizens

Type: struct

Base: System.ValueType; implements IComponentData, IQueryTypeParameter, ISerializable

Summary: A small Unity ECS component used by the citizens system to track a cooldown (in simulation frames) for "school seeker" behavior. Stored per-entity, the component holds a simulation-frame timestamp used to determine when a citizen may next try to seek a school. It implements ISerializable so its single field is persisted by the game's save/load serialization pipeline.


Fields

  • public System.UInt32 m_SimulationFrame Holds the simulation frame value used as the cooldown marker. Typically this is the frame until which the citizen should not attempt to find/seek a school. The value is written and read during serialization.

Properties

  • None. This struct exposes a plain public field for compact ECS storage.

Constructors

  • public SchoolSeekerCooldown()
    The type has the default value-type constructor (zero-initialized). You can set m_SimulationFrame after creating the struct. Example convenience constructor is not defined in-game, but you can create one yourself when assigning the component.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_SimulationFrame value into the provided writer for persistence. The method is generic and constrained to writers implementing the game's IWriter interface.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the m_SimulationFrame value from the provided reader during load. The method is generic and constrained to readers implementing the game's IReader interface.

Implements IComponentData and IQueryTypeParameter so this struct can be attached to entities and used directly in ECS queries. Implements ISerializable to participate in the save/load system.

Usage Example

// Add or set the component on an entity (example in a system)
var cooldown = new SchoolSeekerCooldown { m_SimulationFrame = currentSimulationFrame + cooldownDuration };
entityManager.SetComponentData(someCitizenEntity, cooldown);

// Reading the component in a system
var citizenCooldown = entityManager.GetComponentData<SchoolSeekerCooldown>(someCitizenEntity);
if (currentSimulationFrame >= citizenCooldown.m_SimulationFrame) {
    // Citizen can attempt to seek school again
}

// Serialization is handled by the game's IWriter/IReader system via the component's Serialize/Deserialize methods.
// Example pseudocode for a custom save (the game provides actual writer/reader implementations):
// writer.Write(citizenCooldown.m_SimulationFrame);
// reader.Read(out citizenCooldown.m_SimulationFrame);

Notes: - Keep the field as a simple uint to remain efficient in ECS archetypes and serialization. - When creating custom systems that modify this component, ensure to update the m_SimulationFrame consistently with the game's simulation frame counter.