Game.Events.FacingWeather
Assembly: Assembly-CSharp
Namespace: Game.Events
Type: struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
Summary: Represents an ECS component that marks an entity as "facing" a weather event and records the severity of that effect. This struct is used in the game's Entity Component System (ECS) to link an entity to a weather event Entity and to carry a float severity value. It implements custom serialization/deserialization via ISerializable so the component state can be saved/loaded with Colossal's serialization system.
Fields
-
public Unity.Entities.Entity m_Event
The Entity that represents the weather event affecting the owner of this component. Typically this is an entity that contains the weather event data/state. -
public System.Single m_Severity
A float in which the severity/intensity of the weather effect is stored. Higher values indicate stronger effect from the referenced weather event.
Properties
- None
Constructors
public FacingWeather(Unity.Entities.Entity _event, float severity)
Creates a FacingWeather component with the provided weather event entity and severity value. Parameters:- _event: The Entity representing the weather event.
- severity: The severity/intensity of the weather effect.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
Serializes the component fields using the provided writer. Writes the event Entity first, then the severity float. This is used by the mod/game save system to persist component state. -
public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
Deserializes the component fields from the provided reader. Reads the event Entity into m_Event and the severity float into m_Severity. Used to restore component state from saved data.
Usage Example
// Create a FacingWeather component and add it to an entity
using Unity.Entities;
using Game.Events;
// Assume entityManager is available and eventEntity is an existing Entity representing the weather event
Entity targetEntity = /* some entity */;
Entity eventEntity = /* weather event entity */;
float severity = 0.75f;
var facingWeather = new FacingWeather(eventEntity, severity);
entityManager.AddComponentData(targetEntity, facingWeather);
// Example: when serializing, the game's serializer will call Serialize(writer) on this component.
// When loading, Deserialize(reader) will reconstruct m_Event and m_Severity.