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

@ -51,7 +51,7 @@ namespace Server.Factions
from.SendLocalizedMessage( 1005242 ); // Only faction Leaders can use townstones
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( @from is PlayerMobile mobile )
else if ( from is PlayerMobile mobile )
mobile.SendGump( new TownStoneGump( mobile, m_Town.Owner, m_Town ) );
}

View file

@ -48,7 +48,7 @@ namespace Server.Factions
PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1042201, from.NetState ); // You are not in my faction, I cannot sell you a horse!
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( @from is PlayerMobile mobile )
else if ( from is PlayerMobile mobile )
mobile.SendGump( new HorseBreederGump( mobile, this.Faction ) );
}

View file

@ -228,7 +228,7 @@ namespace Server.Engines.Harvest
if ( type == typeof( TreasureMap ) )
{
int level;
if ( @from is PlayerMobile mobile && mobile.Young && mobile.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
if ( from is PlayerMobile mobile && mobile.Young && mobile.Map == Map.Trammel && TreasureMap.IsInHavenIsland( from ) )
level = 0;
else
level = 1;

View file

@ -162,10 +162,10 @@ namespace Server.Engines.Harvest
public override void OnBadHarvestTarget( Mobile from, Item tool, object toHarvest )
{
if ( toHarvest is Mobile )
( (Mobile)toHarvest ).PrivateOverheadMessage( MessageType.Regular, 0x3B2, 500450, from.NetState ); // You can only skin dead creatures.
else if ( toHarvest is Item )
( (Item)toHarvest ).LabelTo( from, 500464 ); // Use this on corpses to carve away meat and hide
if ( toHarvest is Mobile mobile )
mobile.PrivateOverheadMessage( MessageType.Regular, 0x3B2, 500450, from.NetState ); // You can only skin dead creatures.
else if ( toHarvest is Item item )
item.LabelTo( from, 500464 ); // Use this on corpses to carve away meat and hide
else if ( toHarvest is Targeting.StaticTarget || toHarvest is Targeting.LandTarget )
from.SendLocalizedMessage( 500489 ); // You can't use an axe on that.
else

View file

@ -194,8 +194,7 @@ namespace Server.Engines.Harvest
{
if ( def == m_OreAndStone )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm != null && pm.StoneMining && pm.ToggleMiningStone && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
if ( from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone && from.Skills[SkillName.Mining].Base >= 100.0 && 0.1 > Utility.RandomDouble() )
return resource.Types[1];
return resource.Types[0];
@ -236,17 +235,17 @@ namespace Server.Engines.Harvest
if ( !base.CheckHarvest( from, tool, def, toHarvest ) )
return false;
if ( def == m_Sand && !(from is PlayerMobile && from.Skills[SkillName.Mining].Base >= 100.0 && ((PlayerMobile)from).SandMining) )
if ( def == m_Sand && !(from is PlayerMobile mobile && mobile.Skills[SkillName.Mining].Base >= 100.0 && mobile.SandMining) )
{
OnBadHarvestTarget( from, tool, toHarvest );
return false;
}
else if ( from.Mounted )
if ( from.Mounted )
{
from.SendLocalizedMessage( 501864 ); // You can't mine while riding.
return false;
}
else if ( from.IsBodyMod && !from.Body.IsHuman )
if ( from.IsBodyMod && !from.Body.IsHuman )
{
from.SendLocalizedMessage( 501865 ); // You can't mine while polymorphed.
return false;
@ -295,9 +294,7 @@ namespace Server.Engines.Harvest
if ( map == null )
return;
BaseCreature spawned = Activator.CreateInstance( res.Types[2], new object[]{ 25 } ) as BaseCreature;
if ( spawned != null )
if ( Activator.CreateInstance( res.Types[2], new object[]{ 25 } ) is BaseCreature spawned )
{
int offset = Utility.Random( 8 ) * 2;
@ -313,17 +310,15 @@ namespace Server.Engines.Harvest
spawned.Combatant = from;
return;
}
else
{
int z = map.GetAverageZ( x, y );
if ( Math.Abs( z - from.Z ) < 10 && map.CanSpawnMobile( x, y, z ) )
{
spawned.OnBeforeSpawn( new Point3D( x, y, z ), map );
spawned.MoveToWorld( new Point3D( x, y, z ), map );
spawned.Combatant = from;
return;
}
int z = map.GetAverageZ( x, y );
if ( Math.Abs( z - from.Z ) < 10 && map.CanSpawnMobile( x, y, z ) )
{
spawned.OnBeforeSpawn( new Point3D( x, y, z ), map );
spawned.MoveToWorld( new Point3D( x, y, z ), map );
spawned.Combatant = from;
return;
}
}
@ -430,4 +425,4 @@ namespace Server.Engines.Harvest
};
#endregion
}
}
}

View file

@ -74,10 +74,7 @@ namespace Server.Engines.Help
private static bool IsYoung( Mobile m )
{
if ( m is PlayerMobile )
return ((PlayerMobile)m).Young;
return false;
return m is PlayerMobile mobile && mobile.Young;
}
public static bool CheckCombat( Mobile m )
@ -162,21 +159,21 @@ namespace Server.Engines.Help
* Use this option when another player is verbally harassing your character.
* Verbal harassment behaviors include but are not limited to, using bad language, threats etc..
* Before you submit a complaint be sure you understand what constitutes harassment
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=40">– what is verbal harassment? -</A>
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=40"><EFBFBD> what is verbal harassment? -</A>
* and that you have followed these steps:<BR>
* 1. You have asked the player to stop and they have continued.<BR>
* 2. You have tried to remove yourself from the situation.<BR>
* 3. You have done nothing to instigate or further encourage the harassment.<BR>
* 4. You have added the player to your ignore list.
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=138">- How do I ignore a player?</A><BR>
* 5. You have read and understand Origin’s definition of harassment.<BR>
* 5. You have read and understand Origin<EFBFBD>s definition of harassment.<BR>
* 6. Your account information is up to date. (Including a current email address)<BR>
* *If these steps have not been taken, GMs may be unable to take action against the offending player.<BR>
* **A chat log will be review by a GM to assess the validity of this complaint.
* Abuse of this system is a violation of the Rules of Conduct.<BR>
* EXPLOITING<BR>
* Use this option to report someone who may be exploiting or cheating.
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=41">– What constitutes an exploit?</a>
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=41"><EFBFBD> What constitutes an exploit?</a>
*/
AddButton( 80, 240, 5540, 5541, 8, GumpButtonType.Reply, 0 );
@ -186,14 +183,14 @@ namespace Server.Engines.Help
* Use this option when another player is harassing your character using game mechanics.
* Physical harassment includes but is not limited to luring, Kill Stealing, and any act that causes a players death in Trammel.
* Before you submit a complaint be sure you understand what constitutes harassment
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=59"> – what is physical harassment?</A>
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=59"> <EFBFBD> what is physical harassment?</A>
* and that you have followed these steps:<BR>
* 1. You have asked the player to stop and they have continued.<BR>
* 2. You have tried to remove yourself from the situation.<BR>
* 3. You have done nothing to instigate or further encourage the harassment.<BR>
* 4. You have added the player to your ignore list.
* <A HREF="http://uo.custhelp.com/cgi-bin/uo.cfg/php/enduser/std_adp.php?p_faqid=138"> - how do I ignore a player?</A><BR>
* 5. You have read and understand Origin’s definition of harassment.<BR>
* 5. You have read and understand Origin<EFBFBD>s definition of harassment.<BR>
* 6. Your account information is up to date. (Including a current email address)<BR>
* *If these steps have not been taken, GMs may be unable to take action against the offending player.<BR>
* **This issue will be reviewed by a GM to assess the validity of this complaint.
@ -239,13 +236,13 @@ namespace Server.Engines.Help
{
from.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
}
else if ( from is PlayerMobile && ((PlayerMobile)from).CanUseStuckMenu() && from.Region.CanUseStuckMenu( from ) && !CheckCombat( from ) && !from.Frozen && !from.Criminal && (Core.AOS || from.Kills < 5) )
else if ( from is PlayerMobile mobile && mobile.CanUseStuckMenu() && mobile.Region.CanUseStuckMenu( mobile ) && !CheckCombat( mobile ) && !mobile.Frozen && !mobile.Criminal && (Core.AOS || mobile.Kills < 5) )
{
StuckMenu menu = new StuckMenu( from, from, true );
StuckMenu menu = new StuckMenu( mobile, mobile, true );
menu.BeginClose();
from.SendGump( menu );
mobile.SendGump( menu );
}
else
{
@ -310,4 +307,4 @@ namespace Server.Engines.Help
from.SendGump( new PagePromptGump( from, type ) );
}
}
}
}

