Game.Prefabs.ObjectSubAreas
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component that attaches sub-area definitions to object prefabs (used for building prefabs and building extensions). Holds an array of ObjectSubAreaInfo entries and ensures the area prefabs referenced by those sub-areas are registered as dependencies. It also declares the runtime ECS components required by the prefab (SubArea and SubAreaNode) and the archetype component (Game.Areas.SubArea).
Fields
public ObjectSubAreaInfo[] m_SubAreas
Array of sub-area definitions for this object prefab. Each entry typically contains a reference (m_AreaPrefab) to an area prefab that should be considered a dependency and instantiated/registered when this object prefab is used. Can be null or empty.
Properties
public override bool ignoreUnlockDependencies => true
Indicates this prefab component ignores unlock-dependency checks. Returning true means unlock dependencies for this component are not enforced by the prefab system.
Constructors
public ObjectSubAreas()
Default constructor (implicit). No special initialization logic is present in the source.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds referenced area prefabs from m_SubAreas to the provided prefabs list. Calls base.GetDependencies(prefabs) first. This ensures that any area prefabs referenced by the object’s sub-areas are included as prefab dependencies so they are loaded/available at runtime. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds component types required by the prefab instances: SubArea and SubAreaNode (as read/write). This informs the prefab system which ECS components should be present on entities spawned from this prefab. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds the archetype-level component Game.Areas.SubArea (as read/write). This ensures the archetype used for entity creation contains the SubArea component.
Usage Example
// Example of how this component adds its area-prefab dependencies.
// This is essentially the implementation from the component.
public override void GetDependencies(List<PrefabBase> prefabs)
{
base.GetDependencies(prefabs);
if (m_SubAreas != null)
{
for (int i = 0; i < m_SubAreas.Length; i++)
{
prefabs.Add(m_SubAreas[i].m_AreaPrefab);
}
}
}
Additional notes: - ObjectSubAreas is intended to be added to building-related prefabs (see ComponentMenu attribute targeting BuildingPrefab and BuildingExtensionPrefab). - The component interacts with Unity.Entities.ComponentType (ECS) to declare runtime and archetype components required by the prefab. Ensure referenced area prefabs (m_AreaPrefab) are valid PrefabBase instances to avoid null references during dependency resolution.