Example #1
0
        public void Deserialize(INetDataReader reader)
        {
            Username      = reader.GetString();
            PlayerId      = reader.GetUShort();
            LocalPlanetId = reader.GetInt();
            MechaColors   = new Float4[reader.GetInt()];
            for (int i = 0; i < MechaColors.Length; i++)
            {
                MechaColors[i] = reader.GetFloat4();
            }
            LocalPlanetPosition = reader.GetFloat3();
            UPosition           = reader.GetDouble3();
            Rotation            = reader.GetFloat3();
            BodyRotation        = reader.GetFloat3();
            Mecha = new MechaData();
            Mecha.Deserialize(reader);
            bool isAppearancePresent = reader.GetBool();

            if (isAppearancePresent)
            {
                int    len  = reader.GetInt();
                byte[] data = new byte[len];
                reader.GetBytes(data, len);
                using (MemoryStream ms = new MemoryStream(data))
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Appearance = new MechaAppearance();
                        Appearance.Init();
                        Appearance.Import(br);
                    }
            }
            bool isDIYAppearancePresent = reader.GetBool();

            if (isDIYAppearancePresent)
            {
                int    len  = reader.GetInt();
                byte[] data = new byte[len];
                reader.GetBytes(data, len);
                using (MemoryStream ms = new MemoryStream(data))
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        DIYAppearance = new MechaAppearance();
                        DIYAppearance.Init();
                        DIYAppearance.Import(br);
                    }
            }
            int DIYItemLen = reader.GetInt();

            DIYItemId    = new int[DIYItemLen];
            DIYItemValue = new int[DIYItemLen];
            for (int i = 0; i < DIYItemLen; i++)
            {
                DIYItemId[i]    = reader.GetInt();
                DIYItemValue[i] = reader.GetInt();
            }
        }
Example #2
0
        public void Deserialize(INetDataReader reader)
        {
            TechBonuses    = new PlayerTechBonuses();
            Inventory      = new StorageComponent(4);
            ReactorStorage = new StorageComponent(4);
            WarpStorage    = new StorageComponent(1);
            Forge          = new MechaForge
            {
                tasks      = new List <ForgeTask>(),
                extraItems = new ItemBundle()
            };
            TechBonuses.Deserialize(reader);
            SandCount     = reader.GetInt();
            CoreEnergy    = reader.GetDouble();
            ReactorEnergy = reader.GetDouble();
            bool isPayloadPresent = reader.GetBool();

            if (isPayloadPresent)
            {
                int    mechaLength = reader.GetInt();
                byte[] mechaBytes  = new byte[mechaLength];
                reader.GetBytes(mechaBytes, mechaLength);
                using (MemoryStream ms = new MemoryStream(mechaBytes))
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Inventory.Import(br);
                        ReactorStorage.Import(br);
                        WarpStorage.Import(br);
                        Forge.Import(br);
                    }
            }
        }