Class UnitSystem
- Namespace
- StarterKit
- Assembly
- StarterKit.dll
Simple military unit system. Wraps Core.Units.UnitSystem and provides unit type loading.
public class UnitSystem
- Inheritance
-
objectUnitSystem
Constructors
UnitSystem(GameState, PlayerState, bool)
public UnitSystem(GameState gameStateRef, PlayerState playerStateRef, bool log = true)
Parameters
gameStateRefGameStateplayerStateRefPlayerStatelogbool
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
provinceIdushortunitTypeStringIdstringcountryIdushort
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
provinceIdushortunitTypeIdushortcountryIdushort
Returns
- ushort
DisbandUnit(ushort)
Disband a unit.
public void DisbandUnit(ushort unitId)
Parameters
unitIdushort
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
unitIdushort
Returns
GetUnitCountInProvince(ushort)
Get unit count in a province.
public int GetUnitCountInProvince(ushort provinceId)
Parameters
provinceIdushort
Returns
- int
GetUnitType(string)
Get unit type by string ID (e.g., "infantry").
public UnitType GetUnitType(string stringId)
Parameters
stringIdstring
Returns
GetUnitType(ushort)
Get unit type by numeric ID.
public UnitType GetUnitType(ushort typeId)
Parameters
typeIdushort
Returns
GetUnitsInProvince(ushort)
Get all units in a province.
public List<ushort> GetUnitsInProvince(ushort provinceId)
Parameters
provinceIdushort
Returns
- List<ushort>
IsProvinceOwnedByPlayer(ushort)
Check if a province is owned by the player.
public bool IsProvinceOwnedByPlayer(ushort provinceId)
Parameters
provinceIdushort
Returns
- bool
LoadUnitTypes(string)
Load unit types from Template-Data/units/ directory.
public void LoadUnitTypes(string unitsPath)
Parameters
unitsPathstring
MoveUnit(ushort, ushort)
Move a unit to a new province.
public void MoveUnit(ushort unitId, ushort newProvinceId)
Parameters
unitIdushortnewProvinceIdushort