Skip to content

Game.Prefabs.PlaceholderArea

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

Type: class

Base: ComponentBase

Summary:
PlaceholderArea is a prefab component used by the game to mark an area prefab as a "placeholder" type. It contributes the runtime component types required for placeholder areas (both the per-prefab element type and the archetype component), and performs a safety check during initialization to warn if the associated prefab is also marked as a SpawnableArea. It is decorated with a ComponentMenu attribute so it appears under the Areas menu for prefab editing.


Fields

This class does not declare any private or public fields in its source. It relies on its base class (ComponentBase) for shared state and the provided prefab instance via base.prefab.

Properties

This class does not declare any new properties.

Constructors

  • public PlaceholderArea()
    The default constructor is the implicit parameterless constructor. No special construction logic is declared in the source file.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the per-prefab element component type required by placeholder areas:
  • Adds ComponentType.ReadWrite<PlaceholderObjectElement>() to the provided components set.
    Use: this tells prefab serialization/processing that entities created for this prefab should include the PlaceholderObjectElement component.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds the archetype (entity) component type required by placeholder areas:

  • Adds ComponentType.ReadWrite<Placeholder>() to the provided components set.
    Use: this ensures the entity archetype includes the Placeholder component so systems that act on placeholders will pick up these entities.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Calls the base initialization and then checks whether the prefab has a SpawnableArea component:

  • If base.prefab.Has<SpawnableArea>() is true then a warning is logged via ComponentBase.baseLog.WarnFormat, indicating the prefab is also spawnable.
    Purpose: the check helps catch potentially unintended combinations (a placeholder area that is also marked spawnable) and logs the prefab name for easier debugging.

Additional notes: - The class uses Unity.Entities' ComponentType and EntityManager APIs to declare required components for prefab and archetype creation. - It references game-specific component types: PlaceholderObjectElement, Placeholder, and SpawnableArea which are expected to exist elsewhere in the game's codebase (likely under Game.Objects or related namespaces).

Usage Example

// The class is typically discovered/used by the game's prefab pipeline.
// Example of what GetPrefabComponents / GetArchetypeComponents effectively do:

public override void GetPrefabComponents(HashSet<ComponentType> components)
{
    // Ensure entities created from this prefab include the element type for placeholder objects
    components.Add(ComponentType.ReadWrite<PlaceholderObjectElement>());
}

public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
    // Ensure the entity archetype contains the Placeholder tag/component
    components.Add(ComponentType.ReadWrite<Placeholder>());
}

public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    if (base.prefab.Has<SpawnableArea>())
    {
        ComponentBase.baseLog.WarnFormat(base.prefab, "PlaceholderArea is SpawnableArea: {0}", base.prefab.name);
    }
}

Attribute present on class: - [ComponentMenu("Areas/", new Type[] { typeof(AreaPrefab) })] — places this component in the Areas menu (for AreaPrefab) in the editor/prefab authoring UI.