View file

@ -149,8 +149,7 @@ namespace Server.Engines.Help
m_PageLocation = sender.Location;
m_PageMap = sender.Map;
PlayerMobile pm = sender as PlayerMobile;
if ( pm != null && pm.SpeechLog != null && Array.IndexOf( SpeechLogAttachment, type ) >= 0 )
if ( sender is PlayerMobile pm && pm.SpeechLog != null && Array.IndexOf( SpeechLogAttachment, type ) >= 0 )
m_SpeechLog = new List<SpeechLogEntry>( pm.SpeechLog );
m_Timer = new InternalTimer( this );
@ -183,7 +182,7 @@ namespace Server.Engines.Help
if ( m_Entry.Sender.NetState != null && index != -1 )
{
m_Entry.Sender.SendLocalizedMessage( 1008077, true, (index + 1).ToString() ); // Thank you for paging. Queue status :
m_Entry.Sender.SendLocalizedMessage( 1008077, true, (index + 1).ToString() ); // Thank you for paging. Queue status :
m_Entry.Sender.SendLocalizedMessage( 1008084 ); // You can reference our website at www.uo.com or contact us at support@uo.com. To cancel your page, please select the help button again and select cancel.
if ( m_Entry.Handler != null && m_Entry.Handler.NetState == null ) {
@ -214,9 +213,7 @@ namespace Server.Engines.Help
public static bool CheckAllowedToPage( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
if ( !(from is PlayerMobile pm) )
return true;
if ( pm.DesignContext != null )
@ -224,7 +221,7 @@ namespace Server.Engines.Help
from.SendLocalizedMessage( 500182 ); // You cannot request help while customizing a house or transferring a character.
return false;
}
else if ( pm.PagingSquelched )
if ( pm.PagingSquelched )
{
from.SendMessage( "You cannot request help, sorry." );
return false;
@ -392,4 +389,4 @@ namespace Server.Engines.Help
Email.AsyncSend( mail );
}
}
}
}

View file

@ -43,9 +43,7 @@ namespace Server.Engines.Help
protected override void OnTarget( Mobile from, object targeted )
{
PlayerMobile pm = targeted as PlayerMobile;
if ( pm == null )
if ( !(targeted is PlayerMobile pm) )
{
from.SendMessage( "Speech logs aren't supported on that target." );
}
@ -145,4 +143,4 @@ namespace Server.Engines.Help
m_Created = DateTime.UtcNow;
}
}
}
}

View file

@ -133,8 +133,8 @@ namespace Server.Menus.Questions
m_Mobile = beheld;
m_MarkUse = markUse;
Closable = false;
Dragable = false;
Closable = false;
Dragable = false;
Disposable = false;
AddBackground( 0, 0, 270, 320, 2600 );
@ -198,14 +198,14 @@ namespace Server.Menus.Questions
private void Teleport( StuckMenuEntry entry )
{
if ( m_MarkUse )
if ( m_MarkUse )
{
m_Mobile.SendLocalizedMessage( 1010589 ); // You will be teleported within the next two minutes.
new TeleportTimer( m_Mobile, entry, TimeSpan.FromSeconds( 10.0 + (Utility.RandomDouble() * 110.0) ) ).Start();
if (m_Mobile is PlayerMobile)
((PlayerMobile)m_Mobile).UsedStuckMenu();
if (m_Mobile is PlayerMobile mobile)
mobile.UsedStuckMenu();
}
else
{
@ -237,8 +237,8 @@ namespace Server.Menus.Questions
{
m_Mobile.Frozen = true;
}
}
}
}
}
private class TeleportTimer : Timer
{
@ -289,4 +289,4 @@ namespace Server.Menus.Questions
}
}
}
}
}

View file

@ -7,19 +7,19 @@ namespace Server.Commands
public class GenKhaldun
{
private static int m_Count;
public static void Initialize()
{
CommandSystem.Register( "GenKhaldun", AccessLevel.Administrator, new CommandEventHandler( GenKhaldun_OnCommand ) );
}
public static bool FindMorphItem( int x, int y, int z, int inactiveItemID, int activeItemID )
{
IPooledEnumerable<Item> eable = Map.Felucca.GetItemsInRange( new Point3D( x, y, z ), 0 );
foreach ( Item item in eable )
{
if ( item is MorphItem && item.Z == z && ((MorphItem)item).InactiveItemID == inactiveItemID && ((MorphItem)item).ActiveItemID == activeItemID )
if ( item is MorphItem morphItem && morphItem.Z == z && morphItem.InactiveItemID == inactiveItemID && morphItem.ActiveItemID == activeItemID )
{
eable.Free();
return true;
@ -29,7 +29,7 @@ namespace Server.Commands
eable.Free();
return false;
}
public static bool FindEffectController( int x, int y, int z )
{
IPooledEnumerable eable = Map.Felucca.GetItemsInRange( new Point3D( x, y, z ), 0 );
@ -46,7 +46,7 @@ namespace Server.Commands
eable.Free();
return false;
}
public static Item TryCreateItem( int x, int y, int z, Item srcItem )
{
IPooledEnumerable<Item> eable = Map.Felucca.GetItemsInBounds( new Rectangle2D( x, y, 1, 1 ) );
@ -64,68 +64,68 @@ namespace Server.Commands
eable.Free();
srcItem.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
return srcItem;
}
public static void CreateMorphItem( int x, int y, int z, int inactiveItemID, int activeItemID, int range )
{
if ( FindMorphItem( x, y, z, inactiveItemID, activeItemID ) )
return;
MorphItem item = new MorphItem( inactiveItemID, activeItemID, range, 3 );
item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
}
public static void CreateApproachLight( int x, int y, int z, int off, int on, LightType light )
{
if ( FindMorphItem( x, y, z, off, on ) )
return;
MorphItem item = new MorphItem( off, on, 2, 3 );
item.Light = light;
item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
}
public static void CreateSoundEffect( int x, int y, int z, int sound, int range )
{
if ( FindEffectController( x, y, z ) )
return;
EffectController item = new EffectController();
item.SoundID = sound;
item.TriggerType = EffectTriggerType.InRange;
item.TriggerRange = range;
item.MoveToWorld( new Point3D( x, y, z ), Map.Felucca );
m_Count++;
}
public static void CreateBigTeleporterItem( int x, int y, bool reverse )
{
if ( FindMorphItem( x, y, 0, reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC ) )
return;
MorphItem item = new MorphItem( reverse ? 0x17DC : 0x17EE, reverse ? 0x17EE : 0x17DC, 1, 3 );
item.MoveToWorld( new Point3D( x, y, 0 ), Map.Felucca );
m_Count++;
}
public static void GenKhaldun_OnCommand( CommandEventArgs e )
{
m_Count = 0;
// Generate Morph Items
CreateMorphItem( 5459, 1416, 0, 0x1D0, 0x1, 1 );
CreateMorphItem( 5459, 1416, 0, 0x1D0, 0x1, 1 );
CreateMorphItem( 5460, 1416, 0, 0x1D0, 0x1, 1 );
CreateMorphItem( 5459, 1416, 0, 0x1, 0x53D, 1 );
CreateMorphItem( 5460, 1416, 0, 0x1, 0x53B, 1 );
CreateMorphItem( 5459, 1425, 0, 0x1, 0x53B, 2 );
CreateMorphItem( 5459, 1426, 0, 0x1, 0x53B, 2 );
CreateMorphItem( 5459, 1427, 0, 0x1, 0x53B, 2 );
@ -151,7 +151,7 @@ namespace Server.Commands
CreateMorphItem( 5459, 1417, 0, 0x1, 0x54C, 1 );
CreateMorphItem( 5459, 1419, 0, 0x1, 0x54C, 2 );
CreateMorphItem( 5459, 1424, 0, 0x1, 0x54C, 2 );
CreateMorphItem( 5458, 1426, 0, 0x1, 0x1D1, 2 );
CreateMorphItem( 5459, 1427, 0, 0x1, 0x1E3, 2 );
CreateMorphItem( 5458, 1425, 3, 0x1, 0x1E4, 2 );
@ -161,50 +161,50 @@ namespace Server.Commands
CreateMorphItem( 5458, 1425, 0, 0x1, 0x1EA, 2 );
CreateMorphItem( 5458, 1427, 0, 0x1, 0x1EA, 2 );
CreateMorphItem( 5458, 1427, 3, 0x1, 0x1EA, 2 );
// Generate Approach Lights
CreateApproachLight( 5393, 1417, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5393, 1420, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5395, 1421, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5396, 1417, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5397, 1419, 0, 0x1857, 0x1858, LightType.Circle150 );
CreateApproachLight( 5441, 1393, 5, 0x1F2B, 0x19BB, LightType.Circle225 );
CreateApproachLight( 5446, 1393, 5, 0x1F2B, 0x19BB, LightType.Circle225 );
// Generate Sound Effects
CreateSoundEffect( 5425, 1489, 5, 0x102, 1 );
CreateSoundEffect( 5425, 1491, 5, 0x102, 1 );
CreateSoundEffect( 5449, 1499, 10, 0xF5, 1 );
CreateSoundEffect( 5451, 1499, 10, 0xF5, 1 );
CreateSoundEffect( 5453, 1499, 10, 0xF5, 1 );
CreateSoundEffect( 5524, 1367, 0, 0x102, 1 );
CreateSoundEffect( 5450, 1370, 0, 0x220, 2 );
CreateSoundEffect( 5450, 1372, 0, 0x220, 2 );
CreateSoundEffect( 5460, 1416, 0, 0x244, 2 );
CreateSoundEffect( 5483, 1439, 5, 0x14, 3 );
// Generate Big Teleporter
CreateBigTeleporterItem( 5387, 1325, true );
CreateBigTeleporterItem( 5388, 1326, true );
CreateBigTeleporterItem( 5388, 1325, false );
CreateBigTeleporterItem( 5387, 1326, false );
// Generate Central Khaldun entrance
DisappearingRaiseSwitch sw = TryCreateItem( 5459, 1426, 10, new DisappearingRaiseSwitch() ) as DisappearingRaiseSwitch;
RaiseSwitch lv = TryCreateItem( 5403, 1359, 0, new RaiseSwitch() ) as RaiseSwitch;
RaisableItem stone = TryCreateItem( 5403, 1360, 0, new RaisableItem( 0x788, 10, 0x477, 0x475, TimeSpan.FromMinutes( 1.5 ) ) ) as RaisableItem;
RaisableItem door = TryCreateItem( 5524, 1367, 0, new RaisableItem( 0x1D0, 20, 0x477, 0x475, TimeSpan.FromMinutes( 5.0 ) ) ) as RaisableItem;
sw.RaisableItem = stone;
lv.RaisableItem = door;
e.Mobile.SendMessage( String.Format( "{0} dynamic Khaldun item{1} generated.", m_Count, m_Count == 1 ? "" : "s" ) );
}
}

View file

@ -591,16 +591,11 @@ namespace Server.Items
else
item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon )
if ( item is BaseWeapon weapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out int attributeCount, out int min, out int max );
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
}
@ -611,18 +606,13 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
}
DropItem( item );
DropItem( weapon );
}
else if ( item is BaseArmor )
else if ( item is BaseArmor armor )
{
BaseArmor armor = (BaseArmor)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out int attributeCount, out int min, out int max );
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
}
@ -632,34 +622,26 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
}
DropItem( item );
DropItem( armor );
}
else if ( item is BaseHat )
else if ( item is BaseHat hat )
{
BaseHat hat = (BaseHat)item;
if ( Core.AOS )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max );
GetRandomAOSStats( out int attributeCount, out int min, out int max );
BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
}
DropItem( item );
DropItem( hat );
}
else if ( item is BaseJewel )
else if ( item is BaseJewel jewel )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out int attributeCount, out int min, out int max );
GetRandomAOSStats( out attributeCount, out min, out max );
BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max );
DropItem( item );
DropItem( jewel );
}
}

