Fixes more casting and other formatting issues.

This commit is contained in:
Kamron Batman 2018-08-19 10:14:40 +08:00
parent 03dd5f1926
commit 61937d9c97
67 changed files with 325 additions and 570 deletions

View file

@ -130,9 +130,7 @@ namespace Server.Engines.Quests.Necro
public static bool HasLostCallingScroll( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
if ( !(from is PlayerMobile pm) )
return false;
QuestSystem qs = pm.Quest;
@ -141,9 +139,7 @@ namespace Server.Engines.Quests.Necro
{
if ( qs.IsObjectiveInProgress( typeof( FindMardothAboutKronusObjective ) ) || qs.IsObjectiveInProgress( typeof( FindWellOfTearsObjective ) ) || qs.IsObjectiveInProgress( typeof( UseCallingScrollObjective ) ) )
{
Container pack = from.Backpack;
return ( pack == null || pack.FindItemByType( typeof( KronusScroll ) ) == null );
return ( from.Backpack?.FindItemByType( typeof( KronusScroll ) ) == null );
}
}

View file

@ -25,9 +25,7 @@ namespace Server.Engines.Quests.Necro
if ( m is BaseCreature )
m = ((BaseCreature)m).ControlMaster;
PlayerMobile pm = m as PlayerMobile;
if ( pm != null )
if ( m is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
@ -69,4 +67,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
}
}

View file

@ -11,9 +11,7 @@ namespace Server.Engines.Quests.Necro
{
public override bool ValidateUse( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
return ( pm != null && pm.Quest is DarkTidesQuest );
return ( from is PlayerMobile pm && pm.Quest is DarkTidesQuest );
}
[Constructible]
@ -41,4 +39,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
}
}

View file

@ -23,16 +23,12 @@ namespace Server.Engines.Quests.Necro
public override bool CanDrop( PlayerMobile player )
{
DarkTidesQuest qs = player.Quest as DarkTidesQuest;
if ( qs == null )
return true;
return !(player.Quest is DarkTidesQuest);
/*return !( qs.IsObjectiveInProgress( typeof( FindCallingScrollObjective ) )
|| qs.IsObjectiveInProgress( typeof( FindMardothAboutKronusObjective ) )
|| qs.IsObjectiveInProgress( typeof( FindWellOfTearsObjective ) )
|| qs.IsObjectiveInProgress( typeof( UseCallingScrollObjective ) ) );*/
return false;
}
private static readonly Rectangle2D m_WellOfTearsArea = new Rectangle2D( 2080, 1346, 10, 10 );
@ -43,9 +39,7 @@ namespace Server.Engines.Quests.Necro
if ( !IsChildOf( from ) )
return;
PlayerMobile pm = from as PlayerMobile;
if ( pm != null )
if ( from is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;

View file

@ -27,9 +27,7 @@ namespace Server.Engines.Quests.Necro
public override void OnDoubleClick( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm != null && pm.InRange( GetWorldLocation(), 2 ) )
if ( from is PlayerMobile pm && pm.InRange( GetWorldLocation(), 2 ) )
{
QuestSystem qs = pm.Quest;
@ -74,4 +72,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
}
}

View file

@ -107,8 +107,8 @@ namespace Server.Engines.Quests.Necro
[CommandProperty( AccessLevel.GameMaster )]
public Point3D SpawnLocation
{
get { return Addon is MaabusCoffin ? ((MaabusCoffin)Addon).SpawnLocation : Point3D.Zero; }
set { if ( Addon is MaabusCoffin ) ((MaabusCoffin)Addon).SpawnLocation = value; }
get { return Addon is MaabusCoffin coffin ? coffin.SpawnLocation : Point3D.Zero; }
set { if ( Addon is MaabusCoffin coffin ) coffin.SpawnLocation = value; }
}
public MaabusCoffinComponent( int itemID ) : this( itemID, itemID )

View file

