Aura.Channel.World.Entities.Creature.GetSpeed C# (CSharp) Method

GetSpeed() public method

Returns current movement speed (x/s).
public GetSpeed ( ) : float
return float
		public float GetSpeed()
		{
			var speed = (!this.IsWalking ? this.RaceData.RunningSpeed : this.RaceData.WalkingSpeed);

			// RaceSpeedFactor
			if (!this.IsWalking)
				speed *= this.RaceData.RunSpeedFactor;

			// The Zombie condition reduces speed to that of a Zombie.
			// We could query it from the speed db, but hardcoding is
			// more efficient, and it shouldn't be changing anyway.
			if (this.Conditions.Has(ConditionsC.Zombie))
				speed = ZombieSpeed;

			// Hurry condition
			if (!this.IsWalking && this.Conditions.Has(ConditionsC.Hurry))
			{
				var hurry = this.Conditions.GetExtraVal(169);
				speed *= 1 + (hurry / 100f);
			}

			return speed;
		}

Usage Example

Beispiel #1
0
        /// <summary>
        /// Activates AIs in range of the movement path.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        public void ActivateAis(Creature creature, Position from, Position to)
        {
            // Bounding rectangle
            var minX = Math.Min(from.X, to.X) - VisibleRange;
            var minY = Math.Min(from.Y, to.Y) - VisibleRange;
            var maxX = Math.Max(from.X, to.X) + VisibleRange;
            var maxY = Math.Max(from.Y, to.Y) + VisibleRange;

            // Activation
            _creaturesRWLS.EnterReadLock();
            try
            {
                foreach (NPC npc in _creatures.Values.Where(a => a.Is(EntityType.NPC)))
                {
                    if (npc.AI == null)
                        continue;

                    var pos = npc.GetPosition();
                    if (!(pos.X >= minX && pos.X <= maxX && pos.Y >= minY && pos.Y <= maxY))
                        continue;

                    var time = (from.GetDistance(to) / creature.GetSpeed()) * 1000;

                    npc.AI.Activate(time);
                }
            }
            finally
            {
                _creaturesRWLS.ExitReadLock();
            }
        }