Example #1
0
            public static void ReadDynamics(PacketReader stream)
            {
                Logger.Log("Read dynamic instances: {0} Bytes.", stream.Length);

                int decomp = stream.ReadInt();

                byte[] data = new byte[decomp];
                using (var ms = new System.IO.MemoryStream(stream.GetRemainingData()))
                    using (var ds = new System.IO.Compression.DeflateStream(ms, System.IO.Compression.CompressionMode.Decompress))
                    {
                        ds.Read(data, 0, decomp);
                    }
                stream.Load(data, decomp);

                // Read models
                if (stream.ReadBit())
                {
                    int count = stream.ReadUShort();
                    for (int i = 0; i < count; i++)
                    {
                        ModelInstance model = ScriptManager.Interface.CreateModelInstance();
                        model.ReadStream(stream);
                        model.ScriptObject.Create();
                    }
                }

                // Read vob instances
                if (stream.ReadBit())
                {
                    int count = stream.ReadUShort();
                    for (int i = 0; i < count; i++)
                    {
                        byte            type = stream.ReadByte();
                        BaseVobInstance inst = ScriptManager.Interface.CreateInstance(type);
                        inst.ReadStream(stream);
                        inst.ScriptObject.Create();
                    }
                }
            }