Game.Simulation.AtmosphereData
Assembly: Game
Namespace: Game.Simulation
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
AtmosphereData is a small ECS component that holds a reference to an atmosphere prefab Entity. It is intended for use with the Unity Entities (ECS) world in Cities: Skylines 2 to associate an atmosphere prefab with an entity, and supports Colossal's serialization system so the reference is saved/loaded with game data.
Fields
public Unity.Entities.Entity m_AtmospherePrefab
Holds the Entity reference to the atmosphere prefab. This is the prefab that will be instantiated or used by systems that manage atmosphere visuals or simulation. It is stored as an Entity handle (not a GameObject).
Properties
- This type has no properties.
Constructors
public AtmosphereData(Unity.Entities.Entity prefab)
Initializes the component with the provided prefab Entity. Use this constructor to create a component instance before adding it to an entity.
Methods
-
public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
Reads the stored Entity reference from the provided reader. This implements ISerializable deserialization so that the atmosphere prefab reference is restored when loading saved game data. -
public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
Writes the stored Entity reference to the provided writer. This implements ISerializable serialization so that the atmosphere prefab reference is persisted when saving game data.
Usage Example
// Example: create an AtmosphereData and attach it to an entity using an EntityManager
// (assumes 'entityManager' and 'atmospherePrefabEntity' are available in your system/context)
var atmosphereData = new AtmosphereData(atmospherePrefabEntity);
// Create a new entity that will use this atmosphere (or use an existing entity)
Entity atmosphereOwner = entityManager.CreateEntity();
// Add the AtmosphereData component to the entity
entityManager.AddComponentData(atmosphereOwner, atmosphereData);
// Systems that query for AtmosphereData can now access m_AtmospherePrefab and instantiate/use the prefab.
Notes: - Because AtmosphereData implements ISerializable, Colossal's save/load pipeline will call Serialize/Deserialize for this component automatically when persisting world state. - As an IComponentData, AtmosphereData is intended for use with Unity.Entities systems and jobs; treat the contained Entity as an identifier/reference rather than a managed object.