Photon Quantum 3.0.0

Public Member Functions | Public Attributes | Properties | List of all members
Photon.Deterministic.DeterministicPlayerMap Class Reference

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< PlayerRefPlayers = 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, PlayerRefPlayerSlotToPlayer = 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ DeterministicPlayerMap()

Photon.Deterministic.DeterministicPlayerMap.DeterministicPlayerMap ( int  max = 128)
inline

Create a player map for a given maximum number of players.

Parameters
maxMax players this collection or a client can have.

Member Function Documentation

◆ Has() [1/2]

bool Photon.Deterministic.DeterministicPlayerMap.Has ( int  slot)
inline

Check if the given player slot is assigned.

Parameters
slotPlayer slot
Returns
true if the player slot has been added

◆ Has() [2/2]

bool Photon.Deterministic.DeterministicPlayerMap.Has ( PlayerRef  player)
inline

Check is the given player is assigned.

Parameters
playerPlayer ref
Returns
true if the player has been added

◆ SearchSlot()

int Photon.Deterministic.DeterministicPlayerMap.SearchSlot ( PlayerRef  player)
inline

Return the player slot that a player ref was assigned to.

Parameters
playerPlayer ref
Returns
The player slot for the player or -1

◆ SearchPlayer()

int Photon.Deterministic.DeterministicPlayerMap.SearchPlayer ( int  slot)
inline

Return the player that a player slot was assigned to.

Parameters
slotPlayer slot
Returns
The player or -1

◆ Add()

bool Photon.Deterministic.DeterministicPlayerMap.Add ( int  local,
PlayerRef  global 
)
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.

Parameters
localPlayer slot
globalPlayer ref
Returns
true when the player was added

◆ Remove() [1/2]

void Photon.Deterministic.DeterministicPlayerMap.Remove ( int  slot)
inline

Remove a player slot and its player from the collection.

Parameters
slotPlayer slot

◆ Remove() [2/2]

void Photon.Deterministic.DeterministicPlayerMap.Remove ( PlayerRef  player)
inline

Remove a player ref and its player slot from the collection.

Parameters
playerPlayer ref

Member Data Documentation

◆ Players

readonly List<PlayerRef> Photon.Deterministic.DeterministicPlayerMap.Players = new List<PlayerRef>()

List of all players.

◆ PlayerSlots

readonly List<int> Photon.Deterministic.DeterministicPlayerMap.PlayerSlots = new List<int>()

List of all player slots to iterate over.

◆ PlayerSlotToPlayer

readonly Dictionary<int, PlayerRef> Photon.Deterministic.DeterministicPlayerMap.PlayerSlotToPlayer = new Dictionary<int, PlayerRef>()

Maps each slot to a player to iterate over.

◆ PlayerToPlayerSlot

readonly Dictionary<PlayerRef, int> Photon.Deterministic.DeterministicPlayerMap.PlayerToPlayerSlot = new Dictionary<PlayerRef, int>()

Maps each player to a slot.

◆ Count

int Photon.Deterministic.DeterministicPlayerMap.Count => PlayerSlots.Count

The number of players in this collection.

◆ Available

bool Photon.Deterministic.DeterministicPlayerMap.Available => Count < _max

The number of player that can be added to this collection.

Property Documentation

◆ MaxCount

int Photon.Deterministic.DeterministicPlayerMap.MaxCount
getset

Set or get the max count.