Game.Buildings.BuildingNotifications
Assembly: Assembly-CSharp
Namespace: Game.Buildings
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: Represents the set of active notifications for a building as a flagged enum value. This struct is an ECS component (IComponentData) that stores a BuildingNotification bitfield, supports serialization for save/load, and can be used as a query parameter (IQueryTypeParameter) in systems that operate on building notification state. The notification value is serialized as a single byte.
Fields
public BuildingNotification m_Notifications
Stores the current notifications for the building as a BuildingNotification flagged enum. Each bit represents a different notification type. Default value is the enum's zero value (no notifications).
Properties
- (none)
This struct exposes its data via the public field m_Notifications; there are no properties.
Constructors
- (implicit) public BuildingNotifications()
The default value-type constructor initializes m_Notifications to the default value of the BuildingNotification enum (typically zero — no notifications).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the notification flags to the provided writer. The implementation writes the m_Notifications enum cast to a single byte. Intended for save/load serialization via Colossal.Serialization.Entities. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes a byte from the provided reader and casts it back to the BuildingNotification enum, restoring the component's notification state. -
public bool HasNotification(BuildingNotification notification)
Checks whether the specified notification flag(s) are set in m_Notifications. Returns true if any of the bits in the passed notification value are present in m_Notifications.
Usage Example
// Example usage in a system or manager
// Set notifications
var comp = new BuildingNotifications();
comp.m_Notifications = BuildingNotification.Fire | BuildingNotification.Crime; // example flags
// Check for a specific notification
if (comp.HasNotification(BuildingNotification.Fire))
{
// react to fire notification (e.g., dispatch fire trucks)
}
// Serialization is handled by the ECS save/load pipeline via Serialize/Deserialize.
// The component will be written/read as a single byte representing the flag set.
[Note: BuildingNotification is a flagged enum defined elsewhere and may include values such as Fire, Crime, PowerOutage, etc.]