Game.Prefabs.Ambulance
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Represents the Ambulance prefab component used by vehicle prefabs (ground ambulances and ambulance aircraft). Controls patient capacity and defines which ECS components are added to entities that use this prefab. This component adapts the prefab's archetype and runtime components depending on whether the prefab is a car-type vehicle or an aircraft.
Fields
public int m_PatientCapacity
Holds the number of patients the ambulance can carry. Default value in code is 1. This value is written into the AmbulanceData component during Initialize and determines runtime passenger handling behavior.
Properties
public override IEnumerable<string> modTags { get; }
Returns the sequence of mod tags for this prefab. It yields all tags from the base ComponentBase.modTags, then adds either "AmbulanceAircraft" (if the prefab has an AircraftPrefab component) or "Ambulance" otherwise. These tags can be used by mods or systems that query prefabs by tag.
Constructors
public Ambulance()
No explicit constructor is defined in source; the default parameterless constructor is used. Initialization of prefab-specific data is performed in the override Initialize method rather than in a constructor.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the component types that should be present on the prefab entity. Specifically, this adds:- AmbulanceData (read/write) — stores ambulance-specific configuration (patient capacity, etc.).
-
UpdateFrameData (read/write) — present for vehicles that require frame updates (set during Initialize for car-type ambulances).
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds archetype components that the instantiated entity should contain: - Game.Vehicles.Ambulance (read/write) — runtime vehicle ambulance behavior data.
- Passenger (read/write) — passenger handling component. If the archetype already contains Moving (i.e., this prefab is mobile), the method also adds:
- PathInformation (read/write) — pathfinding information required for movement.
-
ServiceDispatch (read/write) — dispatch/service logic used by emergency vehicles.
-
public override void Initialize(EntityManager entityManager, Entity entity)
Writes initial component data to the created entity: - Sets AmbulanceData on the entity using the m_PatientCapacity field.
- If the entity has a CarData component (i.e., the prefab is a car-type vehicle), it also sets UpdateFrameData(0) to initialize frame update tracking for ground vehicles.
Notes: - The class uses ComponentMenu to place this component under "Vehicles/" in the editor, and the menu hints show it is intended for use with CarPrefab and AircraftPrefab. - The behavior differentiates between aircraft and car prefabs (mod tag and UpdateFrameData handling).
Usage Example
// Attach to a prefab GameObject (or add via code) to configure ambulance capacity.
// In editor: set m_PatientCapacity on the Ambulance component.
// Example: add and configure at runtime
var ambulanceComponent = gameObject.AddComponent<Game.Prefabs.Ambulance>();
ambulanceComponent.m_PatientCapacity = 2;
// When the prefab is instantiated into an ECS Entity, Initialize will write
// AmbulanceData(patientCapacity) and, for car prefabs, UpdateFrameData(0).