Skip to content

Game.Prefabs.AdministrationBuilding

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, IServiceUpgrade

Summary:
AdministrationBuilding is a prefab component used to configure ECS components for "administration" style city service buildings. It registers the prefab in the Unity component menu under "Buildings/CityServices/" (applicable to BuildingPrefab and BuildingExtensionPrefab) and adds the necessary component types to prefab and archetype bitsets. On initialization it sets the entity's UpdateFrameData to 4. The class also exposes the set of components used when this prefab is applied as a service upgrade.


Fields

  • This type declares no explicit fields.
    The class itself does not store instance fields; it operates by adding and setting ECS component data on created entities.

Properties

  • This type declares no explicit properties.
    All behavior is provided through overridden methods and interface implementation.

Constructors

  • public AdministrationBuilding()
    Default parameterless constructor (compiler-provided). The class does not declare a custom constructor.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds component types that should be present in the prefab's entity when the prefab is instantiated:
  • AdminBuildingData (ReadWrite)
  • UpdateFrameData (ReadWrite)

Use: This ensures prefab entities created from this prefab will have the data containers required by administration buildings and a configurable update frame interval.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds component types used when building the entity archetype for this prefab. Always adds:
  • AdminBuilding (ReadWrite)

Additionally, when the prefab does not include a ServiceUpgrade component, the method conditionally adds: - Efficiency (ReadWrite) if the prefab contains a CityServiceBuilding component - ServiceDistrict (ReadWrite) if the prefab does NOT contain a UniqueObject component

Use: These conditionals allow administration prefabs to include efficiency and district components only when appropriate (i.e., for standard city service buildings that are not unique and not part of a service upgrade).

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Implements IServiceUpgrade. Adds components required when this prefab is used as a service upgrade:
  • AdminBuilding (ReadWrite)

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when an entity is instantiated from the prefab. This implementation sets the entity's UpdateFrameData to an interval of 4:

  • entityManager.SetComponentData(entity, new UpdateFrameData(4));

Use: Ensures administration buildings use a 4-frame update interval by default.

Usage Example

// The prefab class itself already configures the prefab. Example of what Initialize does:
public override void Initialize(EntityManager entityManager, Entity entity)
{
    // Ensure this entity updates every 4 frames
    entityManager.SetComponentData(entity, new UpdateFrameData(4));
}

Additional notes: - The class is annotated with [ComponentMenu("Buildings/CityServices/", new Type[] { typeof(BuildingPrefab), typeof(BuildingExtensionPrefab) })], which exposes it in Unity's Add Component menu for building prefabs/extensions under the specified menu path. - Component types referenced/added by this prefab include: AdminBuildingData, UpdateFrameData, AdminBuilding, Efficiency, ServiceDistrict. These component types must exist in the project and be compatible with read/write usage indicated here. - The conditional logic in GetArchetypeComponents depends on runtime inspection via GetComponent() calls on the prefab (ServiceUpgrade, CityServiceBuilding, UniqueObject). That means archetype composition varies depending on other components attached to the same prefab.