Skip to content

Game.Prefabs.Park

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Represents the Park prefab component used by the game's prefab system to prepare ECS archetypes and initialize entity component data for park buildings. Adds the runtime ECS component types required by park prefabs (ParkData, UpdateFrameData) and, depending on other components present on the prefab (e.g., ServiceUpgrade, CityServiceBuilding), configures additional archetype components such as Efficiency, MaintenanceConsumer and coverage/district related components. On initialization it writes the ParkData and an UpdateFrameData(9) to the created entity.


Fields

  • public short m_MaintenancePool
    Holds the maintenance pool value that will be written into the ParkData component on entity initialization. Represents how much maintenance the park has/consumes (short).

  • public bool m_AllowHomeless = true
    Flag that will be stored in ParkData indicating whether the park allows "homeless" (or related allowed-renter behavior). Defaults to true.

Properties

  • This class does not define any public properties.

Constructors

  • public Park()
    Default public constructor. The class relies on Unity/inspector initialization for its serialized fields; no custom construction logic is provided in the source.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component types required on the prefab asset level. Implementation adds:
  • ParkData (ReadWrite)
  • UpdateFrameData (ReadWrite)

This tells the prefab importer which component data instances the prefab expects to have when converted to an entity.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds component types required on the runtime archetype when spawning entities from this prefab. Implementation always adds:
  • Game.Buildings.Park (ReadWrite)
  • Renter (ReadWrite)

If the prefab does not have a ServiceUpgrade component, the method additionally adds: - Efficiency (if the prefab also has CityServiceBuilding) - MaintenanceConsumer - ModifiedServiceCoverage - UpdateFrame - CurrentDistrict

These selections control the runtime behavior and systems that will operate on spawned park entities.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Writes initial component data into the created entity:
  • Sets ParkData with m_MaintenancePool and m_AllowHomeless from the prefab fields.
  • Sets UpdateFrameData with a value of 9.

This binds the prefab configuration (inspector-set fields) into the entity components used by simulation systems.

Usage Example

// This is effectively what the prefab does on initialization.
// If you subclass or inspect a similar prefab, you'll see the same pattern.
public override void Initialize(EntityManager entityManager, Entity entity)
{
    entityManager.SetComponentData(entity, new ParkData
    {
        m_MaintenancePool = m_MaintenancePool,
        m_AllowHomeless = m_AllowHomeless
    });
    entityManager.SetComponentData(entity, new UpdateFrameData(9));
}

{{ Additional notes: - The class is annotated with [ComponentMenu("Buildings/CityServices/", ...)] so it appears under that menu in the Unity editor when assembling building prefabs. - This prefab collaborates with ECS components defined elsewhere: ParkData, UpdateFrameData, Game.Buildings.Park, Renter, ServiceUpgrade, CityServiceBuilding, Efficiency, MaintenanceConsumer, ModifiedServiceCoverage, UpdateFrame, CurrentDistrict. - If you need to change when the UpdateFrameData value is set (currently 9), modify the Initialize call accordingly. }}