Fixes dictionary uses (#7)
This commit is contained in:
parent
d4a52344f2
commit
916d404c51
161 changed files with 1211 additions and 1722 deletions
|
|
@ -59,11 +59,10 @@ namespace Server.Items
|
|||
|
||||
public static void BeginBleed(Mobile m, Mobile from)
|
||||
{
|
||||
Timer t = m_Table[m];
|
||||
m_Table.TryGetValue(m, out Timer t);
|
||||
t?.Stop();
|
||||
|
||||
m_Table[m] = t = new InternalTimer(from, m);
|
||||
|
||||
t.Start();
|
||||
}
|
||||
|
||||
|
|
@ -90,9 +89,7 @@ namespace Server.Items
|
|||
|
||||
public static void EndBleed(Mobile m, bool message)
|
||||
{
|
||||
Timer t = m_Table[m];
|
||||
|
||||
if (t == null)
|
||||
if (!m_Table.TryGetValue(m, out Timer t))
|
||||
return;
|
||||
|
||||
t.Stop();
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ namespace Server.Items
|
|||
|
||||
public static bool GetBonus(Mobile targ, ref int bonus)
|
||||
{
|
||||
BlockInfo info = m_Table[targ];
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(targ, out BlockInfo info))
|
||||
return false;
|
||||
|
||||
bonus = info.m_Bonus;
|
||||
|
|
@ -61,9 +60,7 @@ namespace Server.Items
|
|||
|
||||
public static void EndBlock(Mobile m)
|
||||
{
|
||||
BlockInfo info = m_Table[m];
|
||||
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(m, out BlockInfo info))
|
||||
return;
|
||||
|
||||
info.m_Timer?.Stop();
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ namespace Server.Items
|
|||
((Math.Max(attacker.Skills.Bushido.Value, attacker.Skills.Ninjitsu.Value) -
|
||||
50.0) / 70.0));
|
||||
|
||||
DefenseMasteryInfo info = m_Table[attacker];
|
||||
|
||||
if (info != null)
|
||||
if (m_Table.TryGetValue(attacker, out DefenseMasteryInfo info))
|
||||
EndDefense(info);
|
||||
|
||||
ResistanceMod mod = new ResistanceMod(ResistanceType.Physical, 50 + modifier);
|
||||
|
|
@ -59,9 +57,7 @@ namespace Server.Items
|
|||
|
||||
public static bool GetMalus(Mobile targ, ref int damageMalus)
|
||||
{
|
||||
DefenseMasteryInfo info = m_Table[targ];
|
||||
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(targ, out DefenseMasteryInfo info))
|
||||
return false;
|
||||
|
||||
damageMalus = info.m_DamageMalus;
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ namespace Server.Items
|
|||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
return;
|
||||
|
||||
DualWieldTimer timer = Registry[attacker];
|
||||
if (timer != null)
|
||||
if (Registry.TryGetValue(attacker, out DualWieldTimer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
Registry.Remove(attacker);
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ namespace Server.Items
|
|||
if (!Validate(attacker) || !CheckMana(attacker, true))
|
||||
return;
|
||||
|
||||
FeintTimer timer = Registry[defender];
|
||||
if (timer != null)
|
||||
if (Registry.TryGetValue(defender, out FeintTimer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
Registry.Remove(defender);
|
||||
|
|
|
|||
|
|
@ -78,9 +78,7 @@ namespace Server.Items
|
|||
Mobile m = targets[i];
|
||||
attacker.DoHarmful(m, true);
|
||||
|
||||
FrenziedWirlwindTimer timer = Registry[m];
|
||||
|
||||
if (timer != null)
|
||||
if (Registry.TryGetValue(m, out FrenziedWirlwindTimer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
Registry.Remove(m);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ namespace Server.Items
|
|||
|
||||
public static void BeginWound(Mobile m, TimeSpan duration)
|
||||
{
|
||||
InternalTimer timer = m_Table[m];
|
||||
timer?.Stop();
|
||||
if (m_Table.TryGetValue(m, out InternalTimer timer))
|
||||
timer?.Stop();
|
||||
|
||||
m_Table[m] = timer = new InternalTimer(m, duration);
|
||||
timer.Start();
|
||||
|
|
@ -52,9 +52,7 @@ namespace Server.Items
|
|||
|
||||
public static void EndWound(Mobile m)
|
||||
{
|
||||
Timer timer = m_Table[m];
|
||||
|
||||
if (timer != null)
|
||||
if (m_Table.TryGetValue(m, out InternalTimer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_Table.Remove(m);
|
||||
|
|
|
|||
|
|
@ -88,18 +88,20 @@ namespace Server.Items
|
|||
|
||||
public static void BeginImmunity(Mobile m, TimeSpan duration)
|
||||
{
|
||||
InternalTimer timer = m_Table[m];
|
||||
if (m_Table.TryGetValue(m, out InternalTimer timer))
|
||||
timer?.Stop();
|
||||
|
||||
timer?.Stop();
|
||||
m_Table[m] = timer = new InternalTimer(m, duration);
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public static void EndImmunity(Mobile m)
|
||||
{
|
||||
InternalTimer timer = m_Table[m];
|
||||
timer?.Stop();
|
||||
m_Table.Remove(m);
|
||||
if (m_Table.TryGetValue(m, out InternalTimer timer))
|
||||
{
|
||||
timer?.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Server.Items
|
|||
/// </summary>
|
||||
public class TalonStrike : WeaponAbility
|
||||
{
|
||||
private static Dictionary<Mobile, InternalTimer> m_Table = new Dictionary<Mobile, InternalTimer>();
|
||||
private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
|
||||
|
||||
public override int BaseMana => 30;
|
||||
public override double DamageScalar => 1.2;
|
||||
|
|
@ -27,7 +27,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnHit(Mobile attacker, Mobile defender, int damage)
|
||||
{
|
||||
if (m_Table.ContainsKey(defender) || !Validate(attacker) || !CheckMana(attacker, true))
|
||||
if (m_Table.Contains(defender) || !Validate(attacker) || !CheckMana(attacker, true))
|
||||
return;
|
||||
|
||||
ClearCurrentAbility(attacker);
|
||||
|
|
@ -42,7 +42,7 @@ namespace Server.Items
|
|||
|
||||
timer.Start();
|
||||
|
||||
m_Table.Add(defender, timer);
|
||||
m_Table.Add(defender);
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ namespace Server.Items
|
|||
return null;
|
||||
}
|
||||
|
||||
WeaponAbility a = Table[m];
|
||||
Table.TryGetValue(m, out WeaponAbility a);
|
||||
|
||||
if (!IsWeaponAbility(m, a))
|
||||
{
|
||||
|
|
@ -446,7 +446,8 @@ namespace Server.Items
|
|||
|
||||
private static WeaponAbilityContext GetContext(Mobile m)
|
||||
{
|
||||
return m_PlayersTable[m];
|
||||
m_PlayersTable.TryGetValue(m, out WeaponAbilityContext context);
|
||||
return context;
|
||||
}
|
||||
|
||||
private class WeaponAbilityTimer : Timer
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ namespace Server.Items
|
|||
public static readonly TimeSpan AttackEffectDuration = TimeSpan.FromSeconds(10.0);
|
||||
public static readonly TimeSpan DefenseEffectDuration = TimeSpan.FromSeconds(8.0);
|
||||
|
||||
private static Dictionary<Mobile, AttackTimer> m_AttackTable = new Dictionary<Mobile, AttackTimer>();
|
||||
private static Dictionary<Mobile, DefenseTimer> m_DefenseTable = new Dictionary<Mobile, DefenseTimer>();
|
||||
private static HashSet<Mobile> m_AttackTable = new HashSet<Mobile>();
|
||||
private static HashSet<Mobile> m_DefenseTable = new HashSet<Mobile>();
|
||||
|
||||
public static bool IsUnderAttackEffect(Mobile m)
|
||||
{
|
||||
return m_AttackTable.ContainsKey(m);
|
||||
return m_AttackTable.Contains(m);
|
||||
}
|
||||
|
||||
public static bool ApplyAttack(Mobile m)
|
||||
|
|
@ -22,7 +22,9 @@ namespace Server.Items
|
|||
if (IsUnderAttackEffect(m))
|
||||
return false;
|
||||
|
||||
m_AttackTable[m] = new AttackTimer(m);
|
||||
m_AttackTable.Add(m);
|
||||
AttackTimer timer = new AttackTimer(m);
|
||||
timer.Start();
|
||||
m.SendLocalizedMessage(1062319); // Your attack chance has been reduced!
|
||||
return true;
|
||||
}
|
||||
|
|
@ -35,7 +37,7 @@ namespace Server.Items
|
|||
|
||||
public static bool IsUnderDefenseEffect(Mobile m)
|
||||
{
|
||||
return m_DefenseTable.ContainsKey(m);
|
||||
return m_DefenseTable.Contains(m);
|
||||
}
|
||||
|
||||
public static bool ApplyDefense(Mobile m)
|
||||
|
|
@ -43,7 +45,9 @@ namespace Server.Items
|
|||
if (IsUnderDefenseEffect(m))
|
||||
return false;
|
||||
|
||||
m_DefenseTable[m] = new DefenseTimer(m);
|
||||
m_DefenseTable.Add(m);
|
||||
DefenseTimer timer = new DefenseTimer(m);
|
||||
timer.Start();
|
||||
m.SendLocalizedMessage(1062318); // Your defense chance has been reduced!
|
||||
return true;
|
||||
}
|
||||
|
|
@ -61,10 +65,7 @@ namespace Server.Items
|
|||
public AttackTimer(Mobile player) : base(AttackEffectDuration)
|
||||
{
|
||||
m_Player = player;
|
||||
|
||||
Priority = TimerPriority.TwoFiftyMS;
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
|
|
@ -80,10 +81,7 @@ namespace Server.Items
|
|||
public DefenseTimer(Mobile player) : base(DefenseEffectDuration)
|
||||
{
|
||||
m_Player = player;
|
||||
|
||||
Priority = TimerPriority.TwoFiftyMS;
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue