Skip to content

Game.Buildings.EarlyDisasterWarningDuration

Assembly: Assembly-CSharp
Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents a small ECS component used by the building/disaster systems to track when an "early disaster warning" for a building should end. The single field m_EndFrame stores the simulation frame index (uint) when the warning is considered expired. This component is serializable so the warning state can be saved/loaded, and it implements IQueryTypeParameter so it can be used in Entities queries.


Fields

  • public uint m_EndFrame
    Holds the simulation frame index at which the early disaster warning ends. Compare this value with the current simulation frame to determine whether the warning is still active (a warning is active while currentFrame < m_EndFrame).

Properties

  • This struct defines no properties.

Constructors

  • public EarlyDisasterWarningDuration()
    Structs in C# have an implicit parameterless constructor that initializes m_EndFrame to 0. You can also initialize the field directly when creating an instance:
var duration = new EarlyDisasterWarningDuration { m_EndFrame = someFrameIndex };

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_EndFrame value to the provided writer. Used when saving the component state to disk or to a serialized stream.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads m_EndFrame from the provided reader. Used when loading the component state from saved data.

Usage Example

// Create or update the component on an entity
var comp = new EarlyDisasterWarningDuration { m_EndFrame = (uint)(currentSimulationFrame + warningDurationInFrames) };
entityManager.AddComponentData(buildingEntity, comp);

// Serialization example (framework-provided writer)
void SaveComponent<TWriter>(ref EarlyDisasterWarningDuration comp, TWriter writer) where TWriter : IWriter
{
    comp.Serialize(writer);
}

// Deserialization example (framework-provided reader)
void LoadComponent<TReader>(out EarlyDisasterWarningDuration comp, TReader reader) where TReader : IReader
{
    comp = new EarlyDisasterWarningDuration();
    comp.Deserialize(reader);
}

{{ This component is intentionally minimal: a single uint frame index. When modding, compare m_EndFrame against the game's current frame counter to decide whether to show or clear a warning. Because it implements IComponentData, it can be attached to entities in the ECS world; because it implements ISerializable, it will participate in the game's save/load serialization. }}