Fixes dictionary uses (#7)
This commit is contained in:
parent
d4a52344f2
commit
916d404c51
161 changed files with 1211 additions and 1722 deletions
|
|
@ -197,10 +197,7 @@ namespace Server.Spells.Ninjitsu
|
|||
|
||||
public int GetLastAnimalForm(Mobile m)
|
||||
{
|
||||
if (m_LastAnimalForms.ContainsKey(m))
|
||||
return m_LastAnimalForms[m];
|
||||
|
||||
return -1;
|
||||
return m_LastAnimalForms.TryGetValue(m, out int value) ? value : -1;
|
||||
}
|
||||
|
||||
public static MorphResult Morph(Mobile m, int entryID)
|
||||
|
|
@ -323,7 +320,7 @@ namespace Server.Spells.Ninjitsu
|
|||
|
||||
public static AnimalFormContext GetContext(Mobile m)
|
||||
{
|
||||
return m_Table[m];
|
||||
return m_Table.TryGetValue(m, out AnimalFormContext context) ? context : null;
|
||||
}
|
||||
|
||||
public static bool UnderTransformation(Mobile m)
|
||||
|
|
@ -445,19 +442,19 @@ namespace Server.Spells.Ninjitsu
|
|||
}
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
int x = pos % 2 == 0 ? 14 : 264;
|
||||
int y = pos / 2 * 64 + 44;
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
Rectangle2D b = ItemBounds.Table[entries[i].ItemID];
|
||||
int x = pos % 2 == 0 ? 14 : 264;
|
||||
int y = pos / 2 * 64 + 44;
|
||||
|
||||
AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entries[i].ItemID,
|
||||
entries[i].Hue, 40 - b.Width / 2 - b.X, 30 - b.Height / 2 - b.Y, entries[i].Tooltip);
|
||||
AddHtmlLocalized(x + 84, y, 250, 60, entries[i].Name, 0x7FFF, false, false);
|
||||
Rectangle2D b = ItemBounds.Table[entries[i].ItemID];
|
||||
|
||||
current++;
|
||||
}
|
||||
AddImageTiledButton(x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entries[i].ItemID,
|
||||
entries[i].Hue, 40 - b.Width / 2 - b.X, 30 - b.Height / 2 - b.Y, entries[i].Tooltip);
|
||||
AddHtmlLocalized(x + 84, y, 250, 60, entries[i].Name, 0x7FFF, false, false);
|
||||
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -484,8 +481,7 @@ namespace Server.Spells.Ninjitsu
|
|||
{
|
||||
#region Dueling
|
||||
|
||||
if ((m_Caster as PlayerMobile)?.DuelContext != null &&
|
||||
!((PlayerMobile)m_Caster).DuelContext.AllowSpellCast(m_Caster, m_Spell))
|
||||
if ((m_Caster as PlayerMobile)?.DuelContext?.AllowSpellCast(m_Caster, m_Spell) == false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,12 +48,9 @@ namespace Server.Spells.Ninjitsu
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
DeathStrikeInfo info = m_Table[defender];
|
||||
|
||||
int damageBonus = 0;
|
||||
|
||||
if (info != null)
|
||||
if (m_Table.TryGetValue(defender, out DeathStrikeInfo info))
|
||||
{
|
||||
defender.SendLocalizedMessage(1063092); // Your opponent lands another Death Strike!
|
||||
|
||||
|
|
@ -86,18 +83,13 @@ namespace Server.Spells.Ninjitsu
|
|||
|
||||
public static void AddStep(Mobile m)
|
||||
{
|
||||
DeathStrikeInfo info = m_Table[m];
|
||||
if (info == null)
|
||||
return;
|
||||
|
||||
if (++info.m_Steps >= 5)
|
||||
if (m_Table.TryGetValue(m, out DeathStrikeInfo info) && ++info.m_Steps >= 5)
|
||||
ProcessDeathStrike(m);
|
||||
}
|
||||
|
||||
private static void ProcessDeathStrike(Mobile defender)
|
||||
{
|
||||
DeathStrikeInfo info = m_Table[defender];
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(defender, out DeathStrikeInfo info))
|
||||
return;
|
||||
|
||||
int damage;
|
||||
|
|
|
|||
|
|
@ -81,20 +81,16 @@ namespace Server.Spells.Ninjitsu
|
|||
|
||||
public override void OnClearMove(Mobile from)
|
||||
{
|
||||
KiAttackInfo info = m_Table[from];
|
||||
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(from, out KiAttackInfo info))
|
||||
return;
|
||||
|
||||
info.m_Timer?.Stop();
|
||||
info.m_Timer.Stop();
|
||||
m_Table.Remove(info.m_Mobile);
|
||||
}
|
||||
|
||||
public static double GetBonus(Mobile from)
|
||||
{
|
||||
KiAttackInfo info = m_Table[from];
|
||||
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(from, out KiAttackInfo info))
|
||||
return 0;
|
||||
|
||||
int xDelta = info.m_Location.X - from.X;
|
||||
|
|
|
|||
|
|
@ -39,24 +39,18 @@ namespace Server.Spells.Ninjitsu
|
|||
if (m == null)
|
||||
return;
|
||||
|
||||
if (m_CloneCount.ContainsKey(m))
|
||||
m_CloneCount[m]++;
|
||||
else
|
||||
m_CloneCount[m] = 1;
|
||||
m_CloneCount[m] = 1 + (m_CloneCount.TryGetValue(m, out int count) ? count : 0);
|
||||
}
|
||||
|
||||
public static void RemoveClone(Mobile m)
|
||||
{
|
||||
if (m == null)
|
||||
if (m == null || !m_CloneCount.TryGetValue(m, out int count))
|
||||
return;
|
||||
|
||||
if (m_CloneCount.ContainsKey(m))
|
||||
{
|
||||
if (count <= 1)
|
||||
m_CloneCount.Remove(m);
|
||||
else
|
||||
m_CloneCount[m]--;
|
||||
|
||||
if (m_CloneCount[m] == 0)
|
||||
m_CloneCount.Remove(m);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CheckCast()
|
||||
|
|
@ -272,4 +266,4 @@ namespace Server.Mobiles
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,7 @@ namespace Server.Spells.Ninjitsu
|
|||
|
||||
attacker.RevealingAction();
|
||||
|
||||
SurpriseAttackInfo info = m_Table[defender];
|
||||
|
||||
if (info != null)
|
||||
if (m_Table.TryGetValue(defender, out SurpriseAttackInfo info))
|
||||
{
|
||||
info.m_Timer?.Stop();
|
||||
|
||||
|
|
@ -85,9 +83,7 @@ namespace Server.Spells.Ninjitsu
|
|||
|
||||
public static bool GetMalus(Mobile target, ref int malus)
|
||||
{
|
||||
SurpriseAttackInfo info = m_Table[target];
|
||||
|
||||
if (info == null)
|
||||
if (!m_Table.TryGetValue(target, out SurpriseAttackInfo info))
|
||||
return false;
|
||||
|
||||
malus = info.m_Malus;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue