Skip to content

Game.Prefabs.SignatureBuilding

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
Component used on building prefabs to mark them as a "signature" / unique building (level 5). Provides configuration for XP reward and an associated zone prefab, registers required ECS components and archetype components, and initializes relevant component data (PlaceableObjectData and SpawnableBuildingData). The class also sets placement flags to ensure the building is treated as unique and placed on ground by default. The component is exposed in the editor via the ComponentMenu attribute.


Fields

  • public const int kStatLevel = 5
    Constant representing the signature building's level used throughout the prefab setup (always 5).

  • public ZonePrefab m_ZoneType
    Optional reference to a ZonePrefab used to provide additional prefab/archetype components and initialization for buildings of this zone/type. If set, many component registrations and initialization steps are delegated to this zone prefab with level = kStatLevel.

  • public int m_XPReward = 300
    Defines the XP reward granted by this placeable object. This value is copied into PlaceableObjectData.m_XPReward during Initialize.

  • [CustomField(typeof(UIIconField))] public string m_UnlockEventImage
    Path or ID for an icon used in unlock event UI. Editable in the editor using a UIIconField.

Properties

  • This class does not declare any public properties.

Constructors

  • public SignatureBuilding()
    No explicit constructor is defined; the default parameterless constructor is used. Initialization logic is handled in the overridden Initialize / LateInitialize methods.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds required prefab dependencies to the provided list. Calls base implementation and adds m_ZoneType (if set) so the zone prefab is included as a dependency.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers the component types this prefab requires at the prefab/component-data level:

  • SignatureBuildingData
  • SpawnableBuildingData
  • PlaceableObjectData
  • PlaceableInfoviewItem
    If m_ZoneType is set, delegates to its GetBuildingPrefabComponents to add zone-specific prefab components for level kStatLevel.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Registers archetype-level components for the entity:

  • BuildingCondition
  • Signature
  • Game.Objects.UniqueObject
    If m_ZoneType is set, delegates to its GetBuildingArchetypeComponents to include zone-specific archetype components for level kStatLevel.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Copies m_XPReward into the entity's PlaceableObjectData.m_XPReward. Ensures placement flags include OnGround unless the prefab already uses Shoreline, Floating, or Hovering flags. Sets the Unique placement flag. If m_ZoneType is set, calls m_ZoneType.InitializeBuilding to let the zone prefab perform additional initialization for level kStatLevel.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Creates and assigns a SpawnableBuildingData component with m_Level set to kStatLevel (5). If m_ZoneType is set, resolves the zone prefab entity using PrefabSystem and stores it in componentData.m_ZonePrefab. This finalizes spawnable-related data after the prefab system is ready.

Usage Example

// Example: configuring a SignatureBuilding component on a BuildingPrefab in editor code
var signature = buildingPrefab.GetComponent<SignatureBuilding>();
if (signature != null)
{
    // change XP reward shown on the placeable object
    signature.m_XPReward = 500;

    // set a different unlock event icon (string key / path depends on project's UI icon system)
    signature.m_UnlockEventImage = "Icons/Unlocks/MySignatureBuilding";

    // assign a ZonePrefab reference in code if needed
    signature.m_ZoneType = someZonePrefab;
}

{{ Additional notes: - kStatLevel is intentionally fixed at 5: this class represents a top-level signature/unique building. - The class relies on the project's PrefabSystem and ECS types (EntityManager, ComponentType, SpawnableBuildingData, PlaceableObjectData, etc.). - To ensure correct behavior, set m_ZoneType when your signature building needs zone-specific components or behavior; otherwise the component still sets unique/on-ground flags and XP. }}