public void Pulse(Mob mob) { var walkingQueue = mob.WalkingQueue; Position position = mob.Position; int height = position.Height; Direction firstDirection = Direction.None; Direction secondDirection = Direction.None; Position next = walkingQueue.Points.Any() ? walkingQueue.Points.RemoveFromFront() : null; if (next != null) { firstDirection = Direction.Between(position, next); if (!_collisionManager.Traversable(position, EntityType.Npc, firstDirection)) { Clear(mob); firstDirection = Direction.None; } else { walkingQueue.PreviousPoints.AddToBack(next); position = new Position(next.X, next.Y, height); mob.LastDirection = firstDirection; if (walkingQueue.Running && walkingQueue.Points.Any()) { next = walkingQueue.Points.RemoveFromFront(); if (next != null) { secondDirection = Direction.Between(position, next); if (!_collisionManager.Traversable(position, EntityType.Npc, secondDirection)) { Clear(mob); secondDirection = Direction.None; } else { walkingQueue.PreviousPoints.AddToBack(next); position = new Position(next.X, next.Y, height); mob.LastDirection = secondDirection; } } } } } mob.FirstDirection = firstDirection; mob.SecondDirection = secondDirection; mob.Position = position; }