Fixes more casting

This commit is contained in:
Kamron Batman 2018-08-19 11:04:07 +08:00
parent 61937d9c97
commit e77d695684
91 changed files with 512 additions and 908 deletions

View file

@ -427,9 +427,7 @@ namespace Server.Engines.Quests.Hag
public override void OnRead()
{
FindIngredientObjective obj = System.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;
if ( obj != null )
if ( System.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj )
System.AddObjective( new FindIngredientObjective( obj.Ingredients, true ) );
}
}
@ -627,9 +625,7 @@ namespace Server.Engines.Quests.Hag
public override void OnRead()
{
FindIngredientObjective obj = System.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;
if ( obj != null )
if ( System.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj )
obj.NextStep();
}

View file

@ -62,17 +62,13 @@ namespace Server.Engines.Quests.Hag
if ( !from.InRange( this.GetWorldLocation(), 2 ) )
return;
PlayerMobile player = from as PlayerMobile;
if ( player != null )
if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest )
{
FindApprenticeObjective obj = qs.FindObjective( typeof( FindApprenticeObjective ) ) as FindApprenticeObjective;
if ( obj != null && !obj.Completed )
if ( qs.FindObjective( typeof( FindApprenticeObjective ) ) is FindApprenticeObjective obj && !obj.Completed )
{
if ( obj.Corpse == this )
{
@ -106,4 +102,4 @@ namespace Server.Engines.Quests.Hag
int version = reader.ReadInt();
}
}
}
}

View file

@ -25,17 +25,13 @@ namespace Server.Engines.Quests.Hag
from.PlaySound( 0x3D );
PlayerMobile player = from as PlayerMobile;
if ( player != null )
if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest )
{
FindZeefzorpulObjective obj = qs.FindObjective( typeof( FindZeefzorpulObjective ) ) as FindZeefzorpulObjective;
if ( obj != null && !obj.Completed )
if ( qs.FindObjective( typeof( FindZeefzorpulObjective ) ) is FindZeefzorpulObjective obj && !obj.Completed )
{
if ( ( player.Map != Map.Trammel && player.Map != Map.Felucca ) || !player.InRange( obj.ImpLocation, 8 ) )
{

View file

@ -58,9 +58,7 @@ namespace Server.Engines.Quests.Hag
if ( qs is WitchApprenticeQuest )
{
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.Whiskey )
if ( qs.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj && !obj.Completed && obj.Ingredient == Ingredient.Whiskey )
{
PlaySound( Utility.RandomBool() ? 0x42E : 0x43F );
@ -71,10 +69,7 @@ namespace Server.Engines.Quests.Hag
{
obj.Complete();
if ( obj.BlackheartMet )
qs.AddConversation( new BlackheartPirateConversation( false ) );
else
qs.AddConversation( new BlackheartPirateConversation( true ) );
qs.AddConversation( new BlackheartPirateConversation( !obj.BlackheartMet ) );
}
else if ( !obj.BlackheartMet )
{

View file

@ -138,10 +138,10 @@ namespace Server.Engines.Quests.Hag
{
item = Loot.RandomArmorOrShieldOrJewelry();
if ( item is BaseArmor )
BaseRunicTool.ApplyAttributesTo( (BaseArmor)item, 2, 20, 30 );
else if ( item is BaseJewel )
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, 2, 20, 30 );
if ( item is BaseArmor armor )
BaseRunicTool.ApplyAttributesTo( armor, 2, 20, 30 );
else if ( item is BaseJewel jewel )
BaseRunicTool.ApplyAttributesTo( jewel, 2, 20, 30 );
}
else
{

View file

@ -75,9 +75,7 @@ namespace Server.Engines.Quests.Hag
private void DeleteImp( object imp )
{
Mobile m = imp as Mobile;
if ( m != null && !m.Deleted )
if ( imp is Mobile m && !m.Deleted )
{
Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 );
Effects.PlaySound( m.Location, m.Map, 0x1FE );
@ -269,9 +267,7 @@ namespace Server.Engines.Quests.Hag
private void DeleteImp( object imp )
{
Mobile m = imp as Mobile;
if ( m != null && !m.Deleted )
if ( imp is Mobile m && !m.Deleted )
{
Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 );
Effects.PlaySound( m.Location, m.Map, 0x1FE );