GetPosition() public abstract method

Entity's current position
public abstract GetPosition ( ) : Position
return 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));
		}