@@ -33,7 +33,7 @@ public partial class CollisionGrid<T>
3333 public int NumberOfCellsY { get ; private set ; }
3434
3535 private Dictionary < Point , List < T > > Grid { get ; set ; }
36- private Dictionary < T , List < Point > > Items { get ; set ; }
36+ private Dictionary < T , List < Point > > ItemDictionary { get ; set ; }
3737 private Queue < List < Point > > ListOfPointQueue { get ; set ; }
3838 private Queue < List < T > > ListOfItemQueue { get ; set ; }
3939
@@ -46,7 +46,7 @@ public CollisionGrid(float width, float height, int numberOfCellsX, int numberOf
4646 CellWidth = Width / NumberOfCellsX ;
4747 CellHeight = Height / NumberOfCellsY ;
4848
49- Items = new Dictionary < T , List < Point > > ( ) ;
49+ ItemDictionary = new Dictionary < T , List < Point > > ( ) ;
5050 Grid = new Dictionary < Point , List < T > > ( ) ;
5151
5252 ListOfPointQueue = new Queue < List < Point > > ( ) ;
@@ -58,7 +58,7 @@ public Point[] Get(T item)
5858 lock ( lockObject )
5959 {
6060 List < Point > pl ;
61- Items . TryGetValue ( item , out pl ) ;
61+ ItemDictionary . TryGetValue ( item , out pl ) ;
6262 if ( pl == null )
6363 {
6464 return new Point [ 0 ] ;
@@ -76,7 +76,7 @@ public void Remove(T item)
7676 lock ( lockObject )
7777 {
7878 List < Point > pl ;
79- Items . TryGetValue ( item , out pl ) ;
79+ ItemDictionary . TryGetValue ( item , out pl ) ;
8080 if ( pl == null )
8181 {
8282 return ;
@@ -89,7 +89,7 @@ public void Remove(T item)
8989
9090 pl . Clear ( ) ;
9191 ListOfPointQueue . Enqueue ( pl ) ;
92- Items . Remove ( item ) ;
92+ ItemDictionary . Remove ( item ) ;
9393 }
9494 }
9595
@@ -102,25 +102,31 @@ private void RemoveFromGrid(T item, Point cell)
102102 tl . Remove ( item ) ;
103103 if ( tl . Count == 0 )
104104 {
105- if ( ListOfItemQueue . Count == 0 )
106- {
107- Console . Out . WriteLine ( "Yippie!" ) ;
108- }
109105 ListOfItemQueue . Enqueue ( tl ) ;
110106 Grid . Remove ( cell ) ;
111107 }
112108 }
113109 }
114110
115- public IEnumerable < T > AllItems ( )
111+ public IEnumerable < T > Items
116112 {
117- return Items . Keys ;
113+ get { return ItemDictionary . Keys ; }
118114 }
119115
120- public IEnumerable < Point > AllOccupiedCells ( )
116+ public IEnumerable < Point > OccupiedCells
121117 {
122- return Grid . Keys ;
123- }
118+ get { return Grid . Keys ; }
119+ }
120+
121+ public int OccupiedCellCount
122+ {
123+ get { return ItemDictionary . Keys . Count ; }
124+ }
125+
126+ public int ItemCount
127+ {
128+ get { return Grid . Keys . Count ; }
129+ }
124130
125131 private Rectangle Rectangle ( Rect rect )
126132 {
@@ -177,8 +183,8 @@ public void Dispose()
177183 ListOfItemQueue = null ;
178184 Grid . Clear ( ) ;
179185 Grid = null ;
180- Items . Clear ( ) ;
181- Items = null ;
186+ ItemDictionary . Clear ( ) ;
187+ ItemDictionary = null ;
182188 }
183189 }
184190 }
0 commit comments