Esempio n. 1
0
 private void OnModMessageReceived(object sender, ModMessageReceivedEventArgs e)
 {
     //Monitor.Log($"Got message: {e.Type}", LogLevel.Debug);
     if (e.FromModID != this.ModManifest.UniqueID)
     {
         return;
     }
     if (e.Type == "UpdateDeliveryOptions")
     {
         SyncDataModel message = e.ReadAs <SyncDataModel>();
         DeliveryChest dchest  = GetDeliveryChestFromMessage(message);
         if (dchest != null)
         {
             //Monitor.Log($"Send:{string.Join(", ", message.DeliveryOptions.Send)}", LogLevel.Debug);
             dchest.DeliveryOptions.Set(message.DeliveryOptions);
             if (this.CurrentOverlay != null)
             {
                 this.CurrentOverlay.ResetEdit();
             }
         }
     }
     else if (e.Type == "RequestDeliveryOptions")
     {
         SerializableChestLocation message = e.ReadAs <SerializableChestLocation>();
         DeliveryChest             dchest  = GetDeliveryChestFromMessage(message);
         if (dchest != null)
         {
             Helper.Multiplayer.SendMessage(new SyncDataModel(dchest), "UpdateDeliveryOptions", modIDs: new[] { e.FromModID }, playerIDs: new[] { e.FromPlayerID });
         }
     }
 }
Esempio n. 2
0
        protected void SaveEdit()
        {
            int[] send    = new int[this.SendCategories.Count];
            int[] receive = new int[this.ReceiveCategories.Count];
            for (int i = 0; i < this.SendCategories.Count; i++)
            {
                send[i]    = this.SendCategories[i].GetValue();
                receive[i] = this.ReceiveCategories[i].GetValue();
            }
            Monitor.Log($"Saving Categories {this.Chest.Location} Send:{string.Join(", ", send)}, Receive:{string.Join(", ", receive)}", LogLevel.Trace);
            this.Chest.DeliveryOptions.Set(send, receive, MatchColor.Value);
            SyncDataModel sync = new SyncDataModel(this.Chest);

            this.Multiplayer.SendMessage(sync, "UpdateDeliveryOptions", modIDs: new[] { this.ModID }); //, playerIDs: new[] { this.HostID });
        }