Skip to content

Game.Prefabs.ParkingFacility

Assembly: Assembly-CSharp (typical Unity game assembly)
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, IServiceUpgrade

Summary:
Prefab component representing a parking facility building (city service). Marked with a ComponentMenu attribute ("Buildings/CityServices/") and usable as both a BuildingPrefab and a BuildingExtensionPrefab. This class configures which ECS components are present on the prefab/archetype and initializes runtime component data for newly created entities. It adds ParkingFacilityData and UpdateFrameData on the prefab and may add Efficiency to archetypes that represent city service buildings which are not already service-upgrade-enabled.


Fields

  • public float m_ComfortFactor = 0.5f
    Controls the comfort factor value written into the ParkingFacilityData component during Initialize. Default value is 0.5.

  • public int m_GarageMarkerCapacity
    Integer capacity value written into ParkingFacilityData during Initialize. Represents number of garage markers the prefab provides (exact gameplay interpretation depends on Game.Buildings.ParkingFacility usage).

Properties

  • None declared on this type.
    All data exposure / configuration is via public fields and ECS component setup methods.

Constructors

  • public ParkingFacility()
    Implicit default constructor. No custom construction logic in source — initialization for runtime components is done in Initialize.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds components that should be present on the prefab entity:
  • ParkingFacilityData (ReadWrite)
  • UpdateFrameData (ReadWrite)

Used by the prefab-building pipeline to ensure the required ECS components exist on the prefab.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds components that should be present on the runtime archetype for this prefab. Always adds:
  • Game.Buildings.ParkingFacility (ReadWrite)

Additionally, if the prefab does not contain a ServiceUpgrade component and does contain a CityServiceBuilding component, this method adds: - Efficiency (ReadWrite)

This conditional logic ensures non-upgradeable city service parking facilities still get an Efficiency component for performance/effectiveness calculations.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Implements IServiceUpgrade. Adds components required when this prefab is used as an upgrade:
  • Game.Buildings.ParkingFacility (ReadWrite)
  • Efficiency (ReadWrite)

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when an entity is instantiated from the prefab. Sets initial component data:

  • Sets ParkingFacilityData on the entity using the prefab fields:
    • m_ComfortFactor <- this.m_ComfortFactor
    • m_GarageMarkerCapacity <- this.m_GarageMarkerCapacity
  • Sets UpdateFrameData on the entity with value 12 (UpdateFrameData(12)).

This populates the runtime ECS components with values sourced from the prefab configuration.

Usage Example

// Example: customizing initialization values or post-initialize adjustments.
[Preserve]
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);

    // Optionally tweak component data after base initialization:
    var data = entityManager.GetComponentData<ParkingFacilityData>(entity);
    data.m_ComfortFactor = 0.75f; // override comfort factor for this instance
    entityManager.SetComponentData(entity, data);
}

Notes: - The prefab uses ComponentType.ReadWrite() to register components; these types must exist in the game's ECS component definitions (ParkingFacilityData, UpdateFrameData, Game.Buildings.ParkingFacility, Efficiency). - UpdateFrameData is set to 12 by default in Initialize — this controls update scheduling for the entity (how often it receives update work). Adjust with care.