Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Spells;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -35,7 +36,7 @@ namespace Server.Items
|
|||
{
|
||||
Map map = Map;
|
||||
|
||||
if (map != null && map.GetSector(GetWorldLocation()).Active)
|
||||
if (map?.GetSector(GetWorldLocation()).Active == true)
|
||||
StartTimer();
|
||||
else
|
||||
StopTimer();
|
||||
|
|
@ -81,27 +82,16 @@ namespace Server.Items
|
|||
if (Deleted)
|
||||
return;
|
||||
|
||||
bool foundPlayer = false;
|
||||
|
||||
foreach (Mobile mob in GetMobilesInRange(3))
|
||||
{
|
||||
if (!mob.Player || !mob.Alive || mob.AccessLevel > AccessLevel.Player)
|
||||
continue;
|
||||
|
||||
if (Z + 8 >= mob.Z && mob.Z + 16 > Z)
|
||||
{
|
||||
foundPlayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool foundPlayer = GetMobilesInRange(3)
|
||||
.Where(mob => mob.Player && mob.Alive && mob.AccessLevel <= AccessLevel.Player)
|
||||
.Any(mob => Z + 8 >= mob.Z && mob.Z + 16 > Z);
|
||||
|
||||
if (!foundPlayer)
|
||||
{
|
||||
m_Spurt?.Delete();
|
||||
|
||||
m_Spurt = null;
|
||||
}
|
||||
else if (m_Spurt == null || m_Spurt.Deleted)
|
||||
else if (m_Spurt?.Deleted != false)
|
||||
{
|
||||
m_Spurt = new Static(0x3709);
|
||||
m_Spurt.MoveToWorld(Location, Map);
|
||||
|
|
@ -115,13 +105,13 @@ namespace Server.Items
|
|||
if (m.AccessLevel > AccessLevel.Player)
|
||||
return true;
|
||||
|
||||
if (m.Player && m.Alive)
|
||||
{
|
||||
CheckTimer();
|
||||
if (!(m.Player && m.Alive))
|
||||
return false;
|
||||
|
||||
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 30));
|
||||
m.PlaySound(m.Female ? 0x327 : 0x437);
|
||||
}
|
||||
CheckTimer();
|
||||
|
||||
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 30));
|
||||
m.PlaySound(m.Female ? 0x327 : 0x437);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -130,19 +120,17 @@ namespace Server.Items
|
|||
{
|
||||
base.OnMovement(m, oldLocation);
|
||||
|
||||
if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player)
|
||||
if (m.Location == oldLocation || !m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player
|
||||
|| !CheckRange(m.Location, oldLocation, 1))
|
||||
return;
|
||||
|
||||
if (CheckRange(m.Location, oldLocation, 1))
|
||||
{
|
||||
CheckTimer();
|
||||
CheckTimer();
|
||||
|
||||
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 10));
|
||||
m.PlaySound(m.Female ? 0x327 : 0x437);
|
||||
SpellHelper.Damage(TimeSpan.FromTicks(1), m, m, Utility.RandomMinMax(1, 10));
|
||||
m.PlaySound(m.Female ? 0x327 : 0x437);
|
||||
|
||||
if (m.Body.IsHuman)
|
||||
m.Animate(20, 1, 1, true, false, 0);
|
||||
}
|
||||
if (m.Body.IsHuman)
|
||||
m.Animate(20, 1, 1, true, false, 0);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -175,4 +163,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,22 +13,17 @@ namespace Server.Items
|
|||
public class GasTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public GasTrap() : this(GasTrapType.Floor)
|
||||
public GasTrap() : this(Poison.Lesser)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GasTrap(GasTrapType type) : this(type, Poison.Lesser)
|
||||
public GasTrap(Poison poison) : this(GasTrapType.Floor, poison)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GasTrap(Poison poison) : this(GasTrapType.Floor, Poison.Lesser)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public GasTrap(GasTrapType type, Poison poison) : base(GetBaseID(type))
|
||||
public GasTrap(GasTrapType type, Poison poison = null) : base(GetBaseID(type))
|
||||
{
|
||||
Poison = poison;
|
||||
}
|
||||
|
|
@ -112,4 +107,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,7 @@ namespace Server.Items
|
|||
public class SawTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public SawTrap() : this(SawTrapType.NorthFloor)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SawTrap(SawTrapType type) : base(GetBaseID(type))
|
||||
public SawTrap(SawTrapType type = SawTrapType.NorthFloor) : base(GetBaseID(type))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -91,4 +86,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,7 @@ namespace Server.Items
|
|||
public class SpikeTrap : BaseTrap
|
||||
{
|
||||
[Constructible]
|
||||
public SpikeTrap() : this(SpikeTrapType.WestFloor)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SpikeTrap(SpikeTrapType type) : base(GetBaseID(type))
|
||||
public SpikeTrap(SpikeTrapType type = SpikeTrapType.WestFloor) : base(GetBaseID(type))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -153,4 +148,4 @@ namespace Server.Items
|
|||
Extended = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue