public MultiComponentList(BinaryReader reader, int count)
 {
     this.m_Min = this.m_Max = Point.Empty;
       MultiComponentList.MultiTileEntry[] multiTileEntryArray = new MultiComponentList.MultiTileEntry[count];
       for (int index = 0; index < count; ++index)
       {
     multiTileEntryArray[index].m_ItemID = reader.ReadInt16();
     multiTileEntryArray[index].m_OffsetX = reader.ReadInt16();
     multiTileEntryArray[index].m_OffsetY = reader.ReadInt16();
     multiTileEntryArray[index].m_OffsetZ = reader.ReadInt16();
     multiTileEntryArray[index].m_Flags = reader.ReadInt32();
     MultiComponentList.MultiTileEntry multiTileEntry = multiTileEntryArray[index];
     if ((int) multiTileEntry.m_OffsetX < this.m_Min.X)
       this.m_Min.X = (int) multiTileEntry.m_OffsetX;
     if ((int) multiTileEntry.m_OffsetY < this.m_Min.Y)
       this.m_Min.Y = (int) multiTileEntry.m_OffsetY;
     if ((int) multiTileEntry.m_OffsetX > this.m_Max.X)
       this.m_Max.X = (int) multiTileEntry.m_OffsetX;
     if ((int) multiTileEntry.m_OffsetY > this.m_Max.Y)
       this.m_Max.Y = (int) multiTileEntry.m_OffsetY;
       }
       this.m_Center = new Point(-this.m_Min.X, -this.m_Min.Y);
       this.m_Width = this.m_Max.X - this.m_Min.X + 1;
       this.m_Height = this.m_Max.Y - this.m_Min.Y + 1;
       TileList[][] tileListArray = new TileList[this.m_Width][];
       this.m_Tiles = new Tile[this.m_Width][][];
       for (int index1 = 0; index1 < this.m_Width; ++index1)
       {
     tileListArray[index1] = new TileList[this.m_Height];
     this.m_Tiles[index1] = new Tile[this.m_Height][];
     for (int index2 = 0; index2 < this.m_Height; ++index2)
       tileListArray[index1][index2] = new TileList();
       }
       for (int index1 = 0; index1 < multiTileEntryArray.Length; ++index1)
       {
     int index2 = (int) multiTileEntryArray[index1].m_OffsetX + this.m_Center.X;
     int index3 = (int) multiTileEntryArray[index1].m_OffsetY + this.m_Center.Y;
     tileListArray[index2][index3].Add((short) (((int) multiTileEntryArray[index1].m_ItemID & 16383) + 16384), (sbyte) multiTileEntryArray[index1].m_OffsetZ);
       }
       for (int index1 = 0; index1 < this.m_Width; ++index1)
       {
     for (int index2 = 0; index2 < this.m_Height; ++index2)
     {
       this.m_Tiles[index1][index2] = tileListArray[index1][index2].ToArray();
       if (this.m_Tiles[index1][index2].Length > 1)
     Array.Sort((Array) this.m_Tiles[index1][index2]);
     }
       }
 }
