Skip to content

Game.Prefabs.WelfareOffice

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, IServiceUpgrade

Summary:
WelfareOffice is a prefab component used to configure the ECS components for the Welfare Office city service building. It registers which components should be present on instantiated prefab entities (GetPrefabComponents), which components should be included in the archetype for runtime instances (GetArchetypeComponents), and which components are required for the upgrade path (GetUpgradeComponents). On initialization it sets an UpdateFrameData value (5), which controls update scheduling for the entity.


Fields

  • This class declares no private fields.
    {{ The WelfareOffice prefab only manipulates component sets and does not hold instance state fields in this script. }}

Properties

  • This class declares no properties.
    {{ Properties are not defined on this prefab class; component data is provided via ECS components on entities. }}

Constructors

  • public WelfareOffice()
    {{ Implied parameterless constructor provided by the compiler. No special construction logic is required. }}

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    {{ Adds components that every prefab entity should have when the prefab is instantiated. Specifically this adds WelfareOfficeData and UpdateFrameData as ReadWrite components so the entity will contain the data structure for welfare office logic and the update frame scheduling data. }}

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    {{ Adds components to the runtime archetype for created building entities unless the prefab contains a ServiceUpgrade component. Behavior:

  • If ServiceUpgrade is not present, adds Game.Buildings.WelfareOffice component.
  • If the prefab has CityServiceBuilding, also adds Efficiency.
  • If the prefab does not have UniqueObject, also adds ServiceDistrict. This controls which ECS components are included in the entity archetype for performance and feature wiring. }}

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    {{ Implements IServiceUpgrade to declare which components correspond to the upgrade. It adds Game.Buildings.WelfareOffice as a ReadWrite component so upgrade logic can swap/modify that component on upgrade. }}

  • public override void Initialize(EntityManager entityManager, Entity entity)
    {{ Called when the entity is created/initialized. This implementation sets an UpdateFrameData component with a value of 5: entityManager.SetComponentData(entity, new UpdateFrameData(5)); This schedules the entity's update cadence as intended by the prefab. }}

Usage Example

// Example: The prefab ensures the entity has UpdateFrameData set to 5.
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity); // if base has initialization behavior
    entityManager.SetComponentData(entity, new UpdateFrameData(5));
}

{{ Notes: - This prefab is intended to be attached to building prefabs (BuildingPrefab / BuildingExtensionPrefab) to configure ECS data for Welfare Office buildings. - The component checks (ServiceUpgrade, CityServiceBuilding, UniqueObject) are done via GetComponent() on the prefab class to conditionally include archetype components. - The exact component types referenced (WelfareOfficeData, Game.Buildings.WelfareOffice, Efficiency, ServiceDistrict, UpdateFrameData) must be defined elsewhere in the game's ECS codebase. }}