Game.Buildings.FirewatchTower
Assembly:
Game (assembly containing runtime components for Cities: Skylines II)
Namespace:
Game.Buildings
Type:
struct (value type)
Base:
Implements: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
Represents a lightweight ECS component that marks a building entity as a firewatch tower and stores its state flags. The component provides custom binary serialization by writing the underlying FirewatchTowerFlags value as a single byte. This struct is intended for use in Unity's DOTS-style entity systems used by Cities: Skylines II modding.
Fields
public FirewatchTowerFlags m_Flags
Stores the current flags/state for the firewatch tower. The value is serialized as a single byte in Serialize/Deserialize. The FirewatchTowerFlags enum is expected to be defined elsewhere in the codebase and should fit within a byte.
Properties
- (none)
Constructors
public FirewatchTower()
Implicit default constructor provided by C#. Creates a FirewatchTower with default-initialized m_Flags (usually zero / default enum value).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component state to a generic writer. The implementation casts m_Flags to byte and writes that single byte. This compact representation is suitable for on-disk or network storage where the enum fits within one byte. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component state from a generic reader. The implementation reads a single byte, then casts it back to FirewatchTowerFlags and stores it in m_Flags. Ensure the reader provides the same byte-order/format expected by the writer.
Usage Example
// Add the component to an entity and set flags (replace FirewatchTowerFlags.None with appropriate enum value)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity(typeof(Game.Buildings.FirewatchTower));
entityManager.SetComponentData(entity, new Game.Buildings.FirewatchTower {
m_Flags = FirewatchTowerFlags.None // use the appropriate enum member
});
// When implementing custom save/load code that uses IWriter/IReader:
// writer.Write((byte)component.m_Flags);
// reader.Read(out byte value); component.m_Flags = (FirewatchTowerFlags)value;
Additional notes: - The struct implements IQueryTypeParameter to allow it to be used in entity query/type parameter contexts in DOTS systems. - The explicit Serialize/Deserialize implementation means the component controls its binary layout; changes to FirewatchTowerFlags size or semantics must be coordinated with serialization code. - File path/location: Game\Buildings\FirewatchTower.cs