Esempio n. 1
0
        public void RemovePrimitive(int index)
        {
            m_removingPrimitive = index;
            MyHighLevelPrimitive primitive = null;

            if (!m_primitives.TryGetValue(index, out primitive))
            {
                Debug.Assert(false, "Could not find the primitive to remove!");
                m_removingPrimitive = -1;
                return;
            }

            List <IMyHighLevelPrimitiveObserver> observers = null;

            if (m_primitiveObservers.TryGetValue(index, out observers))
            {
                foreach (var path in observers)
                {
                    path.Invalidate();
                }
            }
            m_primitiveObservers.Remove(index);

            m_links.RemoveAllLinks(primitive);

            m_tmpNeighbors.Clear();
            primitive.GetNeighbours(m_tmpNeighbors);

            foreach (var neighborIndex in m_tmpNeighbors)
            {
                MyHighLevelPrimitive neighbor = null;
                m_primitives.TryGetValue(neighborIndex, out neighbor);

                Debug.Assert(neighbor != null, "Could not find the neighbor of a high-level primitive!");
                if (neighbor == null)
                {
                    continue;
                }

                neighbor.Disconnect(index);
            }

            m_primitives.Remove(index);
            m_removingPrimitive = -1;
        }
Esempio n. 2
0
        public void RemovePrimitive(int index)
        {
            this.m_removingPrimitive = index;
            MyHighLevelPrimitive primitive = null;

            if (!this.m_primitives.TryGetValue(index, out primitive))
            {
                this.m_removingPrimitive = -1;
            }
            else
            {
                List <IMyHighLevelPrimitiveObserver> list = null;
                if (this.m_primitiveObservers.TryGetValue(index, out list))
                {
                    using (List <IMyHighLevelPrimitiveObserver> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            enumerator.Current.Invalidate();
                        }
                    }
                }
                this.m_primitiveObservers.Remove(index);
                this.m_links.RemoveAllLinks(primitive);
                m_tmpNeighbors.Clear();
                primitive.GetNeighbours(m_tmpNeighbors);
                foreach (int num in m_tmpNeighbors)
                {
                    MyHighLevelPrimitive primitive2 = null;
                    this.m_primitives.TryGetValue(num, out primitive2);
                    if (primitive2 != null)
                    {
                        primitive2.Disconnect(index);
                    }
                }
                this.m_primitives.Remove(index);
                this.m_removingPrimitive = -1;
            }
        }