View file

@ -126,9 +126,7 @@ namespace Server.Engines.MLQuests.Definitions
public override bool CheckItem( Item item )
{
Pitcher pitcher = item as Pitcher; // Only pitchers work
return ( pitcher != null && pitcher.Content == BeverageType.Water && pitcher.Quantity > 0 );
return ( item is Pitcher pitcher && pitcher.Content == BeverageType.Water && pitcher.Quantity > 0 );
}
}
}

View file

@ -620,9 +620,7 @@ namespace Server.Engines.MLQuests.Definitions
{
Item item = base.CreateItem();
Spellbook book = item as Spellbook;
if ( book != null )
if ( item is Spellbook book )
book.Content = ( 1ul << book.BookCount ) - 1;
return item;

View file

@ -39,9 +39,7 @@ namespace Server.Engines.MLQuests.Gumps
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if ( pm == null )
if ( !(sender.Mobile is PlayerMobile pm) )
return;
switch ( info.ButtonID )

View file

@ -193,9 +193,7 @@ namespace Server.Engines.MLQuests.Gumps
CloseCurrent( state );
PlayerMobile pm = state.Mobile as PlayerMobile;
if ( pm == null )
if ( !(state.Mobile is PlayerMobile pm) )
return;
IRaceChanger owner = raceChangeState.m_Owner;
@ -203,8 +201,7 @@ namespace Server.Engines.MLQuests.Gumps
if ( pvSrc.Size == 5 )
{
if ( owner != null )
owner.OnCancel( pm );
owner?.OnCancel( pm );
return;
}
@ -248,8 +245,7 @@ namespace Server.Engines.MLQuests.Gumps
else
pm.SendMessage( "You have fully changed your race to {0}.", targetRace.Name );
if ( owner != null )
owner.ConsumeNeeded( pm );
owner?.ConsumeNeeded( pm );
}
}
@ -319,9 +315,7 @@ namespace Server.Engines.MLQuests.Gumps
public override void OnDoubleClick( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
if ( !(from is PlayerMobile pm) )
return;
if ( CheckComplete( pm ) )

View file

@ -27,12 +27,10 @@ namespace Server.Engines.MLQuests.Items
return;
}
MLQuestContext context;
if ( from is PlayerMobile && ( context = MLQuestSystem.GetContext( (PlayerMobile)from ) ) != null && context.BedlamAccess )
if ( from is PlayerMobile mobile && MLQuestSystem.GetContext( mobile )?.BedlamAccess == true )
{
BaseCreature.TeleportPets( from, PointDest, MapDest );
from.MoveToWorld( PointDest, MapDest );
BaseCreature.TeleportPets( mobile, PointDest, MapDest );
mobile.MoveToWorld( PointDest, MapDest );
}
else
{

View file

@ -24,16 +24,12 @@ namespace Server.Items
public override void OnDoubleClick( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null || pm.Backpack == null )
if ( !(from is PlayerMobile pm) || pm.Backpack == null )
return;
if ( pm.InRange( GetWorldLocation(), 2 ) )
{
MLQuestContext context = MLQuestSystem.GetContext( pm );
if ( context != null && context.IsDoingQuest( typeof( UnfadingMemoriesPartOne ) ) && pm.Backpack.FindItemByType( typeof( PrismaticAmber ), false ) == null )
if ( MLQuestSystem.GetContext( pm )?.IsDoingQuest( typeof( UnfadingMemoriesPartOne ) ) == true && pm.Backpack.FindItemByType( typeof( PrismaticAmber ), false ) == null )
{
Item amber = new PrismaticAmber();

View file

@ -52,8 +52,8 @@ namespace Server.Engines.MLQuests.Items
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042593 ); // That is not in your backpack.
else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile )
MLQuestSystem.OnDoubleClick( this, (PlayerMobile)from );
else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile )
MLQuestSystem.OnDoubleClick( this, mobile );
}
public override void OnAfterDelete()
@ -133,8 +133,8 @@ namespace Server.Engines.MLQuests.Items
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( !IsChildOf( from.Backpack ) )
from.SendLocalizedMessage( 1042593 ); // That is not in your backpack.
else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile )
MLQuestSystem.OnDoubleClick( this, (PlayerMobile)from );
else if ( MLQuestSystem.Enabled && CanGiveMLQuest && from is PlayerMobile mobile )
MLQuestSystem.OnDoubleClick( this, mobile );
}
public override void OnAfterDelete()

