Game.Prefabs.GarbageFacility
Assembly:
Assembly-CSharp (game code / main assembly)
Namespace:
Game.Prefabs
Type:
class GarbageFacility
Base:
ComponentBase, IServiceUpgrade
Summary:
Prefab component that configures and initializes garbage facility entities. It exposes editable prefab fields for capacities, processing speed and behavior flags, declares which ECS components the prefab requires (via GetPrefabComponents / GetArchetypeComponents), and writes the initial GarbageFacilityData and UpdateFrameData to the entity in Initialize. It also implements IServiceUpgrade to provide the set of components required when the building is used as an upgrade.
Fields
-
public int m_GarbageCapacity = 100000
Capacity of stored garbage in units. This value is copied into GarbageFacilityData during Initialize. -
public int m_VehicleCapacity = 10
Maximum number of service vehicles the facility can own. A non‑zero value causes vehicle-related ECS components to be added. -
public int m_TransportCapacity
Transport capacity per vehicle or transport-related capacity — copied to GarbageFacilityData. -
public int m_ProcessingSpeed
Rate at which the facility processes garbage — copied to GarbageFacilityData. -
public bool m_IndustrialWasteOnly
If true, the facility will accept/process only industrial waste. Copied to GarbageFacilityData. -
public bool m_LongTermStorage
If true, facility acts as long-term storage for garbage. Copied to GarbageFacilityData.
Properties
- This class declares no public properties.
Constructors
public GarbageFacility()
Default parameterless constructor (implicit). The prefab fields have defaults set inline (e.g., m_GarbageCapacity = 100000).
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the minimal components needed on any prefab instance: GarbageFacilityData and UpdateFrameData. Called when the engine collects components that every instantiated prefab entity should have. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds the set of components required for the archetype based on prefab configuration and other attached components: - Always adds Game.Buildings.GarbageFacility (the building tag/component).
-
If the prefab does not have a ServiceUpgrade component:
- Adds Resources (resource bookkeeping).
- If it has CityServiceBuilding, also adds GuestVehicle and Efficiency.
- If m_VehicleCapacity > 0 or m_TransportCapacity > 0, adds ServiceDispatch and OwnedVehicle (vehicle dispatch/ownership).
- If not a UniqueObject, adds ServiceDistrict (district assignment for service coverage). This controls the ECS archetype composition that will be created for entities using this prefab.
-
public void GetUpgradeComponents(HashSet<ComponentType> components)
Implements IServiceUpgrade. When this prefab is used as an upgrade, it declares the components needed for the upgraded entity: Game.Buildings.GarbageFacility and Resources, and vehicle/dispatch components if applicable (m_VehicleCapacity > 0 or m_TransportCapacity > 0). -
public override void Initialize(EntityManager entityManager, Entity entity)
Writes initial component data into the entity: - Constructs a GarbageFacilityData struct and copies the prefab fields (m_GarbageCapacity, m_VehicleCapacity, m_TransportCapacity, m_ProcessingSpeed, m_IndustrialWasteOnly, m_LongTermStorage) into it and assigns it to the entity.
- Sets UpdateFrameData(5) on the entity (schedules update frame interval). This method is called during entity creation from the prefab to populate ECS component data.
Usage Example
// When the prefab is instantiated, the engine calls Initialize.
// After that you can read the written component data from the EntityManager:
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = /* entity created from the GarbageFacility prefab */;
var gfData = em.GetComponentData<Game.Prefabs.GarbageFacilityData>(entity);
Debug.Log($"Garbage capacity: {gfData.m_GarbageCapacity}");
Debug.Log($"Vehicle capacity: {gfData.m_VehicleCapacity}");
// The prefab's GetArchetypeComponents() and GetPrefabComponents() determine
// which ECS components exist on the entity before Initialize writes data.