Skip to content

Game.Prefabs.Modes.ParkingFacilityMode

Assembly:
Namespace: Game.Prefabs.Modes

Type: class

Base: LocalModePrefab

Summary:
Handles per-mode configuration for parking facility prefabs. ParkingFacilityMode stores an array of ModeData entries that map a Prefab (PrefabBase) to a comfort factor value. The class provides methods used by the prefab/mode system to record, apply and restore the comfort factor value on the ECS entity that represents the parking facility (ParkingFacilityData.m_ComfortFactor). The class logs a critical message when a referenced target prefab does not contain the expected ParkingFacility component.


Fields

  • public ModeData[] m_ModeDatas
    Array of ModeData entries. Each entry pairs a PrefabBase with a comfort factor to be applied to the ECS ParkingFacilityData for that prefab.

  • public class ModeData
    Serializable nested class that holds data for a single mode entry.

  • public PrefabBase m_Prefab
    Reference to the prefab that contains a ParkingFacility component. Used to find the corresponding entity via PrefabSystem.

  • public float m_ComfortFactor
    The comfort factor value to apply to ParkingFacilityData.m_ComfortFactor for the associated prefab.

Properties

  • (none)
    This type does not expose any properties.

Constructors

  • public ParkingFacilityMode()
    Default parameterless constructor (implicit). Instances are typically created/managed by the prefab system or editor; no special construction logic is defined.

Methods

  • public override void RecordChanges(EntityManager entityManager, PrefabSystem prefabSystem)
    Iterates all entries in m_ModeDatas, attempts to get the ParkingFacility component from each referenced prefab, logs a critical error if the component is missing, and retrieves the ECS entity for the prefab. For each entity it calls entityManager.GetComponentData(entity) — this effectively ensures the component exists and may be used by the system to record that the component was observed/changed. No modifications are made in this method.

  • public override void ApplyModeData(EntityManager entityManager, PrefabSystem prefabSystem)
    For each ModeData entry: gets the ParkingFacility component from the referenced prefab, logs a critical error if missing, obtains the entity from PrefabSystem, reads ParkingFacilityData from the entity, sets ParkingFacilityData.m_ComfortFactor to the ModeData.m_ComfortFactor, and writes the modified component back with entityManager.SetComponentData. Use this to push the mode-specific comfort value into the running ECS data.

  • public override void RestoreDefaultData(EntityManager entityManager, PrefabSystem prefabSystem)
    For each ModeData entry: gets the ParkingFacility component from the referenced prefab, logs a critical error if missing, obtains the entity, reads ParkingFacilityData, sets ParkingFacilityData.m_ComfortFactor back to the prefab's default value (component.m_ComfortFactor — the value defined on the original Prefab component), and writes the component back. Use this to revert to prefab defaults when a mode is cleared.

Notes and behavior details: - All methods assume the referenced PrefabBase contains a ParkingFacility MonoBehaviour component; if not found the code logs via ComponentBase.baseLog.Critical and skips that entry. - Methods interact directly with Unity.Entities.EntityManager and expect PrefabSystem.GetEntity(prefab) to return a valid entity for the prefab. - No exception handling is present beyond the log-on-missing-component; callers should ensure EntityManager and PrefabSystem are valid and that the prefab/entity mapping exists. - Because ApplyModeData/RestoreDefaultData call GetComponentData and SetComponentData, these methods execute synchronously on the main thread in the context they are invoked — ensure this aligns with job and threading expectations of your mod.

Usage Example

// Example: programmatically set up one mode entry and apply it.
// (In practice this component is usually configured in the editor and invoked by the prefab/mode system.)

var mode = new ParkingFacilityMode();
mode.m_ModeDatas = new ParkingFacilityMode.ModeData[]
{
    new ParkingFacilityMode.ModeData
    {
        m_Prefab = somePrefabBaseReference,   // assign a PrefabBase that contains a ParkingFacility component
        m_ComfortFactor = 1.25f
    }
};

// Apply mode data to ECS entities (entityManager and prefabSystem must be valid)
mode.ApplyModeData(entityManager, prefabSystem);

// Later, to restore defaults:
mode.RestoreDefaultData(entityManager, prefabSystem);