View file

@ -43,14 +43,18 @@ namespace Server.Engines.MLQuests.Items
public static void Enhance( Item loot )
{
if ( loot is BaseWeapon )
BaseRunicTool.ApplyAttributesTo( (BaseWeapon)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
else if ( loot is BaseArmor )
BaseRunicTool.ApplyAttributesTo( (BaseArmor)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
else if ( loot is BaseShield )
BaseRunicTool.ApplyAttributesTo( (BaseShield)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
else if ( loot is BaseJewel )
BaseRunicTool.ApplyAttributesTo( (BaseJewel)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
switch (loot)
{
case BaseWeapon weapon:
BaseRunicTool.ApplyAttributesTo( weapon, Utility.RandomMinMax( 1, 5 ), 10, 80 );
break;
case BaseArmor armor:
BaseRunicTool.ApplyAttributesTo( armor, Utility.RandomMinMax( 1, 5 ), 10, 80 );
break;
default:
BaseRunicTool.ApplyAttributesTo((BaseJewel)loot, Utility.RandomMinMax( 1, 5 ), 10, 80 );
break;
}
}
}

View file

@ -51,23 +51,19 @@ namespace Server.Engines.MLQuests.Items
if (!base.CanTeleport(m))
return false;
if (m_QuestType != null)
{
PlayerMobile pm = m as PlayerMobile;
if (m_QuestType == null)
return true;
if (!(m is PlayerMobile pm))
return false;
if (pm == null)
return false;
MLQuestContext context = MLQuestSystem.GetContext(pm);
MLQuestContext context = MLQuestSystem.GetContext(pm);
if (context?.IsDoingQuest(m_QuestType) == true || context?.HasDoneQuest(m_QuestType) == true)
return true;
if (context == null || (!context.IsDoingQuest(m_QuestType) && !context.HasDoneQuest(m_QuestType)))
{
TextDefinition.SendMessageTo(m, m_Message);
return false;
}
}
TextDefinition.SendMessageTo(m, m_Message);
return false;
return true;
}
public override void GetProperties(ObjectPropertyList list)
@ -169,7 +165,7 @@ namespace Server.Engines.MLQuests.Items
{
foreach (Item item in m.Items) // Check paperdoll
{
if (m_TicketType.IsAssignableFrom(item.GetType()))
if (m_TicketType.IsInstanceOfType(item))
{
ticket = item;
break;
@ -183,8 +179,7 @@ namespace Server.Engines.MLQuests.Items
return false;
}
if (ticket is ITicket)
((ITicket)ticket).OnTicketUsed(m);
(ticket as ITicket)?.OnTicketUsed(m);
}
return true;

View file

@ -203,9 +203,8 @@ namespace Server.Engines.MLQuests
public override void Execute( CommandEventArgs e, object obj )
{
Mobile from = e.Mobile;
PlayerMobile pm = obj as PlayerMobile;
if ( pm == null )
if ( !(obj is PlayerMobile pm) )
{
LogFailure( "That is not a player." );
return;
@ -230,9 +229,7 @@ namespace Server.Engines.MLQuests
public override void Execute( CommandEventArgs e, object obj )
{
PlayerMobile pm = obj as PlayerMobile;
if ( pm == null )
if ( !(obj is PlayerMobile pm) )
LogFailure( "They have no ML quest context." );
else
e.Mobile.SendGump( new PropertiesGump( e.Mobile, GetOrCreateContext( pm ) ) );
@ -303,13 +300,9 @@ namespace Server.Engines.MLQuests
{
if ( item.QuestItem )
{
Backpack pack = item.Parent as Backpack;
if ( pack != null )
if ( item.Parent is Backpack pack )
{
PlayerMobile player = pack.Parent as PlayerMobile;
if ( player != null && player.Backpack == pack )
if ( pack.Parent is PlayerMobile player && player.Backpack == pack )
continue;
}
@ -487,9 +480,9 @@ namespace Server.Engines.MLQuests
foreach ( BaseObjectiveInstance objective in instance.Objectives )
{
if ( !objective.Expired && objective is GainSkillObjectiveInstance && ( (GainSkillObjectiveInstance)objective ).Handles( skill ) )
if ( !objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && objectiveInstance.Handles( skill ) )
{
objective.CheckComplete();
objectiveInstance.CheckComplete();
break;
}
}
@ -520,10 +513,8 @@ namespace Server.Engines.MLQuests
*/
foreach ( BaseObjectiveInstance objective in instance.Objectives )
{
if ( !objective.Expired && objective is KillObjectiveInstance )
if ( !objective.Expired && objective is KillObjectiveInstance kill )
{
KillObjectiveInstance kill = (KillObjectiveInstance)objective;
if ( type == null )
type = mob.GetType();
@ -558,26 +549,21 @@ namespace Server.Engines.MLQuests
foreach ( BaseObjectiveInstance objective in instance.Objectives )
{
// Note: On OSI, expired deliveries can still be completed. Bug?
if ( !objective.Expired && objective is DeliverObjectiveInstance )
if ( !objective.Expired && objective is DeliverObjectiveInstance deliver && deliver.IsDestination( quester, questerType ) )
{
DeliverObjectiveInstance deliver = (DeliverObjectiveInstance)objective;
if ( deliver.IsDestination( quester, questerType ) )
if ( !deliver.HasCompleted ) // objective completes only once
{
if ( !deliver.HasCompleted ) // objective completes only once
{
deliver.HasCompleted = true;
deliver.CheckComplete();
deliver.HasCompleted = true;
deliver.CheckComplete();
// The quest is continued with this NPC (important for chains)
instance.Quester = quester;
}
if ( deliverInstance == null )
deliverInstance = instance;
break; // don't return, we may have to complete more deliveries
// The quest is continued with this NPC (important for chains)
instance.Quester = quester;
}
if ( deliverInstance == null )
deliverInstance = instance;
break; // don't return, we may have to complete more deliveries
}
}
}
@ -637,9 +623,7 @@ namespace Server.Engines.MLQuests
public static void EventSink_QuestGumpRequest( QuestGumpRequestArgs args )
{
PlayerMobile pm = args.Mobile as PlayerMobile;
if ( !Enabled || pm == null )
if ( !Enabled || !(args.Mobile is PlayerMobile pm) )
return;
pm.SendGump( new QuestLogGump( pm ) );
@ -681,21 +665,18 @@ namespace Server.Engines.MLQuests
public static void TurnToFace( IQuestGiver quester, Mobile mob )
{
if ( quester is Mobile )
{
Mobile m = (Mobile)quester;
if ( quester is Mobile m )
m.Direction = m.GetDirectionTo( mob );
}
}
public static void Tell( IQuestGiver quester, PlayerMobile pm, int cliloc )
{
TurnToFace( quester, pm );
if ( quester is Mobile )
((Mobile)quester).PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, pm.NetState );
else if ( quester is Item )
MessageHelper.SendLocalizedMessageTo( (Item)quester, pm, cliloc, SpeechColor );
if ( quester is Mobile mobile )
mobile.PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, pm.NetState );
else if ( quester is Item item )
MessageHelper.SendLocalizedMessageTo( item, pm, cliloc, SpeechColor );
else
pm.SendLocalizedMessage( cliloc, "", SpeechColor );
}
@ -704,10 +685,10 @@ namespace Server.Engines.MLQuests
{
TurnToFace( quester, pm );
if ( quester is Mobile )
((Mobile)quester).PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, args, pm.NetState );
else if ( quester is Item )
MessageHelper.SendLocalizedMessageTo( (Item)quester, pm, cliloc, args, SpeechColor );
if ( quester is Mobile mobile )
mobile.PrivateOverheadMessage( MessageType.Regular, SpeechColor, cliloc, args, pm.NetState );
else if ( quester is Item item )
MessageHelper.SendLocalizedMessageTo( item, pm, cliloc, args, SpeechColor );
else
pm.SendLocalizedMessage( cliloc, args, SpeechColor );
}
@ -716,10 +697,10 @@ namespace Server.Engines.MLQuests
{
TurnToFace( quester, pm );
if ( quester is Mobile )
((Mobile)quester).PrivateOverheadMessage( MessageType.Regular, SpeechColor, false, message, pm.NetState );
else if ( quester is Item )
MessageHelper.SendMessageTo( (Item)quester, pm, message, SpeechColor );
if ( quester is Mobile mobile )
mobile.PrivateOverheadMessage( MessageType.Regular, SpeechColor, false, message, pm.NetState );
else if ( quester is Item item )
MessageHelper.SendMessageTo( item, pm, message, SpeechColor );
else
pm.SendMessage( SpeechColor, message );
}

View file

@ -185,8 +185,8 @@ namespace Server.Engines.MLQuests.Objectives
{
bool completed = reader.ReadBool();
if ( objInstance is EscortObjectiveInstance )
( (EscortObjectiveInstance)objInstance ).HasCompleted = completed;
if ( objInstance is EscortObjectiveInstance instance )
instance.HasCompleted = completed;
break;
}
@ -194,8 +194,8 @@ namespace Server.Engines.MLQuests.Objectives
{
int slain = reader.ReadInt();
if ( objInstance is KillObjectiveInstance )
( (KillObjectiveInstance)objInstance ).Slain = slain;
if ( objInstance is KillObjectiveInstance instance )
instance.Slain = slain;
break;
}
@ -203,8 +203,8 @@ namespace Server.Engines.MLQuests.Objectives
{
bool completed = reader.ReadBool();
if ( objInstance is DeliverObjectiveInstance )
( (DeliverObjectiveInstance)objInstance ).HasCompleted = completed;
if ( objInstance is DeliverObjectiveInstance instance )
instance.HasCompleted = completed;
break;
}

View file

@ -76,9 +76,7 @@ namespace Server.Engines.MLQuests.Objectives
for ( int i = 0; i < m_Amount; ++i )
{
Item item = Activator.CreateInstance( m_Delivery ) as Item;
if ( item == null )
if ( !(Activator.CreateInstance( m_Delivery ) is Item item) )
continue;
delivery.Add( item );

View file

@ -31,7 +31,7 @@ namespace Server.Engines.MLQuests.Objectives
public override bool CanOffer( IQuestGiver quester, PlayerMobile pm, bool message )
{
if ( ( quester is BaseCreature && ( (BaseCreature)quester ).Controlled ) || ( quester is BaseEscortable && ( (BaseEscortable)quester ).IsBeingDeleted ) )
if ( ( quester is BaseCreature creature && creature.Controlled ) || ( quester is BaseEscortable escortable && escortable.IsBeingDeleted ) )
return false;
MLQuestContext context = MLQuestSystem.GetContext( pm );
@ -145,7 +145,7 @@ namespace Server.Engines.MLQuests.Objectives
if ( pm.Young || m_Escort.Region.IsPartOf( "Haven Island" ) )
Titles.AwardFame( pm, 10, true );
else
VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, ( m_Escort is BaseEscortable && ( (BaseEscortable)m_Escort ).IsPrisoner ) ? 400 : 200 );
VirtueHelper.AwardVirtue( pm, VirtueName.Compassion, ( m_Escort is BaseEscortable escortable && escortable.IsPrisoner ) ? 400 : 200 );
EndFollow( m_Escort );
StopTimer();
@ -203,8 +203,7 @@ namespace Server.Engines.MLQuests.Objectives
quester.SetControlMaster( null );
if ( quester is BaseEscortable )
( (BaseEscortable)quester ).BeginDelete();
(quester as BaseEscortable)?.BeginDelete();
}
public override void OnQuestAccepted()

View file

@ -162,9 +162,9 @@ namespace Server.Engines.MyRunUO
}
}
}
else if ( obj is string )
else if ( obj is string s )
{
command.CommandText = (string)obj;
command.CommandText = s;
command.ExecuteNonQuery();
}
else
@ -199,4 +199,4 @@ namespace Server.Engines.MyRunUO
}
}
}
}
}

