public IPooledEnumerable GetMobilesInBounds( Rectangle2D bounds ) { if ( this == Map.Internal ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( TypedEnumerator.Instantiate( this, bounds, SectorEnumeratorType.Mobiles ) ); }
public IPooledEnumerable GetItemsInRange( Point3D p ) { if ( this == Map.Internal ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( TypedEnumerator.Instantiate( this, new Rectangle2D( p.m_X - 18, p.m_Y - 18, 37, 37 ), SectorEnumeratorType.Items ) ); }
public IPooledEnumerable GetMobilesInRange( Point3D p, int range ) { if ( this == Map.Internal ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( TypedEnumerator.Instantiate( this, new Rectangle2D( p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1 ), SectorEnumeratorType.Mobiles ) ); }
public IPooledEnumerable GetObjectsInBounds( Rectangle2D bounds ) { if ( this == Map.Internal ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( ObjectEnumerator.Instantiate( this, bounds ) ); }
public IPooledEnumerable GetObjectsInRange( Point3D p, int range ) { if ( this == Map.Internal ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( ObjectEnumerator.Instantiate( this, new Rectangle2D( p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1 ) ) ); }
public IPooledEnumerable GetObjectsInRange( Point3D p ) { if ( this == Map.Internal ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( ObjectEnumerator.Instantiate( this, new Rectangle2D( p.m_X - 18, p.m_Y - 18, 37, 37 ) ) ); }
public IPooledEnumerable GetMultiTilesAt( int x, int y ) { if ( this == Map.Internal ) return NullEnumerable.Instance; Sector sector = GetSector( x, y ); if ( sector.Multis.Count == 0 ) return NullEnumerable.Instance; return PooledEnumerable.Instantiate( MultiTileEnumerator.Instantiate( sector, new Point2D( x, y ) ) ); }
public static PooledEnumerable Instantiate( IPooledEnumerator etor ) { ++m_Depth; if ( m_Depth >= 5 ) Console.WriteLine( "Warning: Make sure to call .Free() on pooled enumerables." ); PooledEnumerable e; if ( m_InstancePool.Count > 0 ) { e = m_InstancePool.Dequeue(); e.m_Enumerator = etor; } else { e = new PooledEnumerable( etor ); } etor.Enumerable = e; return e; }
public static PooledEnumerable Instantiate( IPooledEnumerator etor ) { ++m_Depth; if ( m_Depth >= 5 ) log.WarnFormat("Make sure to call .Free() on pooled enumerables."); PooledEnumerable e; if ( m_InstancePool.Count > 0 ) { e = (PooledEnumerable)m_InstancePool.Dequeue(); e.m_Enumerator = etor; } else { e = new PooledEnumerable( etor ); } etor.Enumerable = e; return e; }
public static PooledEnumerable Instantiate(IPooledEnumerator etor) { ++m_Depth; // track current depth if (m_Depth > m_HighWaterMark) // track max depth m_HighWaterMark = m_Depth; if (m_Depth >= 5) Console.WriteLine("PooledEnumerable: Depth = {0}, High Water Mark = {1}", m_Depth, m_HighWaterMark); PooledEnumerable e; if (m_InstancePool.Count > 0) { e = (PooledEnumerable)m_InstancePool.Dequeue(); e.m_Enumerator = etor; if (e != null && e.Status != PooledEnumerable.status.normal && e.Status != PooledEnumerable.status.derived_moveNext) { // always happens. Back to the drawing board. // string message = String.Format("PooledEnumerable.Instantiate() called after the derived class was: {0}", e.Status.ToString()); // Console.WriteLine(message); } if (etor == null) { // TEST string message = String.Format("PooledEnumerable.Instantiate() etor starting out null"); Console.WriteLine(message); } } else { e = new PooledEnumerable(etor); } etor.Enumerable = e; // reset e.Status = PooledEnumerable.status.normal; return e; }