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

@ -498,9 +498,7 @@ namespace Server.Mobiles
public override void OnDoubleClick( Mobile from )
{
Account acct = from.Account as Account;
if ( acct != null && from.AccessLevel == AccessLevel.Player )
if ( from.Account is Account acct && from.AccessLevel == AccessLevel.Player )
{
TimeSpan time = TimeSpan.FromDays( RewardSystem.RewardInterval.TotalDays * 6 ) - ( DateTime.UtcNow - acct.Created );
@ -585,12 +583,12 @@ namespace Server.Mobiles
BaseHouse house = null;
Point3D loc = new Point3D( p );
if ( targeted is Item && !((Item) targeted).IsLockedDown && !((Item) targeted).IsSecure && !(targeted is AddonComponent) )
if ( targeted is Item item && !item.IsLockedDown && !item.IsSecure && !(item is AddonComponent) )
{
from.SendLocalizedMessage( 1076191 ); // Statues can only be placed in houses.
return;
}
else if ( from.IsBodyMod )
if ( from.IsBodyMod )
{
from.SendLocalizedMessage( 1073648 ); // You may only proceed while in your original state...
return;
@ -605,8 +603,8 @@ namespace Server.Mobiles
house.Addons.Add( plinth );
if ( m_Maker is IRewardItem )
statue.IsRewardItem = ( (IRewardItem) m_Maker).IsRewardItem;
if ( m_Maker is IRewardItem rewardItem )
statue.IsRewardItem = rewardItem.IsRewardItem;
statue.Plinth = plinth;
plinth.MoveToWorld( loc, map );
@ -638,10 +636,10 @@ namespace Server.Mobiles
{
if ( !map.CanFit( p.X, p.Y, p.Z, 20, true, true, true ) )
return AddonFitResult.Blocked;
else if ( !BaseAddon.CheckHouse( from, p, map, 20, ref house ) )
if ( !BaseAddon.CheckHouse( from, p, map, 20, ref house ) )
return AddonFitResult.NotInHouse;
else
return CheckDoors( p, 20, house );
return CheckDoors( p, 20, house );
}
public static AddonFitResult CheckDoors( Point3D p, int height, BaseHouse house )

View file

@ -133,9 +133,9 @@ namespace Server.Gumps
if ( info.ButtonID == (int) Buttons.Sculpt )
{
if ( m_Maker is CharacterStatueDeed )
if ( m_Maker is CharacterStatueDeed deed )
{
CharacterStatue backup = ( (CharacterStatueDeed) m_Maker ).Statue;
CharacterStatue backup = deed.Statue;
if ( backup != null )
backup.Delete();
@ -180,9 +180,9 @@ namespace Server.Gumps
}
else if ( info.ButtonID == (int) Buttons.Restore )
{
if ( m_Maker is CharacterStatueDeed )
if ( m_Maker is CharacterStatueDeed deed )
{
CharacterStatue backup = ( (CharacterStatueDeed) m_Maker ).Statue;
CharacterStatue backup = deed.Statue;
if ( backup != null )
m_Statue.Restore( backup );

View file

@ -1,6 +1,7 @@
using System;
using Server;
using Server.Gumps;
using Server.Items;
using Server.Network;
namespace Server.Engines.VeteranRewards
@ -51,9 +52,9 @@ namespace Server.Engines.VeteranRewards
if ( item != null )
{
if ( item is Server.Items.RedSoulstone )
((Server.Items.RedSoulstone) item).Account = m_From.Account.Username;
if ( item is RedSoulstone soulstone )
soulstone.Account = m_From.Account.Username;
if ( RewardSystem.ConsumeRewardPoint( m_From ) )
m_From.AddToBackpack( item );
else
@ -69,4 +70,4 @@ namespace Server.Engines.VeteranRewards
m_From.SendGump( new RewardNoticeGump( m_From ) );
}
}
}
}

View file

@ -5,11 +5,11 @@ using Server.Multis;
using Server.Network;
namespace Server.Gumps
{
{
public class RewardDemolitionGump : Gump
{
private IAddon m_Addon;
private enum Buttons
{
Cancel,
@ -27,9 +27,9 @@ namespace Server.Gumps
AddBackground( 0, 0, 220, 170, 0x13BE );
AddBackground( 10, 10, 200, 150, 0xBB8 );
AddHtmlLocalized( 20, 30, 180, 60, question, false, false ); // Do you wish to re-deed this decoration?
AddHtmlLocalized( 55, 100, 150, 25, 1011011, false, false ); // CONTINUE
AddButton( 20, 100, 0xFA5, 0xFA7, (int) Buttons.Confirm, GumpButtonType.Reply, 0 );
@ -39,27 +39,25 @@ namespace Server.Gumps
public override void OnResponse( NetState sender, RelayInfo info )
{
Item item = m_Addon as Item;
if ( item == null || item.Deleted )
return;
if ( !(m_Addon is Item item) || item.Deleted )
return;
if ( info.ButtonID == (int) Buttons.Confirm )
{
Mobile m = sender.Mobile;
BaseHouse house = BaseHouse.FindHouseAt( m );
if ( house != null && house.IsOwner( m ) )
BaseHouse house = BaseHouse.FindHouseAt( m );
if ( house?.IsOwner( m ) == true )
{
if ( m.InRange( item.Location, 2 ) )
{
Item deed = m_Addon.Deed;
if ( deed != null )
{
m.AddToBackpack( deed );
m.AddToBackpack( deed );
house.Addons.Remove( item );
item.Delete();
item.Delete();
}
}
else

View file

@ -26,8 +26,8 @@ namespace Server.Engines.VeteranRewards
{
Item item = Activator.CreateInstance( m_ItemType, m_Args ) as Item;
if ( item is IRewardItem )
((IRewardItem)item).IsRewardItem = true;
if ( item is IRewardItem rewardItem )
rewardItem.IsRewardItem = true;
return item;
}
@ -78,4 +78,4 @@ namespace Server.Engines.VeteranRewards
category.Entries.Add( this );
}
}
}
}

View file

@ -73,9 +73,7 @@ namespace Server.Engines.VeteranRewards
return false;
}
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
{
ts = TimeSpan.Zero;
return false;
@ -93,9 +91,7 @@ namespace Server.Engines.VeteranRewards
public static int GetRewardLevel( Mobile mob )
{
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
return 0;
return GetRewardLevel( acct );
@ -115,9 +111,7 @@ namespace Server.Engines.VeteranRewards
public static bool HasHalfLevel( Mobile mob )
{
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
return false;
return HasHalfLevel( acct );
@ -134,16 +128,12 @@ namespace Server.Engines.VeteranRewards
public static bool ConsumeRewardPoint( Mobile mob )
{
int cur, max;
ComputeRewardInfo( mob, out cur, out max );
ComputeRewardInfo( mob, out var cur, out var max );
if ( cur >= max )
return false;
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
return false;
//if ( mob.AccessLevel < AccessLevel.GameMaster )
@ -154,16 +144,12 @@ namespace Server.Engines.VeteranRewards
public static void ComputeRewardInfo( Mobile mob, out int cur, out int max )
{
int level;
ComputeRewardInfo( mob, out cur, out max, out level );
ComputeRewardInfo( mob, out cur, out max, out _ );
}
public static void ComputeRewardInfo( Mobile mob, out int cur, out int max, out int level )
{
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
{
cur = max = level = 0;
return;
@ -213,7 +199,7 @@ namespace Server.Engines.VeteranRewards
{
if ( (!isRelaxedRules || i > 0) && !HasAccess( from, list, out ts ) )
{
from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item :
from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item :
return false;
}
@ -231,7 +217,7 @@ namespace Server.Engines.VeteranRewards
{
if ( (!isRelaxedRules || i > 0) && !HasAccess( from, list, out ts ) )
{
from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item :
from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item :
return false;
}
@ -427,17 +413,17 @@ namespace Server.Engines.VeteranRewards
new RewardEntry( etherealSteeds, 1049748, typeof( EtherealBeetle ) ),
new RewardEntry( houseAddOns, 1049739, typeof( StoneAnkhDeed ) ),
new RewardEntry( houseAddOns, 1080384, typeof( BloodyPentagramDeed ), Expansion.ML )
} ),
} ),
new RewardList( RewardInterval, 6, new RewardEntry[]
{
new RewardEntry( houseAddOns, 1076188, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Jade ),
new RewardEntry( houseAddOns, 1076189, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Marble ),
new RewardEntry( houseAddOns, 1076190, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Bronze ),
new RewardEntry( houseAddOns, 1076190, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Bronze ),
new RewardEntry( houseAddOns, 1080527, typeof( RewardBrazierDeed ), Expansion.ML )
} ),
} ),
new RewardList( RewardInterval, 7, new RewardEntry[]
{
new RewardEntry( houseAddOns, 1076157, typeof( CannonDeed ), Expansion.ML ),
new RewardEntry( houseAddOns, 1076157, typeof( CannonDeed ), Expansion.ML ),
new RewardEntry( houseAddOns, 1080550, typeof( TreeStumpDeed ), Expansion.ML )
} ),
new RewardList( RewardInterval, 8, new RewardEntry[]
@ -450,17 +436,17 @@ namespace Server.Engines.VeteranRewards
new RewardEntry( houseAddOns, 1080549, typeof( WallBannerDeed ), Expansion.ML )
} ),
new RewardList( RewardInterval, 10, new RewardEntry[]
{
{
new RewardEntry( monsterStatues, 1080520, typeof( MonsterStatuette ), Expansion.ML, MonsterStatuetteType.Harrower ),
new RewardEntry( monsterStatues, 1080521, typeof( MonsterStatuette ), Expansion.ML, MonsterStatuetteType.Efreet ),
new RewardEntry( cloaksAndRobes, 1080382, typeof( RewardCloak ), Expansion.ML, Pink, 1080382 ),
new RewardEntry( cloaksAndRobes, 1080380, typeof( RewardRobe ), Expansion.ML, Pink, 1080380 ),
new RewardEntry( cloaksAndRobes, 1080380, typeof( RewardRobe ), Expansion.ML, Pink, 1080380 ),
new RewardEntry( cloaksAndRobes, 1080378, typeof( RewardDress ), Expansion.ML, Pink, 1080378 ),
new RewardEntry( cloaksAndRobes, 1080383, typeof( RewardCloak ), Expansion.ML, Crimson, 1080383 ),
new RewardEntry( cloaksAndRobes, 1080381, typeof( RewardRobe ), Expansion.ML, Crimson, 1080381 ),
new RewardEntry( cloaksAndRobes, 1080381, typeof( RewardRobe ), Expansion.ML, Crimson, 1080381 ),
new RewardEntry( cloaksAndRobes, 1080379, typeof( RewardDress ), Expansion.ML, Crimson, 1080379 ),
new RewardEntry( etherealSteeds, 1080386, typeof( EtherealCuSidhe ), Expansion.ML ),
new RewardEntry( houseAddOns, 1080548, typeof( MiningCartDeed ), Expansion.ML ),
@ -506,10 +492,10 @@ namespace Server.Engines.VeteranRewards
e.Mobile.SkillsCap = 7000;
}
if ( Core.ML && e.Mobile is PlayerMobile && !((PlayerMobile)e.Mobile).HasStatReward && HasHalfLevel( e.Mobile ) )
if ( Core.ML && e.Mobile is PlayerMobile mobile && !mobile.HasStatReward && HasHalfLevel( mobile ) )
{
((PlayerMobile)e.Mobile).HasStatReward = true;
e.Mobile.StatCap += 5;
mobile.HasStatReward = true;
mobile.StatCap += 5;
}
if ( cur < max )