UpdateManager.cs

src/Updates/UpdateManager.cs · 2.1 KB

From the archive Arthea-src-1.0.zip

Download the archive   « Back to the archive contents

#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

namespace Arthea.Updates
{
    /// <summary>
    /// Handles the threading of the update methods
    /// </summary>
    public struct UpdateManager
    {
        /// <summary>
        /// How often areas update.
        /// </summary>
        public const int PulseArea = 120*PulseSecond;

        /// <summary>
        /// How often characters update.
        /// </summary>
        public const int PulseCharacters = 40*PulseSecond;

        /// <summary>
        /// How long a round of combat updates.
        /// </summary>
        public const int PulseCombat = 4*PulseSecond;

        /// <summary>
        /// How often items update
        /// </summary>
        public const int PulseItems = 40*PulseSecond;

        /// <summary>
        /// For time based actions.
        /// </summary>
        public const int PulseMinute = 60*PulseSecond;

        /// <summary>
        /// How often mobs wander around.
        /// </summary>
        public const int PulseMobWander = 45*PulseSecond;

        /// <summary>
        /// How many cycles per second.
        /// </summary>
        public const int PulseSecond = 1000;

        private static readonly TimerRegistry reg = new TimerRegistry();

        static UpdateManager()
        {
            reg.AddTimerAction(new MobWanderAction());
            reg.AddTimerAction(new CombatUpdateAction());
            reg.AddTimerAction(new ItemsUpdateAction());
            reg.AddTimerAction(new CharactersUpdateAction());
            reg.AddTimerAction(new AreaUpdateAction());
        }

        /// <summary>
        /// Updates this instance.
        /// </summary>
        public static void Update()
        {
            reg.Run();
        }
    }
}

Site Stats

Snippets: 1791
Codebases: 571