A utility class to collect a list of players and player slots. A client can maintain multiple players with individual player slots. The player always refers to a global player index that is the same on all clients. The player slot is a zero based index counting the number of players that one client controls. E.g. a client has two players: PlayerRef 5 and PlayerRef 2, the player slots are 0 and 1. More...
Public Member Functions | |
DeterministicPlayerMap (int max=128) | |
Create a player map for a given maximum number of players. More... | |
bool | Add (int local, PlayerRef global) |
Add a player and player slot to the collection. Will check if the local player slot is already assigned. Will check if max capacity is reached. More... | |
bool | Has (int slot) |
Check if the given player slot is assigned. More... | |
bool | Has (PlayerRef player) |
Check is the given player is assigned. More... | |
void | Remove (int slot) |
Remove a player slot and its player from the collection. More... | |
void | Remove (PlayerRef player) |
Remove a player ref and its player slot from the collection. More... | |
int | SearchPlayer (int slot) |
Return the player that a player slot was assigned to. More... | |
int | SearchSlot (PlayerRef player) |
Return the player slot that a player ref was assigned to. More... | |
Public Attributes | |
bool | Available => Count < _max |
The number of player that can be added to this collection. More... | |
int | Count => PlayerSlots.Count |
The number of players in this collection. More... | |
readonly List< PlayerRef > | Players = new List<PlayerRef>() |
List of all players. More... | |
readonly List< int > | PlayerSlots = new List<int>() |
List of all player slots to iterate over. More... | |
readonly Dictionary< int, PlayerRef > | PlayerSlotToPlayer = new Dictionary<int, PlayerRef>() |
Maps each slot to a player to iterate over. More... | |
readonly Dictionary< PlayerRef, int > | PlayerToPlayerSlot = new Dictionary<PlayerRef, int>() |
Maps each player to a slot. More... | |
Properties | |
int | MaxCount [get, set] |
Set or get the max count. More... | |
A utility class to collect a list of players and player slots. A client can maintain multiple players with individual player slots. The player always refers to a global player index that is the same on all clients. The player slot is a zero based index counting the number of players that one client controls. E.g. a client has two players: PlayerRef 5 and PlayerRef 2, the player slots are 0 and 1.
|
inline |
Create a player map for a given maximum number of players.
max | Max players this collection or a client can have. |
|
inline |
Check if the given player slot is assigned.
slot | Player slot |
true
if the player slot has been added
|
inline |
Check is the given player is assigned.
player | Player ref |
true
if the player has been added
|
inline |
Return the player slot that a player ref was assigned to.
player | Player ref |
|
inline |
Return the player that a player slot was assigned to.
slot | Player slot |
|
inline |
Add a player and player slot to the collection. Will check if the local player slot is already assigned. Will check if max capacity is reached.
local | Player slot |
global | Player ref |
true
when the player was added
|
inline |
Remove a player slot and its player from the collection.
slot | Player slot |
|
inline |
Remove a player ref and its player slot from the collection.
player | Player ref |
readonly List<PlayerRef> Photon.Deterministic.DeterministicPlayerMap.Players = new List<PlayerRef>() |
List of all players.
readonly List<int> Photon.Deterministic.DeterministicPlayerMap.PlayerSlots = new List<int>() |
List of all player slots to iterate over.
readonly Dictionary<int, PlayerRef> Photon.Deterministic.DeterministicPlayerMap.PlayerSlotToPlayer = new Dictionary<int, PlayerRef>() |
Maps each slot to a player to iterate over.
readonly Dictionary<PlayerRef, int> Photon.Deterministic.DeterministicPlayerMap.PlayerToPlayerSlot = new Dictionary<PlayerRef, int>() |
Maps each player to a slot.
int Photon.Deterministic.DeterministicPlayerMap.Count => PlayerSlots.Count |
The number of players in this collection.
bool Photon.Deterministic.DeterministicPlayerMap.Available => Count < _max |
The number of player that can be added to this collection.
|
getset |
Set or get the max count.