Skip to content

Game.Prefabs.SurfacePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: Game.Areas.AreaPrefab

Summary:
SurfacePrefab is a prefab definition used for area surfaces. It extends AreaPrefab and contributes the ECS component types required both for the prefab representation and for the runtime archetype. Specifically, it registers SurfaceData and AreaGeometryData as prefab-level components, and Surface, Geometry and Expand as archetype components. The class is annotated with Unity's ComponentMenu attribute to appear under the "Areas/" menu in the editor.


Fields

  • (none)
    This class does not declare any instance or static fields.

Properties

  • (none)
    No properties are declared on this class.

Constructors

  • public SurfacePrefab()
    The default public constructor is used (compiler-generated if not explicitly defined). It performs no special initialization beyond the base class constructor.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers component types that should be part of the prefab-level component list. Implementation:
  • Calls base.GetPrefabComponents(components)
  • Adds ComponentType.ReadWrite()
  • Adds ComponentType.ReadWrite()
    Use: ensures entities created from this prefab include data components representing surface-specific data and area geometry.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Registers component types that should be part of the runtime archetype (the set of components present on created entities). Implementation:

  • Calls base.GetArchetypeComponents(components)
  • Adds ComponentType.ReadWrite()
  • Adds ComponentType.ReadWrite()
  • Adds ComponentType.ReadWrite()
    Use: ensures created entities have the expected runtime components (Surface, Geometry, Expand) that systems can operate on.

Usage Example

// The class is already suitable for use as-is. If you need to extend it to add
// additional components to the prefab or archetype, override the methods and
// call base first:

public class MySurfacePrefab : Game.Prefabs.SurfacePrefab
{
    public override void GetPrefabComponents(HashSet<ComponentType> components)
    {
        base.GetPrefabComponents(components);
        components.Add(ComponentType.ReadWrite<MyCustomSurfaceData>());
    }

    public override void GetArchetypeComponents(HashSet<ComponentType> components)
    {
        base.GetArchetypeComponents(components);
        components.Add(ComponentType.ReadWrite<MyCustomSurfaceRuntime>());
    }
}

Notes: - ComponentType.ReadWrite() is used here to indicate the component types added to prefabs/archetypes; ensure the T types (SurfaceData, AreaGeometryData, Surface, Geometry, Expand) are defined in the project's ECS data types. - The ComponentMenu("Areas/") attribute places this prefab type in the "Areas" menu in the Unity editor, helping designers and modders find and add it to scenes.