Skip to content

Game.Prefabs.ParkPrefab

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
ParkPrefab is a prefab definition used by the game's ECS-based prefab system to represent park configuration. It exposes a reference to a park service prefab and ensures that ParkParameterData is present on the prefab entity. During LateInitialize it resolves the referenced PrefabBase to an Entity via the PrefabSystem and stores that Entity in the ParkParameterData component.


Fields

  • public PrefabBase m_ParkServicePrefab
    Reference to another prefab (park service). This field is intended to be set in the editor (or via code) to point at the PrefabBase that provides the park service; LateInitialize resolves this to an Entity and writes it into ParkParameterData.

  • [ComponentMenu("Settings/", new Type[] { })] (class attribute)
    The ComponentMenu attribute places this MonoBehaviour/prefab type under the "Settings/" menu in the Unity Component menu. This is applied to the class itself.

Properties

  • None declared in this class. (All behavior is exposed via fields and overridden methods inherited from PrefabBase.)

Constructors

  • public ParkPrefab()
    Implicit default constructor (not explicitly declared in source). Uses the base PrefabBase constructor.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Overrides PrefabBase.GetPrefabComponents. Calls base implementation and then adds a read/write component type for ParkParameterData:
  • Ensures the prefab entity will include ParkParameterData so that LateInitialize can set its data.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Overrides PrefabBase.GetArchetypeComponents. This override currently just calls the base implementation and does not add additional archetype components.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Overrides PrefabBase.LateInitialize to perform runtime initialization on the created prefab entity:

  • Calls base.LateInitialize(entityManager, entity).
  • Gets (or creates) the PrefabSystem from the entityManager.World.
  • Resolves m_ParkServicePrefab to an Entity with PrefabSystem.GetEntity(m_ParkServicePrefab).
  • Writes a ParkParameterData component to the prefab entity, setting its m_ParkServicePrefab field to the resolved Entity.

Parameters: - entityManager: the ECS EntityManager used to set component data. - entity: the Entity instance representing this prefab in the ECS world.

Remarks: - This class expects ParkParameterData to exist and be writable on the prefab entity; GetPrefabComponents ensures that requirement. - LateInitialize resolves references from editor/asset-time PrefabBase objects to runtime Entity handles.

Usage Example

// Example override of LateInitialize (same logic as in ParkPrefab)
public override void LateInitialize(EntityManager entityManager, Entity entity)
{
    base.LateInitialize(entityManager, entity);

    // Resolve the referenced PrefabBase (m_ParkServicePrefab) to an Entity
    PrefabSystem prefabSystem = entityManager.World.GetOrCreateSystemManaged<PrefabSystem>();
    Entity parkServiceEntity = prefabSystem.GetEntity(m_ParkServicePrefab);

    // Store the resolved Entity into the ParkParameterData component on this prefab entity
    entityManager.SetComponentData(entity, new ParkParameterData
    {
        m_ParkServicePrefab = parkServiceEntity
    });
}

Notes and tips: - Ensure m_ParkServicePrefab is assigned in the editor or before LateInitialize runs; otherwise PrefabSystem.GetEntity may return an invalid Entity. - ParkParameterData must match the structure expected at runtime; adding it in GetPrefabComponents ensures proper archetype setup.