BomberUnits
...a Unity learning project
NetData Class Reference

Holds all player data that needs to be synchronized over the network. More...

+ Collaboration diagram for NetData:

Public Member Functions

 NetData (string name, ColorScheme color, Player.State state, PlayerFigurePrefab prefab)
 
void Send (int uid)
 
void Remove (int uid)
 
bool IsEqualTo (NetData other)
 
bool IsDifferentThan (NetData other)
 
override string ToString ()
 

Static Public Member Functions

static void RegisterType ()
 
static NetData InitNew (int uid, string name, ColorScheme color, Player.State state, PlayerFigurePrefab prefab)
 
static bool Exists (string clientId, int uid)
 
static NetData GetRemote (string clientId, int uid)
 
static NetData GetLocal (int uid)
 
static string GetNetworkKey (int uid)
 A string has to be given as identifier for publishing data. More...
 
static int TryGetIdFromNetworkKey (string key)
 Extracts the player UID from a given string network key. More...
 
static short Serialize (StreamBuffer outStream, object data)
 
static object Deserialize (StreamBuffer inStream, short length)
 

Public Attributes

string name
 
Player.State state
 
ColorScheme color
 
PlayerFigurePrefab prefab
 

Static Private Attributes

static readonly string SerializationKeyPrefix = "Player"
 Added to the player ID for Network publishing.
 
static readonly short memSizeNeededWithoutString = 2 + 4 + 4
 
static readonly object lockFlag = new object()
 A lock is shared between threads to be save.
 

Detailed Description

Holds all player data that needs to be synchronized over the network.

Definition at line 10 of file NetData.cs.

Member Function Documentation

◆ GetNetworkKey()

static string GetNetworkKey ( int  uid)
inlinestatic

A string has to be given as identifier for publishing data.

As there can be other data types, NetData appends a prefix to the NetData's player UID. This allows to detect upon reception whether the key/value pair represents NetData.

Definition at line 63 of file NetData.cs.

◆ TryGetIdFromNetworkKey()

static int TryGetIdFromNetworkKey ( string  key)
inlinestatic

Extracts the player UID from a given string network key.

Returns -1 if the given key does not represent NetData.

Definition at line 70 of file NetData.cs.


The documentation for this class was generated from the following file: