Photon Quantum 3.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Quantum.PlayerRef Struct Reference

Represents a Quantum player. More...

Inherits IEquatable< PlayerRef >.

Public Member Functions

override Boolean Equals (Object obj)
 Returns true if the PlayerRefs are equal. More...
 
bool Equals (PlayerRef other)
 Returns true if the PlayerRefs are equal. More...
 
override Int32 GetHashCode ()
 Overrides the default hash function. More...
 
override String ToString ()
 Converts the numeric value of this instance to its equivalent string representation. More...
 

Static Public Member Functions

static implicit operator Int32 (PlayerRef value)
 Converts a PlayerRef to an integer. More...
 
static implicit operator PlayerRef (Int32 value)
 Converts an integer to a PlayerRef. More...
 
static Boolean operator!= (PlayerRef a, PlayerRef b)
 Operator override for which checks if two instances of PlayerRef are not equal. More...
 
static Boolean operator== (PlayerRef a, PlayerRef b)
 Operator override for which checks if two instances of PlayerRef are equal. More...
 
static void Serialize (void *ptr, IDeterministicFrameSerializer serializer)
 Serializes a PlayerRef into a IDeterministicFrameSerializer to write or read from a frame snapshot. More...
 

Public Attributes

Int32 _index
 PlayerRef backing field. 0 means no player. More...
 

Static Public Attributes

const int SIZE = 4
 The size of the struct in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed. More...
 

Properties

Boolean IsValid [get]
 Returns true if the player reference is valid (larger than 0). More...
 
static PlayerRef None [get]
 None player has index 0. More...
 

Detailed Description

Represents a Quantum player.

The PlayerRef, in contrast to the player index, is 1-based. The reason is that default(PlayerRef) will return a "null/invalid" player ref struct for convenience. There are automatic cast operators that can cast an int into a PlayerRef.

default(PlayerRef), internally a 0, means NOBODY PlayerRef, internally 1, is the same as player index 0 PlayerRef, internally 2, is the same as player index 1

Member Function Documentation

◆ Equals() [1/2]

bool Quantum.PlayerRef.Equals ( PlayerRef  other)
inline

Returns true if the PlayerRefs are equal.

◆ Equals() [2/2]

override Boolean Quantum.PlayerRef.Equals ( Object  obj)
inline

Returns true if the PlayerRefs are equal.

◆ GetHashCode()

override Int32 Quantum.PlayerRef.GetHashCode ( )
inline

Overrides the default hash function.

Returns
A hash code for the current object.

◆ ToString()

override String Quantum.PlayerRef.ToString ( )
inline

Converts the numeric value of this instance to its equivalent string representation.

Returns
The string representation of the value of this instance

◆ operator Int32()

static implicit Quantum.PlayerRef.operator Int32 ( PlayerRef  value)
inlinestatic

Converts a PlayerRef to an integer.

The PlayerRef is 1-based and it will return 0 for player 1 for example.

Parameters
valuePlayerRef to cast to int.

◆ operator PlayerRef()

static implicit Quantum.PlayerRef.operator PlayerRef ( Int32  value)
inlinestatic

Converts an integer to a PlayerRef.

The PlayerRef is 1-based and will return PlayerRef 1 for input 0 for example.

Parameters
valueThe integer to cast into a PlayerRef.

◆ operator==()

static Boolean Quantum.PlayerRef.operator== ( PlayerRef  a,
PlayerRef  b 
)
inlinestatic

Operator override for which checks if two instances of PlayerRef are equal.

Returns
true if the instances are equal.

◆ operator!=()

static Boolean Quantum.PlayerRef.operator!= ( PlayerRef  a,
PlayerRef  b 
)
inlinestatic

Operator override for which checks if two instances of PlayerRef are not equal.

Returns
true if the instances are not equal.

◆ Serialize()

static void Quantum.PlayerRef.Serialize ( void *  ptr,
IDeterministicFrameSerializer  serializer 
)
inlinestatic

Serializes a PlayerRef into a IDeterministicFrameSerializer to write or read from a frame snapshot.

Parameters
ptrThe pointer to the PlayerRef.
serializerThe IDeterministicFrameSerializer instance into which the struct will be serialized.

Member Data Documentation

◆ SIZE

const int Quantum.PlayerRef.SIZE = 4
static

The size of the struct in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.

◆ _index

Int32 Quantum.PlayerRef._index

PlayerRef backing field. 0 means no player.

Property Documentation

◆ None

PlayerRef Quantum.PlayerRef.None
staticget

None player has index 0.

◆ IsValid

Boolean Quantum.PlayerRef.IsValid
get

Returns true if the player reference is valid (larger than 0).