Game.Prefabs.FireEngine
Assembly:
Assembly-CSharp (typical for game scripts)
Namespace:
Game.Prefabs
Type:
class
Base:
ComponentBase
Summary:
Represents the Fire Engine prefab component used by the game to configure firefighting vehicles (car or aircraft variants). Exposes editable parameters for extinguishing rate, spread and capacity and wires up the corresponding ECS component data (FireEngineData) and update scheduling (UpdateFrameData). Also contributes mod tags and archetype component requirements based on other attached components (e.g., Moving, CarData, AircraftPrefab).
Fields
-
public float m_ExtinguishingRate = 7f
Controls how quickly the fire engine extinguishes fires (units per second or internal units used by the FireEngineData). Default value is 7.0. -
public float m_ExtinguishingSpread = 20f
Defines the spread/radius or effectiveness area of the extinguishing action. Default value is 20.0. -
public float m_ExtinguishingCapacity
Total extinguishing capacity (how much fire the vehicle can handle before depleting). Default is 0 unless set in inspector or by code. -
public float m_DestroyedClearDuration = 10f
Duration used to clear destroyed objects or some cleanup timing after destruction. Default value is 10.0.
Properties
public override IEnumerable<string> modTags { get; }
Returns the set of mod tags for this prefab. It yields the base.modTags first, then yields either "FireEngineAircraft" if an AircraftPrefab component is present on the same GameObject, otherwise yields "FireEngine". This is used by the mod system to categorize the prefab.
Constructors
public FireEngine()
No explicit constructor is defined in the source file; the class uses the default parameterless constructor. Fields are initialized with their inline defaults (e.g., m_ExtinguishingRate = 7f).
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds runtime-prefab ECS component requirements that will be present on entities created from this prefab:- Adds FireEngineData (read/write).
-
Adds UpdateFrameData (read/write). This defines the minimal data components required on the entity backing this prefab.
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds additional archetype-level components to the prefab's entity archetype: - Always adds Game.Vehicles.FireEngine (read/write).
-
If the archetype already contains Moving (read/write) then also adds:
- PathInformation (read/write)
- ServiceDispatch (read/write) This ensures moving fire engines get pathfinding and service-dispatch data as part of their archetype.
-
public override void Initialize(EntityManager entityManager, Entity entity)
Called when an entity is created from the prefab to set initial component data: - Writes a FireEngineData component to the entity using the prefab values (m_ExtinguishingRate, m_ExtinguishingSpread, m_ExtinguishingCapacity, m_DestroyedClearDuration).
- If the entity has CarData, sets UpdateFrameData to 4 (schedules lower-frequency updates for cars). This maps the prefab inspector values into ECS component data at spawn time.
Attributes on the class:
- [ExcludeGeneratedModTag]
— prevents automatic generation of a mod tag (the class provides tags explicitly).
- [ComponentMenu("Vehicles/", new Type[]{ typeof(CarPrefab), typeof(AircraftPrefab) })]
— places this prefab in the component menu under "Vehicles/" and indicates it is related to CarPrefab and AircraftPrefab types.
Usage Example
// Typical usage: the prefab is configured in the Unity inspector on a GameObject.
// The engine will convert inspector fields into ECS component data during Initialize.
// Example: modify some defaults via script (e.g., in an editor script or during prefab setup)
public class FireEngineConfigurator : MonoBehaviour
{
void Awake()
{
var fe = GetComponent<Game.Prefabs.FireEngine>();
if (fe != null)
{
fe.m_ExtinguishingRate = 9f;
fe.m_ExtinguishingSpread = 25f;
fe.m_ExtinguishingCapacity = 100f;
fe.m_DestroyedClearDuration = 12f;
}
}
}
// At runtime, when the prefab is instantiated into an Entity, Initialize(...) will write:
// entityManager.SetComponentData(entity, new FireEngineData(9f, 25f, 100f, 12f));
// and if the entity has CarData:
// entityManager.SetComponentData(entity, new UpdateFrameData(4));