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
-
objectBuildingSystem
Constructors
BuildingSystem(GameState, PlayerState, EconomySystem, ModifierSystem, bool)
public BuildingSystem(GameState gameStateRef, PlayerState playerStateRef, EconomySystem economySystemRef, ModifierSystem modifierSystemRef, bool log = true)
Parameters
gameStateRefGameStateplayerStateRefPlayerStateeconomySystemRefEconomySystemmodifierSystemRefModifierSystemlogbool
Properties
PlayerState
public PlayerState PlayerState { get; }
Property Value
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
provinceIdushortbuildingTypeIdstringreasonstring
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
provinceIdushortbuildingTypeIdstringcountryIdushortreasonstring
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
provinceIdushortbuildingTypeIdstring
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
provinceIdushortbuildingTypeIdstring
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
provinceIdushortbuildingTypeIdstringcountryIdushort
Returns
- bool
Deserialize(byte[])
Deserialize building state from byte array
public void Deserialize(byte[] data)
Parameters
databyte[]
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
provinceIdushortbuildingTypeIdushort
Returns
- int
GetBuildingType(string)
Get building type by string ID.
public BuildingType GetBuildingType(string stringId)
Parameters
stringIdstring
Returns
GetBuildingType(ushort)
Get building type by numeric ID.
public BuildingType GetBuildingType(ushort typeId)
Parameters
typeIdushort
Returns
GetProvinceBuildings(ushort)
Get all buildings in a province (buildingTypeId -> count).
public Dictionary<ushort, int> GetProvinceBuildings(ushort provinceId)
Parameters
provinceIdushort
Returns
- Dictionary<ushort, int>
GetTotalBuildingCount(ushort)
Get total building count in a province.
public int GetTotalBuildingCount(ushort provinceId)
Parameters
provinceIdushort
Returns
- int
IsProvinceOwnedByPlayer(ushort)
Check if a province is owned by the player.
public bool IsProvinceOwnedByPlayer(ushort provinceId)
Parameters
provinceIdushort
Returns
- bool
LoadBuildingTypes(string)
Load building types from Template-Data/buildings/ directory.
public void LoadBuildingTypes(string buildingsPath)
Parameters
buildingsPathstring
Serialize()
Serialize building state to byte array
public byte[] Serialize()
Returns
- byte[]