Fixes dictionary uses (#7)
This commit is contained in:
parent
d4a52344f2
commit
916d404c51
161 changed files with 1211 additions and 1722 deletions
|
|
@ -56,7 +56,7 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void BeginConfidence(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
m_Table.TryGetValue(m, out Timer timer);
|
||||
timer?.Stop();
|
||||
m_Table[m] = timer = new InternalTimer(m);
|
||||
|
||||
|
|
@ -65,10 +65,11 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void EndConfidence(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
timer?.Stop();
|
||||
|
||||
m_Table.Remove(m);
|
||||
if (m_Table.TryGetValue(m, out Timer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
|
||||
OnEffectEnd(m, typeof(Confidence));
|
||||
}
|
||||
|
|
@ -80,7 +81,7 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void BeginRegenerating(Mobile m)
|
||||
{
|
||||
Timer timer = m_RegenTable[m];
|
||||
m_RegenTable.TryGetValue(m, out Timer timer);
|
||||
timer?.Stop();
|
||||
|
||||
m_RegenTable[m] = timer = new RegenTimer(m);
|
||||
|
|
@ -90,10 +91,11 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void StopRegenerating(Mobile m)
|
||||
{
|
||||
Timer timer = m_RegenTable[m];
|
||||
timer?.Stop();
|
||||
|
||||
m_RegenTable.Remove(m);
|
||||
if (m_RegenTable.TryGetValue(m, out Timer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_RegenTable.Remove(m);
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void StartCountering(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
m_Table.TryGetValue(m, out Timer timer);
|
||||
timer?.Stop();
|
||||
|
||||
m_Table[m] = timer = new InternalTimer(m);
|
||||
|
|
@ -80,10 +80,11 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void StopCountering(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
timer?.Stop();
|
||||
|
||||
m_Table.Remove(m);
|
||||
if (m_Table.TryGetValue(m, out Timer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
|
||||
OnEffectEnd(m, typeof(CounterAttack));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public override bool CheckCast()
|
||||
{
|
||||
if (VerifyCast(Caster, true))
|
||||
return base.CheckCast();
|
||||
|
||||
return false;
|
||||
return VerifyCast(Caster, true) && base.CheckCast();
|
||||
}
|
||||
|
||||
public static bool VerifyCast(Mobile Caster, bool messages)
|
||||
|
|
@ -180,7 +177,7 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void BeginEvasion(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
m_Table.TryGetValue(m, out Timer timer);
|
||||
timer?.Stop();
|
||||
|
||||
m_Table[m] = timer = new InternalTimer(m, GetEvadeDuration(m));
|
||||
|
|
@ -189,10 +186,11 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static void EndEvasion(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
timer?.Stop();
|
||||
|
||||
m_Table.Remove(m);
|
||||
if (m_Table.TryGetValue(m, out Timer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
|
||||
OnEffectEnd(m, typeof(Evasion));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ namespace Server.Spells.Bushido
|
|||
|
||||
ClearCurrentMove(attacker);
|
||||
|
||||
HonorableExecutionInfo info = m_Table[attacker];
|
||||
|
||||
if (info != null)
|
||||
if (m_Table.TryGetValue(attacker, out HonorableExecutionInfo info))
|
||||
{
|
||||
info.Clear();
|
||||
info.m_Timer?.Stop();
|
||||
|
|
@ -79,29 +77,21 @@ namespace Server.Spells.Bushido
|
|||
|
||||
public static int GetSwingBonus(Mobile target)
|
||||
{
|
||||
if (!(m_Table[target] is HonorableExecutionInfo info))
|
||||
return 0;
|
||||
|
||||
return info.m_SwingBonus;
|
||||
return m_Table.TryGetValue(target, out HonorableExecutionInfo info) ? info.m_SwingBonus : 0;
|
||||
}
|
||||
|
||||
public static bool IsUnderPenalty(Mobile target)
|
||||
{
|
||||
if (!(m_Table[target] is HonorableExecutionInfo info))
|
||||
return false;
|
||||
|
||||
return info.m_Penalty;
|
||||
return m_Table.TryGetValue(target, out HonorableExecutionInfo info) && info.m_Penalty;
|
||||
}
|
||||
|
||||
public static void RemovePenalty(Mobile target)
|
||||
{
|
||||
if (!(m_Table[target] is HonorableExecutionInfo info) || !info.m_Penalty)
|
||||
if (!m_Table.TryGetValue(target, out HonorableExecutionInfo info) || !info.m_Penalty)
|
||||
return;
|
||||
|
||||
info.Clear();
|
||||
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
m_Table.Remove(target);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue