Example #1
0
        public ArrayList Compress()
        {
            ArrayList list = new ArrayList();

            for (int i = 0; i < HouseDesign.Levels; ++i)
            {
                for (int x = 0; x < m_Width; ++x)
                {
                    for (int y = 0; y < m_Height; ++y)
                    {
                        ArrayList comps = m_Components[x][y][i];

                        for (int j = 0; j < comps.Count; ++j)
                        {
                            HouseComponent hc = (HouseComponent)comps[j];

                            list.Add(new BuildEntry(x, y, hc.Z, hc.BaseIndex, hc.Count, i));
                        }
                    }
                }
            }

            bool combined, thisCombined;

            do
            {
                combined = false;

                for (int i = 0; i < list.Count; ++i)
                {
                    BuildEntry be = (BuildEntry)list[i];
                    thisCombined = false;

                    for (int j = 0; !thisCombined && j < list.Count; ++j)
                    {
                        BuildEntry te = (BuildEntry)list[j];

                        if (i != j && be.CombineWith(te))
                        {
                            list.RemoveAt(i);
                            --i;
                            combined = thisCombined = true;
                        }
                    }
                }
            } while (combined);

            return(list);
        }