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 NotifyFarmersIdle(bool idle)
        {
            ShowIdleMessage message = new ShowIdleMessage(idle);

            this.Helper.Multiplayer.SendMessage(message, "ShowIdleMessage", modIDs: new[] { this.ModManifest.UniqueID });
        }