fix: Cleanup IPoint3D calls (#704)

This commit is contained in:
Kamron Batman 2021-08-19 09:11:48 -07:00 • committed by GitHub
parent 788b04b958
commit 3293ffcf06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 158 additions and 264 deletions

View file

@ -1119,8 +1119,7 @@ namespace Server
[CommandProperty(AccessLevel.GameMaster)]
public Container Corpse { get; set; }
public static char[] GhostChars { get; set; } = { 'o', 'O' };
public static char[] GhostChars { get; set; }
public static bool NoSpeechLOS { get; set; }
public static TimeSpan AutoManifestTimeout { get; set; } = TimeSpan.FromSeconds(5.0);
@ -2108,7 +2107,6 @@ namespace Server
if (Stam < StamMax)
{
m_StamTimer ??= new StamTimer(this);
m_StamTimer.Start();
}
else if (Stam > StamMax)
@ -2167,7 +2165,6 @@ namespace Server
if (Mana < ManaMax)
{
m_ManaTimer ??= new ManaTimer(this);
m_ManaTimer.Start();
}
else if (Mana > ManaMax)
@ -2234,17 +2231,14 @@ namespace Server
DamageEntries.Clear(); // reset damage entries on full HP
}
}
else if (CanRegenHits)
{
m_HitsTimer ??= new HitsTimer(this);
m_HitsTimer.Start();
}
else
{
if (CanRegenHits)
{
m_HitsTimer ??= new HitsTimer(this);
m_HitsTimer.Start();
}
else
{
m_HitsTimer?.Stop();
}
m_HitsTimer?.Stop();
}
if (m_Hits != value)
@ -2279,22 +2273,14 @@ namespace Server
value = Math.Clamp(value, 0, StamMax);
if (value == StamMax)
if (CanRegenStam && value < StamMax)
{
m_StamTimer?.Stop();
m_StamTimer ??= new StamTimer(this);
m_StamTimer.Start();
}
else
{
if (CanRegenStam)
{
m_StamTimer ??= new StamTimer(this);
m_StamTimer.Start();
}
else
{
m_StamTimer?.Stop();
}
m_StamTimer?.Stop();
}
if (m_Stam != value)
@ -2342,18 +2328,14 @@ namespace Server
SendLocalizedMessage(501846); // You are at peace.
}
}
else if (CanRegenMana)
{
m_ManaTimer ??= new ManaTimer(this);
m_ManaTimer.Start();
}
else
{
if (CanRegenMana)
{
m_ManaTimer ??= new ManaTimer(this);
m_ManaTimer.Start();
}
else
{
m_ManaTimer?.Stop();
}
m_ManaTimer?.Stop();
}
if (m_Mana != value)
@ -3874,7 +3856,7 @@ namespace Server
}
}
public virtual bool CheckAttack(Mobile m) => Utility.InUpdateRange(this, m) && CanSee(m) && InLOS(m);
public virtual bool CheckAttack(Mobile m) => Utility.InUpdateRange(Location, m.Location) && CanSee(m) && InLOS(m);
/// <summary>
/// Overridable. Virtual event invoked after the <see cref="Combatant" /> property has changed.
@ -5041,7 +5023,7 @@ namespace Server
var root = item.RootParent;
var okay = false;
if (!Utility.InUpdateRange(this, item.GetWorldLocation()))
if (!Utility.InUpdateRange(Location, item.GetWorldLocation()))
{
item.OnDoubleClickOutOfRange(this);
}
@ -5111,7 +5093,7 @@ namespace Server
return;
}
if (!Utility.InUpdateRange(this, m))
if (!Utility.InUpdateRange(Location, m.Location))
{
m.OnDoubleClickOutOfRange(this);
}
@ -5525,7 +5507,7 @@ namespace Server
using var sb = new ValueStringBuilder(stackalloc char[Math.Min(text.Length, 256)]);
for (var i = 0; i < text.Length; ++i)
{
sb.Append(text[i] != ' ' ? GhostChars.RandomElement() : ' ');
sb.Append(text[i] != ' ' ? (GhostChars ?? DefaultGhostChars).RandomElement() : ' ');
}
text = sb.ToString();
@ -6586,7 +6568,6 @@ namespace Server
if (CanRegenStam)
{
m_StamTimer ??= new StamTimer(this);
m_StamTimer.Start();
}
else
@ -6604,7 +6585,6 @@ namespace Server
if (CanRegenMana)
{
m_ManaTimer ??= new ManaTimer(this);
m_ManaTimer.Start();
}
else
@ -7986,7 +7966,7 @@ namespace Server
/// <param name="from"></param>
public virtual void OnStatsQuery(Mobile from)
{
if (from.Map == Map && Utility.InUpdateRange(this, from) && from.CanSee(this))
if (from.Map == Map && Utility.InUpdateRange(Location, from.Location) && from.CanSee(this))
{
from.m_NetState.SendMobileStatus(from, this);
}
@ -8156,6 +8136,8 @@ namespace Server
public static TimeSpan GetManaRegenRate(Mobile m) => ManaRegenRateHandler?.Invoke(m) ?? DefaultManaRate;
public static char[] DefaultGhostChars = { 'o', 'O' };
public Prompt BeginPrompt(PromptCallback callback, PromptCallback cancelCallback) =>
Prompt = new SimplePrompt(callback, cancelCallback);
@ -9309,11 +9291,7 @@ namespace Server
{
private readonly Mobile m_Owner;
public ManaTimer(Mobile m)
: base(GetManaRegenRate(m), GetManaRegenRate(m))
{
m_Owner = m;
}
public ManaTimer(Mobile m) : base(GetManaRegenRate(m), GetManaRegenRate(m)) => m_Owner = m;
protected override void OnTick()
{
@ -9330,11 +9308,7 @@ namespace Server
{
private readonly Mobile m_Owner;
public HitsTimer(Mobile m)
: base(GetHitsRegenRate(m), GetHitsRegenRate(m))
{
m_Owner = m;
}
public HitsTimer(Mobile m) : base(GetHitsRegenRate(m), GetHitsRegenRate(m)) => m_Owner = m;
protected override void OnTick()
{
@ -9351,11 +9325,7 @@ namespace Server
{
private readonly Mobile m_Owner;
public StamTimer(Mobile m)
: base(GetStamRegenRate(m), GetStamRegenRate(m))
{
m_Owner = m;
}
public StamTimer(Mobile m) : base(GetStamRegenRate(m), GetStamRegenRate(m)) => m_Owner = m;
protected override void OnTick()
{