View file

@ -36,9 +36,7 @@ namespace Server.Engines.MyRunUO
[Description( "Enables showing extended character stats and skills in MyRunUO." )]
public static void PublicChar_OnCommand( CommandEventArgs e )
{
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm != null )
if ( e.Mobile is PlayerMobile pm )
{
if ( pm.PublicMyRunUO )
{
@ -56,9 +54,7 @@ namespace Server.Engines.MyRunUO
[Description( "Disables showing extended character stats and skills in MyRunUO." )]
public static void PrivateChar_OnCommand( CommandEventArgs e )
{
PlayerMobile pm = e.Mobile as PlayerMobile;
if ( pm != null )
if ( e.Mobile is PlayerMobile pm )
{
if ( !pm.PublicMyRunUO )
{
@ -91,7 +87,7 @@ namespace Server.Engines.MyRunUO
{
if ( m_Command != null && !m_Command.HasCompleted )
return;
DateTime start = DateTime.Now;
// DateTime start = DateTime.Now;
Console.WriteLine( "MyRunUO: Creating tables" );
try
{
@ -108,8 +104,8 @@ namespace Server.Engines.MyRunUO
Console.WriteLine( "MyRunUO: Error creating tables." );
Console.WriteLine( e );
}
if ( m_Command != null )
m_Command.Enqueue( null );
m_Command?.Enqueue( null );
}
[Usage( "UpdateMyRunUO" )]
@ -334,7 +330,7 @@ namespace Server.Engines.MyRunUO
sb.Append( ent );
}
private string SafeString( string input )
{
if ( input == null )
@ -364,8 +360,7 @@ namespace Server.Engines.MyRunUO
case '\\': AppendCharEntity( input, i, ref sb, c ); break;
default:
{
if ( sb != null )
sb.Append( c );
sb?.Append( c );
break;
}
@ -394,8 +389,8 @@ namespace Server.Engines.MyRunUO
string notoTitle = SafeString( Titles.ComputeTitle( null, mob ) );
string female = ( mob.Female ? "1" : "0" );
bool pubBool = ( mob is PlayerMobile ) && ( ((PlayerMobile)mob).PublicMyRunUO );
bool pubBool = mob is PlayerMobile mobile && mobile.PublicMyRunUO;
string pubString = ( pubBool ? "1" : "0" );
@ -571,8 +566,8 @@ namespace Server.Engines.MyRunUO
{
Mobile mob = (Mobile)m_List[i];
if ( mob is PlayerMobile )
((PlayerMobile)mob).ChangedMyRunUO = false;
if ( mob is PlayerMobile mobile )
mobile.ChangedMyRunUO = false;
if ( !mob.Deleted && mob.AccessLevel < Config.HiddenAccessLevel )
{

View file

@ -13,9 +13,8 @@ namespace Server.Engines.PartySystem
protected override void OnTarget( Mobile from, object o )
{
if ( o is Mobile )
if ( o is Mobile m )
{
Mobile m = (Mobile)o;
Party p = Party.Get( from );
Party mp = Party.Get( m );
@ -44,4 +43,4 @@ namespace Server.Engines.PartySystem
}
}
}
}
}

View file

@ -35,9 +35,9 @@ namespace Server.Engines.PartySystem
public static void ListenToParty_OnTarget( Mobile from, object obj )
{
if ( obj is Mobile )
if ( obj is Mobile mobile )
{
Party p = Party.Get( (Mobile) obj );
Party p = Party.Get( mobile );
if ( p == null )
{

View file

@ -12,9 +12,8 @@ namespace Server.Engines.PartySystem
protected override void OnTarget( Mobile from, object o )
{
if ( o is Mobile )
if ( o is Mobile m )
{
Mobile m = (Mobile)o;
Party p = Party.Get( from );
if ( p == null || p.Leader != from || !p.Contains( m ) )
@ -27,4 +26,4 @@ namespace Server.Engines.PartySystem
}
}
}
}
}

View file

@ -315,7 +315,7 @@ namespace Server.Movement
List<Mobile> mobsLeft = m_MobPools[1];
List<Mobile> mobsRight = m_MobPools[2];
bool checkMobs = ( m is BaseCreature && !((BaseCreature)m).Controlled && ( xForward != m_Goal.X || yForward != m_Goal.Y ) );
bool checkMobs = ( m is BaseCreature creature && !creature.Controlled && ( xForward != m_Goal.X || yForward != m_Goal.Y ) );
if ( checkDiagonals )
{
@ -589,4 +589,4 @@ namespace Server.Movement
}
}
}
}
}

View file

