Exemplo n.º 1
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)
                             {
                                 CraftAddEntry cae = new CraftAddEntry();
                                 cae.playerName = player;
                                 cae.craftType = CraftType.VAB;
                                 cae.craftName = vabCraft;
                                 CraftLibraryWorker.fetch.QueueCraftAdd(cae);
                             }
                         }
                         if (sphExists)
                         {
                             string[] sphCrafts = mr.Read<string[]>();
                             foreach (string sphCraft in sphCrafts)
                             {
                                 CraftAddEntry cae = new CraftAddEntry();
                                 cae.playerName = player;
                                 cae.craftType = CraftType.SPH;
                                 cae.craftName = sphCraft;
                                 CraftLibraryWorker.fetch.QueueCraftAdd(cae);
                             }
                         }
                         if (subassemblyExists)
                         {
                             string[] subassemblyCrafts = mr.Read<string[]>();
                             foreach (string subassemblyCraft in subassemblyCrafts)
                             {
                                 CraftAddEntry cae = new CraftAddEntry();
                                 cae.playerName = player;
                                 cae.craftType = CraftType.SUBASSEMBLY;
                                 cae.craftName = subassemblyCraft;
                                 CraftLibraryWorker.fetch.QueueCraftAdd(cae);
                             }
                         }
                     }
                 }
                 break;
             case CraftMessageType.ADD_FILE:
                 {
                     CraftAddEntry cae = new CraftAddEntry();
                     cae.playerName = mr.Read<string>();
                     cae.craftType = (CraftType)mr.Read<int>();
                     cae.craftName = mr.Read<string>();
                     CraftLibraryWorker.fetch.QueueCraftAdd(cae);
                 }
                 break;
             case CraftMessageType.DELETE_FILE:
                 {
                     CraftDeleteEntry cde = new CraftDeleteEntry();
                     cde.playerName = mr.Read<string>();
                     cde.craftType = (CraftType)mr.Read<int>();
                     cde.craftName = mr.Read<string>();
                     CraftLibraryWorker.fetch.QueueCraftDelete(cde);
                 }
                 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;
         }
     }
 }
Exemplo n.º 2
0
 public void QueueCraftAdd(CraftAddEntry entry)
 {
     craftAddQueue.Enqueue(entry);
 }