- Removes TimerPriority - Removes TimerThread - Adds a [Hashed & Hierarchical Timer Wheel](http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf)
47 lines
965 B
C#
47 lines
965 B
C#
using System;
|
|
using Server.Network;
|
|
|
|
namespace Server.Misc
|
|
{
|
|
public class FoodDecayTimer : Timer
|
|
{
|
|
public FoodDecayTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5))
|
|
{
|
|
}
|
|
|
|
public static void Initialize()
|
|
{
|
|
new FoodDecayTimer().Start();
|
|
}
|
|
|
|
protected override void OnTick()
|
|
{
|
|
FoodDecay();
|
|
}
|
|
|
|
public static void FoodDecay()
|
|
{
|
|
foreach (var state in TcpServer.Instances)
|
|
{
|
|
HungerDecay(state.Mobile);
|
|
ThirstDecay(state.Mobile);
|
|
}
|
|
}
|
|
|
|
public static void HungerDecay(Mobile m)
|
|
{
|
|
if (m?.Hunger >= 1)
|
|
{
|
|
m.Hunger -= 1;
|
|
}
|
|
}
|
|
|
|
public static void ThirstDecay(Mobile m)
|
|
{
|
|
if (m?.Thirst >= 1)
|
|
{
|
|
m.Thirst -= 1;
|
|
}
|
|
}
|
|
}
|
|
}
|