Exemplo n.º 1
0
 /// <summary>
 /// Updates a variable or sends a request to server (if called clientside).
 /// </summary>
 public void Set(T New)
 {
     if (MyAPIGateway.Multiplayer.IsServer && MyAPIGateway.Multiplayer.MultiplayerActive)
     {
         Networker.SendToAll(SenderName, "Update", Serialize(New));
         Data = New;
     }
     else
     {
         Networker.SendToServer(SenderName, "UpdateRequest", Serialize(New));
     }
 }
Exemplo n.º 2
0
 protected void Handler(NetworkerMessage message)
 {
     if (MyAPIGateway.Multiplayer.IsServer)
     {
         if (message.DataDescription == "UpdateRequest")
         {
             Data = Deserialize(message.Data);
         }
         else if (message.DataDescription == "Get")
         {
             Networker.SendTo(message.SenderID, SenderName, "Update", Serialize(Data));
         }
     }
     else
     {
         if (message.DataDescription == "Update" && message.SenderID == MyAPIGateway.Multiplayer.ServerId)
         {
             Data = Deserialize(message.Data);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Asks the server for actual value.
 /// </summary>
 public void Ask()
 {
     Networker.SendToServer(SenderName, "Get", null);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Unregisters a handler.
 /// </summary>
 public void Unregister()
 {
     Networker.UnregisterHandler(SenderName, Handler);
 }