Skip to content

Game.Buildings.Abandoned

Assembly: Assembly-CSharp.dll
Namespace: Game.Buildings

Type: struct

Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable

Summary: This struct is an ECS component used to mark a building as abandoned and to store the time at which abandonment occurred. It is serializable so that the abandonment time is preserved across save/load. The single field is a uint timestamp (the exact time unit is determined by the game's simulation/tick system and is not defined in this file).


Fields

  • public uint m_AbandonmentTime Holds the recorded time when the building became abandoned. The code uses a uint; interpretation of this value (seconds, ticks, frame count, etc.) depends on the broader simulation code. This field is saved/loaded via the struct's ISerializable implementation.

Properties

  • None. This struct exposes a single public field and no C# properties.

Constructors

  • Implicit default constructor (value-type/struct default) Structs have an implicit default constructor that initializes m_AbandonmentTime to 0. There is no explicit constructor defined in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes the m_AbandonmentTime value using the provided writer. The writer is expected to implement the IWriter interface from the game's serialization system. This method ensures the component's state is written into the save stream.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads m_AbandonmentTime from the provided reader. The reader must implement the IReader interface. This restores the saved abandonment timestamp when loading a saved game.

Usage Example

// Mark an entity as abandoned and set the abandonment time:
var abandoned = new Game.Buildings.Abandoned {
    m_AbandonmentTime = (uint)simulationTime // simulationTime: value from your time/tick source
};
entityManager.AddComponentData(entity, abandoned);

// Read the field later in a System:
if (entityManager.HasComponent<Game.Buildings.Abandoned>(entity))
{
    var comp = entityManager.GetComponentData<Game.Buildings.Abandoned>(entity);
    uint when = comp.m_AbandonmentTime;
    // use 'when' to decide cleanup, visual changes, etc.
}

// Serialization is handled by the game's save system via the ISerializable implementation.
// Example conceptual usage (actual writer/reader types come from the game's serialization API):
// writer.Write(comp.m_AbandonmentTime);
// reader.Read(out comp.m_AbandonmentTime);