Game.ClearArea
Assembly: Assembly-CSharp (typical Unity game assembly; mod assemblies may differ)
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
ClearArea is a ComponentBase-derived prefab component used to mark prefabs that represent "clear" areas. It is exposed to the editor via a ComponentMenu attribute ("Areas/") and is associated with SpacePrefab in the menu. At archetype creation time it adds the ECS Clear component to the entity archetype so entities created from this prefab carry the Clear component. The GetPrefabComponents method is intentionally empty in this implementation (no prefab-level components are added there).
Fields
- (none)
No private or public instance fields are declared in this class.
Properties
- (none)
This class does not declare any properties.
Constructors
public ClearArea()
Default parameterless constructor (inherited behavior from ComponentBase). No special initialization is performed in this class.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
This override is intentionally empty in the shipped implementation — it does not add any ComponentType entries for "prefab-level" components. If you need components applied at the prefab level (rather than archetype), override this method and add ComponentType entries to the provided HashSet. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds archetype-level components for entities created from the prefab. The implementation calls: components.Add(ComponentType.ReadWrite<Clear>());
This ensures the ECS archetype for the prefab includes the Clear component (read/write access). Modders can extend this method to add additional components required at archetype creation.
Usage Example
using System.Collections.Generic;
using Unity.Entities;
using Game.Prefabs;
using Game.Areas;
[ComponentMenu("Areas/", new Type[] { typeof(SpacePrefab) })]
public class ClearArea : ComponentBase
{
// No prefab-level components needed here.
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
}
// Ensure the Clear component is present on the archetype.
public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
components.Add(ComponentType.ReadWrite<Clear>());
}
}
Notes and tips for modders:
- The ComponentMenu attribute controls how this component appears in the Unity editor menu; the second argument links it to SpacePrefab so it is available when creating that prefab type.
- Use GetPrefabComponents to add components that should exist on the prefab asset (for example, authoring-only components). Use GetArchetypeComponents to add runtime ECS components to the entity archetype created from the prefab.
- The Clear component referenced here likely resides in the Game.Areas namespace; check its definition to understand the data and behavior it represents (e.g., marking an area to be cleared or processed by area systems).
- When adding components to the HashSet, prefer ComponentType.ReadWrite