Game.Prefabs.HangaroundArea
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used on area prefabs to mark them as "hangaround" spawn locations for citizens. At conversion time this component registers the required SpawnLocationData prefab component and the HangaroundLocation archetype component, and initializes SpawnLocationData from the area's NavigationArea settings and the optional ActivityType list configured on the component. If no activities are specified the area defaults to ActivityType.Standing.
Fields
public ActivityType[] m_Activities
Array of activities that are allowed at this hangaround area. When set, Initialize() builds an ActivityMask by OR-ing masks for each ActivityType in this array. If null or empty, the component uses ActivityType.Standing as the default activity mask.
Properties
- None declared on this component. All data is exposed via fields and the initialization writes SpawnLocationData to the entity.
Constructors
public HangaroundArea()
No explicit constructor is declared in the source, so the default parameterless constructor is used. Initialization work is performed in the overridden Initialize method during prefab-to-entity conversion.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the prefab component types required for runtime conversion. This implementation adds a read/write SpawnLocationData component type so the prefab entity will contain spawn-location configuration. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds archetype-level component types required for entities created from this prefab. This implementation adds a read/write HangaroundLocation component type so the entity archetype includes hangaround-specific data. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called during prefab conversion to entities. Behavior: - Calls base.Initialize(entityManager, entity).
- Reads the NavigationArea component on the GameObject and copies:
- m_ConnectionType -> SpawnLocationData.m_ConnectionType
- m_TrackTypes -> SpawnLocationData.m_TrackTypes
- m_RoadTypes -> SpawnLocationData.m_RoadTypes
- Sets SpawnLocationData.m_RequireAuthorization = false
- Sets SpawnLocationData.m_HangaroundOnLane = false
- Builds SpawnLocationData.m_ActivityMask:
- If m_Activities is non-null/non-empty, initializes the mask to zero and ORs in new ActivityMask(...) for each ActivityType in the array.
- Otherwise sets the mask to ActivityType.Standing.
- Writes the populated SpawnLocationData to the provided entity via entityManager.SetComponentData(entity, componentData).
Notes: - This component depends on a NavigationArea component being present on the same GameObject (it reads navigation-related fields from it). - The component is marked with [ComponentMenu("Areas/", typeof(LotPrefab), typeof(SpacePrefab))], so it appears under the Areas menu when authoring prefabs and is intended for usage on LotPrefab and SpacePrefab types.
Usage Example
// Typical usage: add this component to an area prefab and set allowed activities in the inspector
var hang = gameObject.AddComponent<HangaroundArea>();
hang.m_Activities = new ActivityType[] { ActivityType.Standing, ActivityType.Socializing };
// During prefab-to-entity conversion the Initialize method will:
// - copy NavigationArea connection/track/road types into SpawnLocationData
// - set authorization/hangaround-on-lane flags to false
// - build an ActivityMask from m_Activities (or default to Standing)