Esempio n. 1
0
        public void ProcessPacket(PlanetDataResponse packet, NebulaConnection conn)
        {
            // We have to track the offset we are currently at in the flattened jagged array as we decode
            int currentOffset = 0;

            for (int i = 0; i < packet.PlanetDataIDs.Length; i++)
            {
                PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetDataIDs[i]);

                Log.Info($"Parsing {packet.PlanetDataBytesLengths[i]} bytes of data for planet {planet.name} (ID: {planet.id})");
                byte[] planetData = packet.PlanetDataBytes.Skip(currentOffset).Take(packet.PlanetDataBytesLengths[i]).ToArray();

                using (BinaryUtils.Reader reader = new BinaryUtils.Reader(planetData))
                {
                    planet.ImportRuntime(reader.BinaryReader);
                }

                lock (PlanetModelingManager.genPlanetReqList)
                {
                    PlanetModelingManager.genPlanetReqList.Enqueue(planet);
                }

                currentOffset += packet.PlanetDataBytesLengths[i];
            }
        }
Esempio n. 2
0
        public override void ProcessPacket(PlanetDataResponse packet, NebulaConnection conn)
        {
            if (IsHost)
            {
                return;
            }


            PlanetData planet = null;

            if (Multiplayer.Session.IsInLobby)
            {
                planet = UIRoot.instance.galaxySelect.starmap._galaxyData.PlanetById(packet.PlanetDataID);
            }
            else
            {
                planet = GameMain.galaxy.PlanetById(packet.PlanetDataID);
            }

            Log.Info($"Parsing {packet.PlanetDataByte.Length} bytes of data for planet {planet.name} (ID: {planet.id})");

            using (BinaryUtils.Reader reader = new BinaryUtils.Reader(packet.PlanetDataByte))
            {
                planet.ImportRuntime(reader.BinaryReader);
            }

            if (Multiplayer.Session.IsInLobby)
            {
                // Pretend planet is loaded to make planetDetail show resources
                planet.loaded = true;
                UIRoot.instance.uiGame.planetDetail.RefreshDynamicProperties();
            }
            else
            {
                lock (PlanetModelingManager.genPlanetReqList)
                {
                    PlanetModelingManager.genPlanetReqList.Enqueue(planet);
                }
            }
        }