@ -65,9 +65,7 @@ namespace Server
public static void Path_OnTarget( Mobile from, object obj )
{
IPoint3D p = obj as IPoint3D;
if ( p == null )
if ( !(obj is IPoint3D p) )
return;
Spells.SpellHelper.GetSurfaceTop( ref p );
@ -162,4 +160,4 @@ namespace Server
}
}
}
}
}

View file

@ -45,8 +45,8 @@ namespace Server
public Point3D GetGoalLocation()
{
if ( m_Goal is Item )
return ((Item)m_Goal).GetWorldLocation();
if ( m_Goal is Item item )
return item.GetWorldLocation();
return new Point3D( m_Goal );
}
@ -201,4 +201,4 @@ namespace Server
return Check( m_From.Location, goal, range );
}
}
}
}

View file

@ -228,7 +228,7 @@ namespace Server.Engines.Plants
if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant )
return;
if ( ( ( info.ButtonID >= 6 && info.ButtonID <= 10 ) || info.ButtonID == 12 ) && !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3E9, 500446 ); // That is too far away.
@ -293,15 +293,15 @@ namespace Server.Engines.Plants
case 6: // Water
{
Item[] item = from.Backpack.FindItemsByType( typeof( BaseBeverage ) );
bool foundUsableWater = false;
if ( item != null && item.Length > 0 )
{
for ( int i = 0; i < item.Length; ++i )
{
BaseBeverage beverage = (BaseBeverage)item[i];
if ( !beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water )
{
foundUsableWater = true;
@ -310,7 +310,7 @@ namespace Server.Engines.Plants
}
}
}
if ( !foundUsableWater )
{
from.Target = new PlantPourTarget( m_Plant );
@ -400,10 +400,8 @@ namespace Server.Engines.Plants
foreach ( Item item in items )
{
if ( item is BasePotion )
if ( item is BasePotion potion )
{
BasePotion potion = (BasePotion)item;
if ( Array.IndexOf( effects, potion.PotionEffect ) >= 0 )
return potion;
}
@ -419,4 +417,4 @@ namespace Server.Engines.Plants
return null;
}
}
}
}

View file

@ -78,9 +78,7 @@ namespace Server.Items
return;
}
LandTarget land = targeted as LandTarget;
if ( land == null )
if ( !(targeted is LandTarget land) )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1061912 ); // * You cannot plant a green thorn there! *
}

View file

@ -62,9 +62,7 @@ namespace Server.Items
return;
}
Item item = targeted as Item;
if ( item == null || !item.IsChildOf( from.Backpack ) )
if ( !(targeted is Item item) || !item.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
}

View file

@ -52,12 +52,10 @@ namespace Server.Engines.Plants
return;
}
if ( targeted is FertileDirt )
if ( targeted is FertileDirt dirt )
{
int _dirtNeeded = Core.ML ? 20 : 40;
FertileDirt dirt = (FertileDirt)targeted;
if ( !dirt.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042664 ); // You must have the object in your backpack to use it.
@ -132,12 +130,12 @@ namespace Server.Engines.Plants
{
int tileID;
if ( obj is Static && !((Static)obj).Movable )
tileID = (((Static)obj).ItemID & 0x3FFF) | 0x4000;
else if ( obj is StaticTarget )
tileID = (((StaticTarget)obj).ItemID & 0x3FFF) | 0x4000;
else if ( obj is LandTarget )
tileID = ((LandTarget)obj).TileID;
if ( obj is Static staticObj && !staticObj.Movable )
tileID = (staticObj.ItemID & 0x3FFF) | 0x4000;
else if ( obj is StaticTarget staticTarget )
tileID = (staticTarget.ItemID & 0x3FFF) | 0x4000;
else if ( obj is LandTarget landTarget )
tileID = landTarget.TileID;
else
return false;

View file

@ -151,8 +151,7 @@ namespace Server.Engines.Plants
return true;
Mobile owner = RootParent as Mobile;
if ( owner == null )
if ( !(RootParent is Mobile owner) )
return false;
if ( owner.Backpack != null && IsChildOf( owner.Backpack ) )
@ -318,8 +317,7 @@ namespace Server.Engines.Plants
public bool IsUsableBy( Mobile from )
{
Item root = RootParent as Item;
return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || root != null && root.IsSecure && root.IsAccessibleTo( from );
return IsChildOf( from.Backpack ) || IsChildOf( from.FindBankNoCreate() ) || IsLockedDown && IsAccessibleTo( from ) || RootParent is Item root && root.IsSecure && root.IsAccessibleTo( from );
}
public override void OnDoubleClick( Mobile from )
@ -408,10 +406,8 @@ namespace Server.Engines.Plants
return;
}
if ( item is BaseBeverage )
if ( item is BaseBeverage beverage )
{
BaseBeverage beverage = (BaseBeverage)item;
if ( beverage.IsEmpty || !beverage.Pourable || beverage.Content != BeverageType.Water )
{
LabelTo( from, 1053069 ); // You can't use that on a plant!
@ -427,12 +423,9 @@ namespace Server.Engines.Plants
from.PlaySound( 0x4E );
LabelTo( from, 1061858 ); // You soften the dirt with water.
}
else if ( item is BasePotion )
else if ( item is BasePotion potion )
{
BasePotion potion = (BasePotion)item;
int message;
if ( ApplyPotion( potion.PotionEffect, false, out message ) )
if ( ApplyPotion( potion.PotionEffect, false, out int message ) )
{
potion.Consume();
from.PlaySound( 0x240 );
@ -440,18 +433,15 @@ namespace Server.Engines.Plants
}
LabelTo( from, message );
}
else if ( item is PotionKeg )
else if ( item is PotionKeg keg )
{
PotionKeg keg = (PotionKeg)item;
if ( keg.Held <= 0 )
{
LabelTo( from, 1053069 ); // You can't use that on a plant!
return;
}
int message;
if ( ApplyPotion( keg.Type, false, out message ) )
if ( ApplyPotion( keg.Type, false, out int message ) )
{
keg.Held--;
from.PlaySound( 0x240 );

View file

@ -15,9 +15,9 @@ namespace Server.Engines.Plants
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item )
if ( !m_Plant.Deleted && from.InRange( m_Plant.GetWorldLocation(), 3 ) && targeted is Item item )
{
m_Plant.Pour( from, (Item)targeted );
m_Plant.Pour( from, item );
}
}
@ -32,4 +32,4 @@ namespace Server.Engines.Plants
}
}
}
}
}

View file

