Table of Contents

Class BuildingSystem

Namespace
StarterKit
Assembly
StarterKit.dll

Simple building system. Allows constructing buildings that provide bonuses. Uses ModifierSystem for province-local and country-wide effects.

public class BuildingSystem
Inheritance
object
BuildingSystem

Constructors

BuildingSystem(GameState, PlayerState, EconomySystem, ModifierSystem, bool)

public BuildingSystem(GameState gameStateRef, PlayerState playerStateRef, EconomySystem economySystemRef, ModifierSystem modifierSystemRef, bool log = true)

Parameters

gameStateRef GameState
playerStateRef PlayerState
economySystemRef EconomySystem
modifierSystemRef ModifierSystem
log bool

Properties

PlayerState

public PlayerState PlayerState { get; }

Property Value

PlayerState

Methods

CanConstruct(ushort, string, out string)

Check if a building can be constructed in a province.

public bool CanConstruct(ushort provinceId, string buildingTypeId, out string reason)

Parameters

provinceId ushort
buildingTypeId string
reason string

Returns

bool

CanConstructForCountry(ushort, string, ushort, out string)

Check if a building can be constructed in a province by a specific country. Used by both player and AI.

public bool CanConstructForCountry(ushort provinceId, string buildingTypeId, ushort countryId, out string reason)

Parameters

provinceId ushort
buildingTypeId string
countryId ushort
reason string

Returns

bool

Construct(ushort, string)

Construct a building in a province (instant construction). Applies modifiers via ModifierSystem.

public bool Construct(ushort provinceId, string buildingTypeId)

Parameters

provinceId ushort
buildingTypeId string

Returns

bool

ConstructForAI(ushort, string)

DEPRECATED: Use ConstructForCountry instead. Construct a building for AI (no gold cost, no ownership check).

[Obsolete("Use ConstructForCountry with proper command flow instead")]
public bool ConstructForAI(ushort provinceId, string buildingTypeId)

Parameters

provinceId ushort
buildingTypeId string

Returns

bool

ConstructForCountry(ushort, string, ushort)

Construct a building in a province for a specific country. Used by both player and AI via ConstructBuildingCommand.

public bool ConstructForCountry(ushort provinceId, string buildingTypeId, ushort countryId)

Parameters

provinceId ushort
buildingTypeId string
countryId ushort

Returns

bool

Deserialize(byte[])

Deserialize building state from byte array

public void Deserialize(byte[] data)

Parameters

data byte[]

Dispose()

public void Dispose()

GetAllBuildingTypes()

Get all registered building types.

public IEnumerable<BuildingType> GetAllBuildingTypes()

Returns

IEnumerable<BuildingType>

GetBuildingCount(ushort, ushort)

Get the count of a specific building type in a province.

public int GetBuildingCount(ushort provinceId, ushort buildingTypeId)

Parameters

provinceId ushort
buildingTypeId ushort

Returns

int

GetBuildingType(string)

Get building type by string ID.

public BuildingType GetBuildingType(string stringId)

Parameters

stringId string

Returns

BuildingType

GetBuildingType(ushort)

Get building type by numeric ID.

public BuildingType GetBuildingType(ushort typeId)

Parameters

typeId ushort

Returns

BuildingType

GetProvinceBuildings(ushort)

Get all buildings in a province (buildingTypeId -> count).

public Dictionary<ushort, int> GetProvinceBuildings(ushort provinceId)

Parameters

provinceId ushort

Returns

Dictionary<ushort, int>

GetTotalBuildingCount(ushort)

Get total building count in a province.

public int GetTotalBuildingCount(ushort provinceId)

Parameters

provinceId ushort

Returns

int

IsProvinceOwnedByPlayer(ushort)

Check if a province is owned by the player.

public bool IsProvinceOwnedByPlayer(ushort provinceId)

Parameters

provinceId ushort

Returns

bool

LoadBuildingTypes(string)

Load building types from Template-Data/buildings/ directory.

public void LoadBuildingTypes(string buildingsPath)

Parameters

buildingsPath string

Serialize()

Serialize building state to byte array

public byte[] Serialize()

Returns

byte[]