Table of Contents

Class UnitSystem

Namespace
StarterKit
Assembly
StarterKit.dll

Simple military unit system. Wraps Core.Units.UnitSystem and provides unit type loading.

public class UnitSystem
Inheritance
object
UnitSystem

Constructors

UnitSystem(GameState, PlayerState, bool)

public UnitSystem(GameState gameStateRef, PlayerState playerStateRef, bool log = true)

Parameters

gameStateRef GameState
playerStateRef PlayerState
log bool

Methods

CreateUnit(ushort, string, ushort)

Create a unit at specified province for a specific country. Returns unit ID, or 0 if failed.

public ushort CreateUnit(ushort provinceId, string unitTypeStringId, ushort countryId)

Parameters

provinceId ushort
unitTypeStringId string
countryId ushort

Returns

ushort

CreateUnit(ushort, ushort, ushort)

Create a unit at specified province for a specific country. Returns unit ID, or 0 if failed.

public ushort CreateUnit(ushort provinceId, ushort unitTypeId, ushort countryId)

Parameters

provinceId ushort
unitTypeId ushort
countryId ushort

Returns

ushort

DisbandUnit(ushort)

Disband a unit.

public void DisbandUnit(ushort unitId)

Parameters

unitId ushort

Dispose()

public void Dispose()

GetAllUnitTypes()

Get all registered unit types.

public IEnumerable<UnitType> GetAllUnitTypes()

Returns

IEnumerable<UnitType>

GetPlayerUnits()

Get all units owned by player.

public List<ushort> GetPlayerUnits()

Returns

List<ushort>

GetUnit(ushort)

Get unit state by ID.

public UnitState GetUnit(ushort unitId)

Parameters

unitId ushort

Returns

UnitState

GetUnitCountInProvince(ushort)

Get unit count in a province.

public int GetUnitCountInProvince(ushort provinceId)

Parameters

provinceId ushort

Returns

int

GetUnitType(string)

Get unit type by string ID (e.g., "infantry").

public UnitType GetUnitType(string stringId)

Parameters

stringId string

Returns

UnitType

GetUnitType(ushort)

Get unit type by numeric ID.

public UnitType GetUnitType(ushort typeId)

Parameters

typeId ushort

Returns

UnitType

GetUnitsInProvince(ushort)

Get all units in a province.

public List<ushort> GetUnitsInProvince(ushort provinceId)

Parameters

provinceId ushort

Returns

List<ushort>

IsProvinceOwnedByPlayer(ushort)

Check if a province is owned by the player.

public bool IsProvinceOwnedByPlayer(ushort provinceId)

Parameters

provinceId ushort

Returns

bool

LoadUnitTypes(string)

Load unit types from Template-Data/units/ directory.

public void LoadUnitTypes(string unitsPath)

Parameters

unitsPath string

MoveUnit(ushort, ushort)

Move a unit to a new province.

public void MoveUnit(ushort unitId, ushort newProvinceId)

Parameters

unitId ushort
newProvinceId ushort