Game.Prefabs.MasterArea
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used on area-related prefabs to designate a "master" area that controls one or more slave areas. The component exposes an array of SlaveAreaInfo
entries which reference other area prefabs; those referenced prefabs are added as dependencies when the prefab system gathers dependencies. This component also declares that the prefab requires the SubArea
component in both prefab component lists and ECS archetype component lists. The component is decorated with a ComponentMenu
attribute so it appears under "Areas/" in the editor and is associated with AreaPrefab
.
Fields
public SlaveAreaInfo[] m_SlaveAreas
Array of slave-area entries. EachSlaveAreaInfo
is expected to contain a reference (m_Area
) to anAreaPrefab
.GetDependencies
iterates this array and adds each referenced area prefab to the provided dependency list. The array and its elements should be configured (not null) to avoid missing dependencies.
Properties
public override bool ignoreUnlockDependencies { get; }
Always returnstrue
. This override indicates that unlock dependencies should be ignored for this component/prefab (the prefab will not participate in the normal unlock-dependency checks).
Constructors
public MasterArea()
No explicit constructor is defined in source; the default parameterless constructor is provided by the compiler/Unity runtime. The component is intended to be used/initialized via the Unity editor or prefab creation workflows.
Methods
-
public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
Collects prefab dependencies. Calls the base implementation, then iteratesm_SlaveAreas
and adds eachm_Area
to the providedprefabs
list. Note: the implementation assumesm_SlaveAreas
and eachm_Area
are non-null; callers/creators should ensure the array is populated. -
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
AddsComponentType.ReadWrite<SubArea>()
to thecomponents
set so the prefab will include theSubArea
component in its prefab component list. -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
AddsComponentType.ReadWrite<Game.Areas.SubArea>()
to thecomponents
set so the ECS entity archetype will include theGame.Areas.SubArea
component.
Usage Example
// Example: configuring a MasterArea instance on a prefab (runtime or via editor script)
var master = prefab.GetComponent<Game.Prefabs.MasterArea>();
master.m_SlaveAreas = new SlaveAreaInfo[]
{
new SlaveAreaInfo { m_Area = someAreaPrefab },
new SlaveAreaInfo { m_Area = anotherAreaPrefab }
};
// When the prefab system calls GetDependencies(prefabs),
// the referenced area prefabs will be added to the prefabs list.