#region Arthea License
/***********************************************************************
* Arthea MUD by R. Jennings (2007) http://arthea.googlecode.com/ *
* By using this code you comply with the Artistic and GPLv2 Licenses. *
***********************************************************************/
#endregion
using System;
using Arthea.Connections.Players;
using Arthea.Continents.Areas.Characters;
using Arthea.Continents.Areas.Rooms.Enums;
using Arthea.Environment;
namespace Arthea.Updates
{
/// <summary>
/// Implementation of mob wander action.
/// </summary>
public class MobWanderAction : TimerAction
{
#region [rgn] Constructors (1)
/// <summary>
/// Initializes a new instance of the <see cref="MobWanderAction"/> class.
/// </summary>
public MobWanderAction()
{
interval = UpdateManager.PulseMobWander;
time = DateTime.Now.TimeOfDay.TotalMilliseconds + interval;
}
#endregion [rgn]
#region [rgn] Methods (1)
// [rgn] Public Methods (1)
/// <summary>
/// Executes this instance.
/// </summary>
public override void Execute()
{
base.Execute();
foreach (Character ch in Lists.Characters)
{
if (ch is Player)
continue;
Direction rand = (Direction) Randomizer.Next(0, Enum.GetValues(typeof (Direction)).Length);
if (ch.Room != null && ch.Room.Exits[rand] != null)
{
ch.Act(null, null, Act.ToRoom, "$n moves {0}.", rand.ToString().ToLower());
ch.Room = ch.Room.Exits[rand].ToRoom.Value;
ch.Act(null, null, Act.ToRoom, "$n has arrived from the {0}.", rand.ToString().ToLower());
}
}
}
#endregion [rgn]
}
}