Skip to content

Game.Areas.Area

Assembly: Assembly-CSharp (game runtime assembly)

Namespace: Game.Areas

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents an area record used by the game's ECS (Entity Component System). This struct stores flags describing the state and properties of an area (AreaFlags). It implements serialization so it can be persisted and restored; deserialization contains a compatibility fix that ensures older saved data gets the Complete flag when the save version is older than Version.mapTileCompleteFix.


Fields

  • public AreaFlags m_Flags Stores the bitwise AreaFlags for this area instance. Flags encode area properties (for example whether the area is complete, active, or has other state markers). This value is read/written during serialization and is the primary state carried by the Area component.

Properties

  • This type has no properties.

Constructors

  • public Area(AreaFlags flags) Initializes a new Area with the provided AreaFlags value. Typical usage sets the initial state of the area when creating the component.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes the area state to a writer. Implementation serializes m_Flags as a single byte (casts AreaFlags to byte) for compact storage.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads the area state from a reader. Implementation:

  • Reads a single byte into a local value and casts it back to AreaFlags for m_Flags.
  • Applies a compatibility fix: if reader.context.version is older than Version.mapTileCompleteFix, the method forces the AreaFlags.Complete bit on (m_Flags |= AreaFlags.Complete). This ensures older save formats are interpreted as "complete" where the older format didn't store that bit explicitly.

Usage Example

// Example: creating an Area and (conceptually) serializing/deserializing it.
// IWriter and IReader are framework types used by the game's serialization system.

Area area = new Area(AreaFlags.None);

// Serializing
// TWriter would be a concrete writer type provided by the game's serialization framework.
// writer.Write((byte)area.m_Flags); is what Serialize does internally.
// e.g. myWriter.Use(w => area.Serialize(w));

// Deserializing
// TReader would be a concrete reader type; after reading, older versions will get the Complete flag applied.
// e.g. myReader.Use(r => { Area loaded = new Area(); loaded.Deserialize(r); /* use loaded */ });