Ejemplo n.º 1
0
 public void QueueCraftDelete(CraftChangeEntry entry)
 {
     craftDeleteQueue.Enqueue(entry);
 }
Ejemplo n.º 2
0
 private void HandleCraftLibrary(byte[] messageData)
 {
     using (MessageReader mr = new MessageReader(messageData, false))
     {
         CraftMessageType messageType = (CraftMessageType)mr.Read<int>();
         switch (messageType)
         {
             case CraftMessageType.LIST:
                 {
                     string[] playerList = mr.Read<string[]>();
                     foreach (string player in playerList)
                     {
                         bool vabExists = mr.Read<bool>();
                         bool sphExists = mr.Read<bool>();
                         bool subassemblyExists = mr.Read<bool>();
                         DarkLog.Debug("Player: " + player + ", VAB: " + vabExists + ", SPH: " + sphExists + ", SUBASSEMBLY" + subassemblyExists);
                         if (vabExists)
                         {
                             string[] vabCrafts = mr.Read<string[]>();
                             foreach (string vabCraft in vabCrafts)
                             {
                                 CraftChangeEntry cce = new CraftChangeEntry();
                                 cce.playerName = player;
                                 cce.craftType = CraftType.VAB;
                                 cce.craftName = vabCraft;
                                 CraftLibraryWorker.fetch.QueueCraftAdd(cce);
                             }
                         }
                         if (sphExists)
                         {
                             string[] sphCrafts = mr.Read<string[]>();
                             foreach (string sphCraft in sphCrafts)
                             {
                                 CraftChangeEntry cce = new CraftChangeEntry();
                                 cce.playerName = player;
                                 cce.craftType = CraftType.SPH;
                                 cce.craftName = sphCraft;
                                 CraftLibraryWorker.fetch.QueueCraftAdd(cce);
                             }
                         }
                         if (subassemblyExists)
                         {
                             string[] subassemblyCrafts = mr.Read<string[]>();
                             foreach (string subassemblyCraft in subassemblyCrafts)
                             {
                                 CraftChangeEntry cce = new CraftChangeEntry();
                                 cce.playerName = player;
                                 cce.craftType = CraftType.SUBASSEMBLY;
                                 cce.craftName = subassemblyCraft;
                                 CraftLibraryWorker.fetch.QueueCraftAdd(cce);
                             }
                         }
                     }
                 }
                 break;
             case CraftMessageType.ADD_FILE:
                 {
                     CraftChangeEntry cce = new CraftChangeEntry();
                     cce.playerName = mr.Read<string>();
                     cce.craftType = (CraftType)mr.Read<int>();
                     cce.craftName = mr.Read<string>();
                     CraftLibraryWorker.fetch.QueueCraftAdd(cce);
                     ChatWorker.fetch.QueueChannelMessage(ChatWorker.fetch.consoleIdentifier, "", cce.playerName + " shared " + cce.craftName + " (" + cce.craftType + ")");
                 }
                 break;
             case CraftMessageType.DELETE_FILE:
                 {
                     CraftChangeEntry cce = new CraftChangeEntry();
                     cce.playerName = mr.Read<string>();
                     cce.craftType = (CraftType)mr.Read<int>();
                     cce.craftName = mr.Read<string>();
                     CraftLibraryWorker.fetch.QueueCraftDelete(cce);
                 }
                 break;
             case CraftMessageType.RESPOND_FILE:
                 {
                     CraftResponseEntry cre = new CraftResponseEntry();
                     cre.playerName = mr.Read<string>();
                     cre.craftType = (CraftType)mr.Read<int>();
                     cre.craftName = mr.Read<string>();
                     bool hasCraft = mr.Read<bool>();
                     if (hasCraft)
                     {
                         cre.craftData = mr.Read<byte[]>();
                         CraftLibraryWorker.fetch.QueueCraftResponse(cre);
                     }
                     else
                     {
                         ScreenMessages.PostScreenMessage("Craft " + cre.craftName + " from " + cre.playerName + " not available", 5f, ScreenMessageStyle.UPPER_CENTER);
                     }
                 }
                 break;
         }
     }
 }
Ejemplo n.º 3
0
 public void QueueCraftAdd(CraftChangeEntry entry)
 {
     craftAddQueue.Enqueue(entry);
 }