Table of Contents

Class PlayerState

Namespace
StarterKit
Assembly
StarterKit.dll

Simple player state storage for StarterKit. Tracks which country the player controls.

public class PlayerState
Inheritance
object
PlayerState

Constructors

PlayerState(GameState, bool)

Create a new PlayerState instance.

public PlayerState(GameState gameStateRef, bool log = true)

Parameters

gameStateRef GameState

Reference to the game state.

log bool

Whether to log state changes.

Properties

HasPlayerCountry

True if the player has selected a country to control.

public bool HasPlayerCountry { get; }

Property Value

bool

PlayerCountryId

The country ID the player is currently controlling (0 if none selected).

public ushort PlayerCountryId { get; }

Property Value

ushort

Methods

ClearPlayerCountry()

Clear the player's country selection (sets to 0/none).

public void ClearPlayerCountry()

Deserialize(byte[])

Deserialize player state from byte array

public void Deserialize(byte[] data)

Parameters

data byte[]

GetPlayerCountryColor()

Get the map color for the player's country.

public Color32 GetPlayerCountryColor()

Returns

Color32

Country color, or gray if no country selected.

GetPlayerCountryTag()

Get the 3-letter tag for the player's country.

public string GetPlayerCountryTag()

Returns

string

Country tag (e.g., "ROM") or "NONE" if no country selected.

IsPlayerCountry(ushort)

Check if a given country is the player's country.

public bool IsPlayerCountry(ushort countryId)

Parameters

countryId ushort

The country ID to check.

Returns

bool

True if the player controls this country.

Serialize()

Serialize player state to byte array

public byte[] Serialize()

Returns

byte[]

SetPlayerCountry(ushort)

Set the player's controlled country.

public void SetPlayerCountry(ushort countryId)

Parameters

countryId ushort

The country ID to control (must be non-zero).