Exemplo n.º 2
0
        public static List <MultiComponentList.MultiTileEntry> RebuildTiles(MultiComponentList.MultiTileEntry[] tiles)
        {
            List <MultiComponentList.MultiTileEntry> newtiles = new List <MultiComponentList.MultiTileEntry>();

            newtiles.AddRange(tiles);

            if (newtiles[0].m_OffsetX == 0 && newtiles[0].m_OffsetY == 0 && newtiles[0].m_OffsetZ == 0
                )                                                 // found a centeritem
            {
                if (newtiles[0].m_ItemID != 0x1)                  // its a "good" one
                {
                    for (int j = newtiles.Count - 1; j >= 0; --j) // remove all invis items
                    {
                        if (newtiles[j].m_ItemID == 0x1)
                        {
                            newtiles.RemoveAt(j);
                        }
                    }

                    return(newtiles);
                }
                else // a bad one
                {
                    for (int i = 1; i < newtiles.Count; ++i) // do we have a better one?
                    {
                        if (newtiles[i].m_OffsetX == 0 && newtiles[i].m_OffsetY == 0 &&
                            newtiles[i].m_ItemID != 0x1 && newtiles[i].m_OffsetZ == 0)
                        {
                            MultiComponentList.MultiTileEntry centeritem = newtiles[i];
                            newtiles.RemoveAt(i);                         // jep so save it
                            for (int j = newtiles.Count - 1; j >= 0; --j) // and remove all invis
                            {
                                if (newtiles[j].m_ItemID == 0x1)
                                {
                                    newtiles.RemoveAt(j);
                                }
                            }

                            newtiles.Insert(0, centeritem);
                            return(newtiles);
                        }
                    }

                    for (int j = newtiles.Count - 1; j >= 1; --j) // nothing found so remove all invis exept the first
                    {
                        if (newtiles[j].m_ItemID == 0x1)
                        {
                            newtiles.RemoveAt(j);
                        }
                    }

                    return(newtiles);
                }
            }

            for (int i = 0; i < newtiles.Count; ++i) // is there a good one
            {
                if (newtiles[i].m_OffsetX == 0 && newtiles[i].m_OffsetY == 0 &&
                    newtiles[i].m_ItemID != 0x1 && newtiles[i].m_OffsetZ == 0)
                {
                    MultiComponentList.MultiTileEntry centeritem = newtiles[i];
                    newtiles.RemoveAt(i);                         // store it
                    for (int j = newtiles.Count - 1; j >= 0; --j) // remove all invis
                    {
                        if (newtiles[j].m_ItemID == 0x1)
                        {
                            newtiles.RemoveAt(j);
                        }
                    }

                    newtiles.Insert(0, centeritem);
                    return(newtiles);
                }
            }

            for (int j = newtiles.Count - 1; j >= 0; --j) // nothing found so remove all invis
            {
                if (newtiles[j].m_ItemID == 0x1)
                {
                    newtiles.RemoveAt(j);
                }
            }

            MultiComponentList.MultiTileEntry invisitem = new MultiComponentList.MultiTileEntry();
            invisitem.m_ItemID  = 0x1; // and create a new invis
            invisitem.m_OffsetX = 0;
            invisitem.m_OffsetY = 0;
            invisitem.m_OffsetZ = 0;
            invisitem.m_Flags   = 0;
            invisitem.m_Unk1    = 0;
            newtiles.Insert(0, invisitem);
            return(newtiles);
        }
Exemplo n.º 3
0
        public static List <Object[]> LoadFromDesigner(string FileName)
        {
            List <Object[]> multilist = new List <Object[]>();
            string          root      = Path.GetFileNameWithoutExtension(FileName);
            string          idx       = $"{root}.idx";
            string          bin       = $"{root}.bin";

            if ((!File.Exists(idx)) || (!File.Exists(bin)))
            {
                return(multilist);
            }
            using (FileStream idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read),
                   binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader idxbin = new BinaryReader(idxfs),
                       binbin = new BinaryReader(binfs))
                {
                    int count   = idxbin.ReadInt32();
                    int version = idxbin.ReadInt32();

                    for (int i = 0; i < count; ++i)
                    {
                        Object[] data = new Object[2];
                        switch (version)
                        {
                        case 0:
                            data[0] = ReadUOAString(idxbin);
                            List <MultiComponentList.MultiTileEntry> arr =
                                new List <MultiComponentList.MultiTileEntry>();
                            data[0] += "-" + ReadUOAString(idxbin);
                            data[0] += "-" + ReadUOAString(idxbin);
                            int  width    = idxbin.ReadInt32();
                            int  height   = idxbin.ReadInt32();
                            int  uwidth   = idxbin.ReadInt32();
                            int  uheight  = idxbin.ReadInt32();
                            long filepos  = idxbin.ReadInt64();
                            int  reccount = idxbin.ReadInt32();

                            binbin.BaseStream.Seek(filepos, SeekOrigin.Begin);
                            int index, x, y, z, level, hue;
                            for (int j = 0; j < reccount; ++j)
                            {
                                index = x = y = z = level = hue = 0;
                                int compVersion = binbin.ReadInt32();
                                switch (compVersion)
                                {
                                case 0:
                                    index = binbin.ReadInt32();
                                    x     = binbin.ReadInt32();
                                    y     = binbin.ReadInt32();
                                    z     = binbin.ReadInt32();
                                    level = binbin.ReadInt32();
                                    break;

                                case 1:
                                    index = binbin.ReadInt32();
                                    x     = binbin.ReadInt32();
                                    y     = binbin.ReadInt32();
                                    z     = binbin.ReadInt32();
                                    level = binbin.ReadInt32();
                                    hue   = binbin.ReadInt32();
                                    break;
                                }

                                MultiComponentList.MultiTileEntry
                                    tempitem = new MultiComponentList.MultiTileEntry();
                                tempitem.m_ItemID  = (ushort)index;
                                tempitem.m_Flags   = 1;
                                tempitem.m_OffsetX = (short)x;
                                tempitem.m_OffsetY = (short)y;
                                tempitem.m_OffsetZ = (short)z;
                                tempitem.m_Unk1    = 0;
                                arr.Add(tempitem);
                            }

                            data[1] = new MultiComponentList(arr);
                            break;
                        }

                        multilist.Add(data);
                    }
                }

                return(multilist);
            }
        }
