/** * <summary>Removes a polygon from the level.</summary> * <param name="polygon">Polygon to remove from the level.</param> */ public void RemovePolygon( LevelPolygon polygon ) { if( ! polygons.Contains( polygon ) ) return; polygons.Remove( polygon ); polygon.StopListeningToTextureList( textureList ); for( int i = 0 ; i < polygon.VertexCount ; ++i ) { LevelVertex v = polygon.GetVertex( i ); bool usedElsewhere = false; foreach( LevelPolygon p in polygons ) { if( p.ContainsVertex( v ) ) { usedElsewhere = true; break; } } if( !usedElsewhere ) vertices.Remove( v ); } }
/** * <summary>Adds a polygon to the level's set of total polygons if the polygon is not already * a part of the level.</summary> * <param name="polygon">Polygon to add to the level.</param> */ public void AddPolygon( LevelPolygon polygon ) { if( polygons.Contains( polygon ) ) return; polygons.Add( polygon ); polygon.ListenToTextureList( textureList ); for( int i = 0 ; i < polygon.VertexCount ; ++i ) { AddVertex( polygon.GetVertex( i ) ); } }