feat(timers): Adds timer pooling, fixes timer related bugs, and changes timer api (#667)
### Changes/Fixes:
* Adds timer pooling.
* Allows pool to be configurable in ModernUO.json
* Pool replenishes itself asynchronously if depleted.
* Fixes an issue with barkeeps and town criers
* Fixes an issue with incognito buff icons not being removed
* Fixes an issue with polymorph name mod not being removed
* Fixes several places where timers go on forever even after an object is deleted, keeping a reference (memory leak)
* Eliminates the timer for MiningCart altogether.
* Deletes `AcidSlime` since it is a duplicate of `PoolOfAcid`
* Fixes HonorableExecution and standardizes the code for other Bushido moves.
## Changes to the Timer API:
```cs
public class Timer
{
// Creates a timer that will be returned to the pool once execution stops.
public static void StartTimer(Action callback);
public static void StartTimer(TimeSpan delay, Action callback);
public static void StartTimer(TimeSpan delay, TimeSpan interval, Action callback);
public static void StartTimer(TimeSpan interval, int count, Action callback);
public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback);
// Creates a timer and returns a token for more control. Requires manual cancellation in order for the timer to be returned to the pool.
// If the token is dereferenced, the timer will be dereferenced too. While not returning a timer to the pool is not considered hazardous, it does defeat the purpose of pooled timers.
public static void StartTimer(Action callback, out TimerExecutionToken token);
public static void StartTimer(TimeSpan delay, Action callback, out TimerExecutionToken token);
public static void StartTimer(TimeSpan delay, TimeSpan interval, Action callback, out TimerExecutionToken token);
public static void StartTimer(TimeSpan interval, int count, Action callback, out TimerExecutionToken token);
public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback, out TimerExecutionToken token);
// If you aren't sure how to use the API above, or you don't care about performance, then you can use the old RunUO Timer.DelayCall
public static DelayCallTimer DelayCall(Action callback);
public static DelayCallTimer DelayCall(TimeSpan delay, Action callback);
public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, Action callback);
public static DelayCallTimer DelayCall(TimeSpan interval, int count, Action callback);
public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback);
}
public struct TimerExecutionToken
{
public bool Running { get; }
public int Index { get; }
public int RemainingCount { get; }
public DateTime Next { get; }
}
```
## When to use `TimerExecutionToken`?
Use tokens when you want to gain the performance benefit of using a pooled timer, but you need one of the following:
* Access to the next time the timer will tick:`token.Next`
* Access to which interval, how many intervals there are, or how many are remaining: `token.Index`, `token.Count`, and `token.RemainingCount`
* Stop a timer manually.
* Determine if the timer is running: `timer.Running`
* See notes below about requirements for using tokens!
## Notes about using the TimerExecutionToken:
When you opt-in to receive a token, you must call `Cancel()` to return the timer. This can be done inside of the callback, or outside of the callback at any time.
If this is not called and your timer is an infinite interval, then you will create a potential memory leak, or null pointer exception in your callback.
If the timer ends and is stopped, but cancel is not called, then the timer will never return to the pool and stay referenced until the token is deleted or cancel is called. (Memory leak)
## Is this thread safe?
No. The ModernUO timer system is not thread safe at all. If you require a thread safe timer system, contact me and I'll help adapt this system. Keep in mind that there is a massive performance hit to make this thread safe when there are literally no use cases for it.
If you need to synchronize execution, meaning you want to execute code from another thread on the core thread. Let's say you have a discord bot that is pushing commands to the game server. Then use `EventLoopContext.Post(SendOrPostCallback callback, object state);`.
This commit is contained in:
parent
b4de631f96
commit
9b554f69b0
219 changed files with 1897 additions and 2241 deletions
|
|
@ -9,7 +9,7 @@
|
|||
<SkipLocalsInitiAttribute>true</SkipLocalsInitiAttribute>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
|
||||
<ProjectReference Include="..\Server\Server.csproj" />
|
||||
<ProjectReference Include="..\UOContent\UOContent.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ namespace Server.Tests
|
|||
// Global setup
|
||||
static ServerFixture()
|
||||
{
|
||||
Core.LoopContext = new EventLoopContext();
|
||||
|
||||
Core.Expansion = Expansion.EJ;
|
||||
|
||||
// Load Configurations
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ namespace Server.Tests
|
|||
|
||||
Timer.Init(timerTicks.Ticks);
|
||||
|
||||
var timer = Timer.DelayCall(TimeSpan.FromMilliseconds(ticks), action);
|
||||
timer.Start();
|
||||
Timer.StartTimer(TimeSpan.FromMilliseconds(ticks), action);
|
||||
|
||||
var tickCount = expectedTicks / 8;
|
||||
|
||||
|
|
@ -53,8 +52,7 @@ namespace Server.Tests
|
|||
|
||||
Timer.Init(timerTicks.Ticks);
|
||||
|
||||
var timer = Timer.DelayCall(TimeSpan.FromMilliseconds(delay), TimeSpan.FromMilliseconds(interval), count, action);
|
||||
timer.Start();
|
||||
Timer.StartTimer(TimeSpan.FromMilliseconds(delay), TimeSpan.FromMilliseconds(interval), count, action);
|
||||
|
||||
var tickCount = (expectedDelayTicks + (expectedIntervalTicks * count - 1)) / 8;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ namespace Server
|
|||
|
||||
public override SynchronizationContext CreateCopy() => new EventLoopContext();
|
||||
|
||||
public void Post(Action d) => _queue.Enqueue(d);
|
||||
|
||||
public override void Post(SendOrPostCallback d, object state) => _queue.Enqueue(() => d(state));
|
||||
|
||||
public override void Send(SendOrPostCallback d, object state)
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ namespace Server
|
|||
public void Deserialize(IGenericReader reader)
|
||||
{
|
||||
// Should not actually be saved
|
||||
Timer.DelayCall(Delete);
|
||||
Timer.StartTimer(Delete);
|
||||
}
|
||||
|
||||
public void Serialize(IGenericWriter writer)
|
||||
|
|
|
|||
|
|
@ -3027,7 +3027,7 @@ namespace Server
|
|||
|
||||
if (HeldBy != null)
|
||||
{
|
||||
Timer.DelayCall(FixHolding_Sandbox);
|
||||
Timer.StartTimer(FixHolding_Sandbox);
|
||||
}
|
||||
|
||||
// if (version < 9)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Server
|
|||
|
||||
private static int _itemCount;
|
||||
private static int _mobileCount;
|
||||
private static EventLoopContext _eventLoopContext;
|
||||
public static EventLoopContext LoopContext { get; set; }
|
||||
|
||||
private static readonly Type[] _serialTypeArray = { typeof(Serial) };
|
||||
|
||||
|
|
@ -366,9 +366,9 @@ namespace Server
|
|||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
|
||||
|
||||
_eventLoopContext = new EventLoopContext();
|
||||
LoopContext = new EventLoopContext();
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(_eventLoopContext);
|
||||
SynchronizationContext.SetSynchronizationContext(LoopContext);
|
||||
|
||||
foreach (var a in args)
|
||||
{
|
||||
|
|
@ -505,7 +505,9 @@ namespace Server
|
|||
events += NetState.Slice();
|
||||
|
||||
// Execute captured post-await methods (like Timer.Pause)
|
||||
events += _eventLoopContext.ExecuteTasks();
|
||||
events += LoopContext.ExecuteTasks();
|
||||
|
||||
Timer.CheckTimerPool(); // Check for pool depletion so we can async refill it.
|
||||
|
||||
_tickCount = 0;
|
||||
_now = DateTime.MinValue;
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ namespace Server
|
|||
private List<object> _actions;
|
||||
private AccessLevel m_AccessLevel;
|
||||
|
||||
private Timer m_AutoManifestTimer;
|
||||
private TimerExecutionToken _autoManifestTimerToken;
|
||||
|
||||
private Container m_Backpack;
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ namespace Server
|
|||
|
||||
private int m_ChangingCombatant;
|
||||
private Mobile m_Combatant;
|
||||
private Timer m_CombatTimer;
|
||||
private TimerExecutionToken _combatTimerToken;
|
||||
private ContextMenu m_ContextMenu;
|
||||
private bool m_Criminal;
|
||||
|
||||
|
|
@ -473,14 +473,15 @@ namespace Server
|
|||
private Direction m_Direction;
|
||||
private bool m_DisplayGuildTitle;
|
||||
|
||||
private Timer m_ExpireAggrTimer;
|
||||
private Timer m_ExpireCombatant;
|
||||
private TimerExecutionToken _expireAggrTimerToken;
|
||||
private TimerExecutionToken _expireCombatantTimerToken;
|
||||
private TimerExecutionToken _expireCriminalTimerToken;
|
||||
private FacialHairInfo m_FacialHair;
|
||||
private int m_Fame, m_Karma;
|
||||
private bool m_Female, m_Warmode, m_Hidden, m_Blessed, m_Flying;
|
||||
private int m_Followers, m_FollowersMax;
|
||||
private bool m_Frozen;
|
||||
private Timer m_FrozenTimer;
|
||||
private TimerExecutionToken _frozenTimerToken;
|
||||
private BaseGuild m_Guild;
|
||||
private string m_GuildTitle;
|
||||
|
||||
|
|
@ -498,7 +499,7 @@ namespace Server
|
|||
private string m_Language;
|
||||
private int m_LightLevel;
|
||||
private Point3D m_Location;
|
||||
private Timer m_LogoutTimer;
|
||||
private TimerExecutionToken _logoutTimerToken;
|
||||
private Timer m_ManaTimer, m_HitsTimer, m_StamTimer;
|
||||
|
||||
private Map m_Map;
|
||||
|
|
@ -525,7 +526,7 @@ namespace Server
|
|||
private NetState m_NetState;
|
||||
private DateTime m_NextWarmodeChange;
|
||||
private bool m_Paralyzed;
|
||||
private Timer m_ParaTimer;
|
||||
private TimerExecutionToken _paraTimerToken;
|
||||
private bool m_Player;
|
||||
private Poison m_Poison;
|
||||
private Prompt m_Prompt;
|
||||
|
|
@ -546,7 +547,7 @@ namespace Server
|
|||
private int m_VirtualArmor;
|
||||
private int m_VirtualArmorMod;
|
||||
private int m_WarmodeChanges;
|
||||
private WarmodeTimer m_WarmodeTimer;
|
||||
private bool _warmodeSpamValue;
|
||||
private IWeapon m_Weapon;
|
||||
|
||||
private bool m_YellowHealthbar;
|
||||
|
|
@ -768,12 +769,7 @@ namespace Server
|
|||
Delta(MobileDelta.Flags);
|
||||
|
||||
SendLocalizedMessage(m_Paralyzed ? 502381 : 502382);
|
||||
|
||||
if (m_ParaTimer != null)
|
||||
{
|
||||
m_ParaTimer.Stop();
|
||||
m_ParaTimer = null;
|
||||
}
|
||||
_paraTimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -794,12 +790,7 @@ namespace Server
|
|||
{
|
||||
m_Frozen = value;
|
||||
Delta(MobileDelta.Flags);
|
||||
|
||||
if (m_FrozenTimer != null)
|
||||
{
|
||||
m_FrozenTimer.Stop();
|
||||
m_FrozenTimer = null;
|
||||
}
|
||||
_frozenTimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -880,7 +871,11 @@ namespace Server
|
|||
|
||||
public bool ChangingCombatant => m_ChangingCombatant > 0;
|
||||
|
||||
private void ExpireCombatant() => Combatant = null;
|
||||
private void ExpireCombatant()
|
||||
{
|
||||
Combatant = null;
|
||||
_expireCombatantTimerToken.Cancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Gets or sets which Mobile that this Mobile is currently engaged in combat with.
|
||||
|
|
@ -915,20 +910,14 @@ namespace Server
|
|||
if (m_Combatant == null)
|
||||
{
|
||||
m_NetState.SendChangeCombatant(Serial.Zero);
|
||||
m_ExpireCombatant?.Stop();
|
||||
m_CombatTimer?.Stop();
|
||||
|
||||
m_ExpireCombatant = null;
|
||||
m_CombatTimer = null;
|
||||
_expireCombatantTimerToken.Cancel();
|
||||
_combatTimerToken.Cancel();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NetState.SendChangeCombatant(m_Combatant.Serial);
|
||||
m_ExpireCombatant ??= Timer.DelayCall(ExpireCombatantDelay, ExpireCombatant);
|
||||
m_ExpireCombatant.Start();
|
||||
|
||||
m_CombatTimer ??= new CombatTimer(this);
|
||||
m_CombatTimer.Start();
|
||||
Timer.StartTimer(ExpireCombatantDelay, ExpireCombatant, out _expireCombatantTimerToken);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.01), 0, CheckCombatTime, out _combatTimerToken);
|
||||
|
||||
if (CanBeHarmful(m_Combatant, false))
|
||||
{
|
||||
|
|
@ -943,6 +932,40 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
private void CheckCombatTime()
|
||||
{
|
||||
if (Core.TickCount - NextCombatTime < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var combatant = Combatant;
|
||||
|
||||
// If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat
|
||||
if (combatant?.Deleted != false || Deleted || combatant.m_Map != m_Map ||
|
||||
!combatant.Alive || !Alive || !CanSee(combatant) || combatant.IsDeadBondedPet ||
|
||||
IsDeadBondedPet)
|
||||
{
|
||||
Combatant = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var weapon = Weapon;
|
||||
|
||||
if (!InRange(combatant, weapon.MaxRange))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (InLOS(combatant))
|
||||
{
|
||||
weapon.OnBeforeSwing(this, combatant);
|
||||
RevealingAction();
|
||||
NextCombatTime =
|
||||
Core.TickCount + (int)weapon.OnSwing(this, combatant).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int TotalGold => GetTotal(TotalType.Gold);
|
||||
|
||||
|
|
@ -1347,11 +1370,7 @@ namespace Server
|
|||
|
||||
if (m_Warmode != value)
|
||||
{
|
||||
if (m_AutoManifestTimer != null)
|
||||
{
|
||||
m_AutoManifestTimer.Stop();
|
||||
m_AutoManifestTimer = null;
|
||||
}
|
||||
_autoManifestTimerToken.Cancel();
|
||||
|
||||
m_Warmode = value;
|
||||
Delta(MobileDelta.Flags);
|
||||
|
|
@ -1439,6 +1458,7 @@ namespace Server
|
|||
}
|
||||
|
||||
m_NetState = value;
|
||||
_logoutTimerToken.Cancel();
|
||||
|
||||
if (m_NetState == null)
|
||||
{
|
||||
|
|
@ -1446,27 +1466,13 @@ namespace Server
|
|||
EventSink.InvokeDisconnected(this);
|
||||
|
||||
// Disconnected, start the logout timer
|
||||
if (m_LogoutTimer == null)
|
||||
{
|
||||
m_LogoutTimer = Timer.DelayCall(GetLogoutDelay(), Logout);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LogoutTimer.Stop();
|
||||
m_LogoutTimer.Delay = GetLogoutDelay();
|
||||
m_LogoutTimer.Start();
|
||||
}
|
||||
Timer.StartTimer(GetLogoutDelay(), Logout, out _logoutTimerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnConnected();
|
||||
EventSink.InvokeConnected(this);
|
||||
|
||||
// Connected, stop the logout timer and if needed, move to the world
|
||||
m_LogoutTimer?.Stop();
|
||||
|
||||
m_LogoutTimer = null;
|
||||
|
||||
if (m_Map == Map.Internal && LogoutMap != null)
|
||||
{
|
||||
Map = LogoutMap;
|
||||
|
|
@ -1494,7 +1500,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(item.Delete);
|
||||
Timer.StartTimer(item.Delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1852,8 +1858,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public Timer ExpireCriminalTimer { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public virtual bool Criminal
|
||||
{
|
||||
|
|
@ -1867,23 +1871,11 @@ namespace Server
|
|||
InvalidateProperties();
|
||||
}
|
||||
|
||||
_expireCriminalTimerToken.Cancel();
|
||||
|
||||
if (m_Criminal)
|
||||
{
|
||||
if (ExpireCriminalTimer == null)
|
||||
{
|
||||
ExpireCriminalTimer = Timer.DelayCall(ExpireCriminalDelay, ExpireCriminal);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpireCriminalTimer.Stop();
|
||||
}
|
||||
|
||||
ExpireCriminalTimer.Start();
|
||||
}
|
||||
else if (ExpireCriminalTimer != null)
|
||||
{
|
||||
ExpireCriminalTimer.Stop();
|
||||
ExpireCriminalTimer = null;
|
||||
Timer.StartTimer(ExpireCriminalDelay, ExpireCriminal, out _expireCriminalTimerToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3545,10 +3537,9 @@ namespace Server
|
|||
{
|
||||
StopAggrExpire();
|
||||
}
|
||||
else if (m_ExpireAggrTimer == null)
|
||||
else if (!_expireAggrTimerToken.Running)
|
||||
{
|
||||
m_ExpireAggrTimer = Timer.DelayCall(ExpireAggressorsDelay, ExpireAggressorsDelay, ExpireAggr);
|
||||
m_ExpireAggrTimer.Start();
|
||||
Timer.StartTimer(ExpireAggressorsDelay, ExpireAggressorsDelay, ExpireAggr, out _expireAggrTimerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3566,8 +3557,7 @@ namespace Server
|
|||
|
||||
private void StopAggrExpire()
|
||||
{
|
||||
m_ExpireAggrTimer?.Stop();
|
||||
m_ExpireAggrTimer = null;
|
||||
_expireAggrTimerToken.Cancel();
|
||||
}
|
||||
|
||||
private void CheckAggrExpire()
|
||||
|
|
@ -3712,9 +3702,10 @@ namespace Server
|
|||
|
||||
public void DelayChangeWarmode(bool value)
|
||||
{
|
||||
if (m_WarmodeTimer != null)
|
||||
if (m_WarmodeChanges > WarmodeCatchCount)
|
||||
{
|
||||
m_WarmodeTimer.Value = value;
|
||||
_warmodeSpamValue = value;
|
||||
m_WarmodeChanges++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3731,21 +3722,21 @@ namespace Server
|
|||
m_WarmodeChanges = 1;
|
||||
m_NextWarmodeChange = now + WarmodeSpamCatch;
|
||||
}
|
||||
else if (m_WarmodeChanges == WarmodeCatchCount)
|
||||
else if (m_WarmodeChanges++ == WarmodeCatchCount)
|
||||
{
|
||||
m_WarmodeTimer = new WarmodeTimer(this, value);
|
||||
m_WarmodeTimer.Start();
|
||||
|
||||
Timer.StartTimer(WarmodeSpamDelay, WarmodeSpamTimeout);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
++m_WarmodeChanges;
|
||||
}
|
||||
|
||||
Warmode = value;
|
||||
}
|
||||
|
||||
private void WarmodeSpamTimeout()
|
||||
{
|
||||
Warmode = _warmodeSpamValue;
|
||||
m_WarmodeChanges = 0;
|
||||
}
|
||||
|
||||
public bool InLOS(Mobile target) =>
|
||||
!Deleted && m_Map != null &&
|
||||
(target == this || m_AccessLevel > AccessLevel.Player || m_Map.LineOfSight(this, target));
|
||||
|
|
@ -3808,9 +3799,7 @@ namespace Server
|
|||
if (!m_Paralyzed)
|
||||
{
|
||||
Paralyzed = true;
|
||||
|
||||
m_ParaTimer = Timer.DelayCall(duration, ExpireParalyzed);
|
||||
m_ParaTimer.Start();
|
||||
Timer.StartTimer(duration, ExpireParalyzed, out _paraTimerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3824,9 +3813,7 @@ namespace Server
|
|||
if (!m_Frozen)
|
||||
{
|
||||
Frozen = true;
|
||||
|
||||
m_FrozenTimer = Timer.DelayCall(duration, ExpireFrozen);
|
||||
m_FrozenTimer.Start();
|
||||
Timer.StartTimer(duration, ExpireFrozen, out _frozenTimerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3938,16 +3925,8 @@ namespace Server
|
|||
|
||||
if (Combatant == aggressor)
|
||||
{
|
||||
if (m_ExpireCombatant == null)
|
||||
{
|
||||
m_ExpireCombatant = Timer.DelayCall(ExpireCombatantDelay, ExpireCombatant);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ExpireCombatant.Stop();
|
||||
}
|
||||
|
||||
m_ExpireCombatant.Start();
|
||||
_expireCombatantTimerToken.Cancel();
|
||||
Timer.StartTimer(ExpireCombatantDelay, ExpireCombatant, out _expireCombatantTimerToken);
|
||||
}
|
||||
|
||||
var addAggressor = true;
|
||||
|
|
@ -4787,14 +4766,13 @@ namespace Server
|
|||
m_HitsTimer?.Stop();
|
||||
m_StamTimer?.Stop();
|
||||
m_ManaTimer?.Stop();
|
||||
m_CombatTimer?.Stop();
|
||||
m_ExpireCombatant?.Stop();
|
||||
m_LogoutTimer?.Stop();
|
||||
ExpireCriminalTimer?.Stop();
|
||||
m_WarmodeTimer?.Stop();
|
||||
m_ParaTimer?.Stop();
|
||||
m_FrozenTimer?.Stop();
|
||||
m_AutoManifestTimer?.Stop();
|
||||
_combatTimerToken.Cancel();
|
||||
_expireCombatantTimerToken.Cancel();
|
||||
_logoutTimerToken.Cancel();
|
||||
_expireCriminalTimerToken.Cancel();
|
||||
_paraTimerToken.Cancel();
|
||||
_frozenTimerToken.Cancel();
|
||||
_autoManifestTimerToken.Cancel();
|
||||
}
|
||||
|
||||
public virtual bool AllowSkillUse(SkillName name) => true;
|
||||
|
|
@ -4864,15 +4842,11 @@ namespace Server
|
|||
if (Paralyzed)
|
||||
{
|
||||
Paralyzed = false;
|
||||
|
||||
m_ParaTimer?.Stop();
|
||||
}
|
||||
|
||||
if (Frozen)
|
||||
{
|
||||
Frozen = false;
|
||||
|
||||
m_FrozenTimer?.Stop();
|
||||
}
|
||||
|
||||
var content = new List<Item>();
|
||||
|
|
@ -5570,17 +5544,8 @@ namespace Server
|
|||
public virtual void Manifest(TimeSpan delay)
|
||||
{
|
||||
Warmode = true;
|
||||
|
||||
if (m_AutoManifestTimer == null)
|
||||
{
|
||||
m_AutoManifestTimer = Timer.DelayCall(delay, AutoManifest);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AutoManifestTimer.Stop();
|
||||
}
|
||||
|
||||
m_AutoManifestTimer.Start();
|
||||
_autoManifestTimerToken.Cancel();
|
||||
Timer.StartTimer(delay, AutoManifest, out _autoManifestTimerToken);
|
||||
}
|
||||
|
||||
public virtual bool CheckSpeechManifest()
|
||||
|
|
@ -5592,7 +5557,7 @@ namespace Server
|
|||
|
||||
var delay = AutoManifestTimeout;
|
||||
|
||||
if (delay > TimeSpan.Zero && (!Warmode || m_AutoManifestTimer != null))
|
||||
if (delay > TimeSpan.Zero && (!Warmode || _autoManifestTimerToken.Running))
|
||||
{
|
||||
Manifest(delay);
|
||||
return true;
|
||||
|
|
@ -6548,8 +6513,7 @@ namespace Server
|
|||
|
||||
if (m_Criminal)
|
||||
{
|
||||
ExpireCriminalTimer ??= Timer.DelayCall(ExpireCriminalDelay, ExpireCriminal);
|
||||
ExpireCriminalTimer.Start();
|
||||
Timer.StartTimer(ExpireCriminalDelay, ExpireCriminal, out _expireCriminalTimerToken);
|
||||
}
|
||||
|
||||
if (ShouldCheckStatTimers)
|
||||
|
|
@ -8186,27 +8150,6 @@ namespace Server
|
|||
{
|
||||
}
|
||||
|
||||
private class WarmodeTimer : Timer
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
|
||||
public WarmodeTimer(Mobile m, bool value) : base(WarmodeSpamDelay)
|
||||
{
|
||||
m_Mobile = m;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public bool Value{ get; set; }
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Mobile.Warmode = Value;
|
||||
m_Mobile.m_WarmodeChanges = 0;
|
||||
|
||||
m_Mobile.m_WarmodeTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static TimeSpan GetHitsRegenRate(Mobile m) => HitsRegenRateHandler?.Invoke(m) ?? DefaultHitsRate;
|
||||
|
||||
public static TimeSpan GetStamRegenRate(Mobile m) => StamRegenRateHandler?.Invoke(m) ?? DefaultStamRate;
|
||||
|
|
@ -8588,16 +8531,8 @@ namespace Server
|
|||
Combatant = target;
|
||||
}
|
||||
|
||||
if (m_ExpireCombatant == null)
|
||||
{
|
||||
m_ExpireCombatant = Timer.DelayCall(ExpireCombatantDelay, ExpireCombatant);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ExpireCombatant.Stop();
|
||||
}
|
||||
|
||||
m_ExpireCombatant.Start();
|
||||
_expireCombatantTimerToken.Cancel();
|
||||
Timer.StartTimer(ExpireCombatantDelay, ExpireCombatant, out _expireCombatantTimerToken);
|
||||
}
|
||||
|
||||
public virtual bool HarmfulCheck(Mobile target)
|
||||
|
|
@ -9446,48 +9381,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
private class CombatTimer : Timer
|
||||
{
|
||||
private readonly Mobile m_Mobile;
|
||||
|
||||
public CombatTimer(Mobile m) : base(TimeSpan.FromSeconds(0.0), TimeSpan.FromSeconds(0.01)) =>
|
||||
m_Mobile = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (Core.TickCount - m_Mobile.NextCombatTime < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var combatant = m_Mobile.Combatant;
|
||||
|
||||
// If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat
|
||||
if (combatant?.Deleted != false || m_Mobile.Deleted || combatant.m_Map != m_Mobile.m_Map ||
|
||||
!combatant.Alive || !m_Mobile.Alive || !m_Mobile.CanSee(combatant) || combatant.IsDeadBondedPet ||
|
||||
m_Mobile.IsDeadBondedPet)
|
||||
{
|
||||
m_Mobile.Combatant = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var weapon = m_Mobile.Weapon;
|
||||
|
||||
if (!m_Mobile.InRange(combatant, weapon.MaxRange))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Mobile.InLOS(combatant))
|
||||
{
|
||||
weapon.OnBeforeSwing(m_Mobile, combatant);
|
||||
m_Mobile.RevealingAction();
|
||||
m_Mobile.NextCombatTime =
|
||||
Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ExpireCriminal()
|
||||
{
|
||||
Criminal = false;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Server.Network
|
|||
|
||||
public static void Initialize()
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1.5), CheckAllAlive);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1.5), CheckAllAlive);
|
||||
}
|
||||
|
||||
public NetState(ISocket connection)
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ namespace Server
|
|||
|
||||
ns?.RemoveTrade(this);
|
||||
|
||||
Timer.DelayCall(From.Dispose);
|
||||
Timer.DelayCall(To.Dispose);
|
||||
Timer.StartTimer(From.Dispose);
|
||||
Timer.StartTimer(To.Dispose);
|
||||
}
|
||||
|
||||
public void UpdateFromCurrency()
|
||||
|
|
|
|||
|
|
@ -14,252 +14,222 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
#if DEBUG_TIMERS
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public delegate void TimerStateCallback<in T>(T state);
|
||||
|
||||
public delegate void TimerStateCallback<in T1, in T2>(T1 t1, T2 t2);
|
||||
|
||||
public delegate void TimerStateCallback<in T1, in T2, in T3>(T1 t1, T2 t2, T3 t3);
|
||||
|
||||
public delegate void TimerStateCallback<in T1, in T2, in T3, in T4>(T1 t1, T2 t2, T3 t3, T4 t4);
|
||||
|
||||
public partial class Timer
|
||||
{
|
||||
private static string FormatDelegate(Delegate callback) =>
|
||||
callback == null ? "null" : $"{callback.Method.DeclaringType?.FullName ?? ""}.{callback.Method.Name}";
|
||||
|
||||
public static Timer DelayCall(Action callback) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer DelayCall(Action callback) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback);
|
||||
|
||||
public static Timer DelayCall(TimeSpan delay, Action callback) =>
|
||||
DelayCall(delay, TimeSpan.Zero, 1, callback);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer DelayCall(TimeSpan delay, Action callback) => DelayCall(delay, TimeSpan.Zero, 1, callback);
|
||||
|
||||
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, Action callback) =>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, Action callback) =>
|
||||
DelayCall(delay, interval, 0, callback);
|
||||
|
||||
public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer DelayCall(TimeSpan interval, int count, Action callback) =>
|
||||
DelayCall(TimeSpan.Zero, interval, count, callback);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback)
|
||||
{
|
||||
Timer t = new DelayCallTimer(delay, interval, count, callback);
|
||||
DelayCallTimer t = new DelayCallTimer(delay, interval, count, callback);
|
||||
t.Start();
|
||||
#if DEBUG_TIMERS
|
||||
t._allowFinalization = true;
|
||||
#endif
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Timer DelayCall<T>(TimerStateCallback<T> callback, T state) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(Action callback) => StartTimer(TimeSpan.Zero, TimeSpan.Zero, 1, callback);
|
||||
|
||||
public static Timer DelayCall<T>(TimeSpan delay, TimerStateCallback<T> callback, T state) =>
|
||||
DelayCall(delay, TimeSpan.Zero, 1, callback, state);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, Action callback) => StartTimer(delay, TimeSpan.Zero, 1, callback);
|
||||
|
||||
public static Timer DelayCall<T>(TimeSpan delay, TimeSpan interval, TimerStateCallback<T> callback, T state) =>
|
||||
DelayCall(delay, interval, 0, callback, state);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, TimeSpan interval, Action callback) =>
|
||||
StartTimer(delay, interval, 0, callback);
|
||||
|
||||
public static Timer DelayCall<T>(
|
||||
TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback,
|
||||
T state
|
||||
)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan interval, int count, Action callback) =>
|
||||
StartTimer(TimeSpan.Zero, interval, count, callback);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback)
|
||||
{
|
||||
Timer t = new DelayStateCallTimer<T>(delay, interval, count, callback, state);
|
||||
DelayCallTimer t = DelayCallTimer.GetTimer(delay, interval, count, callback);
|
||||
t._selfReturn = true;
|
||||
t.Start();
|
||||
|
||||
return t;
|
||||
#if DEBUG_TIMERS
|
||||
DelayCallTimer._stackTraces[t.GetHashCode()] = new StackTrace().ToString();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Timer DelayCall<T1, T2>(TimerStateCallback<T1, T2> callback, T1 t1, T2 t2) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(Action callback, out TimerExecutionToken token) =>
|
||||
StartTimer(TimeSpan.Zero, TimeSpan.Zero, 1, callback, out token);
|
||||
|
||||
public static Timer DelayCall<T1, T2>(TimeSpan delay, TimerStateCallback<T1, T2> callback, T1 t1, T2 t2) =>
|
||||
DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, Action callback, out TimerExecutionToken token) =>
|
||||
StartTimer(delay, TimeSpan.Zero, 1, callback, out token);
|
||||
|
||||
public static Timer DelayCall<T1, T2>(
|
||||
TimeSpan delay, TimeSpan interval, TimerStateCallback<T1, T2> callback,
|
||||
T1 t1, T2 t2
|
||||
) => DelayCall(delay, interval, 0, callback, t1, t2);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, TimeSpan interval, Action callback, out TimerExecutionToken token) =>
|
||||
StartTimer(delay, interval, 0, callback, out token);
|
||||
|
||||
public static Timer DelayCall<T1, T2>(
|
||||
TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2> callback,
|
||||
T1 t1, T2 t2
|
||||
)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan interval, int count, Action callback, out TimerExecutionToken token) =>
|
||||
StartTimer(TimeSpan.Zero, interval, count, callback, out token);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback, out TimerExecutionToken token)
|
||||
{
|
||||
Timer t = new DelayStateCallTimer<T1, T2>(delay, interval, count, callback, t1, t2);
|
||||
DelayCallTimer t = DelayCallTimer.GetTimer(delay, interval, count, callback);
|
||||
t.Start();
|
||||
|
||||
return t;
|
||||
#if DEBUG_TIMERS
|
||||
DelayCallTimer._stackTraces[t.GetHashCode()] = new StackTrace().ToString();
|
||||
#endif
|
||||
token = new TimerExecutionToken(t);
|
||||
}
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3>(TimerStateCallback<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer Pause(TimeSpan ms) => new(ms);
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3>(
|
||||
TimeSpan delay, TimerStateCallback<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3
|
||||
) =>
|
||||
DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayCallTimer Pause(int ms) => Pause(TimeSpan.FromMilliseconds(ms));
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3>(
|
||||
TimeSpan delay, TimeSpan interval, TimerStateCallback<T1, T2, T3> callback,
|
||||
T1 t1, T2 t2, T3 t3
|
||||
) => DelayCall(delay, interval, 0, callback, t1, t2, t3);
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3>(
|
||||
TimeSpan delay, TimeSpan interval, int count,
|
||||
TimerStateCallback<T1, T2, T3> callback, T1 t1, T2 t2, T3 t3
|
||||
)
|
||||
public sealed class DelayCallTimer : Timer, INotifyCompletion
|
||||
{
|
||||
Timer t = new DelayStateCallTimer<T1, T2, T3>(delay, interval, count, callback, t1, t2, t3);
|
||||
t.Start();
|
||||
internal bool _selfReturn;
|
||||
#if DEBUG_TIMERS
|
||||
internal bool _allowFinalization;
|
||||
#endif
|
||||
private Action _continuation;
|
||||
private bool _complete;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimerStateCallback<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) =>
|
||||
DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3, t4);
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimeSpan delay, TimerStateCallback<T1, T2, T3, T4> callback,
|
||||
T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) => DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3, t4);
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimeSpan delay, TimeSpan interval,
|
||||
TimerStateCallback<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) =>
|
||||
DelayCall(delay, interval, 0, callback, t1, t2, t3, t4);
|
||||
|
||||
public static Timer DelayCall<T1, T2, T3, T4>(
|
||||
TimeSpan delay, TimeSpan interval, int count,
|
||||
TimerStateCallback<T1, T2, T3, T4> callback, T1 t1, T2 t2, T3 t3, T4 t4
|
||||
)
|
||||
{
|
||||
Timer t = new DelayStateCallTimer<T1, T2, T3, T4>(delay, interval, count, callback, t1, t2, t3, t4);
|
||||
t.Start();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
private class DelayCallTimer : Timer
|
||||
{
|
||||
public DelayCallTimer(TimeSpan delay, TimeSpan interval, int count, Action callback) : base(
|
||||
internal DelayCallTimer(TimeSpan delay, TimeSpan interval, int count, Action callback) : base(
|
||||
delay,
|
||||
interval,
|
||||
count
|
||||
)
|
||||
{
|
||||
Callback = callback;
|
||||
}
|
||||
) =>
|
||||
_continuation = callback;
|
||||
|
||||
public Action Callback { get; }
|
||||
internal DelayCallTimer(TimeSpan delay) : base(delay)
|
||||
{
|
||||
#if DEBUG_TIMERS
|
||||
t._allowFinalization = true;
|
||||
#endif
|
||||
Start();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
Callback?.Invoke();
|
||||
_complete = true;
|
||||
_continuation?.Invoke();
|
||||
}
|
||||
|
||||
public override string ToString() => $"DelayCallTimer[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T> : Timer
|
||||
{
|
||||
private readonly T m_State;
|
||||
|
||||
public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T> callback, T state)
|
||||
: base(delay, interval, count)
|
||||
public override void Stop()
|
||||
{
|
||||
Callback = callback;
|
||||
m_State = state;
|
||||
base.Stop();
|
||||
|
||||
if (_selfReturn)
|
||||
{
|
||||
Return();
|
||||
}
|
||||
}
|
||||
|
||||
public TimerStateCallback<T> Callback { get; }
|
||||
|
||||
protected override void OnTick()
|
||||
internal void Return()
|
||||
{
|
||||
Callback?.Invoke(m_State);
|
||||
if (Running)
|
||||
{
|
||||
logger.Error($"Timer is returned while still running! {new StackTrace()}");
|
||||
return;
|
||||
}
|
||||
|
||||
Version++; // Increment the version so if this is called from OnTick() and another timer is started, we don't have a problem
|
||||
|
||||
if (_poolCount >= _poolCapacity)
|
||||
{
|
||||
#if DEBUG_TIMERS
|
||||
logger.Warning($"DelayCallTimer pool reached maximum of {_poolSize} timers");
|
||||
_allowFinalization = true;
|
||||
_stackTraces.Remove(GetHashCode());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
_continuation = null;
|
||||
ReturnToPool(1, this, this);
|
||||
}
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T1, T2> : Timer
|
||||
{
|
||||
private readonly T1 m_T1;
|
||||
private readonly T2 m_T2;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2> callback,
|
||||
T1 t1, T2 t2
|
||||
) : base(delay, interval, count)
|
||||
public static DelayCallTimer GetTimer(TimeSpan delay, TimeSpan interval, int count, Action callback)
|
||||
{
|
||||
Callback = callback;
|
||||
m_T1 = t1;
|
||||
m_T2 = t2;
|
||||
if (_poolHead != null)
|
||||
{
|
||||
_poolCount--;
|
||||
#if DEBUG_TIMERS
|
||||
logger.Information($"Pool count changed: {_poolCount} ({_poolCapacity})");
|
||||
#endif
|
||||
|
||||
var timer = GetFromPool();
|
||||
|
||||
timer.Init(delay, interval, count);
|
||||
timer._continuation = callback;
|
||||
timer._selfReturn = false;
|
||||
#if DEBUG_TIMERS
|
||||
timer._allowFinalization = false;
|
||||
#endif
|
||||
|
||||
return timer;
|
||||
}
|
||||
|
||||
_timerPoolDepletionAmount++;
|
||||
|
||||
#if DEBUG_TIMERS
|
||||
logger.Warning($"Timer pool depleted and timer was allocated.\n{new StackTrace()});
|
||||
#endif
|
||||
return new DelayCallTimer(delay, interval, count, callback);
|
||||
}
|
||||
|
||||
public TimerStateCallback<T1, T2> Callback { get; }
|
||||
public override string ToString() => $"DelayCallTimer[{FormatDelegate(_continuation)}]";
|
||||
|
||||
protected override void OnTick()
|
||||
#if DEBUG_TIMERS
|
||||
internal static Dictionary<int, string> _stackTraces = new();
|
||||
|
||||
~DelayCallTimer()
|
||||
{
|
||||
Callback?.Invoke(m_T1, m_T2);
|
||||
if (!_allowFinalization)
|
||||
{
|
||||
logger.Warning($"Pooled timer was not returned to the pool.\n{_stackTraces[GetHashCode()]}");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
public DelayCallTimer GetAwaiter() => this;
|
||||
|
||||
private class DelayStateCallTimer<T1, T2, T3> : Timer
|
||||
{
|
||||
private readonly T1 m_T1;
|
||||
private readonly T2 m_T2;
|
||||
private readonly T3 m_T3;
|
||||
public bool IsCompleted => _complete;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2, T3> callback,
|
||||
T1 t1, T2 t2, T3 t3
|
||||
) : base(delay, interval, count)
|
||||
public void OnCompleted(Action continuation) => _continuation = continuation;
|
||||
|
||||
public void GetResult()
|
||||
{
|
||||
Callback = callback;
|
||||
m_T1 = t1;
|
||||
m_T2 = t2;
|
||||
m_T3 = t3;
|
||||
}
|
||||
|
||||
public TimerStateCallback<T1, T2, T3> Callback { get; }
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
Callback?.Invoke(m_T1, m_T2, m_T3);
|
||||
}
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
|
||||
private class DelayStateCallTimer<T1, T2, T3, T4> : Timer
|
||||
{
|
||||
private readonly T1 m_T1;
|
||||
private readonly T2 m_T2;
|
||||
private readonly T3 m_T3;
|
||||
private readonly T4 m_T4;
|
||||
|
||||
public DelayStateCallTimer(
|
||||
TimeSpan delay, TimeSpan interval, int count, TimerStateCallback<T1, T2, T3, T4> callback,
|
||||
T1 t1, T2 t2, T3 t3, T4 t4
|
||||
) : base(delay, interval, count)
|
||||
{
|
||||
Callback = callback;
|
||||
m_T1 = t1;
|
||||
m_T2 = t2;
|
||||
m_T3 = t3;
|
||||
m_T4 = t4;
|
||||
}
|
||||
|
||||
public TimerStateCallback<T1, T2, T3, T4> Callback { get; }
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
Callback?.Invoke(m_T1, m_T2, m_T3, m_T4);
|
||||
}
|
||||
|
||||
public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2021 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Timer.Pause.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public partial class Timer
|
||||
{
|
||||
public class DelayTaskTimer : Timer, INotifyCompletion
|
||||
{
|
||||
private Action _continuation;
|
||||
private bool _complete;
|
||||
|
||||
internal DelayTaskTimer(TimeSpan delay) : base(delay) => Start();
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
_complete = true;
|
||||
_continuation?.Invoke();
|
||||
}
|
||||
|
||||
public DelayTaskTimer GetAwaiter() => this;
|
||||
|
||||
public bool IsCompleted => _complete;
|
||||
|
||||
public void OnCompleted(Action continuation) => _continuation = continuation;
|
||||
|
||||
public void GetResult()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayTaskTimer Pause(TimeSpan ms) => new(ms);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static DelayTaskTimer Pause(int ms) => Pause(TimeSpan.FromMilliseconds(ms));
|
||||
}
|
||||
}
|
||||
128
Projects/Server/Timer/Timer.Pool.cs
Normal file
128
Projects/Server/Timer/Timer.Pool.cs
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2021 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Timer.Pool.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public partial class Timer
|
||||
{
|
||||
private const int _timerPoolDepletionThreshold = 128; // Maximum timers allocated in a single tick before we force adjust
|
||||
private static int _timerPoolDepletionAmount; // Amount the pool has been depleted by
|
||||
private static int _maxPoolCapacity;
|
||||
private static int _poolCapacity;
|
||||
private static int _poolCount;
|
||||
private static DelayCallTimer _poolHead;
|
||||
|
||||
public static void CheckTimerPool()
|
||||
{
|
||||
// Anything less than this threshold and we are ok with the number of allocations.
|
||||
if (_timerPoolDepletionAmount < _timerPoolDepletionThreshold)
|
||||
{
|
||||
_timerPoolDepletionAmount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
var growthFactor = Math.DivRem(_timerPoolDepletionAmount, _poolCapacity, out var rem);
|
||||
var amountToGrow = _poolCapacity * (growthFactor + (rem > 0 ? 1 : 0));
|
||||
var amountToRefill = Math.Min(_maxPoolCapacity, amountToGrow);
|
||||
|
||||
var maximumHit = amountToGrow > amountToRefill ? " Maximum pool size has been reached." : "";
|
||||
|
||||
logger.Warning($"Timer pool depleted by {_timerPoolDepletionAmount}. Refilling with {amountToRefill}.{maximumHit}");
|
||||
RefillPoolAsync(amountToRefill);
|
||||
_timerPoolDepletionAmount = 0;
|
||||
}
|
||||
|
||||
public static void ConfigureTimerPool()
|
||||
{
|
||||
_poolCapacity = ServerConfiguration.GetOrUpdateSetting("timer.intialPoolCapacity", 1024);
|
||||
_maxPoolCapacity = ServerConfiguration.GetOrUpdateSetting("timer.maxPoolCapacity", _poolCapacity * 16);
|
||||
|
||||
RefillPool(_poolCapacity, out var head, out var tail);
|
||||
ReturnToPool(_poolCapacity, head, tail);
|
||||
}
|
||||
|
||||
private static void ReturnToPool(int amount, DelayCallTimer head, DelayCallTimer tail)
|
||||
{
|
||||
tail.Attach(_poolHead);
|
||||
_poolHead = head;
|
||||
_poolCount += amount;
|
||||
#if DEBUG_TIMERS
|
||||
logger.Information($"Pool count changed: {_poolCount} ({_poolCapacity})");
|
||||
#endif
|
||||
}
|
||||
|
||||
private static DelayCallTimer GetFromPool()
|
||||
{
|
||||
var timer = _poolHead;
|
||||
_poolHead = _poolHead._nextTimer as DelayCallTimer;
|
||||
timer.Detach();
|
||||
return timer;
|
||||
}
|
||||
|
||||
internal static void RefillPool(int amount, out DelayCallTimer head, out DelayCallTimer tail)
|
||||
{
|
||||
#if DEBUG_TIMERS
|
||||
logger.Information($"Filling pool with {amount} timers.");
|
||||
#endif
|
||||
|
||||
head = null;
|
||||
tail = null;
|
||||
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
var timer = new DelayCallTimer(TimeSpan.Zero, TimeSpan.Zero, 0, null);
|
||||
timer.Attach(head);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
tail = timer;
|
||||
}
|
||||
|
||||
head = timer;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void RefillPoolAsync(int amountToRefill)
|
||||
{
|
||||
ThreadPool.UnsafeQueueUserWorkItem(
|
||||
static amount =>
|
||||
{
|
||||
RefillPool(amount, out var head, out var tail);
|
||||
|
||||
// Run this on the core thread
|
||||
Core.LoopContext.Post(
|
||||
state =>
|
||||
{
|
||||
if (state == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var (listHead, listTail) = ((DelayCallTimer, DelayCallTimer))state;
|
||||
ReturnToPool(amount, listHead, listTail);
|
||||
_poolCapacity = amount;
|
||||
},
|
||||
(head, tail)
|
||||
);
|
||||
},
|
||||
amountToRefill,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,20 +113,25 @@ namespace Server
|
|||
// This can be done in OnTick by checking if Index < Count - 1 (still more iterations left)
|
||||
RemoveTimer(timer);
|
||||
|
||||
if (finished)
|
||||
{
|
||||
timer.InternalStop();
|
||||
}
|
||||
var version = timer.Version;
|
||||
|
||||
prof?.Start();
|
||||
timer.OnTick();
|
||||
prof?.Finish();
|
||||
|
||||
if (timer.Running && !finished)
|
||||
// If the timer has not been stopped, and it has not been altered (shared timers)
|
||||
if (timer.Running && timer.Version == version)
|
||||
{
|
||||
timer.Delay = timer.Interval;
|
||||
timer.Next = Core.Now + timer.Interval;
|
||||
AddTimer(timer, (long)timer.Delay.TotalMilliseconds);
|
||||
if (finished)
|
||||
{
|
||||
timer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
timer.Delay = timer.Interval;
|
||||
timer.Next = Core.Now + timer.Interval;
|
||||
AddTimer(timer, (long)timer.Delay.TotalMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
timer = next;
|
||||
|
|
@ -200,8 +205,8 @@ namespace Server
|
|||
{
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
tw.WriteLine("Date: {0}", now);
|
||||
tw.WriteLine();
|
||||
tw.WriteLine("Date: {0}\n", now);
|
||||
tw.WriteLine("Pool - Count: {0}; Size {1}\n", _poolCount - _timerPoolDepletionAmount, _poolCapacity);
|
||||
|
||||
var total = 0.0;
|
||||
var hash = new Dictionary<string, int>();
|
||||
|
|
@ -221,9 +226,11 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
tw.WriteLine("Timers:");
|
||||
|
||||
foreach (var (name, count) in hash.OrderByDescending(o => o.Value))
|
||||
{
|
||||
tw.WriteLine($"Type: {name}; Count: {count}; Percent: {count / total}%");
|
||||
tw.WriteLine($"- Type: {name}; Count: {count}; Percent: {count / total}%");
|
||||
}
|
||||
|
||||
tw.WriteLine();
|
||||
|
|
|
|||
|
|
@ -21,12 +21,16 @@ namespace Server
|
|||
{
|
||||
public partial class Timer
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(Timer));
|
||||
protected internal static readonly ILogger logger = LogFactory.GetLogger(typeof(Timer));
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
ConfigureTimerPool();
|
||||
}
|
||||
|
||||
// We need to know what ring/slot we are in so we can be removed if we are "head" of the link list.
|
||||
private int _ring;
|
||||
private int _slot;
|
||||
|
||||
private long _remaining;
|
||||
private Timer _nextTimer;
|
||||
private Timer _prevTimer;
|
||||
|
|
@ -37,10 +41,11 @@ namespace Server
|
|||
|
||||
public Timer(TimeSpan delay, TimeSpan interval, int count = 0) => Init(delay, interval, count);
|
||||
|
||||
public void Init(TimeSpan delay, TimeSpan interval, int count)
|
||||
protected void Init(TimeSpan delay, TimeSpan interval, int count)
|
||||
{
|
||||
Running = false;
|
||||
Delay = delay;
|
||||
Index = 0;
|
||||
Interval = interval;
|
||||
Count = count;
|
||||
_nextTimer = null;
|
||||
|
|
@ -55,6 +60,8 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
protected int Version { get; set; } // Used to determine if a timer was altered and we should abandon it.
|
||||
|
||||
public DateTime Next { get; private set; }
|
||||
public TimeSpan Delay { get; set; }
|
||||
public TimeSpan Interval { get; set; }
|
||||
|
|
@ -87,21 +94,14 @@ namespace Server
|
|||
return this;
|
||||
}
|
||||
|
||||
public Timer Stop()
|
||||
public virtual void Stop()
|
||||
{
|
||||
if (!Running)
|
||||
{
|
||||
return this;
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveTimer(this);
|
||||
InternalStop();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void InternalStop()
|
||||
{
|
||||
Running = false;
|
||||
var prof = GetProfile();
|
||||
|
||||
|
|
|
|||
60
Projects/Server/Timer/TimerExecutionToken.cs
Normal file
60
Projects/Server/Timer/TimerExecutionToken.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2021 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: TimerExecutionToken.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public struct TimerExecutionToken
|
||||
{
|
||||
private Timer.DelayCallTimer _timer;
|
||||
|
||||
internal TimerExecutionToken(Timer.DelayCallTimer timer) => _timer = timer;
|
||||
|
||||
public bool Running
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timer?.Running == true;
|
||||
}
|
||||
|
||||
public int Index
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timer?.Index ?? 0;
|
||||
}
|
||||
|
||||
public int RemainingCount
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timer?.RemainingCount ?? 0;
|
||||
}
|
||||
|
||||
public DateTime Next
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timer?.Next ?? DateTime.MinValue;
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
_timer?.Stop();
|
||||
_timer?.Return();
|
||||
_timer = null;
|
||||
|
||||
this = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -419,7 +419,7 @@ namespace Server
|
|||
|
||||
m_DiskWriteHandle.Set();
|
||||
|
||||
Timer.DelayCall(FinishWorldSave);
|
||||
Timer.StartTimer(FinishWorldSave);
|
||||
}
|
||||
|
||||
private static void ProcessDecay()
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ namespace Server.Accounting
|
|||
|
||||
_totalGameTime = reader.ReadTimeSpan();
|
||||
|
||||
Timer.DelayCall(AfterDeserialization);
|
||||
Timer.StartTimer(AfterDeserialization);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ namespace Server.Engines.BulkOrders
|
|||
RequireExceptional = reader.ReadBool();
|
||||
Material = (BulkMaterialType)reader.ReadInt();
|
||||
|
||||
Timer.DelayCall(AfterDeserialization);
|
||||
Timer.StartTimer(AfterDeserialization);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,10 @@ namespace Server.Engines.CannedEvil
|
|||
|
||||
//Goes back each level, below level 0 and it goes off!
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
private IdolOfTheChampion m_Idol;
|
||||
private TimerExecutionToken _restartTimerToken;
|
||||
|
||||
public virtual string BroadcastMessage => "The Champion has sensed your presence! Beware its wrath!";
|
||||
public virtual bool ProximitySpawn => false;
|
||||
|
|
@ -58,8 +59,6 @@ namespace Server.Engines.CannedEvil
|
|||
|
||||
public Dictionary<Mobile, int> DamageEntries { get; private set; }
|
||||
|
||||
public Timer RestartTimer { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool ConfinedRoaming { get; set; }
|
||||
|
||||
|
|
@ -92,7 +91,7 @@ namespace Server.Engines.CannedEvil
|
|||
RestartDelay = TimeSpan.FromMinutes(30.0);
|
||||
DamageEntries = new Dictionary<Mobile, int>();
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, SetInitialSpawnArea);
|
||||
Timer.StartTimer(TimeSpan.Zero, SetInitialSpawnArea);
|
||||
}
|
||||
|
||||
public void SetInitialSpawnArea()
|
||||
|
|
@ -303,13 +302,10 @@ namespace Server.Engines.CannedEvil
|
|||
HasBeenAdvanced = false;
|
||||
m_MaxLevel = 16 + Utility.Random(3);
|
||||
|
||||
m_Timer?.Stop();
|
||||
_timerToken.Cancel();
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnSlice, out _timerToken);
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnSlice);
|
||||
m_Timer.Start();
|
||||
|
||||
RestartTimer?.Stop();
|
||||
RestartTimer = null;
|
||||
_restartTimerToken.Cancel();
|
||||
|
||||
if (m_Altar != null)
|
||||
{
|
||||
|
|
@ -336,12 +332,8 @@ namespace Server.Engines.CannedEvil
|
|||
HasBeenAdvanced = false;
|
||||
m_MaxLevel = 0;
|
||||
|
||||
m_Timer?.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
|
||||
RestartTimer?.Stop();
|
||||
RestartTimer = null;
|
||||
_timerToken.Cancel();
|
||||
_restartTimerToken.Cancel();
|
||||
|
||||
if (m_Altar != null)
|
||||
{
|
||||
|
|
@ -363,17 +355,14 @@ namespace Server.Engines.CannedEvil
|
|||
NextProximityTime = Core.Now + TimeSpan.FromHours(6.0);
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(10.0), ExpireCreatures);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(10.0), ExpireCreatures);
|
||||
}
|
||||
|
||||
public void BeginRestart(TimeSpan ts)
|
||||
{
|
||||
RestartTimer?.Stop();
|
||||
|
||||
RestartTime = Core.Now + ts;
|
||||
|
||||
RestartTimer = Timer.DelayCall(ts, EndRestart);
|
||||
RestartTimer.Start();
|
||||
_restartTimerToken.Cancel();
|
||||
Timer.StartTimer(ts, EndRestart, out _restartTimerToken);
|
||||
}
|
||||
|
||||
public void EndRestart()
|
||||
|
|
@ -1314,12 +1303,15 @@ namespace Server.Engines.CannedEvil
|
|||
writer.Write(Champion);
|
||||
writer.Write(RestartDelay);
|
||||
|
||||
writer.Write(RestartTimer != null);
|
||||
|
||||
if (RestartTimer != null)
|
||||
if (_restartTimerToken.Running)
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.WriteDeltaTime(RestartTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(false);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
|
|
@ -1456,7 +1448,7 @@ namespace Server.Engines.CannedEvil
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, UpdateRegion);
|
||||
Timer.StartTimer(TimeSpan.Zero, UpdateRegion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
AddButton(314, 173, 247, 248, 1);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(15.0), AutoReject);
|
||||
}
|
||||
|
||||
public string Center(string text) => $"<CENTER>{text}</CENTER>";
|
||||
|
|
|
|||
|
|
@ -333,12 +333,12 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if (IsOccupied)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2.0), Evict);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(2.0), Evict);
|
||||
}
|
||||
|
||||
if (m_Tournament != null)
|
||||
{
|
||||
Timer.DelayCall(AttachToTournament_Sandbox);
|
||||
Timer.StartTimer(AttachToTournament_Sandbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,10 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
private readonly List<Item> m_Walls = new();
|
||||
|
||||
private Timer m_AutoTieTimer;
|
||||
|
||||
private Timer m_Countdown;
|
||||
private TimerExecutionToken _autoTieTimerToken;
|
||||
private TimerExecutionToken _countdownTimerToken;
|
||||
private TimerExecutionToken _SdWarnTimerToken;
|
||||
private TimerExecutionToken _SdActivateTimerToken;
|
||||
|
||||
public EventGame m_EventGame;
|
||||
private Map m_GateFacet;
|
||||
|
|
@ -42,7 +43,6 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public Arena m_OverrideArena;
|
||||
|
||||
private Timer m_SDWarnTimer, m_SDActivateTimer;
|
||||
public Tournament m_Tournament;
|
||||
|
||||
private bool m_Yielding;
|
||||
|
|
@ -109,7 +109,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||
{
|
||||
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||
Timer.StartTimer(ts, () => DelayBounce_Callback(mob, corpse));
|
||||
}
|
||||
|
||||
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) =>
|
||||
|
|
@ -766,7 +766,7 @@ namespace Server.Engines.ConPVP
|
|||
return;
|
||||
}
|
||||
|
||||
EndAutoTie();
|
||||
_autoTieTimerToken.Cancel();
|
||||
StopSDTimers();
|
||||
|
||||
Finished = true;
|
||||
|
|
@ -844,7 +844,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
m_EventGame?.OnStop();
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(9.0), UnregisterRematch);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(9.0), UnregisterRematch);
|
||||
}
|
||||
|
||||
public void Award(Mobile us, Mobile them, bool won)
|
||||
|
|
@ -1057,23 +1057,20 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void StartCountdown(int count, CountdownCallback cb)
|
||||
{
|
||||
cb(count);
|
||||
m_Countdown = Timer.DelayCall(
|
||||
TimeSpan.FromSeconds(1.0),
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromSeconds(1.0),
|
||||
count,
|
||||
() => Countdown_Callback(--count, cb)
|
||||
() => Countdown_Callback(cb),
|
||||
out _countdownTimerToken
|
||||
);
|
||||
}
|
||||
|
||||
public void StopCountdown()
|
||||
{
|
||||
m_Countdown?.Stop();
|
||||
m_Countdown = null;
|
||||
}
|
||||
public void StopCountdown() => _countdownTimerToken.Cancel();
|
||||
|
||||
private void Countdown_Callback(int count, CountdownCallback cb)
|
||||
private void Countdown_Callback(CountdownCallback cb)
|
||||
{
|
||||
var count = _countdownTimerToken.RemainingCount;
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
StopCountdown();
|
||||
|
|
@ -1084,24 +1081,17 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void StopSDTimers()
|
||||
{
|
||||
m_SDWarnTimer?.Stop();
|
||||
|
||||
m_SDWarnTimer = null;
|
||||
|
||||
m_SDActivateTimer?.Stop();
|
||||
|
||||
m_SDActivateTimer = null;
|
||||
_SdWarnTimerToken.Cancel();
|
||||
_SdActivateTimerToken.Cancel();
|
||||
}
|
||||
|
||||
public void StartSuddenDeath(TimeSpan timeUntilActive)
|
||||
{
|
||||
m_SDWarnTimer?.Stop();
|
||||
_SdWarnTimerToken.Cancel();
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(timeUntilActive.TotalMinutes * 0.9), WarnSuddenDeath, out _SdWarnTimerToken);
|
||||
|
||||
m_SDWarnTimer = Timer.DelayCall(TimeSpan.FromMinutes(timeUntilActive.TotalMinutes * 0.9), WarnSuddenDeath);
|
||||
|
||||
m_SDActivateTimer?.Stop();
|
||||
|
||||
m_SDActivateTimer = Timer.DelayCall(timeUntilActive, ActivateSuddenDeath);
|
||||
_SdActivateTimerToken.Cancel();
|
||||
Timer.StartTimer(timeUntilActive, ActivateSuddenDeath, out _SdActivateTimerToken);
|
||||
}
|
||||
|
||||
public void WarnSuddenDeath()
|
||||
|
|
@ -1127,9 +1117,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
m_Tournament?.Alert(Arena, "Sudden death will be active soon!");
|
||||
|
||||
m_SDWarnTimer?.Stop();
|
||||
|
||||
m_SDWarnTimer = null;
|
||||
_SdWarnTimerToken.Cancel();
|
||||
}
|
||||
|
||||
public static bool CheckSuddenDeath(Mobile mob) => mob is PlayerMobile pm && pm.DuelPlayer?.Eliminated == false &&
|
||||
|
|
@ -1163,32 +1151,22 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
IsSuddenDeath = true;
|
||||
|
||||
m_SDActivateTimer?.Stop();
|
||||
|
||||
m_SDActivateTimer = null;
|
||||
_SdActivateTimerToken.Cancel();
|
||||
}
|
||||
|
||||
public void BeginAutoTie()
|
||||
{
|
||||
m_AutoTieTimer?.Stop();
|
||||
|
||||
var ts = m_Tournament == null || m_Tournament.TourneyType == TourneyType.Standard
|
||||
? AutoTieDelay
|
||||
: TimeSpan.FromMinutes(90.0);
|
||||
|
||||
m_AutoTieTimer = Timer.DelayCall(ts, InvokeAutoTie);
|
||||
}
|
||||
|
||||
public void EndAutoTie()
|
||||
{
|
||||
m_AutoTieTimer?.Stop();
|
||||
|
||||
m_AutoTieTimer = null;
|
||||
_autoTieTimerToken.Cancel();
|
||||
Timer.StartTimer(ts, InvokeAutoTie, out _autoTieTimerToken);
|
||||
}
|
||||
|
||||
public void InvokeAutoTie()
|
||||
{
|
||||
m_AutoTieTimer = null;
|
||||
_autoTieTimerToken.Cancel();
|
||||
|
||||
if (!Started || Finished)
|
||||
{
|
||||
|
|
@ -1258,7 +1236,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
m_Tournament?.HandleTie(Arena, m_Match, remaining);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10.0), Unregister);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), Unregister);
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
|
|
@ -1640,9 +1618,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
else
|
||||
{
|
||||
pm.DuelContext.m_Countdown?.Stop();
|
||||
pm.DuelContext.m_Countdown = null;
|
||||
|
||||
pm.DuelContext.StopCountdown();
|
||||
pm.DuelContext.StartedReadyCountdown = false;
|
||||
p.Broadcast(0x22, null, "{0} has yielded.", "You have yielded.");
|
||||
|
||||
|
|
@ -2777,7 +2753,7 @@ namespace Server.Engines.ConPVP
|
|||
TitleColor = 0x7800;
|
||||
TitleNumber = 1062051; // Gate Warning
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10.0), Delete);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), Delete);
|
||||
}
|
||||
|
||||
public ArenaMoongate(Serial serial) : base(serial)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(Delete); // delete this after the world loads
|
||||
Timer.StartTimer(Delete); // delete this after the world loads
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
|
|
@ -243,7 +243,7 @@ namespace Server.Engines.ConPVP
|
|||
m_Path.Clear();
|
||||
m_PathIdx = 0;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.05), ContinueFlight);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.05), ContinueFlight);
|
||||
}
|
||||
|
||||
private bool CheckCatch(Mobile m, Point3D myLoc)
|
||||
|
|
@ -640,7 +640,7 @@ namespace Server.Engines.ConPVP
|
|||
DoAnim(GetWorldLocation(), m_Path[m_PathIdx - 1], Map);
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.1), ContinueFlight);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.1), ContinueFlight);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -864,7 +864,7 @@ namespace Server.Engines.ConPVP
|
|||
// has to be delayed in case some other target canceled us...
|
||||
if (m_Resend)
|
||||
{
|
||||
Timer.DelayCall(ResendBombTarget);
|
||||
Timer.StartTimer(ResendBombTarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1613,24 +1613,13 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
private BRBomb m_Bomb;
|
||||
|
||||
private Timer m_FinishTimer;
|
||||
private TimerExecutionToken _finishTimerToken;
|
||||
|
||||
public BRGame(BRController controller, DuelContext context) : base(context) => Controller = controller;
|
||||
|
||||
public BRController Controller { get; }
|
||||
|
||||
public Map Facet
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Context.Arena != null)
|
||||
{
|
||||
return m_Context.Arena.Facet;
|
||||
}
|
||||
|
||||
return Controller.Map;
|
||||
}
|
||||
}
|
||||
public Map Facet => m_Context.Arena != null ? m_Context.Arena.Facet : Controller.Map;
|
||||
|
||||
public override bool CantDoAnything(Mobile mob) =>
|
||||
mob.Backpack?.FindItemByType<BRBomb>() != null && GetTeamInfo(mob) != null;
|
||||
|
|
@ -1641,7 +1630,7 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
m_Bomb.Visible = false;
|
||||
m_Bomb.MoveToWorld(Controller.BombHome, Controller.Map);
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 15)), UnhideBomb);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 15)), UnhideBomb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1724,7 +1713,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||
{
|
||||
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||
Timer.StartTimer(ts, () => DelayBounce_Callback(mob, corpse));
|
||||
}
|
||||
|
||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||
|
|
@ -1821,12 +1810,12 @@ namespace Server.Engines.ConPVP
|
|||
);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
_finishTimerToken.Cancel();
|
||||
|
||||
m_Bomb = new BRBomb(this);
|
||||
ReturnBomb();
|
||||
|
||||
m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback);
|
||||
Timer.StartTimer(Controller.Duration, Finish_Callback, out _finishTimerToken);
|
||||
}
|
||||
|
||||
private void Finish_Callback()
|
||||
|
|
@ -2047,8 +2036,7 @@ namespace Server.Engines.ConPVP
|
|||
ApplyHues(m_Context.Participants[i], -1);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = null;
|
||||
_finishTimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public Mobile m_Returner;
|
||||
public DateTime m_ReturnTime;
|
||||
private Timer m_ReturnTimer;
|
||||
private TimerExecutionToken _returnTimerToken;
|
||||
public CTFTeamInfo m_TeamInfo;
|
||||
|
||||
[Constructible]
|
||||
|
|
@ -370,18 +370,11 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
private void StopCountdown()
|
||||
{
|
||||
m_ReturnTimer?.Stop();
|
||||
|
||||
m_ReturnTimer = null;
|
||||
}
|
||||
|
||||
private void BeginCountdown(int returnCount)
|
||||
{
|
||||
StopCountdown();
|
||||
_returnTimerToken.Cancel();
|
||||
|
||||
m_ReturnTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Countdown_OnTick);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Countdown_OnTick, out _returnTimerToken);
|
||||
m_ReturnCount = returnCount;
|
||||
}
|
||||
|
||||
|
|
@ -518,7 +511,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void SendHome()
|
||||
{
|
||||
StopCountdown();
|
||||
_returnTimerToken.Cancel();
|
||||
|
||||
if (m_TeamInfo == null)
|
||||
{
|
||||
|
|
@ -897,7 +890,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public sealed class CTFGame : EventGame
|
||||
{
|
||||
private Timer m_FinishTimer;
|
||||
private TimerExecutionToken _finishTimerToken;
|
||||
|
||||
public CTFGame(CTFController controller, DuelContext context) : base(context) => Controller = controller;
|
||||
|
||||
|
|
@ -1004,7 +997,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||
{
|
||||
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||
Timer.StartTimer(ts, () => DelayBounce_Callback(mob, corpse));
|
||||
}
|
||||
|
||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||
|
|
@ -1135,9 +1128,8 @@ namespace Server.Engines.ConPVP
|
|||
ApplyHues(m_Context.Participants[i], Controller.TeamInfo[i % 8].Color);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
|
||||
m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback);
|
||||
_finishTimerToken.Cancel();
|
||||
Timer.StartTimer(Controller.Duration, Finish_Callback, out _finishTimerToken);
|
||||
}
|
||||
|
||||
private void Finish_Callback()
|
||||
|
|
@ -1364,9 +1356,7 @@ namespace Server.Engines.ConPVP
|
|||
ApplyHues(m_Context.Participants[i], -1);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
|
||||
m_FinishTimer = null;
|
||||
_finishTimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -495,10 +495,9 @@ namespace Server.Engines.ConPVP
|
|||
private int m_CapStage;
|
||||
|
||||
private bool m_Capturable = true;
|
||||
private Timer m_CaptureTimer;
|
||||
|
||||
private Timer m_FinishTimer;
|
||||
private Timer m_UncaptureTimer;
|
||||
private TimerExecutionToken _captureTimerToken;
|
||||
private TimerExecutionToken _finishTimerToken;
|
||||
private TimerExecutionToken _uncaptureTimerToken;
|
||||
|
||||
public DDGame(DDController controller, DuelContext context) : base(context) => Controller = controller;
|
||||
|
||||
|
|
@ -587,7 +586,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||
{
|
||||
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||
Timer.StartTimer(ts, () => DelayBounce_Callback(mob, corpse));
|
||||
}
|
||||
|
||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||
|
|
@ -668,17 +667,8 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
m_Capturable = true;
|
||||
|
||||
if (m_CaptureTimer != null)
|
||||
{
|
||||
m_CaptureTimer.Stop();
|
||||
m_CaptureTimer = null;
|
||||
}
|
||||
|
||||
if (m_UncaptureTimer != null)
|
||||
{
|
||||
m_UncaptureTimer.Stop();
|
||||
m_UncaptureTimer = null;
|
||||
}
|
||||
_captureTimerToken.Cancel();
|
||||
_uncaptureTimerToken.Cancel();
|
||||
|
||||
for (var i = 0; i < Controller.TeamInfo.Length; ++i)
|
||||
{
|
||||
|
|
@ -706,8 +696,8 @@ namespace Server.Engines.ConPVP
|
|||
);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback);
|
||||
_finishTimerToken.Cancel();
|
||||
Timer.StartTimer(Controller.Duration, Finish_Callback, out _finishTimerToken);
|
||||
}
|
||||
|
||||
private void Finish_Callback()
|
||||
|
|
@ -933,25 +923,15 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
m_Capturable = false;
|
||||
|
||||
if (m_CaptureTimer != null)
|
||||
{
|
||||
m_CaptureTimer.Stop();
|
||||
m_CaptureTimer = null;
|
||||
}
|
||||
|
||||
if (m_UncaptureTimer != null)
|
||||
{
|
||||
m_UncaptureTimer.Stop();
|
||||
m_UncaptureTimer = null;
|
||||
}
|
||||
_captureTimerToken.Cancel();
|
||||
_uncaptureTimerToken.Cancel();
|
||||
|
||||
for (var i = 0; i < m_Context.Participants.Count; ++i)
|
||||
{
|
||||
ApplyHues(m_Context.Participants[i], -1);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = null;
|
||||
_finishTimerToken.Cancel();
|
||||
}
|
||||
|
||||
public void Dominate(DDWayPoint point, Mobile from, DDTeamInfo team)
|
||||
|
|
@ -975,14 +955,13 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
Controller.PointA?.SetNonCaptureHue();
|
||||
Controller.PointB?.SetNonCaptureHue();
|
||||
m_CaptureTimer?.Stop();
|
||||
m_CaptureTimer = null;
|
||||
_captureTimerToken.Cancel();
|
||||
}
|
||||
|
||||
if (!wasDom && isDom)
|
||||
{
|
||||
m_CapStage = 0;
|
||||
m_CaptureTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick);
|
||||
Timer.StartTimer(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), CaptureTick, out _captureTimerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -993,8 +972,7 @@ namespace Server.Engines.ConPVP
|
|||
if (team == null)
|
||||
{
|
||||
m_Capturable = true;
|
||||
m_CaptureTimer?.Stop();
|
||||
m_CaptureTimer = null;
|
||||
_captureTimerToken.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1014,8 +992,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
m_Capturable = false;
|
||||
m_CapStage = 0;
|
||||
m_CaptureTimer.Stop();
|
||||
m_CaptureTimer = null;
|
||||
_captureTimerToken.Cancel();
|
||||
|
||||
if (Controller.PointA != null)
|
||||
{
|
||||
|
|
@ -1029,8 +1006,7 @@ namespace Server.Engines.ConPVP
|
|||
Controller.PointB.SetUncapturableHue();
|
||||
}
|
||||
|
||||
m_UncaptureTimer = Timer.DelayCall(TimeSpan.FromSeconds(30.0), UncaptureTick);
|
||||
m_UncaptureTimer.Start();
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30.0), UncaptureTick, out _uncaptureTimerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1038,17 +1014,8 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
m_Capturable = true;
|
||||
|
||||
if (m_CaptureTimer != null)
|
||||
{
|
||||
m_CaptureTimer.Stop();
|
||||
m_CaptureTimer = null;
|
||||
}
|
||||
|
||||
if (m_UncaptureTimer != null)
|
||||
{
|
||||
m_UncaptureTimer.Stop();
|
||||
m_UncaptureTimer = null;
|
||||
}
|
||||
_captureTimerToken.Cancel();
|
||||
_uncaptureTimerToken.Cancel();
|
||||
|
||||
if (Controller.PointA != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ namespace Server.Engines.ConPVP
|
|||
Name = "the hill";
|
||||
}
|
||||
|
||||
public HillOfTheKing(Serial s)
|
||||
: base(s)
|
||||
public HillOfTheKing(Serial s) : base(s)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -49,18 +48,7 @@ namespace Server.Engines.ConPVP
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int ScoreInterval { get; set; }
|
||||
|
||||
public int CapturesSoFar
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_KingTimer != null)
|
||||
{
|
||||
return m_KingTimer.Captures;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int CapturesSoFar => m_KingTimer?.Captures ?? 0;
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
|
|
@ -864,7 +852,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public sealed class KHGame : EventGame
|
||||
{
|
||||
private Timer m_FinishTimer;
|
||||
private TimerExecutionToken _finishTimerToken;
|
||||
|
||||
public KHGame(KHController controller, DuelContext context) : base(context) => Controller = controller;
|
||||
|
||||
|
|
@ -969,7 +957,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void DelayBounce(TimeSpan ts, Mobile mob, Container corpse)
|
||||
{
|
||||
Timer.DelayCall(ts, DelayBounce_Callback, mob, corpse);
|
||||
Timer.StartTimer(ts, () => DelayBounce_Callback(mob, corpse));
|
||||
}
|
||||
|
||||
private void DelayBounce_Callback(Mobile mob, Container corpse)
|
||||
|
|
@ -994,7 +982,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if (corpse?.Deleted == false)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(30), corpse.Delete);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30), corpse.Delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1067,8 +1055,6 @@ namespace Server.Engines.ConPVP
|
|||
);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
|
||||
for (var i = 0; i < Controller.Hills.Length; i++)
|
||||
{
|
||||
if (Controller.Hills[i] != null)
|
||||
|
|
@ -1085,7 +1071,8 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
m_FinishTimer = Timer.DelayCall(Controller.Duration, Finish_Callback);
|
||||
_finishTimerToken.Cancel();
|
||||
Timer.StartTimer(Controller.Duration, Finish_Callback, out _finishTimerToken);
|
||||
}
|
||||
|
||||
private void Finish_Callback()
|
||||
|
|
@ -1310,8 +1297,7 @@ namespace Server.Engines.ConPVP
|
|||
ApplyHues(m_Context.Participants[i], -1);
|
||||
}
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = null;
|
||||
_finishTimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ namespace Server.Engines.ConPVP
|
|||
y -= 3;
|
||||
AddButton(314, y, 247, 248, 1);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(15.0), AutoReject);
|
||||
}
|
||||
|
||||
public string Center(string text) => $"<CENTER>{text}</CENTER>";
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(SliceInterval, SliceInterval, Slice);
|
||||
Timer.StartTimer(SliceInterval, SliceInterval, Slice);
|
||||
}
|
||||
|
||||
public Tournament()
|
||||
|
|
@ -122,7 +122,7 @@ namespace Server.Engines.ConPVP
|
|||
Arenas = new List<Arena>();
|
||||
SignupPeriod = TimeSpan.FromMinutes(10.0);
|
||||
|
||||
Timer.DelayCall(SliceInterval, SliceInterval, Slice);
|
||||
Timer.StartTimer(SliceInterval, SliceInterval, Slice);
|
||||
}
|
||||
|
||||
public bool IsNotoRestricted => TourneyType != TourneyType.Standard;
|
||||
|
|
@ -992,18 +992,19 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public void Alert(Arena arena, params string[] alerts)
|
||||
{
|
||||
if (arena?.Announcer != null)
|
||||
if (arena?.Announcer == null)
|
||||
{
|
||||
for (var j = 0; j < alerts.Length; ++j)
|
||||
{
|
||||
Timer.DelayCall(
|
||||
TimeSpan.FromSeconds(Math.Max(j - 0.5, 0.0)),
|
||||
(announcer, alert) => announcer.PublicOverheadMessage(MessageType.Regular, 0x35, false, alert),
|
||||
arena.Announcer,
|
||||
alerts[j]
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.5), alerts.Length,
|
||||
() =>
|
||||
{
|
||||
arena.Announcer.PublicOverheadMessage(MessageType.Regular, 0x35, false, alerts[count++]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Server.Engines.ConPVP
|
|||
[Constructible]
|
||||
public TournamentRegistrar()
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
|
||||
}
|
||||
|
||||
public TournamentRegistrar(Serial serial) : base(serial)
|
||||
|
|
@ -70,7 +70,7 @@ namespace Server.Engines.ConPVP
|
|||
m.NetState
|
||||
);
|
||||
m.BeginAction(this);
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10.0), ReleaseLock_Callback, m);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), () => ReleaseLock_Callback(m));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ namespace Server.Engines.Craft
|
|||
toDelete = true;
|
||||
|
||||
from.BeginAction<Golem>();
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(12.0), from.EndAction<Golem>);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(12.0), from.EndAction<Golem>);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Server.Engines.Doom
|
|||
|
||||
private GauntletSpawnerState m_State;
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public GauntletSpawner(string typeName = null) : base(0x36FE)
|
||||
|
|
@ -136,7 +136,7 @@ namespace Server.Engines.Doom
|
|||
CreateRegion();
|
||||
FullSpawn();
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Slice);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), Slice, out _timerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -176,8 +176,7 @@ namespace Server.Engines.Doom
|
|||
ClearTraps();
|
||||
DestroyRegion();
|
||||
|
||||
m_Timer?.Stop();
|
||||
m_Timer = null;
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ namespace Server.Engines.Doom
|
|||
private static readonly int[] ms2 = { 0x13F, 0x14B };
|
||||
private static readonly int[] cs1 = { 0x244 };
|
||||
private static readonly int[] exp = { 0x307 };
|
||||
private Timer l_Timer;
|
||||
private TimerExecutionToken _resetTimerToken;
|
||||
private LampRoomBox m_Box;
|
||||
private Region m_LampRoom;
|
||||
|
||||
|
|
@ -331,15 +331,8 @@ namespace Server.Engines.Doom
|
|||
|
||||
public virtual void KillTimers()
|
||||
{
|
||||
if (l_Timer?.Running == true)
|
||||
{
|
||||
l_Timer.Stop();
|
||||
}
|
||||
|
||||
if (m_Timer?.Running == true)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
}
|
||||
_resetTimerToken.Cancel();
|
||||
m_Timer?.Stop();
|
||||
}
|
||||
|
||||
public virtual void RemoveSuccessful()
|
||||
|
|
@ -357,7 +350,7 @@ namespace Server.Engines.Doom
|
|||
|
||||
if ((TheirKey = (ushort)(code | (TheirKey <<= 4))) < 0x0FFF)
|
||||
{
|
||||
l_Timer = Timer.DelayCall(TimeSpan.FromSeconds(30.0), ResetPuzzle);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30.0), ResetPuzzle, out _resetTimerToken);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Server.Engines.Doom
|
|||
m_Wanderer = new WandererOfTheVoid();
|
||||
m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);
|
||||
m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002); // I am the guardian of...
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), CallBackMessage);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), CallBackMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ namespace Server.Ethics
|
|||
|
||||
if (pl.Mobile != null)
|
||||
{
|
||||
Timer.DelayCall(pl.CheckAttach);
|
||||
Timer.StartTimer(pl.CheckAttach);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Server.Factions
|
|||
public static readonly TimeSpan CampaignPeriod = TimeSpan.FromDays(1.0);
|
||||
public static readonly TimeSpan VotingPeriod = TimeSpan.FromDays(3.0);
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
public Election(Faction faction)
|
||||
{
|
||||
|
|
@ -109,7 +109,7 @@ namespace Server.Factions
|
|||
|
||||
public void StartTimer()
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), Slice);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), Slice, out _timerToken);
|
||||
}
|
||||
|
||||
public void Serialize(IGenericWriter writer)
|
||||
|
|
@ -274,9 +274,7 @@ namespace Server.Factions
|
|||
{
|
||||
if (Faction.Election != this)
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
m_Timer = null;
|
||||
|
||||
_timerToken.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -621,9 +621,9 @@ namespace Server.Factions
|
|||
EventSink.Login += EventSink_Login;
|
||||
EventSink.Logout += EventSink_Logout;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(10.0), HandleAtrophy);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(10.0), HandleAtrophy);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), ProcessTick);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), ProcessTick);
|
||||
|
||||
CommandSystem.Register("FactionElection", AccessLevel.GameMaster, FactionElection_OnCommand);
|
||||
CommandSystem.Register("FactionCommander", AccessLevel.Administrator, FactionCommander_OnCommand);
|
||||
|
|
@ -1332,7 +1332,7 @@ namespace Server.Factions
|
|||
}
|
||||
}
|
||||
|
||||
context.m_Timer = Timer.DelayCall(SkillLossPeriod, ClearSkillLoss_Event, mob);
|
||||
Timer.StartTimer(SkillLossPeriod, () => ClearSkillLoss_Event(mob), out context._timerToken);
|
||||
}
|
||||
|
||||
private static void ClearSkillLoss_Event(Mobile mob) => ClearSkillLoss(mob);
|
||||
|
|
@ -1353,7 +1353,7 @@ namespace Server.Factions
|
|||
mob.RemoveSkillMod(mods[i]);
|
||||
}
|
||||
|
||||
context.m_Timer.Stop();
|
||||
context._timerToken.Cancel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1373,7 +1373,7 @@ namespace Server.Factions
|
|||
private class SkillLossContext
|
||||
{
|
||||
public List<SkillMod> m_Mods;
|
||||
public Timer m_Timer;
|
||||
public TimerExecutionToken _timerToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Server.Factions
|
|||
{
|
||||
var factionItem = new FactionItem(reader, m_Faction);
|
||||
|
||||
Timer.DelayCall(factionItem.CheckAttach); // sandbox attachment
|
||||
Timer.StartTimer(factionItem.CheckAttach); // sandbox attachment
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ namespace Server.Factions
|
|||
|
||||
if (pl != null)
|
||||
{
|
||||
Timer.DelayCall(ShowScore_Sandbox, pl);
|
||||
Timer.StartTimer(() => ShowScore_Sandbox(pl));
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Server.Factions
|
|||
public static readonly TimeSpan TaxChangePeriod = TimeSpan.FromHours(12.0);
|
||||
public static readonly TimeSpan IncomePeriod = TimeSpan.FromDays(1.0);
|
||||
|
||||
private Timer m_IncomeTimer;
|
||||
private Timer _incomeTimer;
|
||||
private TownState m_State;
|
||||
|
||||
public Town()
|
||||
|
|
@ -222,16 +222,12 @@ namespace Server.Factions
|
|||
|
||||
public void StartIncomeTimer()
|
||||
{
|
||||
m_IncomeTimer?.Stop();
|
||||
|
||||
m_IncomeTimer = Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), CheckIncome);
|
||||
_incomeTimer ??= Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), CheckIncome);
|
||||
}
|
||||
|
||||
public void StopIncomeTimer()
|
||||
public void Delete()
|
||||
{
|
||||
m_IncomeTimer?.Stop();
|
||||
|
||||
m_IncomeTimer = null;
|
||||
_incomeTimer?.Stop();
|
||||
}
|
||||
|
||||
public void CheckIncome()
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Server
|
|||
from.PlaySound(0x1EE);
|
||||
from.AddStatMod(new StatMod(StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes(time)));
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(time), from.EndAction<ClarityPotion>);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(time), from.EndAction<ClarityPotion>);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace Server
|
|||
"The object vanishes from your hands as you touch it."
|
||||
);
|
||||
|
||||
Timer.DelayCall(
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromSeconds(1.0),
|
||||
() => from.LocalOverheadMessage(
|
||||
MessageType.Regular,
|
||||
|
|
@ -119,7 +119,7 @@ namespace Server
|
|||
)
|
||||
);
|
||||
|
||||
Timer.DelayCall(
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromSeconds(4.0),
|
||||
() => { from.LocalOverheadMessage(MessageType.Regular, 2118, false, "Your skin begins to burn."); }
|
||||
);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Server
|
|||
Hue - 1
|
||||
);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.5), OnDelay, from, stormsEye, origin, facet);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.5), () => OnDelay(from, stormsEye, origin, facet));
|
||||
},
|
||||
this
|
||||
);
|
||||
|
|
@ -85,7 +85,7 @@ namespace Server
|
|||
2
|
||||
);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), OnHit, from, origin, facet);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => OnHit(from, origin, facet));
|
||||
}
|
||||
|
||||
private static void OnHit(Mobile from, Point3D origin, Map facet)
|
||||
|
|
@ -165,7 +165,7 @@ namespace Server
|
|||
100
|
||||
);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.50), mob.PlaySound, 0x1FB);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.50), () => mob.PlaySound(0x1FB));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Server.Factions
|
|||
|
||||
public abstract class BaseFactionTrap : BaseTrap
|
||||
{
|
||||
private Timer m_Concealing;
|
||||
private TimerExecutionToken _concealingTimerToken;
|
||||
|
||||
public BaseFactionTrap(Faction f, Mobile m, int itemID) : base(itemID)
|
||||
{
|
||||
|
|
@ -52,18 +52,7 @@ namespace Server.Factions
|
|||
|
||||
public virtual TimeSpan ConcealPeriod => TimeSpan.FromMinutes(1.0);
|
||||
|
||||
public virtual TimeSpan DecayPeriod
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Core.AOS)
|
||||
{
|
||||
return TimeSpan.FromDays(1.0);
|
||||
}
|
||||
|
||||
return TimeSpan.MaxValue; // no decay
|
||||
}
|
||||
}
|
||||
public virtual TimeSpan DecayPeriod => Core.AOS ? TimeSpan.FromDays(1.0) : TimeSpan.MaxValue;
|
||||
|
||||
public override void OnTrigger(Mobile from)
|
||||
{
|
||||
|
|
@ -206,7 +195,7 @@ namespace Server.Factions
|
|||
|
||||
if (TimeOfPlacement + decayPeriod < Core.Now)
|
||||
{
|
||||
Timer.DelayCall(Delete);
|
||||
Timer.StartTimer(Delete);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -215,16 +204,13 @@ namespace Server.Factions
|
|||
|
||||
public virtual void BeginConceal()
|
||||
{
|
||||
m_Concealing?.Stop();
|
||||
|
||||
m_Concealing = Timer.DelayCall(ConcealPeriod, Conceal);
|
||||
_concealingTimerToken.Cancel();
|
||||
Timer.StartTimer(ConcealPeriod, Conceal, out _concealingTimerToken);
|
||||
}
|
||||
|
||||
public virtual void Conceal()
|
||||
{
|
||||
m_Concealing?.Stop();
|
||||
|
||||
m_Concealing = null;
|
||||
_concealingTimerToken.Cancel();
|
||||
|
||||
if (!Deleted)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ namespace Server.Factions
|
|||
m_Town = Town.ReadReference(reader);
|
||||
Orders = new Orders(this, reader);
|
||||
|
||||
Timer.DelayCall(Register);
|
||||
Timer.StartTimer(Register);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ namespace Server.Engines.Harvest
|
|||
|
||||
if (GetHarvestDetails(from, tool, toHarvest, out _, out var map, out var loc))
|
||||
{
|
||||
Timer.DelayCall(
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromSeconds(1.5),
|
||||
() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,8 +153,7 @@ namespace Server.Items
|
|||
|
||||
var delay = m_CloseTime - Core.Now;
|
||||
|
||||
static void start(Timer timer) => timer.Start();
|
||||
DelayCall(delay, start, this);
|
||||
StartTimer(delay, () => Start());
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ namespace Server.Items
|
|||
|
||||
var version = reader.ReadEncodedInt();
|
||||
|
||||
Timer.DelayCall(Refresh);
|
||||
Timer.StartTimer(Refresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
{
|
||||
if (m_Pending.TryGetValue(ns, out var state))
|
||||
{
|
||||
state.m_Timeout.Stop();
|
||||
state._timeoutToken.Cancel();
|
||||
m_Pending.Remove(ns);
|
||||
}
|
||||
|
||||
|
|
@ -273,13 +273,13 @@ namespace Server.Engines.MLQuests.Gumps
|
|||
|
||||
public readonly IRaceChanger m_Owner;
|
||||
public readonly Race m_TargetRace;
|
||||
public readonly Timer m_Timeout;
|
||||
public TimerExecutionToken _timeoutToken;
|
||||
|
||||
public RaceChangeState(IRaceChanger owner, NetState ns, Race targetRace)
|
||||
{
|
||||
m_Owner = owner;
|
||||
m_TargetRace = targetRace;
|
||||
m_Timeout = Timer.DelayCall(m_TimeoutDelay, Timeout, ns);
|
||||
Timer.StartTimer(m_TimeoutDelay, () => Timeout(ns), out _timeoutToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Server.Engines.MLQuests
|
|||
private MLQuestInstanceFlags m_Flags;
|
||||
private IQuestGiver m_Quester;
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
public MLQuestInstance(MLQuest quest, IQuestGiver quester, PlayerMobile player)
|
||||
{
|
||||
|
|
@ -52,7 +52,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
if (timed)
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), Slice);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), Slice, out _timerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -476,13 +476,7 @@ namespace Server.Engines.MLQuests
|
|||
|
||||
private void StopTimer()
|
||||
{
|
||||
if (m_Timer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
public void OnQuesterDeleted()
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
if (from.CanBeginAction(this))
|
||||
{
|
||||
from.BeginAction(this);
|
||||
Timer.DelayCall(m_ShoutCooldown, EndLock, from);
|
||||
Timer.StartTimer(m_ShoutCooldown, () => EndLock(from));
|
||||
}
|
||||
|
||||
MLQuestSystem.TurnToFace(this, from);
|
||||
|
|
|
|||
|
|
@ -98,14 +98,14 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
private readonly BaseCreature m_Escort;
|
||||
private readonly EscortObjective m_Objective;
|
||||
private DateTime m_LastSeenEscorter;
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
public EscortObjectiveInstance(EscortObjective objective, MLQuestInstance instance)
|
||||
: base(instance, objective)
|
||||
{
|
||||
m_Objective = objective;
|
||||
HasCompleted = false;
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), CheckDestination);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), CheckDestination, out _timerToken);
|
||||
m_LastSeenEscorter = Core.Now;
|
||||
m_Escort = instance.Quester as BaseCreature;
|
||||
|
||||
|
|
@ -183,11 +183,7 @@ namespace Server.Engines.MLQuests.Objectives
|
|||
|
||||
private void StopTimer()
|
||||
{
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
public static void BeginFollow(BaseCreature quester, PlayerMobile pm)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Server.Engines.Quests
|
|||
{
|
||||
private int m_Charges;
|
||||
|
||||
private Timer m_PlayTimer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public HornOfRetreat() : base(0xFC4)
|
||||
|
|
@ -62,7 +62,7 @@ namespace Server.Engines.Quests
|
|||
{
|
||||
from.SendLocalizedMessage(1076154); // You can only use this in Trammel and Malas.
|
||||
}
|
||||
else if (m_PlayTimer != null)
|
||||
else if (_timerToken.Running)
|
||||
{
|
||||
SendLocalizedMessageTo(from, 1042144); // This is currently in use.
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ namespace Server.Engines.Quests
|
|||
|
||||
--Charges;
|
||||
|
||||
m_PlayTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), PlayTimer_Callback, from);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), () => PlayTimer_Callback(from), out _timerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -89,7 +89,7 @@ namespace Server.Engines.Quests
|
|||
|
||||
public virtual void PlayTimer_Callback(Mobile from)
|
||||
{
|
||||
m_PlayTimer = null;
|
||||
_timerToken.Cancel();
|
||||
|
||||
var gate = new HornOfRetreatMoongate(DestLoc, DestMap, from, Hue);
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ namespace Server.Engines.Quests
|
|||
|
||||
Dispellable = false;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10.0), Delete);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), Delete);
|
||||
}
|
||||
|
||||
public HornOfRetreatMoongate(Serial serial) : base(serial)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Server.Engines.Quests
|
|||
typeof(TerribleHatchlingsQuest)
|
||||
};
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
public QuestSystem(PlayerMobile from)
|
||||
{
|
||||
|
|
@ -69,19 +69,18 @@ namespace Server.Engines.Quests
|
|||
|
||||
public virtual void StartTimer()
|
||||
{
|
||||
if (m_Timer != null)
|
||||
if (_timerToken.Running)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), Slice);
|
||||
// TODO: Find out if this can go on forever. We should not allow timers to leak if this is the case.
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), Slice, out _timerToken);
|
||||
}
|
||||
|
||||
public virtual void StopTimer()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
public virtual void Slice()
|
||||
|
|
@ -344,36 +343,38 @@ namespace Server.Engines.Quests
|
|||
{
|
||||
StopTimer();
|
||||
|
||||
if (From.Quest == this)
|
||||
if (From.Quest != this)
|
||||
{
|
||||
From.Quest = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var restartDelay = RestartDelay;
|
||||
From.Quest = null;
|
||||
|
||||
if (completed && restartDelay > TimeSpan.Zero || !completed && restartDelay == TimeSpan.MaxValue)
|
||||
var restartDelay = RestartDelay;
|
||||
|
||||
if (completed && restartDelay > TimeSpan.Zero || !completed && restartDelay == TimeSpan.MaxValue)
|
||||
{
|
||||
From.DoneQuests ??= new List<QuestRestartInfo>();
|
||||
|
||||
var found = false;
|
||||
|
||||
var ourQuestType = GetType();
|
||||
|
||||
for (var i = 0; i < From.DoneQuests.Count; ++i)
|
||||
{
|
||||
From.DoneQuests ??= new List<QuestRestartInfo>();
|
||||
var restartInfo = From.DoneQuests[i];
|
||||
|
||||
var found = false;
|
||||
|
||||
var ourQuestType = GetType();
|
||||
|
||||
for (var i = 0; i < From.DoneQuests.Count; ++i)
|
||||
if (restartInfo.QuestType == ourQuestType)
|
||||
{
|
||||
var restartInfo = From.DoneQuests[i];
|
||||
|
||||
if (restartInfo.QuestType == ourQuestType)
|
||||
{
|
||||
restartInfo.Reset(restartDelay);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
restartInfo.Reset(restartDelay);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
From.DoneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay));
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
From.DoneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Server.Engines.Quests.Necro
|
|||
Maabus = new Maabus { Location = SpawnLocation, Map = Map };
|
||||
Maabus.Direction = Maabus.GetDirectionTo(caller);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(7.5), BeginSleep);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(7.5), BeginSleep);
|
||||
}
|
||||
|
||||
public void BeginSleep()
|
||||
|
|
@ -56,7 +56,7 @@ namespace Server.Engines.Quests.Necro
|
|||
|
||||
Effects.PlaySound(Maabus.Location, Maabus.Map, 0x48E);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2.5), Sleep);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(2.5), Sleep);
|
||||
}
|
||||
|
||||
public void Sleep()
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Server.Engines.Quests.Necro
|
|||
|
||||
m_ToDelete = true;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), Delete);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), Delete);
|
||||
}
|
||||
else if (m_Necromancer.Map != Map || GetDistanceToSqrt(m_Necromancer) > RangePerception + 1)
|
||||
{
|
||||
|
|
@ -239,7 +239,7 @@ namespace Server.Engines.Quests.Necro
|
|||
Hue = 0x482;
|
||||
Light = LightType.Circle300;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10.0), Delete);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), Delete);
|
||||
}
|
||||
|
||||
public SummonedPaladinMoongate(Serial serial) : base(serial)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace Server.Engines.Quests.Samurai
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(2.0), GenerateTreasure);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(2.0), GenerateTreasure);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
|
|
@ -98,7 +98,7 @@ namespace Server.Engines.Quests.Samurai
|
|||
|
||||
var version = reader.ReadEncodedInt();
|
||||
|
||||
Timer.DelayCall(GenerateTreasure);
|
||||
Timer.StartTimer(GenerateTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,16 +39,14 @@ namespace Server.Engines.Quests.Naturalist
|
|||
|
||||
if (m_CurrentNest.Special)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1054057
|
||||
); // You complete your examination of this bizarre Egg Nest. The Naturalist will undoubtedly be quite interested in these notes!
|
||||
// You complete your examination of this bizarre Egg Nest. The Naturalist will undoubtedly be quite interested in these notes!
|
||||
from.SendLocalizedMessage(1054057);
|
||||
StudiedSpecialNest = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1054054
|
||||
); // You have completed your study of this Solen Egg Nest. You put your notes away.
|
||||
// You have completed your study of this Solen Egg Nest. You put your notes away.
|
||||
from.SendLocalizedMessage(1054054);
|
||||
CurProgress++;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,9 +54,8 @@ namespace Server.Engines.Quests.Naturalist
|
|||
{
|
||||
if (!nest.Special)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1054058
|
||||
); // You begin recording your completed notes on a bit of parchment.
|
||||
// You begin recording your completed notes on a bit of parchment.
|
||||
from.SendLocalizedMessage(1054058);
|
||||
}
|
||||
|
||||
m_StudyState = StudyState.SecondStep;
|
||||
|
|
@ -69,9 +66,8 @@ namespace Server.Engines.Quests.Naturalist
|
|||
{
|
||||
if (m_StudyState != StudyState.Inactive)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1054046
|
||||
); // You abandon your study of the Solen Egg Nest without gathering the needed information.
|
||||
// You abandon your study of the Solen Egg Nest without gathering the needed information.
|
||||
from.SendLocalizedMessage(1054046);
|
||||
}
|
||||
|
||||
m_CurrentNest = null;
|
||||
|
|
@ -90,9 +86,8 @@ namespace Server.Engines.Quests.Naturalist
|
|||
{
|
||||
m_StudyState = StudyState.Inactive;
|
||||
|
||||
from.SendLocalizedMessage(
|
||||
1054047
|
||||
); // You glance at the Egg Nest, realizing you've already studied this one.
|
||||
// You glance at the Egg Nest, realizing you've already studied this one.
|
||||
from.SendLocalizedMessage(1054047);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -100,15 +95,13 @@ namespace Server.Engines.Quests.Naturalist
|
|||
|
||||
if (nest.Special)
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1054056
|
||||
); // You notice something very odd about this Solen Egg Nest. You begin taking notes.
|
||||
// You notice something very odd about this Solen Egg Nest. You begin taking notes.
|
||||
from.SendLocalizedMessage(105405);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(
|
||||
1054045
|
||||
); // You begin studying the Solen Egg Nest to gather information.
|
||||
// You begin studying the Solen Egg Nest to gather information.
|
||||
from.SendLocalizedMessage(1054045);
|
||||
}
|
||||
|
||||
if (from.Female)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Server.Engines.Quests.Doom
|
|||
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x100);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(8.0), EndSummon, from);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(8.0), () => EndSummon(from));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace Server.Engines.Quests.Doom
|
|||
return;
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(4.0), EndGiveWarning);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(4.0), EndGiveWarning);
|
||||
}
|
||||
|
||||
public virtual void EndGiveWarning()
|
||||
|
|
@ -84,12 +84,12 @@ namespace Server.Engines.Quests.Doom
|
|||
return;
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(30.0), EndSummonDragon);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30.0), EndSummonDragon);
|
||||
}
|
||||
|
||||
public virtual void BeginRemove(TimeSpan delay)
|
||||
{
|
||||
Timer.DelayCall(delay, EndRemove);
|
||||
Timer.StartTimer(delay, EndRemove);
|
||||
}
|
||||
|
||||
public virtual void EndRemove()
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ namespace Server.Engines.Quests.Hag
|
|||
{
|
||||
PublicOverheadMessage(MessageType.Regular, 0x3B2, 500849); // *hic*
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(60, 180)), Heave);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(Utility.RandomMinMax(60, 180)), Heave);
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Server.Engines.Quests.Hag
|
|||
// * You see a strange imp stealing a scrap of paper from the bloodied corpse *
|
||||
Corpse.SendLocalizedMessageTo(player, 1055049);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(3.0), DeleteImp, imp);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(3.0), () => DeleteImp(imp));
|
||||
}
|
||||
|
||||
private void DeleteImp(Mobile m)
|
||||
|
|
@ -221,7 +221,7 @@ namespace Server.Engines.Quests.Hag
|
|||
|
||||
imp.Direction = imp.GetDirectionTo(from);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(3.0), DeleteImp, imp);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(3.0), () => DeleteImp(imp));
|
||||
}
|
||||
|
||||
private void DeleteImp(object imp)
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ namespace Server.Mobiles
|
|||
|
||||
if (m_SculptedBy == null || Map == Map.Internal) // Remove preview statues
|
||||
{
|
||||
Timer.DelayCall(Delete);
|
||||
Timer.StartTimer(Delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace Server.Items
|
|||
|
||||
if (m_Statue?.SculptedBy == null || Map == Map.Internal)
|
||||
{
|
||||
Timer.DelayCall(Delete);
|
||||
Timer.StartTimer(Delete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace Server
|
|||
pm.HonorActive = true;
|
||||
pm.SendLocalizedMessage(1063235); // You embrace your honor
|
||||
|
||||
Timer.DelayCall(
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromSeconds(duration),
|
||||
() =>
|
||||
{
|
||||
|
|
@ -227,7 +227,7 @@ namespace Server
|
|||
m_Timer.Start();
|
||||
source.m_hontime = Core.Now + TimeSpan.FromMinutes(40);
|
||||
|
||||
Timer.DelayCall(
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromMinutes(40),
|
||||
() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ namespace Server
|
|||
|
||||
if (protector.BeginAction<JusticeVirtue>())
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(15.0), protector.EndAction<JusticeVirtue>);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(15.0), protector.EndAction<JusticeVirtue>);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ namespace Server
|
|||
|
||||
from.SendLocalizedMessage(1052010); // You have set the creature free.
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), targ.Delete);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), targ.Delete);
|
||||
|
||||
pm.LastSacrificeGain = Core.Now;
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ namespace Server.Gumps
|
|||
if (Core.SE)
|
||||
{
|
||||
from.RecentlyReported.Add(killer);
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(10), ReportedListExpiry_Callback, from, killer);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer));
|
||||
}
|
||||
|
||||
if (killer is PlayerMobile pk)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Events.Halloween;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
|
|
@ -64,7 +65,7 @@ namespace Server.Engines.Events
|
|||
{
|
||||
target.SolidHueOverride = Utility.RandomMinMax(2501, 2644);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(10), RemoveHueMod, target);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10), () => RemoveHueMod(target));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +114,7 @@ namespace Server.Engines.Events
|
|||
|
||||
twin.MoveToWorld(m_From.Map.CanSpawnMobile(point) ? point : m_From.Location, m_From.Map);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5), DeleteTwin, twin);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5), () => DeleteTwin(twin));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +135,7 @@ namespace Server.Engines.Events
|
|||
return loc;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool CheckMobile(Mobile mobile) =>
|
||||
mobile?.Map != null && !mobile.Deleted && mobile.Alive && mobile.Map != Map.Internal;
|
||||
|
||||
|
|
@ -214,15 +216,15 @@ namespace Server.Engines.Events
|
|||
|
||||
if (action == 0)
|
||||
{
|
||||
Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from);
|
||||
Timer.StartTimer(OneSecond, OneSecond, 10, () => Bleeding(from));
|
||||
}
|
||||
else if (action == 1)
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(2), () => SolidHueMobile(from));
|
||||
}
|
||||
else
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(2), () => MakeTwin(from));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -283,7 +285,7 @@ namespace Server.Engines.Events
|
|||
m_From = from;
|
||||
Name = $"{from.Name}\'s Naughty Twin";
|
||||
|
||||
Timer.DelayCall(TrickOrTreat.OneSecond, StealCandyOrGate, m_From);
|
||||
Timer.StartTimer(TrickOrTreat.OneSecond, () => StealCandyOrGate(m_From));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Server.Engines.Events
|
|||
{
|
||||
public static class PumpkinPatchSpawner
|
||||
{
|
||||
private static Timer m_Timer;
|
||||
private static Timer _timer;
|
||||
|
||||
private static readonly Rectangle2D[] m_PumpkinFields =
|
||||
{
|
||||
|
|
@ -25,9 +25,10 @@ namespace Server.Engines.Events
|
|||
{
|
||||
var now = Core.Now;
|
||||
|
||||
// TODO: World timer to turn these on/off
|
||||
if (now >= HolidaySettings.StartHalloween && now <= HolidaySettings.FinishHalloween)
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(30), 0, PumpkinPatchSpawnerCallback);
|
||||
_timer = Timer.DelayCall(TimeSpan.FromSeconds(30), 0, PumpkinPatchSpawnerCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +36,12 @@ namespace Server.Engines.Events
|
|||
{
|
||||
AddPumpkin(Map.Felucca);
|
||||
AddPumpkin(Map.Trammel);
|
||||
|
||||
if (Core.Now > HolidaySettings.FinishHalloween)
|
||||
{
|
||||
_timer.Stop();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddPumpkin(Map map)
|
||||
|
|
|
|||
|
|
@ -92,16 +92,12 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public override Item NewHarmfulItem()
|
||||
{
|
||||
Item bad = new AcidSlime(TimeSpan.FromSeconds(10), 25, 30);
|
||||
|
||||
bad.Name = "gooey nasty pumpkin hummus";
|
||||
|
||||
bad.Hue = 144;
|
||||
|
||||
return bad;
|
||||
}
|
||||
public override Item NewHarmfulItem() =>
|
||||
new PoolOfAcid(TimeSpan.FromSeconds(10), 25, 30)
|
||||
{
|
||||
Name = "gooey nasty pumpkin hummus",
|
||||
Hue = 144
|
||||
};
|
||||
|
||||
public override void OnDamage(int amount, Mobile from, bool willKill)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ namespace Server.Engines.Events
|
|||
{
|
||||
public static class HalloweenHauntings
|
||||
{
|
||||
private static Timer m_Timer;
|
||||
private static Timer m_ClearTimer;
|
||||
private static Timer _timer;
|
||||
private static Timer _clearTimer;
|
||||
|
||||
private static int m_TotalZombieLimit;
|
||||
private static int m_DeathQueueLimit;
|
||||
private static int m_QueueDelaySeconds;
|
||||
private static int m_QueueClearIntervalSeconds;
|
||||
|
||||
private static List<PlayerMobile> m_DeathQueue;
|
||||
private static HashSet<PlayerMobile> _deathQueue;
|
||||
|
||||
private static readonly Rectangle2D[] m_Cemetaries =
|
||||
{
|
||||
|
|
@ -39,7 +39,7 @@ namespace Server.Engines.Events
|
|||
new(5224, 3655, 5, 14) // T2A
|
||||
};
|
||||
|
||||
public static Dictionary<PlayerMobile, ZombieSkeleton> ReAnimated { get; set; }
|
||||
internal static Dictionary<PlayerMobile, ZombieSkeleton> _reAnimated;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
|
@ -52,14 +52,13 @@ namespace Server.Engines.Events
|
|||
var tick = TimeSpan.FromSeconds(m_QueueDelaySeconds);
|
||||
var clear = TimeSpan.FromSeconds(m_QueueClearIntervalSeconds);
|
||||
|
||||
ReAnimated = new Dictionary<PlayerMobile, ZombieSkeleton>();
|
||||
m_DeathQueue = new List<PlayerMobile>();
|
||||
_reAnimated = new Dictionary<PlayerMobile, ZombieSkeleton>();
|
||||
_deathQueue = new HashSet<PlayerMobile>();
|
||||
|
||||
if (today >= HolidaySettings.StartHalloween && today <= HolidaySettings.FinishHalloween)
|
||||
{
|
||||
m_Timer = Timer.DelayCall(tick, tick, Timer_Callback);
|
||||
|
||||
m_ClearTimer = Timer.DelayCall(clear, clear, Clear_Callback);
|
||||
_timer = Timer.DelayCall(tick, 0, Timer_Callback);
|
||||
_clearTimer = Timer.DelayCall(clear, 0, Clear_Callback);
|
||||
|
||||
EventSink.PlayerDeath += EventSink_PlayerDeath;
|
||||
}
|
||||
|
|
@ -67,65 +66,69 @@ namespace Server.Engines.Events
|
|||
|
||||
public static void EventSink_PlayerDeath(Mobile m)
|
||||
{
|
||||
if (m is PlayerMobile pm && !pm.Deleted && m_Timer.Running && !m_DeathQueue.Contains(pm) &&
|
||||
m_DeathQueue.Count < m_DeathQueueLimit)
|
||||
if (m is PlayerMobile { Deleted: false } pm &&
|
||||
_timer.Running && !_deathQueue.Contains(pm) && _deathQueue.Count < m_DeathQueueLimit)
|
||||
{
|
||||
m_DeathQueue.Add(pm);
|
||||
_deathQueue.Add(pm);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Clear_Callback()
|
||||
{
|
||||
ReAnimated.Clear();
|
||||
|
||||
m_DeathQueue.Clear();
|
||||
|
||||
if (Core.Now <= HolidaySettings.FinishHalloween)
|
||||
if (Core.Now > HolidaySettings.FinishHalloween)
|
||||
{
|
||||
m_ClearTimer.Stop();
|
||||
_clearTimer.Stop();
|
||||
_clearTimer = null;
|
||||
_reAnimated = null;
|
||||
_deathQueue = null;
|
||||
return;
|
||||
}
|
||||
|
||||
_reAnimated.Clear();
|
||||
_deathQueue.Clear();
|
||||
}
|
||||
|
||||
private static void Timer_Callback()
|
||||
{
|
||||
|
||||
if (Core.Now > HolidaySettings.FinishHalloween)
|
||||
{
|
||||
_timer.Stop();
|
||||
_timer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerMobile player = null;
|
||||
|
||||
if (Core.Now <= HolidaySettings.FinishHalloween)
|
||||
foreach (var entry in _deathQueue)
|
||||
{
|
||||
for (var index = 0; m_DeathQueue.Count > 0 && index < m_DeathQueue.Count; index++)
|
||||
if (!_reAnimated.ContainsKey(entry))
|
||||
{
|
||||
var entry = m_DeathQueue[index];
|
||||
|
||||
if (!ReAnimated.ContainsKey(entry))
|
||||
{
|
||||
player = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (player?.Deleted == false && ReAnimated.Count < m_TotalZombieLimit)
|
||||
{
|
||||
var map = Utility.RandomBool() ? Map.Trammel : Map.Felucca;
|
||||
|
||||
var home = GetRandomPointInRect(m_Cemetaries.RandomElement(), map);
|
||||
|
||||
if (map.CanSpawnMobile(home))
|
||||
{
|
||||
var zombieskel = new ZombieSkeleton(player);
|
||||
|
||||
ReAnimated.Add(player, zombieskel);
|
||||
zombieskel.Home = home;
|
||||
zombieskel.RangeHome = 10;
|
||||
|
||||
zombieskel.MoveToWorld(home, map);
|
||||
|
||||
m_DeathQueue.Remove(player);
|
||||
}
|
||||
player = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (player?.Deleted != false || _reAnimated.Count >= m_TotalZombieLimit)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
var map = Utility.RandomBool() ? Map.Trammel : Map.Felucca;
|
||||
|
||||
var home = GetRandomPointInRect(m_Cemetaries.RandomElement(), map);
|
||||
|
||||
if (map.CanSpawnMobile(home))
|
||||
{
|
||||
var zombieskel = new ZombieSkeleton(player);
|
||||
|
||||
_reAnimated.Add(player, zombieskel);
|
||||
zombieskel.Home = home;
|
||||
zombieskel.RangeHome = 10;
|
||||
|
||||
zombieskel.MoveToWorld(home, map);
|
||||
|
||||
_deathQueue.Remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +251,7 @@ namespace Server.Engines.Events
|
|||
{
|
||||
if (_deadPlayer?.Deleted == false)
|
||||
{
|
||||
HalloweenHauntings.ReAnimated?.Remove(_deadPlayer);
|
||||
HalloweenHauntings._reAnimated?.Remove(_deadPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ namespace Server.Items
|
|||
};
|
||||
|
||||
private int m_Flour;
|
||||
private Timer m_Timer;
|
||||
|
||||
[Constructible]
|
||||
public FlourMillEastAddon()
|
||||
|
|
@ -49,7 +48,7 @@ namespace Server.Items
|
|||
public bool IsFull => m_Flour >= MaxFlour;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool IsWorking => m_Timer != null;
|
||||
public bool IsWorking { get; private set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int MaxFlour => 2;
|
||||
|
|
@ -72,17 +71,14 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), FinishWorking_Callback, from);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), () => FinishWorking_Callback(from));
|
||||
IsWorking = true;
|
||||
UpdateStage();
|
||||
}
|
||||
|
||||
private void FinishWorking_Callback(Mobile from)
|
||||
{
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
IsWorking = false;
|
||||
|
||||
if (from?.Deleted == false && !Deleted && IsFull)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ namespace Server.Items
|
|||
};
|
||||
|
||||
private int m_Flour;
|
||||
private Timer m_Timer;
|
||||
|
||||
[Constructible]
|
||||
public FlourMillSouthAddon()
|
||||
|
|
@ -36,7 +35,7 @@ namespace Server.Items
|
|||
public bool IsFull => m_Flour >= MaxFlour;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool IsWorking => m_Timer != null;
|
||||
public bool IsWorking { get; private set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int MaxFlour => 2;
|
||||
|
|
@ -59,17 +58,14 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), FinishWorking_Callback, from);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), () => FinishWorking_Callback(from));
|
||||
IsWorking = true;
|
||||
UpdateStage();
|
||||
}
|
||||
|
||||
private void FinishWorking_Callback(Mobile from)
|
||||
{
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
IsWorking = false;
|
||||
|
||||
if (from?.Deleted == false && !Deleted && IsFull)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Server.Items
|
|||
|
||||
if (version <= 1)
|
||||
{
|
||||
Timer.DelayCall(Fix, version);
|
||||
Timer.StartTimer(() => Fix(version));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Server.Items
|
|||
SendLocalizedMessageTo(from, 500803); // You feel as though you've slept for days!
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromHours(2.0), ReleaseUseLock_Callback, from, random);
|
||||
Timer.StartTimer(TimeSpan.FromHours(2.0), () => ReleaseUseLock_Callback(from, random));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Server.Items
|
|||
private bool m_RewardAvailable;
|
||||
|
||||
// evaluate timer
|
||||
private Timer m_Timer;
|
||||
private Timer _timer;
|
||||
|
||||
// vacation info
|
||||
private int m_VacationLeft;
|
||||
|
|
@ -68,7 +68,7 @@ namespace Server.Items
|
|||
|
||||
Events = new List<int>();
|
||||
|
||||
m_Timer = Timer.DelayCall(EvaluationInterval, EvaluationInterval, Evaluate);
|
||||
_timer = Timer.DelayCall(EvaluationInterval, EvaluationInterval, Evaluate);
|
||||
}
|
||||
|
||||
public Aquarium(Serial serial) : base(serial)
|
||||
|
|
@ -76,7 +76,6 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
// items info
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int LiveCreatures { get; private set; }
|
||||
|
||||
|
|
@ -193,11 +192,8 @@ namespace Server.Items
|
|||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if (m_Timer != null)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
m_Timer = null;
|
||||
}
|
||||
_timer.Stop();
|
||||
_timer = null;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
|
|
@ -529,14 +525,7 @@ namespace Server.Items
|
|||
writer.Write(3); // Version
|
||||
|
||||
// version 1
|
||||
if (m_Timer != null)
|
||||
{
|
||||
writer.Write(m_Timer.Next);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(Core.Now + EvaluationInterval);
|
||||
}
|
||||
writer.Write(_timer?.Running == true ? _timer.Next : Core.Now + EvaluationInterval);
|
||||
|
||||
// version 0
|
||||
writer.Write(LiveCreatures);
|
||||
|
|
@ -574,7 +563,7 @@ namespace Server.Items
|
|||
next = Core.Now;
|
||||
}
|
||||
|
||||
m_Timer = Timer.DelayCall(next - Core.Now, EvaluationInterval, Evaluate);
|
||||
_timer = Timer.DelayCall(next - Core.Now, EvaluationInterval, Evaluate);
|
||||
|
||||
goto case 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Server.Items
|
|||
{
|
||||
private static readonly TimeSpan DeathDelay = TimeSpan.FromMinutes(5);
|
||||
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public BaseFish(int itemID) : base(itemID)
|
||||
|
|
@ -23,19 +23,15 @@ namespace Server.Items
|
|||
|
||||
public virtual void StartTimer()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
m_Timer = Timer.DelayCall(DeathDelay, Kill);
|
||||
_timerToken.Cancel();
|
||||
Timer.StartTimer(DeathDelay, Kill, out _timerToken);
|
||||
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
public virtual void StopTimer()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
|
||||
_timerToken.Cancel();
|
||||
InvalidateProperties();
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +70,7 @@ namespace Server.Items
|
|||
|
||||
list.Add(GetDescription());
|
||||
|
||||
if (!Dead && m_Timer != null)
|
||||
if (!Dead && _timerToken.Running)
|
||||
{
|
||||
list.Add(1074507); // Gasping for air
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,9 @@ namespace Server.Items
|
|||
protected FillableContent m_Content;
|
||||
|
||||
protected DateTime m_NextRespawnTime;
|
||||
protected Timer m_RespawnTimer;
|
||||
protected TimerExecutionToken _respawnTimerToken;
|
||||
|
||||
public FillableContainer(int itemID)
|
||||
: base(itemID) =>
|
||||
Movable = false;
|
||||
public FillableContainer(int itemID) : base(itemID) => Movable = false;
|
||||
|
||||
public FillableContainer(Serial serial)
|
||||
: base(serial)
|
||||
|
|
@ -98,11 +96,7 @@ namespace Server.Items
|
|||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
if (m_RespawnTimer != null)
|
||||
{
|
||||
m_RespawnTimer.Stop();
|
||||
m_RespawnTimer = null;
|
||||
}
|
||||
_respawnTimerToken.Cancel();
|
||||
}
|
||||
|
||||
public int GetItemsCount()
|
||||
|
|
@ -124,29 +118,24 @@ namespace Server.Items
|
|||
|
||||
if (canSpawn)
|
||||
{
|
||||
if (m_RespawnTimer == null)
|
||||
if (!_respawnTimerToken.Running)
|
||||
{
|
||||
var mins = Utility.RandomMinMax(MinRespawnMinutes, MaxRespawnMinutes);
|
||||
var delay = TimeSpan.FromMinutes(mins);
|
||||
|
||||
m_NextRespawnTime = Core.Now + delay;
|
||||
m_RespawnTimer = Timer.DelayCall(delay, Respawn);
|
||||
Timer.StartTimer(delay, Respawn, out _respawnTimerToken);
|
||||
}
|
||||
}
|
||||
else if (m_RespawnTimer != null)
|
||||
else if (_respawnTimerToken.Running)
|
||||
{
|
||||
m_RespawnTimer.Stop();
|
||||
m_RespawnTimer = null;
|
||||
_respawnTimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public void Respawn()
|
||||
{
|
||||
if (m_RespawnTimer != null)
|
||||
{
|
||||
m_RespawnTimer.Stop();
|
||||
m_RespawnTimer = null;
|
||||
}
|
||||
_respawnTimerToken.Cancel();
|
||||
|
||||
if (m_Content == null || Deleted)
|
||||
{
|
||||
|
|
@ -249,7 +238,7 @@ namespace Server.Items
|
|||
|
||||
writer.Write((int)ContentType);
|
||||
|
||||
if (m_RespawnTimer != null)
|
||||
if (_respawnTimerToken.Running)
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.WriteDeltaTime(m_NextRespawnTime);
|
||||
|
|
@ -280,7 +269,7 @@ namespace Server.Items
|
|||
m_NextRespawnTime = reader.ReadDeltaTime();
|
||||
|
||||
var delay = m_NextRespawnTime - Core.Now;
|
||||
m_RespawnTimer = Timer.DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, Respawn);
|
||||
Timer.StartTimer(delay, Respawn, out _respawnTimerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -341,7 +330,7 @@ namespace Server.Items
|
|||
|
||||
if (version == 0 && m_Content == null)
|
||||
{
|
||||
Timer.DelayCall(AcquireContent);
|
||||
Timer.StartTimer(AcquireContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), Validate);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), Validate);
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Server.Items
|
|||
private static Type[] m_TypesOfEntries;
|
||||
private StealableInstance[] m_Artifacts;
|
||||
|
||||
private Timer m_RespawnTimer;
|
||||
private Timer _respawnTimer;
|
||||
private Dictionary<Item, StealableInstance> m_Table;
|
||||
|
||||
private StealableArtifactsSpawner() : base(1)
|
||||
|
|
@ -24,7 +24,7 @@ namespace Server.Items
|
|||
m_Artifacts[i] = new StealableInstance(Entries[i]);
|
||||
}
|
||||
|
||||
m_RespawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn);
|
||||
_respawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn);
|
||||
}
|
||||
|
||||
public StealableArtifactsSpawner(Serial serial) : base(serial) => Instance = this;
|
||||
|
|
@ -244,11 +244,8 @@ namespace Server.Items
|
|||
{
|
||||
base.OnDelete();
|
||||
|
||||
if (m_RespawnTimer != null)
|
||||
{
|
||||
m_RespawnTimer.Stop();
|
||||
m_RespawnTimer = null;
|
||||
}
|
||||
_respawnTimer.Stop();
|
||||
_respawnTimer = null;
|
||||
|
||||
foreach (var si in m_Artifacts)
|
||||
{
|
||||
|
|
@ -316,7 +313,7 @@ namespace Server.Items
|
|||
m_Artifacts[i] = new StealableInstance(Entries[i]);
|
||||
}
|
||||
|
||||
m_RespawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn);
|
||||
_respawnTimer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromMinutes(15.0), CheckRespawn);
|
||||
}
|
||||
|
||||
public class StealableEntry
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Server.Items
|
|||
|
||||
Unlink();
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(5.0), Delete);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(5.0), Delete);
|
||||
}
|
||||
|
||||
public void Unlink()
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ namespace Server.Items
|
|||
|
||||
if (Guild.NewGuildSystem && m_BeforeChangeover)
|
||||
{
|
||||
Timer.DelayCall(AddToHouse);
|
||||
Timer.StartTimer(AddToHouse);
|
||||
}
|
||||
|
||||
if (!Guild.NewGuildSystem && Guild == null)
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ namespace Server.Items
|
|||
{
|
||||
Movable = false;
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromMinutes(2.0), Delete);
|
||||
Timer.StartTimer(TimeSpan.FromMinutes(2.0), Delete);
|
||||
}
|
||||
|
||||
public TreasureChestDirt(Serial serial) : base(serial)
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class AcidSlime : Item
|
||||
{
|
||||
private readonly DateTime m_Created;
|
||||
private readonly TimeSpan m_Duration;
|
||||
private readonly int m_MaxDamage;
|
||||
private readonly int m_MinDamage;
|
||||
private readonly Timer m_Timer;
|
||||
private bool m_Drying;
|
||||
|
||||
[Constructible]
|
||||
public AcidSlime() : this(TimeSpan.FromSeconds(10.0), 5, 10)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public AcidSlime(TimeSpan duration, int minDamage, int maxDamage)
|
||||
: base(0x122A)
|
||||
{
|
||||
Hue = 0x3F;
|
||||
Movable = false;
|
||||
m_MinDamage = minDamage;
|
||||
m_MaxDamage = maxDamage;
|
||||
m_Created = Core.Now;
|
||||
m_Duration = duration;
|
||||
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick);
|
||||
}
|
||||
|
||||
public AcidSlime(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override string DefaultName => "slime";
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
var now = Core.Now;
|
||||
var age = now - m_Created;
|
||||
|
||||
if (age > m_Duration)
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_Drying && age > m_Duration - age)
|
||||
{
|
||||
m_Drying = true;
|
||||
ItemID = 0x122B;
|
||||
}
|
||||
|
||||
var toDamage = new List<Mobile>();
|
||||
|
||||
foreach (var m in GetMobilesInRange(0))
|
||||
{
|
||||
if (m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned))
|
||||
{
|
||||
toDamage.Add(m);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < toDamage.Count; i++)
|
||||
{
|
||||
Damage(toDamage[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnMoveOver(Mobile m)
|
||||
{
|
||||
Damage(m);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Damage(Mobile m)
|
||||
{
|
||||
var damage = Utility.RandomMinMax(m_MinDamage, m_MaxDamage);
|
||||
if (Core.AOS)
|
||||
{
|
||||
AOS.Damage(m, damage, 0, 0, 0, 100, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.Damage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ namespace Server.Items
|
|||
|
||||
to.Damage(1);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2.0), from.EndAction<Bola>);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(2.0), from.EndAction<Bola>);
|
||||
}
|
||||
|
||||
private static bool HasFreeHands(Mobile from)
|
||||
|
|
@ -213,7 +213,7 @@ namespace Server.Items
|
|||
from.Animate(11, 5, 1, true, false, 0);
|
||||
from.MovingEffect(to, 0x26AC, 10, 0, false, false);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.5), FinishThrow, from, to);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.5), () => FinishThrow(from, to));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Server.Items
|
|||
{
|
||||
public class DeceitBrazier : Item
|
||||
{
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
[Constructible]
|
||||
public DeceitBrazier() : base(0xE31)
|
||||
|
|
@ -95,22 +95,21 @@ namespace Server.Items
|
|||
PublicOverheadMessage(
|
||||
MessageType.Regular,
|
||||
0x3B2,
|
||||
500761
|
||||
); // Heed this warning well, and use this brazier at your own peril.
|
||||
500761 // Heed this warning well, and use this brazier at your own peril.
|
||||
);
|
||||
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
public override void OnMovement(Mobile m, Point3D oldLocation)
|
||||
{
|
||||
if (NextSpawn < Core.Now) // means we haven't spawned anything if the next spawn is below
|
||||
// means we haven't spawned anything if the next spawn is below
|
||||
if (NextSpawn < Core.Now &&
|
||||
Utility.InRange(m.Location, Location, 1) &&
|
||||
!Utility.InRange(oldLocation, Location, 1) &&
|
||||
m.Player && !(m.AccessLevel > AccessLevel.Player || m.Hidden) && !_timerToken.Running)
|
||||
{
|
||||
if (Utility.InRange(m.Location, Location, 1) && !Utility.InRange(oldLocation, Location, 1) && m.Player &&
|
||||
!(m.AccessLevel > AccessLevel.Player || m.Hidden))
|
||||
{
|
||||
if (m_Timer?.Running != true)
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(2), HeedWarning);
|
||||
}
|
||||
}
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(2), HeedWarning, out _timerToken);
|
||||
}
|
||||
|
||||
base.OnMovement(m, oldLocation);
|
||||
|
|
@ -180,7 +179,7 @@ namespace Server.Items
|
|||
|
||||
DoEffect(spawnLoc, map);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1), SummonCreatureToWorld, bc, spawnLoc, map);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1), () => SummonCreatureToWorld(bc, spawnLoc, map));
|
||||
|
||||
NextSpawn = Core.Now + NextSpawnDelay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,24 +286,24 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (trigger is Mobile mobile && mobile.Hidden && mobile.AccessLevel > AccessLevel.Player)
|
||||
if (trigger is Mobile { Hidden: true } mobile && mobile.AccessLevel > AccessLevel.Player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoundID > 0)
|
||||
{
|
||||
Timer.DelayCall(SoundDelay, PlaySound, trigger);
|
||||
Timer.StartTimer(SoundDelay, () => PlaySound(trigger));
|
||||
}
|
||||
|
||||
if (Sequence != null)
|
||||
{
|
||||
Timer.DelayCall(TriggerDelay, Sequence.DoEffect, trigger);
|
||||
Timer.StartTimer(TriggerDelay, () => Sequence.DoEffect(trigger));
|
||||
}
|
||||
|
||||
if (EffectType != ECEffectType.None)
|
||||
{
|
||||
Timer.DelayCall(EffectDelay, InternalDoEffect, trigger);
|
||||
Timer.StartTimer(EffectDelay, () => InternalDoEffect(trigger));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Items
|
|||
{
|
||||
private Mobile m_LitBy;
|
||||
private int m_Ticks;
|
||||
private Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
private List<Mobile> m_Users;
|
||||
|
||||
[Constructible]
|
||||
|
|
@ -55,15 +55,15 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_Timer == null)
|
||||
if (_timerToken.Running)
|
||||
{
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), OnFirebombTimerTick);
|
||||
m_LitBy = from;
|
||||
from.SendLocalizedMessage(1060582); // You light the firebomb. Throw it now!
|
||||
from.SendLocalizedMessage(1060581); // You've already lit it! Better throw it now!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1060581); // You've already lit it! Better throw it now!
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), OnFirebombTimerTick, out _timerToken);
|
||||
m_LitBy = from;
|
||||
from.SendLocalizedMessage(1060582); // You light the firebomb. Throw it now!
|
||||
}
|
||||
|
||||
m_Users ??= new List<Mobile>();
|
||||
|
|
@ -80,7 +80,7 @@ namespace Server.Items
|
|||
{
|
||||
if (Deleted)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
_timerToken.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ namespace Server.Items
|
|||
new FirebombField(m_LitBy, toDamage).MoveToWorld(Location, Map);
|
||||
}
|
||||
|
||||
m_Timer.Stop();
|
||||
_timerToken.Cancel();
|
||||
Delete();
|
||||
break;
|
||||
}
|
||||
|
|
@ -172,33 +172,35 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(obj is IPoint3D p))
|
||||
if (obj is not IPoint3D p)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SpellHelper.GetSurfaceTop(ref p);
|
||||
var loc = new Point3D(p);
|
||||
var map = Map;
|
||||
|
||||
from.RevealingAction();
|
||||
|
||||
var to = p as IEntity ?? new Entity(Serial.Zero, new Point3D(p), Map);
|
||||
var to = p as IEntity ?? new Entity(Serial.Zero, loc, map);
|
||||
|
||||
Effects.SendMovingEffect(from, to, ItemID, 7, 0, false, false, Hue);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.0), FirebombReposition_OnTick, p, Map);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0),
|
||||
() =>
|
||||
{
|
||||
if (Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveToWorld(loc, map);
|
||||
}
|
||||
);
|
||||
Internalize();
|
||||
}
|
||||
|
||||
private void FirebombReposition_OnTick(IPoint3D p, Map map)
|
||||
{
|
||||
if (Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveToWorld(new Point3D(p), map);
|
||||
}
|
||||
|
||||
private class ThrowTarget : Target
|
||||
{
|
||||
public ThrowTarget(Firebomb bomb)
|
||||
|
|
@ -219,7 +221,7 @@ namespace Server.Items
|
|||
private readonly List<Mobile> m_Burning;
|
||||
private readonly DateTime m_Expire;
|
||||
private readonly Mobile m_LitBy;
|
||||
private readonly Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
public FirebombField(Mobile litBy, List<Mobile> toDamage) : base(0x376A)
|
||||
{
|
||||
|
|
@ -227,7 +229,7 @@ namespace Server.Items
|
|||
m_LitBy = litBy;
|
||||
m_Expire = Core.Now + TimeSpan.FromSeconds(10);
|
||||
m_Burning = toDamage;
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnFirebombFieldTimerTick);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnFirebombFieldTimerTick, out _timerToken);
|
||||
}
|
||||
|
||||
public FirebombField(Serial serial) : base(serial)
|
||||
|
|
@ -266,7 +268,7 @@ namespace Server.Items
|
|||
{
|
||||
if (Deleted)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
_timerToken.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +299,7 @@ namespace Server.Items
|
|||
|
||||
if (Core.Now >= m_Expire)
|
||||
{
|
||||
m_Timer.Stop();
|
||||
_timerToken.Cancel();
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ namespace Server.Items
|
|||
|
||||
Effects.PlaySound(GetWorldLocation(), Map, 0x387);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.25), Down1);
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(0.50), Down2);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.25), Down1);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(0.50), Down2);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.00), BackUp);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.00), BackUp);
|
||||
|
||||
m_NextUse = Core.Now + TimeSpan.FromSeconds(10.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(Refresh);
|
||||
Timer.StartTimer(Refresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ using Server.Mobiles;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
[TypeAlias("Server.Items.AcidSlime")]
|
||||
public class PoolOfAcid : Item
|
||||
{
|
||||
private readonly DateTime m_Created;
|
||||
private readonly TimeSpan m_Duration;
|
||||
private readonly int m_MaxDamage;
|
||||
private readonly int m_MinDamage;
|
||||
private readonly Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
private bool m_Drying;
|
||||
|
||||
[Constructible]
|
||||
|
|
@ -30,7 +31,7 @@ namespace Server.Items
|
|||
m_Created = Core.Now;
|
||||
m_Duration = duration;
|
||||
|
||||
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick);
|
||||
Timer.StartTimer(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick, out _timerToken);
|
||||
}
|
||||
|
||||
public PoolOfAcid(Serial serial) : base(serial)
|
||||
|
|
@ -39,9 +40,9 @@ namespace Server.Items
|
|||
|
||||
public override string DefaultName => "a pool of acid";
|
||||
|
||||
public override void OnAfterDelete()
|
||||
public override void OnDelete()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
_timerToken.Cancel();
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ namespace Server.Items
|
|||
}
|
||||
else
|
||||
{
|
||||
Timer.DelayCall(m_Delay, DoTeleport, m);
|
||||
Timer.StartTimer(m_Delay, () => DoTeleport(m));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ namespace Server.Items
|
|||
);
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), m.EndAction, this);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5.0), () => m.EndAction(this));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -671,7 +671,7 @@ namespace Server.Items
|
|||
|
||||
public class WaitTeleporter : KeywordTeleporter
|
||||
{
|
||||
private static Dictionary<Mobile, TeleportingInfo> m_Table;
|
||||
private static Dictionary<Mobile, TeleportingInfo> m_Table = new Dictionary<Mobile, TeleportingInfo>();
|
||||
|
||||
[Constructible]
|
||||
public WaitTeleporter()
|
||||
|
|
@ -700,8 +700,6 @@ namespace Server.Items
|
|||
|
||||
public static void Initialize()
|
||||
{
|
||||
m_Table = new Dictionary<Mobile, TeleportingInfo>();
|
||||
|
||||
EventSink.Logout += EventSink_Logout;
|
||||
}
|
||||
|
||||
|
|
@ -709,7 +707,7 @@ namespace Server.Items
|
|||
{
|
||||
if (from != null && m_Table.Remove(from, out var info))
|
||||
{
|
||||
info.Timer.Stop();
|
||||
info.TimerToken.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -731,11 +729,6 @@ namespace Server.Items
|
|||
return $"{s} second{(s == 1 ? "" : "s")}";
|
||||
}
|
||||
|
||||
private void EndLock(Mobile m)
|
||||
{
|
||||
m.EndAction(this);
|
||||
}
|
||||
|
||||
public override void StartTeleport(Mobile m)
|
||||
{
|
||||
if (m_Table.TryGetValue(m, out var info))
|
||||
|
|
@ -755,16 +748,16 @@ namespace Server.Items
|
|||
|
||||
if (ShowTimeRemaining)
|
||||
{
|
||||
m.SendMessage("Time remaining: {0}", FormatTime(info.Timer.Next - Core.Now));
|
||||
m.SendMessage("Time remaining: {0}", FormatTime(info.TimerToken.Next - Core.Now));
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5), EndLock, m);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(5), () => m.EndAction(this));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
info.Timer.Stop();
|
||||
info.TimerToken.Cancel();
|
||||
}
|
||||
|
||||
if (StartMessage != null)
|
||||
|
|
@ -782,7 +775,8 @@ namespace Server.Items
|
|||
}
|
||||
else
|
||||
{
|
||||
m_Table[m] = new TeleportingInfo(this, Timer.DelayCall(Delay, DoTeleport, m));
|
||||
Timer.StartTimer(Delay, () => DoTeleport(m), out var timerToken);
|
||||
m_Table[m] = new TeleportingInfo(this, timerToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -821,21 +815,21 @@ namespace Server.Items
|
|||
|
||||
private class TeleportingInfo
|
||||
{
|
||||
public TeleportingInfo(WaitTeleporter tele, Timer t)
|
||||
public TeleportingInfo(WaitTeleporter tele, TimerExecutionToken token)
|
||||
{
|
||||
Teleporter = tele;
|
||||
Timer = t;
|
||||
TimerToken = token;
|
||||
}
|
||||
|
||||
public WaitTeleporter Teleporter { get; }
|
||||
|
||||
public Timer Timer { get; }
|
||||
public TimerExecutionToken TimerToken { get; }
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeoutTeleporter : Teleporter
|
||||
{
|
||||
private Dictionary<Mobile, Timer> m_Teleporting;
|
||||
private Dictionary<Mobile, TimerExecutionToken> m_Teleporting;
|
||||
|
||||
[Constructible]
|
||||
public TimeoutTeleporter() : this(new Point3D(0, 0, 0))
|
||||
|
|
@ -845,7 +839,7 @@ namespace Server.Items
|
|||
[Constructible]
|
||||
public TimeoutTeleporter(Point3D pointDest, Map mapDest = null, bool creatures = false)
|
||||
: base(pointDest, mapDest, creatures) =>
|
||||
m_Teleporting = new Dictionary<Mobile, Timer>();
|
||||
m_Teleporting = new Dictionary<Mobile, TimerExecutionToken>();
|
||||
|
||||
public TimeoutTeleporter(Serial serial)
|
||||
: base(serial)
|
||||
|
|
@ -862,19 +856,16 @@ namespace Server.Items
|
|||
|
||||
private void StartTimer(Mobile m, TimeSpan delay)
|
||||
{
|
||||
if (m_Teleporting.TryGetValue(m, out var t))
|
||||
{
|
||||
t.Stop();
|
||||
}
|
||||
|
||||
m_Teleporting[m] = Timer.DelayCall(delay, StartTeleport, m);
|
||||
StopTimer(m);
|
||||
Timer.StartTimer(delay, () => StartTeleport(m), out var timerToken);
|
||||
m_Teleporting[m] = timerToken;
|
||||
}
|
||||
|
||||
public void StopTimer(Mobile m)
|
||||
{
|
||||
if (m_Teleporting.Remove(m, out var t))
|
||||
{
|
||||
t.Stop();
|
||||
t.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -923,7 +914,7 @@ namespace Server.Items
|
|||
var version = reader.ReadInt();
|
||||
|
||||
TimeoutDelay = reader.ReadTimeSpan();
|
||||
m_Teleporting = new Dictionary<Mobile, Timer>();
|
||||
m_Teleporting = new Dictionary<Mobile, TimerExecutionToken>();
|
||||
|
||||
var count = reader.ReadInt();
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(StopBroadcasting);
|
||||
Timer.StartTimer(StopBroadcasting);
|
||||
}
|
||||
|
||||
private void StopBroadcasting()
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace Server.Items
|
|||
private class LogoutGump : Gump
|
||||
{
|
||||
private readonly Bedroll m_Bedroll;
|
||||
private readonly Timer m_CloseTimer;
|
||||
private TimerExecutionToken _closeTimerToken;
|
||||
|
||||
private readonly CampfireEntry m_Entry;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ namespace Server.Items
|
|||
m_Entry = entry;
|
||||
m_Bedroll = bedroll;
|
||||
|
||||
m_CloseTimer = Timer.DelayCall(TimeSpan.FromSeconds(10.0), CloseGump);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(10.0), CloseGump, out _closeTimerToken);
|
||||
|
||||
AddBackground(0, 0, 400, 350, 0xA28);
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ namespace Server.Items
|
|||
{
|
||||
var pm = m_Entry.Player;
|
||||
|
||||
m_CloseTimer.Stop();
|
||||
_closeTimerToken.Cancel();
|
||||
|
||||
if (Campfire.GetEntry(pm) != m_Entry)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Server.Items
|
|||
|
||||
private readonly List<CampfireEntry> m_Entries;
|
||||
|
||||
private readonly Timer m_Timer;
|
||||
private TimerExecutionToken _timerToken;
|
||||
|
||||
public Campfire() : base(0xDE3)
|
||||
{
|
||||
|
|
@ -30,7 +30,7 @@ namespace Server.Items
|
|||
m_Entries = new List<CampfireEntry>();
|
||||
|
||||
Created = Core.Now;
|
||||
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnTick);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0), OnTick, out _timerToken);
|
||||
}
|
||||
|
||||
public Campfire(Serial serial) : base(serial)
|
||||
|
|
@ -161,7 +161,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
_timerToken.Cancel();
|
||||
|
||||
ClearEntries();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
Timer.DelayCall(FixMovingCrate);
|
||||
Timer.StartTimer(FixMovingCrate);
|
||||
}
|
||||
|
||||
private void FixMovingCrate()
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ namespace Server.Items
|
|||
|
||||
var index = 0;
|
||||
|
||||
Timer.DelayCall(
|
||||
Timer.StartTimer(
|
||||
TimeSpan.FromSeconds(1.0),
|
||||
TimeSpan.FromSeconds(1.25),
|
||||
14,
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ namespace Server.Items
|
|||
|
||||
if (version < 1)
|
||||
{
|
||||
Timer.DelayCall(UpdateWeight);
|
||||
Timer.StartTimer(UpdateWeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Server.Items
|
|||
{
|
||||
public abstract class BaseConflagrationPotion : BasePotion
|
||||
{
|
||||
private static readonly Dictionary<Mobile, Timer> m_Delay = new();
|
||||
private static readonly Dictionary<Mobile, TimerExecutionToken> m_Delay = new();
|
||||
private readonly List<Mobile> m_Users = new();
|
||||
|
||||
public BaseConflagrationPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x489;
|
||||
|
|
@ -107,8 +107,10 @@ namespace Server.Items
|
|||
public static void AddDelay(Mobile m)
|
||||
{
|
||||
m_Delay.TryGetValue(m, out var timer);
|
||||
timer?.Stop();
|
||||
m_Delay[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), EndDelay, m);
|
||||
timer.Cancel();
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(30), () => EndDelay(m), out timer);
|
||||
m_Delay[m] = timer;
|
||||
}
|
||||
|
||||
public static int GetDelay(Mobile m)
|
||||
|
|
@ -125,7 +127,7 @@ namespace Server.Items
|
|||
{
|
||||
if (m_Delay.Remove(m, out var timer))
|
||||
{
|
||||
timer.Stop();
|
||||
timer.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +144,7 @@ namespace Server.Items
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(targeted is IPoint3D p) || from.Map == null)
|
||||
if (targeted is not IPoint3D p || from.Map == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -151,6 +153,8 @@ namespace Server.Items
|
|||
AddDelay(from);
|
||||
|
||||
SpellHelper.GetSurfaceTop(ref p);
|
||||
var loc = new Point3D(p);
|
||||
var map = from.Map;
|
||||
|
||||
from.RevealingAction();
|
||||
|
||||
|
|
@ -162,11 +166,11 @@ namespace Server.Items
|
|||
}
|
||||
else
|
||||
{
|
||||
to = new Entity(Serial.Zero, new Point3D(p), from.Map);
|
||||
to = new Entity(Serial.Zero, loc, map);
|
||||
}
|
||||
|
||||
Effects.SendMovingEffect(from, to, 0xF0D, 7, 0, false, false, Potion.Hue);
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(1.5), Potion.Explode, from, new Point3D(p), from.Map);
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.5), () => Potion.Explode(from, loc, map));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue