예제 #1
0
        public virtual void ForEachFigID(Dictionary <uint, MpFigure_v1001> allMap, Action <uint> d)
        {
            d(ID);

            if (ChildIdList == null)
            {
                return;
            }

            int i;

            for (i = 0; i < ChildIdList.Count; i++)
            {
                uint           id       = ChildIdList[i];
                MpFigure_v1001 childFig = allMap[id];
                childFig.ForEachFigID(allMap, d);
            }
        }
예제 #2
0
        public void GarbageCollect()
        {
            var idMap = new Dictionary <uint, MpFigure_v1001>();

            foreach (MpFigure_v1001 fig in FigureList)
            {
                idMap.Add(fig.ID, fig);
            }

            var activeSet = new HashSet <uint>();

            foreach (MpLayer_v1001 layer in LayerList)
            {
                foreach (uint id in layer.FigureIdList)
                {
                    MpFigure_v1001 fig = idMap[id];

                    fig.ForEachFigID(idMap, (a) =>
                    {
                        activeSet.Add(a);
                    });
                }
            }

            int i = FigureList.Count - 1;

            for (; i >= 0; i--)
            {
                MpFigure_v1001 fig = FigureList[i];

                if (!activeSet.Contains(fig.ID))
                {
                    FigureList.RemoveAt(i);
                }
            }
        }