Пример #1
0
        private void ConvertList()
        {
            m_Center = new Point(-m_Min.X, -m_Min.Y);
            m_Width  = (m_Max.X - m_Min.X) + 1;
            m_Height = (m_Max.Y - m_Min.Y) + 1;

            var tiles = new MTileList[m_Width][];

            m_Tiles = new MTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new MTileList[m_Height];
                m_Tiles[x] = new MTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new MTileList();
                }
            }

            for (int i = 0; i < m_SortedTiles.Length; ++i)
            {
                int xOffset = m_SortedTiles[i].m_OffsetX + m_Center.X;
                int yOffset = m_SortedTiles[i].m_OffsetY + m_Center.Y;

                tiles[xOffset][yOffset].Add(
                    (m_SortedTiles[i].m_ItemID),
                    (sbyte)m_SortedTiles[i].m_OffsetZ,
                    (sbyte)m_SortedTiles[i].m_Flags,
                    m_SortedTiles[i].m_Unk1);
            }

            m_Surface = 0;

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                    for (int i = 0; i < m_Tiles[x][y].Length; ++i)
                    {
                        m_Tiles[x][y][i].Solver = i;
                    }
                    if (m_Tiles[x][y].Length > 1)
                    {
                        Array.Sort(m_Tiles[x][y]);
                    }
                    if (m_Tiles[x][y].Length > 0)
                    {
                        ++m_Surface;
                    }
                }
            }
        }
Пример #2
0
        private void ConvertList()
        {
            _center = new Point(-_min.X, -_min.Y);
            Width   = (_max.X - _min.X) + 1;
            Height  = (_max.Y - _min.Y) + 1;

            var tiles = new MTileList[Width][];

            Tiles = new MTile[Width][][];

            for (int x = 0; x < Width; ++x)
            {
                tiles[x] = new MTileList[Height];
                Tiles[x] = new MTile[Height][];

                for (int y = 0; y < Height; ++y)
                {
                    tiles[x][y] = new MTileList();
                }
            }

            for (int i = 0; i < SortedTiles.Length; ++i)
            {
                int xOffset = SortedTiles[i].m_OffsetX + _center.X;
                int yOffset = SortedTiles[i].m_OffsetY + _center.Y;

                tiles[xOffset][yOffset].Add(SortedTiles[i].m_ItemID, (sbyte)SortedTiles[i].m_OffsetZ,
                                            (sbyte)SortedTiles[i].m_Flags, SortedTiles[i].m_Unk1);
            }

            Surface = 0;

            for (int x = 0; x < Width; ++x)
            {
                for (int y = 0; y < Height; ++y)
                {
                    Tiles[x][y] = tiles[x][y].ToArray();
                    for (int i = 0; i < Tiles[x][y].Length; ++i)
                    {
                        Tiles[x][y][i].Solver = i;
                    }

                    if (Tiles[x][y].Length > 1)
                    {
                        Array.Sort(Tiles[x][y]);
                    }

                    if (Tiles[x][y].Length > 0)
                    {
                        ++Surface;
                    }
                }
            }
        }
 public MultiComponentList ConvertToSDK()
 {
     int count = 0;
     MTileList[][] tiles = new MTileList[Width][];
     for (int x = 0; x < Width; ++x)
     {
         tiles[x] = new MTileList[Height];
         for (int y = 0; y < Height; ++y)
         {
             tiles[x][y] = new MTileList();
         }
     }
     for (int i = 0; i < Tiles.Count; ++i)
     {
         MultiTile tile = Tiles[i];
         if (tile.isVirtualFloor)
             continue;
         tiles[tile.X][tile.Y].Add((ushort)(tile.ID), (sbyte)tile.Z, tile.Invisible ? (sbyte)0 : (sbyte)1);
         ++count;
     }
     return new MultiComponentList(tiles, count, Width, Height);
 }
Пример #4
0
        private void ConvertList()
        {
            m_Center = new Point(-m_Min.X, -m_Min.Y);
            m_Width = (m_Max.X - m_Min.X) + 1;
            m_Height = (m_Max.Y - m_Min.Y) + 1;

            MTileList[][] tiles = new MTileList[m_Width][];
            m_Tiles = new MTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x] = new MTileList[m_Height];
                m_Tiles[x] = new MTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                    tiles[x][y] = new MTileList();
            }

            for (int i = 0; i < m_SortedTiles.Length; ++i)
            {
                int xOffset = m_SortedTiles[i].m_OffsetX + m_Center.X;
                int yOffset = m_SortedTiles[i].m_OffsetY + m_Center.Y;

                tiles[xOffset][yOffset].Add((ushort)(m_SortedTiles[i].m_ItemID), (sbyte)m_SortedTiles[i].m_OffsetZ, (sbyte)m_SortedTiles[i].m_Flags, m_SortedTiles[i].m_Unk1);
            }

            m_Surface = 0;

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                    for (int i = 0; i < m_Tiles[x][y].Length; ++i)
                        m_Tiles[x][y][i].Solver = i;
                    if (m_Tiles[x][y].Length > 1)
                        Array.Sort(m_Tiles[x][y]);
                    if (m_Tiles[x][y].Length > 0)
                        ++m_Surface;
                }
            }
        }
