Game.PostFacility
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: ComponentBase, Implements: IServiceUpgrade
Summary:
Prefab component that configures post office (postal service) buildings. Exposes editable capacities and sorting rate used when the prefab is instantiated as an entity. Controls which ECS components are added to the building entity (resources, service dispatch, vehicle ownership, mailbox routing data, efficiency/guest vehicle for city service buildings, etc.) depending on configured capacities and whether the prefab is an upgrade. The component is used by the game's prefab-to-entity initialization pipeline.
Fields
-
public int m_PostVanCapacity = 10
Number of delivery vans the facility can own/dispatch. When > 0 the prefab will include ServiceDispatch, ServiceDistrict and OwnedVehicle archetype components (unless a ServiceUpgrade component is present). Default value 10. -
public int m_PostTruckCapacity
Number of trucks (larger vehicles) the facility can own/dispatch. When > 0 the prefab will include ServiceDispatch and OwnedVehicle archetype components (unless a ServiceUpgrade component is present). Default 0. -
public int m_MailStorageCapacity = 100000
Internal mail storage capacity of the building (total mail that can be held inside the facility). This value is written into the PostFacilityData.m_MailCapacity during initialization. -
public int m_MailBoxCapacity = 10000
Capacity of mailboxes hosted by the building (route/mailbox capacity). When > 0 the prefab will include Game.Routes.MailBox / MailBoxData components so the building participates in mailbox routing and stops. -
public int m_SortingRate
Sorting throughput of the facility. Written to PostFacilityData.m_SortingRate during initialization.
Properties
- None are declared by this component. (It implements IServiceUpgrade and provides GetUpgradeComponents, but no C# properties are defined.)
Constructors
public PostFacility()
Default parameterless constructor provided by C#. Field defaults are as declared in the source (m_PostVanCapacity = 10, m_MailStorageCapacity = 100000, m_MailBoxCapacity = 10000, others default to 0).
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime component types this prefab will request when creating an entity from the prefab. Always adds PostFacilityData and UpdateFrameData. Adds MailBoxData if m_MailBoxCapacity > 0. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds archetype components used when creating the entity archetype (structure of components on the entity) if the prefab is not an upgrade (GetComponent() == null). Always adds Game.Buildings.PostFacility. If not an upgrade, also adds Resources, and if the prefab is a CityServiceBuilding it adds GuestVehicle and Efficiency. Adds ServiceDispatch and OwnedVehicle depending on truck/van capacities, and adds Game.Routes.MailBox if m_MailBoxCapacity > 0. -
public void GetUpgradeComponents(HashSet<ComponentType> components)
When this prefab functions as an upgrade, this method is used to declare components required by the upgraded entity. Adds Game.Buildings.PostFacility and Resources. Adds ServiceDispatch and OwnedVehicle for either truck or van capacities, and adds Game.Routes.MailBox if m_MailBoxCapacity > 0. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is instantiated as an ECS entity. Populates PostFacilityData with m_PostVanCapacity, m_PostTruckCapacity, m_MailStorageCapacity (written as m_MailCapacity) and m_SortingRate. If m_MailBoxCapacity > 0, creates and sets MailBoxData with m_MailCapacity = m_MailBoxCapacity. Also sets UpdateFrameData to 11. These component data writes configure the runtime behavior of the created postal facility entity.
Usage Example
// Example: shows what Initialize does when the prefab is turned into an entity.
// This is effectively the same logic found in the prefab's Initialize method.
public override void Initialize(EntityManager entityManager, Entity entity)
{
PostFacilityData facilityData = default(PostFacilityData);
facilityData.m_PostVanCapacity = m_PostVanCapacity;
facilityData.m_PostTruckCapacity = m_PostTruckCapacity;
facilityData.m_MailCapacity = m_MailStorageCapacity;
facilityData.m_SortingRate = m_SortingRate;
entityManager.SetComponentData(entity, facilityData);
if (m_MailBoxCapacity > 0)
{
MailBoxData mailbox = default(MailBoxData);
mailbox.m_MailCapacity = m_MailBoxCapacity;
entityManager.SetComponentData(entity, mailbox);
}
// Schedule updates on frame group 11 (matches prefab behavior)
entityManager.SetComponentData(entity, new UpdateFrameData(11));
}