Skip to content

Game.Prefabs.EmergencyShelter

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, implements IServiceUpgrade

Summary:
Prefab component for the Emergency Shelter building. This class exposes inspector fields to configure shelter and vehicle capacity and is responsible for adding the appropriate ECS component types to the prefab/archetype and initializing per-entity component data (EmergencyShelterData and UpdateFrameData). It also provides the set of components needed when the prefab is used as a service upgrade.


Fields

  • public int m_ShelterCapacity = 100
    Configurable shelter capacity (default 100). Used during Initialize to populate EmergencyShelterData.m_ShelterCapacity on the created entity.

  • public int m_VehicleCapacity
    Configurable vehicle capacity (default 0). Used during Initialize to populate EmergencyShelterData.m_VehicleCapacity on the created entity.

Properties

  • None
    This prefab does not declare any C# properties. All configuration is exposed through public fields.

Constructors

  • public EmergencyShelter()
    Default parameterless constructor (implicit). Typical Unity/serialization constructor — no custom construction logic in the class.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component types required on the prefab instance itself. This method registers:
  • EmergencyShelterData (ReadWrite)
  • UpdateFrameData (ReadWrite)

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds component types required for the archetype of the building/entity. It always adds:

  • Game.Buildings.EmergencyShelter (ReadWrite)
    If the prefab does not have a ServiceUpgrade component:
  • If it has CityServiceBuilding: Efficiency (ReadWrite) and ServiceUsage (ReadWrite)
  • Occupant, ServiceDispatch, OwnedVehicle, Resources (all ReadWrite)
  • If it does not have UniqueObject: ServiceDistrict (ReadWrite)
    This conditional logic ensures only the correct service-related components are present depending on whether the prefab is an upgrade, unique object, or city service building.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Implements IServiceUpgrade. Adds the set of components needed when this prefab is applied as a service upgrade:

  • Game.Buildings.EmergencyShelter (ReadWrite)
  • Occupant, ServiceDispatch, OwnedVehicle, Resources, ServiceUsage (all ReadWrite)

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Initializes per-entity data when the prefab is instantiated. It creates and sets:

  • EmergencyShelterData with m_ShelterCapacity and m_VehicleCapacity copied from the prefab fields
  • UpdateFrameData with an update interval of 15 (calls SetComponentData for both)

Remarks: - The class works with Unity.Entities ECS: it registers ComponentType entries for archetype/prefab and writes component data on entity creation. - The UpdateFrameData(15) indicates the building/entity will be updated on a 15-frame interval (game frames).

Usage Example

public override void Initialize(EntityManager entityManager, Entity entity)
{
    EmergencyShelterData data = default(EmergencyShelterData);
    data.m_ShelterCapacity = m_ShelterCapacity;
    data.m_VehicleCapacity = m_VehicleCapacity;
    entityManager.SetComponentData(entity, data);

    // Set the building to be updated every 15 frames
    entityManager.SetComponentData(entity, new UpdateFrameData(15));
}

Additional notes for modders: - To change capacities, set m_ShelterCapacity and m_VehicleCapacity on the prefab (via inspector or in code) before the prefab is spawned. - If you add a ServiceUpgrade component to the prefab, GetArchetypeComponents will omit certain service components — use GetUpgradeComponents to know exactly which components an upgrade will provide. - Related types you may need to inspect/modify: EmergencyShelterData, Game.Buildings.EmergencyShelter, Occupant, ServiceDispatch, OwnedVehicle, Resources, ServiceDistrict, Efficiency, ServiceUsage, UpdateFrameData.