@ -35,9 +35,7 @@ namespace Server.Engines.Plants
}
else
{
PlantItem targ = targeted as PlantItem;
if ( targ == null || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
if ( !(targeted is PlantItem targ) || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt )
{
m_Plant.LabelTo( from, 1053070 ); // You can only pollinate other specially grown plants!
}

View file

@ -158,22 +158,12 @@ namespace Server.Engines.Plants
public override bool StackWith( Mobile from, Item dropped, bool playSound )
{
if ( dropped is Seed )
{
Seed other = (Seed)dropped;
if ( other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType )
return base.StackWith( from, dropped, playSound );
}
return false;
return dropped is Seed other && other.PlantType == m_PlantType && other.PlantHue == m_PlantHue && other.ShowType == m_ShowType && base.StackWith( from, other, playSound );
}
public override void OnAfterDuped( Item newItem )
{
Seed newSeed = newItem as Seed;
if ( newSeed == null )
if ( !(newItem is Seed newSeed) )
return;
newSeed.PlantType = m_PlantType;
@ -202,15 +192,13 @@ namespace Server.Engines.Plants
return;
}
if ( targeted is PlantItem )
if ( targeted is PlantItem plant )
{
PlantItem plant = (PlantItem)targeted;
plant.PlantSeed( from, m_Seed );
}
else if ( targeted is Item )
else if ( targeted is Item item )
{
((Item)targeted).LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
item.LabelTo( from, 1061919 ); // You must use a seed on a bowl of dirt!
}
else
{

View file

@ -34,9 +34,7 @@ namespace Server.Engines.Quests.Ambitious
{
this.Direction = GetDirectionTo( player );
AmbitiousQueenQuest qs = player.Quest as AmbitiousQueenQuest;
if ( qs != null && qs.RedSolen == this.RedSolen )
if ( player.Quest is AmbitiousQueenQuest qs && qs.RedSolen == this.RedSolen )
{
if ( qs.IsObjectiveInProgress( typeof( KillQueensObjective ) ) )
{
@ -56,9 +54,7 @@ namespace Server.Engines.Quests.Ambitious
}
else
{
GetRewardObjective lastObj = qs.FindObjective( typeof( GetRewardObjective ) ) as GetRewardObjective;
if ( lastObj != null && !lastObj.Completed )
if ( qs.FindObjective( typeof( GetRewardObjective ) ) is GetRewardObjective lastObj && !lastObj.Completed )
{
bool bagOfSending = lastObj.BagOfSending;
bool powderOfTranslocation = lastObj.PowderOfTranslocation;
@ -101,22 +97,16 @@ namespace Server.Engines.Quests.Ambitious
{
this.Direction = GetDirectionTo( from );
PlayerMobile player = from as PlayerMobile;
if ( player != null )
if ( from is PlayerMobile player )
{
AmbitiousQueenQuest qs = player.Quest as AmbitiousQueenQuest;
if ( qs != null && qs.RedSolen == this.RedSolen )
if ( player.Quest is AmbitiousQueenQuest qs && qs.RedSolen == this.RedSolen )
{
QuestObjective obj = qs.FindObjective( typeof( GatherFungiObjective ) );
if ( obj != null && !obj.Completed )
{
if ( dropped is ZoogiFungus )
if ( dropped is ZoogiFungus fungi )
{
ZoogiFungus fungi = (ZoogiFungus)dropped;
if ( fungi.Amount >= 50 )
{
obj.Complete();
@ -128,16 +118,12 @@ namespace Server.Engines.Quests.Ambitious
fungi.Delete();
return true;
}
else
{
return false;
}
}
else
{
SayTo( player, 1054072 ); // Our arrangement was for 50 of the zoogi fungus. Please return to me when you have that amount.
return false;
}
SayTo( player, 1054072 ); // Our arrangement was for 50 of the zoogi fungus. Please return to me when you have that amount.
return false;
}
}
}

View file

@ -22,21 +22,15 @@ namespace Server.Engines.Quests.Collector
public override bool CanDrop( PlayerMobile player )
{
CollectorQuest qs = player.Quest as CollectorQuest;
if ( qs == null )
return true;
return !(player.Quest is CollectorQuest);
/*return !( qs.IsObjectiveInProgress( typeof( CaptureImagesObjective ) )
|| qs.IsObjectiveInProgress( typeof( ReturnImagesObjective ) ) );*/
return false;
}
public override void OnDoubleClick( Mobile from )
{
PlayerMobile player = from as PlayerMobile;
if ( player != null )
if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
@ -70,22 +64,17 @@ namespace Server.Engines.Quests.Collector
if ( m_Paints.Deleted || !m_Paints.IsChildOf( from.Backpack ) )
return;
PlayerMobile player = from as PlayerMobile;
if ( player != null )
if ( from is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is CollectorQuest )
{
CaptureImagesObjective obj = qs.FindObjective( typeof( CaptureImagesObjective ) ) as CaptureImagesObjective;
if ( obj != null && !obj.Completed )
if ( qs.FindObjective( typeof( CaptureImagesObjective ) ) is CaptureImagesObjective obj && !obj.Completed )
{
if ( targeted is Mobile )
{
ImageType image;
CaptureResponse response = obj.CaptureImage(( targeted.GetType().Name=="GreaterMongbat" ? new Mongbat().GetType() : targeted.GetType() ), out image );
CaptureResponse response = obj.CaptureImage(( targeted.GetType().Name=="GreaterMongbat" ? new Mongbat().GetType() : targeted.GetType() ), out ImageType image );
switch ( response )
{
@ -138,4 +127,4 @@ namespace Server.Engines.Quests.Collector
int version = reader.ReadInt();
}
}
}
}

View file

@ -203,13 +203,11 @@ namespace Server.Engines.Quests.Collector
protected override void OnTarget( Mobile from, object targeted )
{
Item targ = targeted as Item;
if ( m_Obsidian.Deleted || m_Obsidian.Quantity >= Obsidian.m_Completed || targ == null )
if ( m_Obsidian.Deleted || m_Obsidian.Quantity >= Obsidian.m_Completed || !(targeted is Item targ) )
return;
if ( m_Obsidian.IsChildOf( from.Backpack ) && targ.IsChildOf( from.Backpack ) && targ is Obsidian && targ != m_Obsidian )
if ( m_Obsidian.IsChildOf( from.Backpack ) && targ.IsChildOf( from.Backpack ) && targ is Obsidian targObsidian && targ != m_Obsidian )
{
Obsidian targObsidian = (Obsidian)targ;
if ( targObsidian.Quantity < Obsidian.m_Completed )
{
if ( targObsidian.Quantity + m_Obsidian.Quantity <= Obsidian.m_Completed )

View file

@ -197,10 +197,10 @@ namespace Server.Engines.Quests.Collector
{
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

@ -56,9 +56,7 @@ namespace Server.Engines.Quests.Collector
if ( qs is CollectorQuest )
{
FindSheetMusicObjective obj = qs.FindObjective( typeof( FindSheetMusicObjective ) ) as FindSheetMusicObjective;
if ( obj != null && !obj.Completed )
if ( qs.FindObjective( typeof( FindSheetMusicObjective ) ) is FindSheetMusicObjective obj && !obj.Completed )
{
Direction = GetDirectionTo( player );
@ -135,20 +133,14 @@ namespace Server.Engines.Quests.Collector
{
if ( info.ButtonID == 1 && info.IsSwitched( 1 ) )
{
PlayerMobile player = sender.Mobile as PlayerMobile;
if ( player != null )
if ( sender.Mobile is PlayerMobile player )
{
QuestSystem qs = player.Quest;
if ( qs is CollectorQuest )
{
FindSheetMusicObjective obj = qs.FindObjective( typeof( FindSheetMusicObjective ) ) as FindSheetMusicObjective;
if ( obj != null && !obj.Completed )
if ( qs.FindObjective( typeof( FindSheetMusicObjective ) ) is FindSheetMusicObjective obj && !obj.Completed )
{
if ( player.Backpack!= null && player.Backpack.ConsumeTotal( typeof( Gold ), 10 ) )
{
obj.Complete();
@ -160,7 +152,7 @@ namespace Server.Engines.Quests.Collector
{
obj.Complete();
}
else
{
player.SendLocalizedMessage( 1055108 ); // You don't have enough gold to buy the sheet music.
@ -172,4 +164,4 @@ namespace Server.Engines.Quests.Collector
}
}
}
}
}

View file

@ -21,8 +21,8 @@ namespace Server.Engines.Quests
{
Mobile from = Owner.From;
if ( from.CheckAlive() && from is PlayerMobile && m_Quester.CanTalkTo( (PlayerMobile)from ) )
m_Quester.OnTalk( (PlayerMobile)from, true );
if ( from.CheckAlive() && from is PlayerMobile mobile && m_Quester.CanTalkTo( mobile ) )
m_Quester.OnTalk( mobile, true );
}
}
@ -82,19 +82,17 @@ namespace Server.Engines.Quests
{
base.AddCustomContextEntries( from, list );
if ( from.Alive && from is PlayerMobile && TalkNumber > 0 && CanTalkTo( (PlayerMobile)from ) )
if ( from.Alive && from is PlayerMobile mobile && TalkNumber > 0 && CanTalkTo( mobile ) )
list.Add( new TalkEntry( this ) );
}
public override void OnMovement( Mobile m, Point3D oldLocation )
{
if ( m.Alive && m is PlayerMobile )
if ( m.Alive && m is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)m;
int range = GetAutoTalkRange( pm );
if ( m.Alive && range >= 0 && InRange( m, range ) && !InRange( oldLocation, range ) && CanTalkTo( pm ) )
if ( pm.Alive && range >= 0 && InRange( m, range ) && !InRange( oldLocation, range ) && CanTalkTo( pm ) )
OnTalk( pm, false );
}
}

View file

@ -24,9 +24,7 @@ namespace Server.Engines.Quests
public override bool OnMoveOver( Mobile m )
{
PlayerMobile pm = m as PlayerMobile;
if ( pm != null )
if ( m is PlayerMobile pm )
{
Point3D loc = Point3D.Zero;
Map map = null;
@ -40,10 +38,8 @@ namespace Server.Engines.Quests
return false;
}
else
{
pm.SendLocalizedMessage( this.NotWorkingMessage );
}
pm.SendLocalizedMessage( this.NotWorkingMessage );
}
return base.OnMoveOver( m );

View file

@ -90,18 +90,15 @@ namespace Server.Engines.Quests
return false;
}
}
else
{
return ret;
}
return ret;
}
public override DeathMoveResult OnParentDeath( Mobile parent )
{
if ( parent is PlayerMobile && !CanDrop( (PlayerMobile)parent ) )
if ( parent is PlayerMobile mobile && !CanDrop( mobile ) )
return DeathMoveResult.MoveToBackpack;
else
return base.OnParentDeath( parent );
return base.OnParentDeath( parent );
}
public override void Serialize( GenericWriter writer )

View file

@ -403,9 +403,7 @@ namespace Server.Engines.Quests
{
inRestartPeriod = false;
PlayerMobile pm = check as PlayerMobile;
if ( pm == null )
if ( !(check is PlayerMobile pm) )
return false;
if ( pm.HasGump( typeof( QuestOfferGump ) ) )
@ -656,31 +654,19 @@ namespace Server.Engines.Quests
public static ArrayList BuildList( object obj )
{
ArrayList list = new ArrayList();
list.Add( obj );
return list;
return new ArrayList { obj };
}
public void AddHtmlObject( int x, int y, int width, int height, object message, int color, bool back, bool scroll )
{
if ( message is string )
{
string html = (string)message;
AddHtml( x, y, width, height, Color( html, C16232( color ) ), back, scroll );
}
else if ( message is int )
{
int html = (int)message;
if ( message is int html )
AddHtmlLocalized( x, y, width, height, html, C16216( color ), back, scroll );
}
else
AddHtml( x, y, width, height, Color( message.ToString(), C16232( color ) ), back, scroll );
}
public BaseQuestGump( int x, int y ) : base( x, y )
{
}
}
}
}

View file

@ -28,9 +28,7 @@ namespace Server.Engines.Quests
if ( m_Quest == null )
return true;
PlayerMobile player = m as PlayerMobile;
if ( player != null && player.Quest != null && player.Quest.GetType() == m_Quest )
if ( m is PlayerMobile player && player.Quest != null && player.Quest.GetType() == m_Quest )
{
if ( !player.HasGump( typeof( QuestCancelGump ) ) )
player.Quest.BeginCancelQuest();
@ -41,4 +39,4 @@ namespace Server.Engines.Quests
return true;
}
}
}
}

View file

@ -28,9 +28,7 @@ namespace Server.Engines.Quests
if ( m_Quest != null && m_Objective != null )
{
PlayerMobile player = m as PlayerMobile;
if ( player != null && player.Quest != null && player.Quest.GetType() == m_Quest )
if ( m is PlayerMobile player && player.Quest != null && player.Quest.GetType() == m_Quest )
{
QuestObjective obj = player.Quest.FindObjective( m_Objective );
@ -40,4 +38,4 @@ namespace Server.Engines.Quests
}
}
}
}
}

View file

@ -36,32 +36,23 @@ namespace Server.Engines.Quests
if ( m.AccessLevel > AccessLevel.Player )
return true;
if ( m is BaseCreature )
{
BaseCreature bc = m as BaseCreature;
if ( !bc.Controlled && !bc.Summoned )
return true;
}
if ( m is BaseCreature bc && !bc.Controlled && !bc.Summoned )
return true;
if ( m_Quest == null )
return true;
PlayerMobile player = m as PlayerMobile;
if ( player != null && player.Quest != null && player.Quest.GetType() == m_Quest
if ( m is PlayerMobile player && player.Quest != null && player.Quest.GetType() == m_Quest
&& ( m_MinObjective == null || player.Quest.FindObjective( m_MinObjective ) != null )
&& ( m_MaxObjective == null || player.Quest.FindObjective( m_MaxObjective ) == null ) )
{
return true;
}
else
{
if ( m_Message != 0 )
m.SendLocalizedMessage( m_Message );
return false;
}
if ( m_Message != 0 )
m.SendLocalizedMessage( m_Message );
return false;
}
}
}

View file

@ -24,9 +24,7 @@ namespace Server.Engines.Quests
if ( m_Quest == null )
return;
PlayerMobile player = m as PlayerMobile;
if ( player != null && player.Quest == null && QuestSystem.CanOfferQuest( m, m_Quest ) )
if ( m is PlayerMobile player && player.Quest == null && QuestSystem.CanOfferQuest( m, m_Quest ) )
{
try
{
@ -40,4 +38,4 @@ namespace Server.Engines.Quests
}
}
}
}
}

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 );