Exemplo n.º 4
0
        public static List <object[]> LoadFromDesigner(string fileName)
        {
            var multiList = new List <object[]>();

            string root = Path.GetFileNameWithoutExtension(fileName);
            string idx  = $"{root}.idx";
            string bin  = $"{root}.bin";

            if ((!File.Exists(idx)) || (!File.Exists(bin)))
            {
                return(multiList);
            }

            using (var idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (var binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (var idxbin = new BinaryReader(idxfs))
                        using (var binbin = new BinaryReader(binfs))
                        {
                            int count   = idxbin.ReadInt32();
                            int version = idxbin.ReadInt32();

                            for (int i = 0; i < count; ++i)
                            {
                                var data = new object[2];

                                switch (version)
                                {
                                case 0:
                                    data[0] = ReadUOAString(idxbin);
                                    var arr = new List <MultiComponentList.MultiTileEntry>();
                                    data[0] += "-" + ReadUOAString(idxbin);
                                    data[0] += "-" + ReadUOAString(idxbin);

                                    _ = idxbin.ReadInt32();
                                    _ = idxbin.ReadInt32();
                                    _ = idxbin.ReadInt32();
                                    _ = idxbin.ReadInt32();

                                    long filepos  = idxbin.ReadInt64();
                                    int  reccount = idxbin.ReadInt32();

                                    binbin.BaseStream.Seek(filepos, SeekOrigin.Begin);
                                    for (int j = 0; j < reccount; ++j)
                                    {
                                        int x;
                                        int y;
                                        int z;
                                        int index = x = y = z = 0;

                                        switch (binbin.ReadInt32())
                                        {
                                        case 0:
                                            index = binbin.ReadInt32();
                                            x     = binbin.ReadInt32();
                                            y     = binbin.ReadInt32();
                                            z     = binbin.ReadInt32();
                                            binbin.ReadInt32();
                                            break;

                                        case 1:
                                            index = binbin.ReadInt32();
                                            x     = binbin.ReadInt32();
                                            y     = binbin.ReadInt32();
                                            z     = binbin.ReadInt32();
                                            binbin.ReadInt32();
                                            binbin.ReadInt32();
                                            break;
                                        }

                                        var tempItem =
                                            new MultiComponentList.MultiTileEntry
                                        {
                                            m_ItemID  = (ushort)index,
                                            m_Flags   = 1,
                                            m_OffsetX = (short)x,
                                            m_OffsetY = (short)y,
                                            m_OffsetZ = (short)z,
                                            m_Unk1    = 0
                                        };
                                        arr.Add(tempItem);
                                    }

                                    data[1] = new MultiComponentList(arr);
                                    break;
                                }

                                multiList.Add(data);
                            }
                        }

                    return(multiList);
                }
        }
Exemplo n.º 5
0
        public static List<Object[]> LoadFromDesigner(string FileName)
        {
            List<Object[]> multilist = new List<Object[]>();
            string root = Path.GetFileNameWithoutExtension(FileName);
            string idx = String.Format("{0}.idx", root);
            string bin = String.Format("{0}.bin", root);
            if ((!File.Exists(idx)) || (!File.Exists(bin)))
                return multilist;
            using (FileStream idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read),
                              binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader idxbin = new BinaryReader(idxfs),
                                    binbin = new BinaryReader(binfs))
                {
                    int count = idxbin.ReadInt32();
                    int version = idxbin.ReadInt32();

                    for (int i = 0; i < count; ++i)
                    {
                        Object[] data = new Object[2];
                        switch (version)
                        {
                            case 0:
                                data[0] = ReadUOAString(idxbin);
                                List<MultiComponentList.MultiTileEntry> arr = new List<MultiComponentList.MultiTileEntry>();
                                data[0] += "-" + ReadUOAString(idxbin);
                                data[0] += "-" + ReadUOAString(idxbin);
                                int width = idxbin.ReadInt32();
                                int height = idxbin.ReadInt32();
                                int uwidth = idxbin.ReadInt32();
                                int uheight = idxbin.ReadInt32();
                                long filepos = idxbin.ReadInt64();
                                int reccount = idxbin.ReadInt32();

                                binbin.BaseStream.Seek(filepos, SeekOrigin.Begin);
                                int index, x, y, z, level, hue;
                                for (int j = 0; j < reccount; ++j)
                                {
                                    index = x = y = z = level = hue = 0;
                                    int compVersion = binbin.ReadInt32();
                                    switch (compVersion)
                                    {
                                        case 0:
                                            index = binbin.ReadInt32();
                                            x = binbin.ReadInt32();
                                            y = binbin.ReadInt32();
                                            z = binbin.ReadInt32();
                                            level = binbin.ReadInt32();
                                            break;

                                        case 1:
                                            index = binbin.ReadInt32();
                                            x = binbin.ReadInt32();
                                            y = binbin.ReadInt32();
                                            z = binbin.ReadInt32();
                                            level = binbin.ReadInt32();
                                            hue = binbin.ReadInt32();
                                            break;
                                    }
                                    MultiComponentList.MultiTileEntry tempitem = new MultiComponentList.MultiTileEntry();
                                    tempitem.m_ItemID = (ushort)index;
                                    tempitem.m_Flags = 1;
                                    tempitem.m_OffsetX = (short)x;
                                    tempitem.m_OffsetY = (short)y;
                                    tempitem.m_OffsetZ = (short)z;
                                    tempitem.m_Unk1 = 0;
                                    arr.Add(tempitem);

                                }
                                data[1] = new MultiComponentList(arr);
                                break;

                        }
                        multilist.Add(data);
                    }
                }
                return multilist;
            }
        }
