Skip to content

Game.Prefabs.Climate.WeatherOverride

Assembly: Assembly-CSharp (typical)
Namespace: Game.Prefabs.Climate

Type: class

Base: ComponentBase

Summary:
Component used on weather prefabs to declare and wire up placeholder weather prefabs (WeatherPrefab). It exposes an array of WeatherPrefab placeholders that are treated as dependencies for the prefab system. At initialization it registers this prefab as a placeholder target by adding a PlaceholderObjectElement referencing this entity into each placeholder prefab's buffer. It also declares that prefabs using this component require the SpawnableObjectData component.


Fields

  • public WeatherPrefab[] m_Placeholders
    Array of WeatherPrefab references that act as placeholders/slots for this weather prefab. These entries are added to the prefab dependency list (GetDependencies) and are used during LateInitialize to obtain the placeholder entities and add this prefab's entity to their PlaceholderObjectElement buffers.

Properties

  • (none declared)
    This class does not declare any properties. It relies on inherited behavior from ComponentBase.

Constructors

  • public WeatherOverride()
    Default parameterless constructor (implicit). No custom construction logic is defined in the source.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds all WeatherPrefab entries from m_Placeholders to the supplied prefabs list so the prefab system knows these prefabs must be available/loaded as dependencies.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the set of components required by the prefab. This ensures entities spawned from the prefab will include SpawnableObjectData.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    No archetype components are added by this component (method intentionally empty).

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    After the prefab entity has been created, this method:

  • Retrieves the PrefabSystem from the EntityManager's World.
  • For each WeatherPrefab in m_Placeholders, gets the corresponding entity for that prefab.
  • Adds a PlaceholderObjectElement pointing back to this prefab's entity into the placeholder prefab entity's buffer. This registers this prefab as a candidate for that placeholder.

Notes: Uses EntityManager, PrefabSystem, PlaceholderObjectElement buffer, and assumes placeholder prefabs are represented as entities managed by PrefabSystem.

Usage Example

// Example: a prefab component that references WeatherPrefabs via the inspector.
// The prefab system will call GetDependencies and LateInitialize automatically.

[ComponentMenu("Weather/", new Type[] { typeof(WeatherPrefab) })]
public class WeatherOverride : ComponentBase
{
    public WeatherPrefab[] m_Placeholders;

    // ... (methods from source) ...
}

// At runtime (handled by prefab system):
// - GetDependencies will ensure the referenced WeatherPrefab prefabs are loaded.
// - LateInitialize will add this prefab entity to each placeholder's PlaceholderObjectElement buffer.

{{ Additional information: - Typical use: attach this component to a weather prefab asset to connect it to placeholder weather prefabs used by climate/season systems. - Important ECS types referenced: EntityManager, Entity, PrefabSystem, ComponentType, PlaceholderObjectElement, SpawnableObjectData. - The component relies on the PrefabSystem existing in the World; ensure the world's systems are initialized before LateInitialize runs. }}