View file

@ -114,9 +114,7 @@ namespace Server.Engines.Quests.Ninja
public static bool HasLostNoteForZoel( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
if ( !(from is PlayerMobile pm) )
return false;
QuestSystem qs = pm.Quest;
@ -125,9 +123,7 @@ namespace Server.Engines.Quests.Ninja
{
if ( qs.IsObjectiveInProgress( typeof( GiveZoelNoteObjective ) ) )
{
Container pack = from.Backpack;
return ( pack == null || pack.FindItemByType( typeof( NoteForZoel ) ) == null );
return ( from.Backpack?.FindItemByType( typeof( NoteForZoel ) ) == null );
}
}
@ -136,9 +132,7 @@ namespace Server.Engines.Quests.Ninja
public static bool HasLostEminosKatana( Mobile from )
{
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
if ( !(from is PlayerMobile pm) )
return false;
QuestSystem qs = pm.Quest;
@ -147,9 +141,7 @@ namespace Server.Engines.Quests.Ninja
{
if ( qs.IsObjectiveInProgress( typeof( GiveEminoSwordObjective ) ) )
{
Container pack = from.Backpack;
return ( pack == null || pack.FindItemByType( typeof( EminosKatana ) ) == null );
return ( from.Backpack?.FindItemByType( typeof( EminosKatana ) ) == null );
}
}

View file

@ -20,15 +20,11 @@ namespace Server.Engines.Quests.Ninja
public override bool CanDrop( PlayerMobile player )
{
EminosUndertakingQuest qs = player.Quest as EminosUndertakingQuest;
if ( qs == null )
return true;
return !(player.Quest is EminosUndertakingQuest);
/*return !qs.IsObjectiveInProgress( typeof( ReturnSwordObjective ) )
&& !qs.IsObjectiveInProgress( typeof( SlayHenchmenObjective ) )
&& !qs.IsObjectiveInProgress( typeof( GiveEminoSwordObjective ) );*/
return false;
}
public override void Serialize( GenericWriter writer )

View file

@ -41,9 +41,7 @@ namespace Server.Engines.Quests.Ninja
public override void OnDoubleClick( Mobile from )
{
PlayerMobile player = from as PlayerMobile;
if ( player != null && player.InRange( GetWorldLocation(), 2 ) )
if ( from is PlayerMobile player && player.InRange( GetWorldLocation(), 2 ) )
{
QuestSystem qs = player.Quest;
@ -100,13 +98,9 @@ namespace Server.Engines.Quests.Ninja
if ( from.AccessLevel >= AccessLevel.GameMaster )
return true;
PlayerMobile player = from as PlayerMobile;
if ( player != null && player.Quest is EminosUndertakingQuest )
if ( from is PlayerMobile player && player.Quest is EminosUndertakingQuest )
{
HallwayWalkObjective obj = player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) as HallwayWalkObjective;
if ( obj != null )
if ( player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) is HallwayWalkObjective obj )
{
if ( obj.StolenTreasure )
from.SendLocalizedMessage( 1063247 ); // The guard is watching you carefully! It would be unwise to remove another item from here.
@ -120,13 +114,9 @@ namespace Server.Engines.Quests.Ninja
public override void OnItemLifted( Mobile from, Item item )
{
PlayerMobile player = from as PlayerMobile;
if ( player != null && player.Quest is EminosUndertakingQuest )
if ( from is PlayerMobile player && player.Quest is EminosUndertakingQuest )
{
HallwayWalkObjective obj = player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) as HallwayWalkObjective;
if ( obj != null )
if ( player.Quest.FindObjective( typeof( HallwayWalkObjective ) ) is HallwayWalkObjective obj )
obj.StolenTreasure = true;
}
}