Skip to content

Game.ActivityLocationPrefab

Assembly:
Assembly-CSharp (game/mod assembly)

Namespace:
Game.Prefabs

Type:
class

Base:
TransformPrefab

Summary:
ActivityLocationPrefab is a prefab component used to mark a transform/entity as an activity location and to configure which activities are available at that location. At build/initialization time it adds an ActivityLocationData component to the entity and populates its ActivityMask from the public m_Activities array. This prefab is intended to be used in the game's prefab/Entity creation pipeline (Unity.Entities).


Fields

  • public ActivityType[] m_Activities
    This array (exposed to the inspector) lists the ActivityType entries that this location supports. During Initialize the entries are converted into an ActivityMask and combined into the ActivityLocationData.m_ActivityMask. If null or empty, the mask remains default (no activities).

Properties

  • (none)

Constructors

  • public ActivityLocationPrefab()
    No explicit constructor is defined in the source—uses the default parameterless constructor provided by C#.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component requirements for this prefab. Implementation calls the base TransformPrefab.GetPrefabComponents(components) and then adds the ActivityLocationData component descriptor: components.Add(ComponentType.ReadWrite());
    This ensures entities created from the prefab include an ActivityLocationData component (read/write access).

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab is initialized onto an entity. Implementation:

  • Calls base.Initialize(entityManager, entity) to allow the base class to set up transform-related data.
  • Prepares a default ActivityLocationData instance.
  • If m_Activities is non-null, iterates each ActivityType and builds an ActivityMask for it; the underlying bit mask values (ActivityMask.m_Mask) are OR'ed into componentData.m_ActivityMask.m_Mask to accumulate supported activities.
  • Writes the resulting ActivityLocationData into the entity via entityManager.SetComponentData(entity, componentData).

Notes: - ActivityMask appears to be a struct wrapping a numeric mask (m_Mask); this code constructs ActivityMask from each ActivityType and combines their m_Mask values. - Uses Unity.Entities API (EntityManager, Entity, ComponentType).

Usage Example

// Typical usage is via the prefab/inspector: assign m_Activities in the prefab asset.
// Example showing what Initialize produces (conceptual):

// In editor: assign m_Activities = new ActivityType[] { ActivityType.Shop, ActivityType.Restaurant }

// At runtime, when prefab initializes:
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    // After ActivityLocationPrefab.Initialize has run, you can read the component:
    var data = entityManager.GetComponentData<ActivityLocationData>(entity);
    ActivityMask mask = data.m_ActivityMask;
    // mask now contains bits for Shop and Restaurant (as combined by ActivityMask)
}

Additional remarks: - This prefab does not perform validation of ActivityType entries; ensure ActivityType values are valid for the version of the game/mod APIs you target. - Because the mask is computed via bitwise OR, duplicate ActivityType entries in m_Activities are harmless (no duplicate bits).