Aura.Channel.World.Region.GetEntitiesInRange C# (CSharp) Method

GetEntitiesInRange() public method

Returns new list of all entities within range of source.
public GetEntitiesInRange ( Entity source, int range = -1 ) : List
source Entity
range int Leave at default for visible range.
return List
		public List<Entity> GetEntitiesInRange(Entity source, int range = -1)
		{
			if (range < 0)
				range = VisibleRange;

			var result = new List<Entity>();

			_creaturesRWLS.EnterReadLock();
			try
			{
				result.AddRange(_creatures.Values.Where(a => a.GetPosition().InRange(source.GetPosition(), range)));
			}
			finally
			{
				_creaturesRWLS.ExitReadLock();
			}

			_itemsRWLS.EnterReadLock();
			try
			{
				result.AddRange(_items.Values.Where(a => a.GetPosition().InRange(source.GetPosition(), range)));
			}
			finally
			{
				_itemsRWLS.ExitReadLock();
			}

			_propsRWLS.EnterReadLock();
			try
			{
				// All props are visible, but not all of them are in range.
				result.AddRange(_props.Values.Where(a => a.GetPosition().InRange(source.GetPosition(), range)));
			}
			finally
			{
				_propsRWLS.ExitReadLock();
			}

			return result;
		}