Ejemplo n.º 1
0
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOv") return;

            Version = reader.ReadInt32();
            Compressed = reader.ReadBoolean();

            var uReader = reader;
            MemoryStream cStream = null;
            GZipStream zipStream = null;
            if (Compressed)
            {
                var length = reader.ReadInt32();
                cStream = new MemoryStream(reader.ReadBytes(length));
                zipStream = new GZipStream(cStream, CompressionMode.Decompress);
                reader = new BinaryReader(zipStream);
            }

            Context = new VMContextMarshal();
            Context.Deserialize(reader);

            int ents = reader.ReadInt32();
            Entities = new VMEntityMarshal[ents];
            for (int i=0; i<ents; i++)
            {
                var type = reader.ReadByte();
                var ent = (type == 1) ? (VMEntityMarshal) new VMAvatarMarshal(Version) : new VMGameObjectMarshal(Version);
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            int thrN = reader.ReadInt32();
            Threads = new VMThreadMarshal[thrN];
            for (int i = 0; i < thrN; i++)
            {
                Threads[i] = new VMThreadMarshal(Version);
                Threads[i].Deserialize(reader);
            }

            int mtgN = reader.ReadInt32();
            MultitileGroups = new VMMultitileGroupMarshal[mtgN];
            for (int i = 0; i < mtgN; i++)
            {
                MultitileGroups[i] = new VMMultitileGroupMarshal();
                MultitileGroups[i].Deserialize(reader);
            }

            int globs = reader.ReadInt32();
            GlobalState = new short[globs];
            for (int i = 0; i < globs; i++)
            {
                GlobalState[i] = reader.ReadInt16();
            }

            //assume TSO for now
            PlatformState = new VMTSOLotState();
            PlatformState.Deserialize(reader);

            ObjectId = reader.ReadInt16();
        }
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOo")
            {
                return;
            }

            Version    = reader.ReadInt32();
            Compressed = reader.ReadBoolean();

            var          uReader   = reader;
            MemoryStream cStream   = null;
            GZipStream   zipStream = null;

            if (Compressed)
            {
                var length = reader.ReadInt32();
                cStream   = new MemoryStream(reader.ReadBytes(length));
                zipStream = new GZipStream(cStream, CompressionMode.Decompress);
                reader    = new BinaryReader(zipStream);
            }

            int ents = reader.ReadInt32();

            Entities = new VMEntityMarshal[ents];
            for (int i = 0; i < ents; i++)
            {
                var ent = new VMGameObjectMarshal();
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            MultitileGroup = new VMMultitileGroupMarshal();
            MultitileGroup.Deserialize(reader);
        }
Ejemplo n.º 3
0
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOv")
            {
                return;
            }

            Context = new VMContextMarshal();
            Context.Deserialize(reader);

            int ents = reader.ReadInt32();

            Entities = new VMEntityMarshal[ents];
            for (int i = 0; i < ents; i++)
            {
                var type = reader.ReadByte();
                var ent  = (type == 1) ? (VMEntityMarshal) new VMAvatarMarshal() : new VMGameObjectMarshal();
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            int thrN = reader.ReadInt32();

            Threads = new VMThreadMarshal[thrN];
            for (int i = 0; i < thrN; i++)
            {
                Threads[i] = new VMThreadMarshal();
                Threads[i].Deserialize(reader);
            }

            int mtgN = reader.ReadInt32();

            MultitileGroups = new VMMultitileGroupMarshal[mtgN];
            for (int i = 0; i < mtgN; i++)
            {
                MultitileGroups[i] = new VMMultitileGroupMarshal();
                MultitileGroups[i].Deserialize(reader);
            }

            int globs = reader.ReadInt32();

            GlobalState = new short[globs];
            for (int i = 0; i < globs; i++)
            {
                GlobalState[i] = reader.ReadInt16();
            }

            ObjectId = reader.ReadInt16();
        }
        public VMStandaloneObjectMarshal(VMMultitileGroup group)
        {
            if (group.BaseObject is VMAvatar)
            {
                return;                               //do not attempt to create standalone object marshals for avatars.
            }
            Entities       = new VMEntityMarshal[group.Objects.Count];
            MultitileGroup = group.Save();

            int i = 0;

            foreach (var ent in group.Objects)
            {
                var sent = ((VMGameObject)ent).Save();
                sent.Contained = new short[sent.Contained.Length];
                Entities[i++]  = sent;
            }
        }
Ejemplo n.º 5
0
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOv") return;

            Context = new VMContextMarshal();
            Context.Deserialize(reader);

            int ents = reader.ReadInt32();
            Entities = new VMEntityMarshal[ents];
            for (int i=0; i<ents; i++)
            {
                var type = reader.ReadByte();
                var ent = (type == 1) ? (VMEntityMarshal) new VMAvatarMarshal() : new VMGameObjectMarshal();
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            int thrN = reader.ReadInt32();
            Threads = new VMThreadMarshal[thrN];
            for (int i = 0; i < thrN; i++)
            {
                Threads[i] = new VMThreadMarshal();
                Threads[i].Deserialize(reader);
            }

            int mtgN = reader.ReadInt32();
            MultitileGroups = new VMMultitileGroupMarshal[mtgN];
            for (int i = 0; i < mtgN; i++)
            {
                MultitileGroups[i] = new VMMultitileGroupMarshal();
                MultitileGroups[i].Deserialize(reader);
            }

            int globs = reader.ReadInt32();
            GlobalState = new short[globs];
            for (int i = 0; i < globs; i++)
            {
                GlobalState[i] = reader.ReadInt16();
            }

            ObjectId = reader.ReadInt16();
        }
Ejemplo n.º 6
0
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOv")
            {
                return;
            }

            Version    = reader.ReadInt32();
            Compressed = reader.ReadBoolean();

            var uReader = reader;

            if (Compressed)
            {
                var length       = reader.ReadInt32();
                var cStream      = new MemoryStream(reader.ReadBytes(length));
                var zipStream    = new GZipStream(cStream, CompressionMode.Decompress);
                var decompStream = new MemoryStream();
                zipStream.CopyTo(decompStream);
                decompStream.Seek(0, SeekOrigin.Begin);
                reader = new BinaryReader(decompStream);
                cStream.Close();
                zipStream.Close();
            }

            Context = new VMContextMarshal(Version);
            Context.Deserialize(reader);

            int ents = reader.ReadInt32();

            Entities = new VMEntityMarshal[ents];
            for (int i = 0; i < ents; i++)
            {
                var type = reader.ReadByte();
                var ent  = (type == 1) ? (VMEntityMarshal) new VMAvatarMarshal(Version) : new VMGameObjectMarshal(Version);
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            int thrN = reader.ReadInt32();

            Threads = new VMThreadMarshal[thrN];
            for (int i = 0; i < thrN; i++)
            {
                Threads[i] = new VMThreadMarshal(Version);
                Threads[i].Deserialize(reader);
            }

            int mtgN = reader.ReadInt32();

            MultitileGroups = new VMMultitileGroupMarshal[mtgN];
            for (int i = 0; i < mtgN; i++)
            {
                MultitileGroups[i] = new VMMultitileGroupMarshal(Version);
                MultitileGroups[i].Deserialize(reader);
            }

            int globs = reader.ReadInt32();

            GlobalState = new short[globs];
            for (int i = 0; i < globs; i++)
            {
                GlobalState[i] = reader.ReadInt16();
            }

            //assume TSO for now
            PlatformState = new VMTSOLotState(Version);
            PlatformState.Deserialize(reader);

            ObjectId = reader.ReadInt16();

            if (Compressed)
            {
                reader.BaseStream.Close();
            }
        }
Ejemplo n.º 7
0
 public VMMultitileGroup(VMMultitileGroupMarshal input, VMContext context)
 {
     Load(input, context);
 }
Ejemplo n.º 8
0
 public virtual void Load(VMMultitileGroupMarshal input, VMContext context)
 {
     MultiTile = input.MultiTile;
     Objects = new List<VMEntity>();
     foreach (var id in input.Objects)
     {
         var obj = context.VM.GetObjectById(id);
         Objects.Add(obj);
         obj.MultitileGroup = this;
     }
 }