@ -20,22 +20,16 @@ namespace Server.Engines.Quests.Necro
public override bool CanDrop( PlayerMobile player )
{
DarkTidesQuest qs = player.Quest as DarkTidesQuest;
if ( qs == null )
return true;
return !(player.Quest is DarkTidesQuest);
//return !( qs.IsObjectiveInProgress( typeof( RetrieveAbraxusScrollObjective ) ) || qs.IsObjectiveInProgress( typeof( ReadAbraxusScrollObjective ) ) );
return false;
}
public override void OnAdded(IEntity parent)
{
base.OnAdded( parent );
PlayerMobile pm = RootParent as PlayerMobile;
if ( pm != null )
if ( RootParent is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;
@ -55,9 +49,7 @@ namespace Server.Engines.Quests.Necro
{
from.SendGump( new ScrollOfAbraxusGump() );
PlayerMobile pm = from as PlayerMobile;
if ( pm != null )
if ( from is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;

View file

@ -21,9 +21,7 @@ namespace Server.Engines.Quests.Necro
if ( m.AccessLevel > AccessLevel.Player )
return true;
PlayerMobile pm = m as PlayerMobile;
if ( pm != null && pm.Profession == 4 )
if ( m is PlayerMobile pm && pm.Profession == 4 )
{
m.SendLocalizedMessage( 1060188, "", 0x24 ); // The wicked may not enter!
return false;
@ -50,4 +48,4 @@ namespace Server.Engines.Quests.Necro
int version = reader.ReadInt();
}
}
}
}

View file

@ -74,9 +74,8 @@ namespace Server.Engines.Quests.Necro
{
base.OnMovement( m, oldLocation );
if ( InRange( m.Location, 2 ) && !InRange( oldLocation, 2 ) && m is PlayerMobile )
if ( InRange( m.Location, 2 ) && !InRange( oldLocation, 2 ) && m is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)m;
QuestSystem qs = pm.Quest;
if ( qs is DarkTidesQuest )
@ -121,9 +120,7 @@ namespace Server.Engines.Quests.Necro
if ( from.Alive )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm != null )
if ( from is PlayerMobile pm )
{
QuestSystem qs = pm.Quest;

View file

@ -27,20 +27,16 @@ namespace Server.Engines.Quests.Necro
public override bool OnDragDrop( Mobile from, Item dropped )
{
PlayerMobile player = from as PlayerMobile;
if ( player != null )
if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is DarkTidesQuest )
{
if ( dropped is DarkTidesHorn )
if ( dropped is DarkTidesHorn horn )
{
if ( player.Young )
{
DarkTidesHorn horn = (DarkTidesHorn)dropped;
if ( horn.Charges < 10 )
{
SayTo( from, 1049384 ); // I have recharged the item for you.
@ -93,9 +89,7 @@ namespace Server.Engines.Quests.Necro
public override bool CanTalkTo( PlayerMobile to )
{
DarkTidesQuest qs = to.Quest as DarkTidesQuest;
if ( qs == null )
if ( !(to.Quest is DarkTidesQuest qs) )
return ( to.Quest == null && QuestSystem.CanOfferQuest( to, typeof( DarkTidesQuest ) ) );
return ( qs.FindObjective( typeof( FindMardothAboutVaultObjective ) ) != null );

View file

@ -225,9 +225,7 @@ namespace Server.Engines.Quests.Necro
{
if ( System.From.Map == Map.Malas && System.From.InRange( new Point3D( 1076, 450, -84 ), 5 ) )
{
HordeMinionFamiliar hmf = Spells.Necromancy.SummonFamiliarSpell.Table[System.From] as HordeMinionFamiliar;
if ( hmf != null && hmf.InRange( System.From, 5 ) && hmf.TargetLocation == null )
if ( Spells.Necromancy.SummonFamiliarSpell.Table[System.From] is HordeMinionFamiliar hmf && hmf.InRange( System.From, 5 ) && hmf.TargetLocation == null )
{
System.From.SendLocalizedMessage( 1060113 ); // You instinctively will your familiar to fetch the scroll for you.
hmf.TargetLocation = new Point2D( 1076, 450 );