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

GetVisibleEntities() public method

Returns a list of visible entities, from the view point of creature.
public GetVisibleEntities ( Creature creature ) : List
creature Aura.Channel.World.Entities.Creature
return List
		public List<Entity> GetVisibleEntities(Creature creature)
		{
			var result = new List<Entity>();
			var pos = creature.GetPosition();

			// Players don't see anything else while they're watching a cutscene.
			// This automatically (de)spawns entities (from LookAround) while watching.
			if (creature.Temp.CurrentCutscene == null || !creature.IsPlayer)
			{
				_creaturesRWLS.EnterReadLock();
				try
				{
					result.AddRange(_creatures.Values.Where(a => a.GetPosition().InRange(pos, VisibleRange) && !a.Conditions.Has(ConditionsA.Invisible)));
				}
				finally
				{
					_creaturesRWLS.ExitReadLock();
				}

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

			_propsRWLS.EnterReadLock();
			try
			{
				// Send all props of a region, so they're visible from afar.
				// While client props are visible as well they don't have to
				// be sent, the client already has them.
				//
				// ^^^^^^^^^^^^^^^^^^ This caused a bug with client prop states
				// not being set until the prop was used by a player while
				// the creature was in the region (eg windmill) so we'll count
				// all props as visible. -- Xcelled
				//
				// ^^^^^^^^^^^^^^^^^^ That causes a huge EntitiesAppear packet,
				// because there are thousands of client props. We only need
				// the ones that make a difference. Added check for
				// state and XML. [exec]
				// 
				// After the MusicQ update (NA242) I thought this might become
				// a problem, that you would hear the music from the new music
				// props from across the region, but it seems like the client
				// filters them, based on the creature that spawned them.
				// Is the creature not in range, the music stops. [exec]

				result.AddRange(_props.Values.Where(a => a.ServerSide || a.ModifiedClientSide));
			}
			finally
			{
				_propsRWLS.ExitReadLock();
			}

			return result;
		}