Exemplo n.º 6
0
        public static List<MultiComponentList.MultiTileEntry> RebuildTiles(MultiComponentList.MultiTileEntry[] tiles)
        {
            List<MultiComponentList.MultiTileEntry> newtiles = new List<MultiComponentList.MultiTileEntry>();
            newtiles.AddRange(tiles);

            if (newtiles[0].m_OffsetX == 0 && newtiles[0].m_OffsetY == 0 && newtiles[0].m_OffsetZ == 0) // found a centeritem
            {
                if (newtiles[0].m_ItemID != 0x1) // its a "good" one
                {
                    for (int j = newtiles.Count - 1; j >= 0; --j) // remove all invis items
                    {
                        if (newtiles[j].m_ItemID == 0x1)
                            newtiles.RemoveAt(j);
                    }
                    return newtiles;
                }
                else // a bad one
                {
                    for (int i = 1; i < newtiles.Count; ++i) // do we have a better one?
                    {
                        if (newtiles[i].m_OffsetX == 0 && newtiles[i].m_OffsetY == 0
                            && newtiles[i].m_ItemID != 0x1 && newtiles[i].m_OffsetZ == 0 )
                        {
                            MultiComponentList.MultiTileEntry centeritem = newtiles[i];
                            newtiles.RemoveAt(i); // jep so save it
                            for (int j = newtiles.Count-1; j >= 0; --j) // and remove all invis
                            {
                                if (newtiles[j].m_ItemID == 0x1)
                                    newtiles.RemoveAt(j);
                            }
                            newtiles.Insert(0, centeritem);
                            return newtiles;
                        }
                    }
                    for (int j = newtiles.Count-1; j >= 1; --j) // nothing found so remove all invis exept the first
                    {
                        if (newtiles[j].m_ItemID == 0x1)
                            newtiles.RemoveAt(j);
                    }
                    return newtiles;
                }
            }
            for (int i = 0; i < newtiles.Count; ++i) // is there a good one
            {
                if (newtiles[i].m_OffsetX == 0 && newtiles[i].m_OffsetY == 0
                    && newtiles[i].m_ItemID != 0x1 && newtiles[i].m_OffsetZ == 0)
                {
                    MultiComponentList.MultiTileEntry centeritem = newtiles[i];
                    newtiles.RemoveAt(i); // store it
                    for (int j = newtiles.Count-1; j >= 0; --j) // remove all invis
                    {
                        if (newtiles[j].m_ItemID == 0x1)
                            newtiles.RemoveAt(j);
                    }
                    newtiles.Insert(0, centeritem);
                    return newtiles;
                }
            }
            for (int j = newtiles.Count-1; j >= 0; --j) // nothing found so remove all invis
            {
                if (newtiles[j].m_ItemID == 0x1)
                    newtiles.RemoveAt(j);
            }
            MultiComponentList.MultiTileEntry invisitem = new MultiComponentList.MultiTileEntry();
            invisitem.m_ItemID = 0x1; // and create a new invis
            invisitem.m_OffsetX = 0;
            invisitem.m_OffsetY = 0;
            invisitem.m_OffsetZ = 0;
            invisitem.m_Flags = 0;
            invisitem.m_Unk1 = 0;
            newtiles.Insert(0, invisitem);
            return newtiles;
        }
 public MultiComponentList(BinaryReader reader, int count)
 {
     Point empty = Point.Empty;
     Point point = empty;
     this.m_Max = empty;
     this.m_Min = point;
     MultiComponentList.MultiTileEntry[] multiTileEntryArray = new MultiComponentList.MultiTileEntry[count];
     for (int i = 0; i < count; i++)
     {
         multiTileEntryArray[i].m_ItemID = reader.ReadInt16();
         multiTileEntryArray[i].m_OffsetX = reader.ReadInt16();
         multiTileEntryArray[i].m_OffsetY = reader.ReadInt16();
         multiTileEntryArray[i].m_OffsetZ = reader.ReadInt16();
         multiTileEntryArray[i].m_Flags = reader.ReadInt32();
         MultiComponentList.MultiTileEntry multiTileEntry = multiTileEntryArray[i];
         if (multiTileEntry.m_OffsetX < this.m_Min.X)
         {
             this.m_Min.X = multiTileEntry.m_OffsetX;
         }
         if (multiTileEntry.m_OffsetY < this.m_Min.Y)
         {
             this.m_Min.Y = multiTileEntry.m_OffsetY;
         }
         if (multiTileEntry.m_OffsetX > this.m_Max.X)
         {
             this.m_Max.X = multiTileEntry.m_OffsetX;
         }
         if (multiTileEntry.m_OffsetY > this.m_Max.Y)
         {
             this.m_Max.Y = multiTileEntry.m_OffsetY;
         }
     }
     this.m_Center = new Point(-this.m_Min.X, -this.m_Min.Y);
     this.m_Width = this.m_Max.X - this.m_Min.X + 1;
     this.m_Height = this.m_Max.Y - this.m_Min.Y + 1;
     TileList[][] tileList = new TileList[this.m_Width][];
     this.m_Tiles = new Tile[this.m_Width][][];
     for (int j = 0; j < this.m_Width; j++)
     {
         tileList[j] = new TileList[this.m_Height];
         this.m_Tiles[j] = new Tile[this.m_Height][];
         for (int k = 0; k < this.m_Height; k++)
         {
             tileList[j][k] = new TileList();
         }
     }
     for (int l = 0; l < (int)multiTileEntryArray.Length; l++)
     {
         int mOffsetX = multiTileEntryArray[l].m_OffsetX + this.m_Center.X;
         int mOffsetY = multiTileEntryArray[l].m_OffsetY + this.m_Center.Y;
         tileList[mOffsetX][mOffsetY].Add((short)((multiTileEntryArray[l].m_ItemID & 16383) + 16384), (sbyte)multiTileEntryArray[l].m_OffsetZ);
     }
     for (int m = 0; m < this.m_Width; m++)
     {
         for (int n = 0; n < this.m_Height; n++)
         {
             this.m_Tiles[m][n] = tileList[m][n].ToArray();
             if ((int)this.m_Tiles[m][n].Length > 1)
             {
                 Array.Sort(this.m_Tiles[m][n]);
             }
         }
     }
 }
