Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -5,12 +5,12 @@ namespace Server.Engines.Doom
{
public class LampRoomRegion : BaseRegion
{
private LeverPuzzleController Controller;
private LeverPuzzleController m_Controller;
public LampRoomRegion(LeverPuzzleController controller)
: base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), LeverPuzzleController.lr_Rect)
{
Controller = controller;
m_Controller = controller;
Register();
}
@ -38,13 +38,13 @@ namespace Server.Engines.Doom
if (m.AccessLevel > AccessLevel.Player)
return;
if (Controller.Successful != null)
if (m_Controller.Successful != null)
{
if (m is PlayerMobile)
{
if (m == Controller.Successful) return;
if (m == m_Controller.Successful) return;
}
else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == Controller.Successful ||
else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == m_Controller.Successful ||
bc.Summoned))
{
return;
@ -57,49 +57,36 @@ namespace Server.Engines.Doom
public override void OnExit(Mobile m)
{
if (m != null && m == Controller.Successful)
Controller.RemoveSuccessful();
if (m != null && m == m_Controller.Successful)
m_Controller.RemoveSuccessful();
}
public override void OnDeath(Mobile m)
{
if (m != null && !m.Deleted && !(m is WandererOfTheVoid))
{
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
kick.Start();
}
if (m?.Deleted != false || m is WandererOfTheVoid)
return;
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
kick.Start();
}
public override bool OnSkillUse(Mobile m, int Skill) /* just in case */
{
if (Controller.Successful == null || m.AccessLevel == AccessLevel.Player && m != Controller.Successful)
return false;
return true;
return m_Controller.Successful != null && (m.AccessLevel != AccessLevel.Player || m == m_Controller.Successful);
}
}
public class LeverPuzzleRegion : BaseRegion
{
private LeverPuzzleController Controller;
public Mobile m_Occupant;
public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc)
: base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0], loc[1], 1, 1))
{
Controller = controller;
Register();
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Occupant
{
get
{
if (m_Occupant != null && m_Occupant.Alive)
return m_Occupant;
return null;
}
}
public Mobile Occupant => m_Occupant?.Alive == true ? m_Occupant : null;
public override void OnEnter(Mobile m)
{
@ -113,4 +100,4 @@ namespace Server.Engines.Doom
m_Occupant = null;
}
}
}
}