public bool Deserialize(BinaryStream stream, AssetManager assetManager) { // Header string magic = stream.ReadString(4); Assert.AreEqual(MAGIC, magic, "Zone file does not have the correct header!"); Version = stream.ReadUInt32(); if (!Enum.IsDefined(typeof(ZoneType), (int)Version)) { Debug.LogWarning("Could not decode zone " + Name + ". Unknown ZONE version " + Version); return(false); } ZoneType = (ZoneType)(int)Version; if (ZoneType == ZoneType.H1Z1) { stream.ReadUInt32(); } Offsets = new Dictionary <string, uint>(); Offsets["ecos"] = stream.ReadUInt32(); Offsets["floras"] = stream.ReadUInt32(); Offsets["invisibleWalls"] = stream.ReadUInt32(); Offsets["objects"] = stream.ReadUInt32(); Offsets["lights"] = stream.ReadUInt32(); Offsets["unknowns"] = stream.ReadUInt32(); if (ZoneType == ZoneType.H1Z1) { Offsets["decals"] = stream.ReadUInt32(); } QuadsPerTile = stream.ReadUInt32(); TileSize = stream.ReadSingle(); TileHeight = stream.ReadSingle(); VertsPerTile = stream.ReadUInt32(); TilesPerChunk = stream.ReadUInt32(); StartX = stream.ReadInt32(); StartY = stream.ReadInt32(); ChunksX = stream.ReadUInt32(); ChunksY = stream.ReadUInt32(); // Ecos Ecos = new List <Eco>(); uint ecosLength = stream.ReadUInt32(); for (uint i = 0; i < ecosLength; i++) { Ecos.Add(Eco.ReadFromStream(stream)); } // Floras Floras = new List <Flora>(); uint florasLength = stream.ReadUInt32(); for (uint i = 0; i < florasLength; i++) { Floras.Add(Flora.ReadFromStream(stream, ZoneType)); } // Invisible Walls InvisibleWalls = new List <InvisibleWall>(); uint invisibleWallsLength = stream.ReadUInt32(); for (uint i = 0; i < invisibleWallsLength; i++) { InvisibleWalls.Add(InvisibleWall.ReadFromStream(stream)); } // Objects Objects = new List <Object>(); uint objectsLength = stream.ReadUInt32(); for (uint i = 0; i < objectsLength; i++) { Objects.Add(Object.ReadFromStream(stream, ZoneType)); } // Lights Lights = new List <Light>(); uint lightsLength = stream.ReadUInt32(); for (uint i = 0; i < lightsLength; i++) { Lights.Add(Light.ReadFromStream(stream)); } // Unknowns uint unknownsLength = stream.ReadUInt32(); Unknowns = new List <Unknown>((int)unknownsLength); //for (int i = 0; i < unknownsLength; i++) //{ // //Unknowns.Add(Unknown.ReadFromStream(stream)); // //??? //} // Decals if (ZoneType == ZoneType.H1Z1) { uint decalsLength = stream.ReadUInt32(); Decals = new List <Decal>((int)decalsLength); for (int i = 0; i < decalsLength; i++) { Decals.Add(Decal.ReadFromStream(stream)); } } return(true); }