Photon Quantum 3.0.0

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

Quantum entity reference identifies a unique Entity. More...

Inheritance diagram for Quantum.EntityRef:
Quantum.ILogSource

Public Member Functions

bool Equals (EntityRef other)
 Returns a value indicating whether this instance is equal to a specified EntityRef value. More...
 
override bool Equals (object obj)
 Determines whether two object instances are equal. More...
 
override int 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 bool operator!= (EntityRef a, EntityRef b)
 Operator override for which checks if two instances of EntityRef are not equal. More...
 
static bool operator== (EntityRef a, EntityRef b)
 Operator override for which checks if two instances of EntityRef are equal. More...
 
static void Print (void *ptr, FramePrinter printer)
 Prints the REPLACE using a FramePrinter. More...
 
static void Serialize (void *ptr, FrameSerializer stream)
 Serializes a EntityRef into a FrameSerializer to write or read from a frame snapshot. More...
 
static bool TryParse (string str, out EntityRef result)
 Try to parse an EntityRef from a string. More...
 

Public Attributes

int Index
 Entity index. More...
 
bool IsValid => Raw != 0
 Returns false if this entity is equal to EntityRef.None More...
 
int Version
 Entity version is incremented during the entity life cycle when the entity slot is reused. More...
 

Static Public Attributes

const int SIZE = sizeof(int) + sizeof(int)
 The size of the component (or struct/type) 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

static IEqualityComparer< EntityRefComparer [get]
 Global Entity ref comparer. More...
 
static EntityRef None [get]
 The EntityRef value defining a non-existent Entity. More...
 

Detailed Description

Quantum entity reference identifies a unique Entity.

Quantum implements a sparse-set ECS model (similar to enTT). This means entities are just references to collections of components.

Most important advantages: memory consumption is proportional to instantiated entities + ability to add and remove components dynamically.

Member Function Documentation

◆ operator==()

static bool Quantum.EntityRef.operator== ( EntityRef  a,
EntityRef  b 
)
inlinestatic

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

Returns
true if the instances are equal.

◆ operator!=()

static bool Quantum.EntityRef.operator!= ( EntityRef  a,
EntityRef  b 
)
inlinestatic

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

Returns
true if the instances are not equal.

◆ Equals() [1/2]

bool Quantum.EntityRef.Equals ( EntityRef  other)
inline

Returns a value indicating whether this instance is equal to a specified EntityRef value.

Parameters
otherAn EntityRef value to compare to this instance.
Returns
true if other has the same value as this instance; otherwise, false.

◆ Equals() [2/2]

override bool Quantum.EntityRef.Equals ( object  obj)
inline

Determines whether two object instances are equal.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object; otherwise, false.

◆ GetHashCode()

override int Quantum.EntityRef.GetHashCode ( )
inline

Overrides the default hash function.

Returns
A hash code for the current object.

◆ Serialize()

static void Quantum.EntityRef.Serialize ( void *  ptr,
FrameSerializer  stream 
)
inlinestatic

Serializes a EntityRef into a FrameSerializer to write or read from a frame snapshot.

Parameters
ptrThe pointer to the EntityRef.
streamThe FrameSerializer instance into which the struct will be serialized.

◆ Print()

static void Quantum.EntityRef.Print ( void *  ptr,
FramePrinter  printer 
)
inlinestatic

Prints the REPLACE using a FramePrinter.

Parameters
ptrPointer to REPLACE instance
printerPrinter object

◆ ToString()

override string Quantum.EntityRef.ToString ( )
inline

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

Returns
The string representation of the value of this instance

◆ TryParse()

static bool Quantum.EntityRef.TryParse ( string  str,
out EntityRef  result 
)
inlinestatic

Try to parse an EntityRef from a string.

Parameters
strString
resultResulting EntityRef
Returns
true if the entity ref was successfully parsed

Member Data Documentation

◆ SIZE

const int Quantum.EntityRef.SIZE = sizeof(int) + sizeof(int)
static

The size of the component (or struct/type) 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.

◆ IsValid

bool Quantum.EntityRef.IsValid => Raw != 0

Returns false if this entity is equal to EntityRef.None

◆ Index

int Quantum.EntityRef.Index

Entity index.

◆ Version

int Quantum.EntityRef.Version

Entity version is incremented during the entity life cycle when the entity slot is reused.

Property Documentation

◆ Comparer

IEqualityComparer<EntityRef> Quantum.EntityRef.Comparer
staticget

Global Entity ref comparer.

◆ None

EntityRef Quantum.EntityRef.None
staticget

The EntityRef value defining a non-existent Entity.