GetPosition() 공개 추상적인 메소드

Entity's current position
public abstract GetPosition ( ) : Position
리턴 Position
예제 #1
0
파일: Creature.cs 프로젝트: NegativeJ/aura
		/// <summary>
		/// Sets region, x, and y, to be near entity.
		/// Also randomizes direction.
		/// </summary>
		/// <param name="entity"></param>
		/// <param name="range"></param>
		public void SetLocationNear(Entity entity, int range)
		{
			var rnd = RandomProvider.Get();
			var pos = entity.GetPosition();
			var target = pos.GetRandomInRange(range, rnd);
			var dir = (byte)rnd.Next(256);

			this.SetLocation(entity.RegionId, target.X, target.Y);
			this.Direction = dir;
		}
예제 #2
0
파일: Region.cs 프로젝트: pie3467/aura
 /// <summary>
 /// Returns all visible creatures in range of entity, excluding itself.
 /// </summary>
 /// <param name="range"></param>
 /// <returns></returns>
 public List<Creature> GetVisibleCreaturesInRange(Entity entity, int range = VisibleRange)
 {
     _creaturesRWLS.EnterReadLock();
     try
     {
         return _creatures.Values.Where(a => a != entity && a.GetPosition().InRange(entity.GetPosition(), range) && !a.Conditions.Has(ConditionsA.Invisible)).ToList();
     }
     finally
     {
         _creaturesRWLS.ExitReadLock();
     }
 }
예제 #3
0
파일: Region.cs 프로젝트: pie3467/aura
        /// <summary>
        /// Broadcasts packet to all creatures in range of source.
        /// </summary>
        public void Broadcast(Packet packet, Entity source, bool sendToSource = true, int range = -1)
        {
            if (range < 0)
                range = VisibleRange;

            var pos = source.GetPosition();

            lock (_clients)
            {
                foreach (var client in _clients)
                {
                    if (!client.Controlling.GetPosition().InRange(pos, range))
                        continue;

                    if (client.Controlling == source && !sendToSource)
                        continue;

                    client.Send(packet);
                }
            }
        }
예제 #4
0
파일: Region.cs 프로젝트: pie3467/aura
        /// <summary>
        /// Returns new list of all entities within range of source.
        /// </summary>
        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) && a.ServerSide));
            }
            finally
            {
                _propsRWLS.ExitReadLock();
            }

            return result;
        }
예제 #5
0
파일: Region.cs 프로젝트: aura-project/aura
		/// <summary>
		/// Returns all visible creatures in range of entity, excluding itself.
		/// </summary>
		/// <param name="entity"></param>
		/// <param name="range"></param>
		/// <returns></returns>
		public ICollection<Creature> GetVisibleCreaturesInRange(Entity entity, int range = VisibleRange)
		{
			return this.GetCreatures(a => a != entity && a.GetPosition().InRange(entity.GetPosition(), range) && !a.Conditions.Has(ConditionsA.Invisible));
		}