Exemplo n.º 8
0
        public MultiComponentList(BinaryReader reader, int count)
        {
            Point empty = Point.Empty;
            Point point = empty;

            this.m_Max = empty;
            this.m_Min = point;
            MultiComponentList.MultiTileEntry[] multiTileEntryArray = new MultiComponentList.MultiTileEntry[count];
            for (int i = 0; i < count; i++)
            {
                multiTileEntryArray[i].m_ItemID  = reader.ReadInt16();
                multiTileEntryArray[i].m_OffsetX = reader.ReadInt16();
                multiTileEntryArray[i].m_OffsetY = reader.ReadInt16();
                multiTileEntryArray[i].m_OffsetZ = reader.ReadInt16();
                multiTileEntryArray[i].m_Flags   = reader.ReadInt32();
                MultiComponentList.MultiTileEntry multiTileEntry = multiTileEntryArray[i];
                if (multiTileEntry.m_OffsetX < this.m_Min.X)
                {
                    this.m_Min.X = multiTileEntry.m_OffsetX;
                }
                if (multiTileEntry.m_OffsetY < this.m_Min.Y)
                {
                    this.m_Min.Y = multiTileEntry.m_OffsetY;
                }
                if (multiTileEntry.m_OffsetX > this.m_Max.X)
                {
                    this.m_Max.X = multiTileEntry.m_OffsetX;
                }
                if (multiTileEntry.m_OffsetY > this.m_Max.Y)
                {
                    this.m_Max.Y = multiTileEntry.m_OffsetY;
                }
            }
            this.m_Center = new Point(-this.m_Min.X, -this.m_Min.Y);
            this.m_Width  = this.m_Max.X - this.m_Min.X + 1;
            this.m_Height = this.m_Max.Y - this.m_Min.Y + 1;
            TileList[][] tileList = new TileList[this.m_Width][];
            this.m_Tiles = new Tile[this.m_Width][][];
            for (int j = 0; j < this.m_Width; j++)
            {
                tileList[j]     = new TileList[this.m_Height];
                this.m_Tiles[j] = new Tile[this.m_Height][];
                for (int k = 0; k < this.m_Height; k++)
                {
                    tileList[j][k] = new TileList();
                }
            }
            for (int l = 0; l < (int)multiTileEntryArray.Length; l++)
            {
                int mOffsetX = multiTileEntryArray[l].m_OffsetX + this.m_Center.X;
                int mOffsetY = multiTileEntryArray[l].m_OffsetY + this.m_Center.Y;
                tileList[mOffsetX][mOffsetY].Add((short)((multiTileEntryArray[l].m_ItemID & 16383) + 16384), (sbyte)multiTileEntryArray[l].m_OffsetZ);
            }
            for (int m = 0; m < this.m_Width; m++)
            {
                for (int n = 0; n < this.m_Height; n++)
                {
                    this.m_Tiles[m][n] = tileList[m][n].ToArray();
                    if ((int)this.m_Tiles[m][n].Length > 1)
                    {
                        Array.Sort(this.m_Tiles[m][n]);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public static List <object[]> LoadFromDesigner(string FileName)
        {
            var multilist = new List <object[]>();
            var root      = Path.GetFileNameWithoutExtension(FileName);
            var idx       = String.Format("{0}.idx", root);
            var bin       = String.Format("{0}.bin", root);

            if ((!File.Exists(idx)) || (!File.Exists(bin)))
            {
                return(multilist);
            }

            using (FileStream idxfs = new FileStream(idx, FileMode.Open, FileAccess.Read, FileShare.Read),
                   binfs = new FileStream(bin, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (BinaryReader idxbin = new BinaryReader(idxfs),
                       binbin = new BinaryReader(binfs))
                {
                    var count   = idxbin.ReadInt32();
                    var version = idxbin.ReadInt32();

                    for (var i = 0; i < count; ++i)
                    {
                        var data = new object[2];
                        switch (version)
                        {
                        case 0:
                            data[0] = ReadUOAString(idxbin);
                            var arr = new List <MultiComponentList.MultiTileEntry>();
                            data[0] += "-" + ReadUOAString(idxbin);
                            data[0] += "-" + ReadUOAString(idxbin);
                            var width    = idxbin.ReadInt32();
                            var height   = idxbin.ReadInt32();
                            var uwidth   = idxbin.ReadInt32();
                            var uheight  = idxbin.ReadInt32();
                            var filepos  = idxbin.ReadInt64();
                            var reccount = idxbin.ReadInt32();

                            binbin.BaseStream.Seek(filepos, SeekOrigin.Begin);
                            int index, x, y, z, level, hue;
                            for (var j = 0; j < reccount; ++j)
                            {
                                index = x = y = z = level = hue = 0;
                                var compVersion = binbin.ReadInt32();
                                switch (compVersion)
                                {
                                case 0:
                                    index = binbin.ReadInt32();
                                    x     = binbin.ReadInt32();
                                    y     = binbin.ReadInt32();
                                    z     = binbin.ReadInt32();
                                    level = binbin.ReadInt32();
                                    break;

                                case 1:
                                    index = binbin.ReadInt32();
                                    x     = binbin.ReadInt32();
                                    y     = binbin.ReadInt32();
                                    z     = binbin.ReadInt32();
                                    level = binbin.ReadInt32();
                                    hue   = binbin.ReadInt32();
                                    break;
                                }
                                var tempitem = new MultiComponentList.MultiTileEntry
                                {
                                    m_ItemID  = (ushort)index,
                                    m_Flags   = 1,
                                    m_OffsetX = (short)x,
                                    m_OffsetY = (short)y,
                                    m_OffsetZ = (short)z,
                                    m_Unk1    = 0
                                };
                                arr.Add(tempitem);
                            }
                            data[1] = new MultiComponentList(arr);
                            break;
                        }
                        multilist.Add(data);
                    }
                }
                return(multilist);
            }
        }
Exemplo n.º 10
0
 public MultiComponentList(BinaryReader reader, int count)
 {
     this.m_Min = this.m_Max = Point.Empty;
     MultiComponentList.MultiTileEntry[] multiTileEntryArray = new MultiComponentList.MultiTileEntry[count];
     for (int index = 0; index < count; ++index)
     {
         multiTileEntryArray[index].m_ItemID  = reader.ReadInt16();
         multiTileEntryArray[index].m_OffsetX = reader.ReadInt16();
         multiTileEntryArray[index].m_OffsetY = reader.ReadInt16();
         multiTileEntryArray[index].m_OffsetZ = reader.ReadInt16();
         multiTileEntryArray[index].m_Flags   = reader.ReadInt32();
         MultiComponentList.MultiTileEntry multiTileEntry = multiTileEntryArray[index];
         if ((int)multiTileEntry.m_OffsetX < this.m_Min.X)
         {
             this.m_Min.X = (int)multiTileEntry.m_OffsetX;
         }
         if ((int)multiTileEntry.m_OffsetY < this.m_Min.Y)
         {
             this.m_Min.Y = (int)multiTileEntry.m_OffsetY;
         }
         if ((int)multiTileEntry.m_OffsetX > this.m_Max.X)
         {
             this.m_Max.X = (int)multiTileEntry.m_OffsetX;
         }
         if ((int)multiTileEntry.m_OffsetY > this.m_Max.Y)
         {
             this.m_Max.Y = (int)multiTileEntry.m_OffsetY;
         }
     }
     this.m_Center = new Point(-this.m_Min.X, -this.m_Min.Y);
     this.m_Width  = this.m_Max.X - this.m_Min.X + 1;
     this.m_Height = this.m_Max.Y - this.m_Min.Y + 1;
     TileList[][] tileListArray = new TileList[this.m_Width][];
     this.m_Tiles = new Tile[this.m_Width][][];
     for (int index1 = 0; index1 < this.m_Width; ++index1)
     {
         tileListArray[index1] = new TileList[this.m_Height];
         this.m_Tiles[index1]  = new Tile[this.m_Height][];
         for (int index2 = 0; index2 < this.m_Height; ++index2)
         {
             tileListArray[index1][index2] = new TileList();
         }
     }
     for (int index1 = 0; index1 < multiTileEntryArray.Length; ++index1)
     {
         int index2 = (int)multiTileEntryArray[index1].m_OffsetX + this.m_Center.X;
         int index3 = (int)multiTileEntryArray[index1].m_OffsetY + this.m_Center.Y;
         tileListArray[index2][index3].Add((short)(((int)multiTileEntryArray[index1].m_ItemID & 16383) + 16384), (sbyte)multiTileEntryArray[index1].m_OffsetZ);
     }
     for (int index1 = 0; index1 < this.m_Width; ++index1)
     {
         for (int index2 = 0; index2 < this.m_Height; ++index2)
         {
             this.m_Tiles[index1][index2] = tileListArray[index1][index2].ToArray();
             if (this.m_Tiles[index1][index2].Length > 1)
             {
                 Array.Sort((Array)this.m_Tiles[index1][index2]);
             }
         }
     }
 }