Пример #5
0
        public MultiComponentList(MTileList[][] newtiles, int count, int width, int height)
        {
            m_Min = m_Max = Point.Empty;
            m_SortedTiles = new MultiTileEntry[count];
            m_Center = new Point((int)(Math.Round((width / 2.0))) - 1, (int)(Math.Round((height / 2.0))) - 1);
            if (m_Center.X < 0)
                m_Center.X = width / 2;
            if (m_Center.Y < 0)
                m_Center.Y = height / 2;
            m_maxHeight = -128;

            int counter = 0;
            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    MTile[] tiles = newtiles[x][y].ToArray();
                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        m_SortedTiles[counter].m_ItemID = (ushort)(tiles[i].ID);
                        m_SortedTiles[counter].m_OffsetX = (short)(x - m_Center.X);
                        m_SortedTiles[counter].m_OffsetY = (short)(y - m_Center.Y);
                        m_SortedTiles[counter].m_OffsetZ = (short)(tiles[i].Z);
                        m_SortedTiles[counter].m_Flags = (int)tiles[i].Flag;
                        m_SortedTiles[counter].m_Unk1 = 0;

                        if (m_SortedTiles[counter].m_OffsetX < m_Min.X)
                            m_Min.X = m_SortedTiles[counter].m_OffsetX;
                        if (m_SortedTiles[counter].m_OffsetX > m_Max.X)
                            m_Max.X = m_SortedTiles[counter].m_OffsetX;
                        if (m_SortedTiles[counter].m_OffsetY < m_Min.Y)
                            m_Min.Y = m_SortedTiles[counter].m_OffsetY;
                        if (m_SortedTiles[counter].m_OffsetY > m_Max.Y)
                            m_Max.Y = m_SortedTiles[counter].m_OffsetY;
                        if (m_SortedTiles[counter].m_OffsetZ > m_maxHeight)
                            m_maxHeight = m_SortedTiles[counter].m_OffsetZ;
                        ++counter;
                    }
                }
            }
            ConvertList();
        }
Пример #6
0
        public MultiComponentList(MTileList[][] newtiles, int count, int width, int height)
        {
            m_Min = m_Max = Point.Empty;
            m_SortedTiles = new MultiTileEntry[count];
            m_Center = new Point((width / 2) - 1, (height / 2) - 1);
            if (m_Center.X < 0)
                m_Center.X = width / 2;
            if (m_Center.Y < 0)
                m_Center.Y = height / 2;
            m_maxHeight = -128;

            bool centerfound = false;
            if (newtiles[m_Center.X][m_Center.Y].Count > 0)
            {
                for (int i = 0; i < newtiles[m_Center.X][m_Center.Y].Count; ++i)
                {
                    if ((newtiles[m_Center.X][m_Center.Y].Get(i).ID == 0x1) &&
                        (newtiles[m_Center.X][m_Center.Y].Get(i).Z == 0))
                    {
                        m_SortedTiles[0].m_OffsetX = 0;
                        m_SortedTiles[0].m_OffsetY = 0;
                        m_SortedTiles[0].m_OffsetZ = 0;
                        m_SortedTiles[0].m_Flags = 0;
                        m_SortedTiles[0].m_ItemID = 0x1;
                        centerfound = true;
                        newtiles[m_Center.X][m_Center.Y].Set(i, 0xFFFF, 0);
                        break;
                    }
                }
            }
            int counter = 1;
            if (!centerfound)
            {
                if (MessageBox.Show("No invisible Center Item found do you want to add it?",
                    "Multi Save",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button1) == DialogResult.OK)
                {
                    m_SortedTiles = new MultiTileEntry[count + 1];
                    m_SortedTiles[0].m_ItemID = 0x1; // insert invis center item
                    m_SortedTiles[0].m_OffsetX = 0;
                    m_SortedTiles[0].m_OffsetY = 0;
                    m_SortedTiles[0].m_Flags = 0;
                }
                else
                    counter = 0;
            }

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    MTile[] tiles = newtiles[x][y].ToArray();
                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        if (tiles[i].ID != 0xFFFF)
                        {
                            m_SortedTiles[counter].m_ItemID = (ushort)(tiles[i].ID);
                            m_SortedTiles[counter].m_OffsetX = (short)(x - m_Center.X);
                            m_SortedTiles[counter].m_OffsetY = (short)(y - m_Center.Y);
                            m_SortedTiles[counter].m_OffsetZ = (short)(tiles[i].Z);
                            m_SortedTiles[counter].m_Flags = (int)tiles[i].Flag;

                            if (m_SortedTiles[counter].m_OffsetX < m_Min.X)
                                m_Min.X = m_SortedTiles[counter].m_OffsetX;
                            if (m_SortedTiles[counter].m_OffsetX > m_Max.X)
                                m_Max.X = m_SortedTiles[counter].m_OffsetX;
                            if (m_SortedTiles[counter].m_OffsetY < m_Min.Y)
                                m_Min.Y = m_SortedTiles[counter].m_OffsetY;
                            if (m_SortedTiles[counter].m_OffsetY > m_Max.Y)
                                m_Max.Y = m_SortedTiles[counter].m_OffsetY;
                            if (m_SortedTiles[counter].m_OffsetZ > m_maxHeight)
                                m_maxHeight = m_SortedTiles[counter].m_OffsetZ;
                            ++counter;
                        }
                    }
                }
            }
            ConvertList();
        }