Exemplo n.º 1
0
 private void OnModMessageReceived(object sender, ModMessageReceivedEventArgs e)
 {
     if (e.FromModID == this.ModManifest.UniqueID && e.Type == "IdleMessage")
     {
         IdleMessage message = e.ReadAs <IdleMessage>();
         // handle message fields here
         if (CheckIdle() && !message.Idle)
         {
             _peers[e.FromPlayerID] = message.Idle;
             if (!CheckIdle())
             {
                 showIdle = false;
                 NotifyFarmersIdle(showIdle);
             }
         }
         else if (!CheckIdle() && message.Idle)
         {
             _peers[e.FromPlayerID] = message.Idle;
             if (CheckIdle())
             {
                 showIdle = true;
                 NotifyFarmersIdle(showIdle);
             }
         }
         _peers[e.FromPlayerID] = message.Idle;
     }
     if (e.FromModID == this.ModManifest.UniqueID && e.Type == "ShowIdleMessage" && !Context.IsMainPlayer)
     {
         ShowIdleMessage message = e.ReadAs <ShowIdleMessage>();
         showIdle = message.Idle;
     }
 }
Exemplo n.º 2
0
 private void NotifyHosterIdle(bool idle)
 {
     foreach (IMultiplayerPeer peer in this.Helper.Multiplayer.GetConnectedPlayers())
     {
         if (peer.HasSmapi || peer.IsHost)
         {
             IdleMessage message = new IdleMessage(idle);
             this.Helper.Multiplayer.SendMessage(message, "IdleMessage", modIDs: new[] { this.ModManifest.UniqueID }, playerIDs: new[] { peer.PlayerID });
         }
     }
 }