コード例 #1
0
 public void ProcessPacket(StationUIInitialSyncRequest packet, NebulaConnection conn)
 {
     StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
     if (packet.stationGId < gStationPool.Length)
     {
         StationComponent stationComponent = null;
         if (packet.planetId == 0)
         {
             stationComponent = gStationPool[packet.stationGId];
         }
         else
         {
             PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId);
             // GId is the id in this case as we look at a PLS
             if (pData?.factory?.transport != null && pData.factory.transport.stationPool.Length > packet.stationGId)
             {
                 stationComponent = pData.factory.transport.stationPool[packet.stationGId];
             }
         }
         if (stationComponent != null)
         {
             StationStore[] storage      = stationComponent.storage;
             int[]          itemId       = new int[storage.Length];
             int[]          itemCountMax = new int[storage.Length];
             int[]          itemCount    = new int[storage.Length];
             int[]          localLogic   = new int[storage.Length];
             int[]          remoteLogic  = new int[storage.Length];
             int[]          remoteOrder  = new int[storage.Length];
             for (int i = 0; i < stationComponent.storage.Length; i++)
             {
                 itemId[i]       = storage[i].itemId;
                 itemCountMax[i] = storage[i].max;
                 itemCount[i]    = storage[i].count;
                 localLogic[i]   = (int)storage[i].localLogic;
                 remoteLogic[i]  = (int)storage[i].remoteLogic;
                 remoteOrder[i]  = storage[i].remoteOrder;
             }
             StationUIInitialSync packet2 = new StationUIInitialSync(packet.stationGId,
                                                                     packet.planetId,
                                                                     stationComponent.tripRangeDrones,
                                                                     stationComponent.tripRangeShips,
                                                                     stationComponent.deliveryDrones,
                                                                     stationComponent.deliveryShips,
                                                                     stationComponent.warpEnableDist,
                                                                     stationComponent.warperNecessary,
                                                                     stationComponent.includeOrbitCollector,
                                                                     stationComponent.energy,
                                                                     stationComponent.energyPerTick,
                                                                     itemId,
                                                                     itemCountMax,
                                                                     itemCount,
                                                                     localLogic,
                                                                     remoteLogic,
                                                                     remoteOrder);
             conn.SendPacket(packet2);
         }
     }
 }
コード例 #2
0
        public void ProcessPacket(StationUIInitialSyncRequest packet, NebulaConnection conn)
        {
            StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
            if (packet.stationGId < gStationPool.Length)
            {
                StationComponent stationComponent = gStationPool[packet.stationGId];
                if (stationComponent != null)
                {
                    List <int> itemId       = new List <int>();
                    List <int> itemCountMax = new List <int>();
                    List <int> localLogic   = new List <int>();
                    List <int> remoteLogic  = new List <int>();
                    for (int i = 0; i < stationComponent.storage.Length; i++)
                    {
                        itemId.Add(stationComponent.storage[i].itemId);
                        itemCountMax.Add(stationComponent.storage[i].max);
                        switch (stationComponent.storage[i].localLogic)
                        {
                        case (ELogisticStorage.None):
                            localLogic.Add(0);
                            break;

                        case (ELogisticStorage.Supply):
                            localLogic.Add(1);
                            break;

                        case (ELogisticStorage.Demand):
                            localLogic.Add(2);
                            break;
                        }
                        switch (stationComponent.storage[i].remoteLogic)
                        {
                        case (ELogisticStorage.None):
                            remoteLogic.Add(0);
                            break;

                        case (ELogisticStorage.Supply):
                            remoteLogic.Add(1);
                            break;

                        case (ELogisticStorage.Demand):
                            remoteLogic.Add(2);
                            break;
                        }
                    }
                    StationUIInitialSync packet2 = new StationUIInitialSync(packet.stationGId,
                                                                            stationComponent.tripRangeDrones,
                                                                            stationComponent.tripRangeShips,
                                                                            stationComponent.deliveryDrones,
                                                                            stationComponent.deliveryShips,
                                                                            stationComponent.warpEnableDist,
                                                                            stationComponent.warperNecessary,
                                                                            stationComponent.includeOrbitCollector,
                                                                            itemId.ToArray(),
                                                                            itemCountMax.ToArray(),
                                                                            localLogic.ToArray(),
                                                                            remoteLogic.ToArray());
                    conn.SendPacket(packet2);
                    Debug.Log("send syncing packet " + packet.stationGId);
                }
            }
        }