Game.Prefabs.Modes.FireStationMode
Assembly:
Assembly-CSharp (typical Unity game assembly; adjust if different)
Namespace:
Game.Prefabs.Modes
Type:
class
Base:
LocalModePrefab
Summary:
A mode component used to override per-prefab fire station runtime data (specifically vehicle efficiency) for one or more fire station prefabs. Each entry references a PrefabBase that must contain a FireStation component; methods use the PrefabSystem to resolve the prefab Entity and the EntityManager to read/write the FireStationData component. The nested ModeData type is serializable so entries can be configured in the Unity inspector.
Fields
-
public ModeData[] m_ModeDatas
Holds the list of mode entries. Each ModeData references a PrefabBase and a vehicle efficiency value to apply to the corresponding FireStationData. -
public class ModeData
public PrefabBase m_Prefab
Reference to the prefab (must contain a FireStation component). Configurable in inspector.public float m_VehicleEfficiency
The vehicle efficiency value that will be applied to the prefab's FireStationData.
Properties
- None (no public properties declared by this type)
Constructors
public FireStationMode()
Default constructor (no custom initialization in source).
Methods
public override void RecordChanges(EntityManager entityManager, PrefabSystem prefabSystem)
Iterates m_ModeDatas and for each entry:- Retrieves the FireStation component from the referenced PrefabBase.
- If missing, logs a critical error via ComponentBase.baseLog and continues.
- Resolves the prefab Entity via PrefabSystem.GetEntity(component.prefab).
-
Calls entityManager.GetComponentData
(entity) to read the current data (this appears to force tracking/reading of the component for change recording). -
public override void ApplyModeData(EntityManager entityManager, PrefabSystem prefabSystem)
Iterates m_ModeDatas and for each entry: - Retrieves the FireStation component from the referenced PrefabBase.
- If missing, logs a critical error and continues.
- Resolves the prefab Entity.
-
Reads the current FireStationData from the Entity, modifies m_VehicleEfficiency to the ModeData value, and writes it back with entityManager.SetComponentData.
-
public override void RestoreDefaultData(EntityManager entityManager, PrefabSystem prefabSystem)
Iterates m_ModeDatas and for each entry: - Retrieves the FireStation component; logs and continues if missing.
- Resolves the prefab Entity.
- Reads the FireStationData, sets m_VehicleEfficiency back to the original value taken from the FireStation component instance (component.m_VehicleEfficiency), and writes it back to the entity.
Notes and behavior details:
- All methods rely on the referenced PrefabBase to have a FireStation component; otherwise a critical log entry is emitted and that entry is skipped.
- Methods use EntityManager.GetComponentData
Usage Example
// Typical usage: configure entries in the inspector on the FireStation prefab by adding a FireStationMode component.
// Example of programmatically applying a single ModeData entry at runtime (requires access to EntityManager and PrefabSystem):
var mode = new FireStationMode();
mode.m_ModeDatas = new FireStationMode.ModeData[1];
mode.m_ModeDatas[0] = new FireStationMode.ModeData {
m_Prefab = somePrefabBaseReference, // must reference a prefab containing a FireStation component
m_VehicleEfficiency = 0.85f
};
// Later, when you have the entityManager and prefabSystem instances:
mode.ApplyModeData(entityManager, prefabSystem);
// To restore defaults:
mode.RestoreDefaultData(entityManager, prefabSystem);
Additional tips: - Populate m_ModeDatas in the inspector for easier mod configuration. - Ensure the PrefabBase references point to the correct prefab assets and that those prefabs contain a FireStation component, otherwise entries will be skipped and a critical log will be produced.