Skip to content

Game.Prefabs.FirewatchTower

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, IServiceUpgrade

Summary:
Component prefab used to configure the ECS representation of a Firewatch Tower building (city service). Registers the component types required on the prefab/archetype and sets an initial UpdateFrameData value when the entity is initialized. The class also exposes upgrade-related component setup via IServiceUpgrade. The class is annotated with a ComponentMenu attribute to place it under Buildings/CityServices in the editor.


Fields

  • This component class declares no private fields in the source file.

Properties

  • This component class does not declare any public properties.

Constructors

  • public FirewatchTower()
    The class does not define an explicit constructor; the default parameterless constructor provided by C# is used.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the component types that should be present on the prefab instance. Specifically:
  • FirewatchTowerData (read/write) — data specific to the firewatch tower prefab.
  • UpdateFrameData (read/write) — used to control/update scheduling per-frame.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Adds component types required on the runtime archetype (entity instances) for this prefab. Specifically:

  • Game.Buildings.FirewatchTower (read/write) — runtime building component.
    Additionally, if the prefab does not have a ServiceUpgrade component but does have a CityServiceBuilding component, the Efficiency (read/write) component is added. This conditional ensures non-upgrade city service buildings receive efficiency handling.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Part of IServiceUpgrade; adds the components required when this building is used as an upgrade. It adds:

  • Game.Buildings.FirewatchTower (read/write)

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Called when the prefab/entity is initialized. This implementation sets the UpdateFrameData component on the entity to a value of 1:

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

Usage Example

// This mirrors the initialization logic used by the prefab to set the update frame.
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity); // if ComponentBase implements behavior
    entityManager.SetComponentData(entity, new UpdateFrameData(1));
}

Additional notes for modders: - The ComponentMenu attribute places this component under Buildings/CityServices in the component selection UI. - GetArchetypeComponents contains a conditional check that adds Efficiency only when the prefab is a plain city service building (no ServiceUpgrade present). If you want all firewatch towers (including upgraded ones) to have Efficiency, adjust that condition or add Efficiency explicitly in GetPrefabComponents/GetArchetypeComponents. - The code references types from Game.Buildings and ECS ComponentType entries; ensure your mod has access to those types and that any custom components you add follow the same read/write semantics.