Skip to content

Game.Prefabs.Climate.WeatherPlaceholder

Assembly:
Namespace: Game.Prefabs.Climate

Type: class

Base: ComponentBase

Summary:
WeatherPlaceholder is a prefab component used by the game's weather system. It designates that the prefab should include a PlaceholderObjectElement component at prefab-creation time. The class is also decorated with a ComponentMenu attribute so it appears under the "Weather/" menu (associated with WeatherPrefab) in the editor. During initialization it detects if the underlying prefab is a WeatherOverride and logs a warning if so.


Fields

  • (none declared on this type)
    This class does not declare any private or public fields. It relies on behavior provided by its base class (ComponentBase).

Properties

  • (none declared on this type)
    No properties are defined on WeatherPlaceholder.

Constructors

  • public WeatherPlaceholder()
    This type does not declare an explicit constructor; a default parameterless constructor is provided by the C# compiler.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the provided HashSet. This ensures that prefabs using this component will include a PlaceholderObjectElement component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty implementation. No additional archetype components are added by this component.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Calls base.Initialize(entityManager, entity). After base initialization, it checks whether the associated prefab has a WeatherOverride. If so, it logs a warning via ComponentBase.baseLog.WarnFormat indicating the prefab is a WeatherOverride.

Additional notes: - The class is annotated with [ComponentMenu("Weather/", new Type[] { typeof(WeatherPrefab) })], which affects how the component appears in the editor menus. - The PlaceholderObjectElement component is added as a prefab component (ReadWrite) rather than an archetype component.

Usage Example

// Example: Inspecting what prefab components WeatherPlaceholder requests
var components = new HashSet<ComponentType>();
var placeholder = new WeatherPlaceholder();
placeholder.GetPrefabComponents(components);

// components now contains ComponentType.ReadWrite<PlaceholderObjectElement>()

// Example: Typical runtime initialization happens via the engine when a prefab is instantiated.
// The component's Initialize method logs a warning if the prefab has a WeatherOverride:
[Preserve]
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    // If prefab.Has<WeatherOverride>() is true, a warning will be emitted by this component.
}