Fixes casting checks

This commit is contained in:
Kamron Batman 2018-08-19 01:38:55 +08:00
parent 7ea00fbf4f
commit 03dd5f1926
431 changed files with 5616 additions and 6250 deletions

View file

@ -409,8 +409,8 @@ namespace Server.Factions
{
TimeSpan gameTime = TimeSpan.Zero;
if ( m_From is PlayerMobile )
gameTime = ((PlayerMobile)m_From).GameTime;
if ( m_From is PlayerMobile mobile )
gameTime = mobile.GameTime;
int kp = 0;

View file

@ -198,10 +198,8 @@ namespace Server.Factions
public void HonorLeadership_OnTarget( Mobile from, object obj )
{
if ( obj is Mobile )
if ( obj is Mobile recv )
{
Mobile recv = (Mobile) obj;
PlayerState giveState = PlayerState.Find( from );
PlayerState recvState = PlayerState.Find( recv );
@ -353,7 +351,7 @@ namespace Server.Factions
int killPoints = pl.KillPoints;
if( mob.Backpack != null )
if ( mob.Backpack != null )
{
//Ordinarily, through normal faction removal, this will never find any sigils.
//Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything
@ -377,8 +375,8 @@ namespace Server.Factions
Members.Remove( pl );
if ( mob is PlayerMobile )
((PlayerMobile)mob).FactionPlayerState = null;
if ( mob is PlayerMobile mobile )
mobile.FactionPlayerState = null;
mob.InvalidateProperties();
mob.Delta( MobileDelta.Noto );
@ -397,8 +395,8 @@ namespace Server.Factions
if ( Commander == mob )
Commander = null;
if ( mob is PlayerMobile )
((PlayerMobile)mob).ValidateEquipment();
if ( mob is PlayerMobile playerMobile )
playerMobile.ValidateEquipment();
if ( killPoints > 0 )
DistributePoints( killPoints );
@ -436,9 +434,7 @@ namespace Server.Factions
private bool AlreadyHasCharInFaction( Mobile mob )
{
Account acct = mob.Account as Account;
if ( acct != null )
if ( mob.Account is Account acct )
{
for ( int i = 0; i < acct.Length; ++i )
{
@ -454,9 +450,7 @@ namespace Server.Factions
public static bool IsFactionBanned( Mobile mob )
{
Account acct = mob.Account as Account;
if ( acct == null )
if ( !(mob.Account is Account acct) )
return false;
return ( acct.GetTag( "FactionBanned" ) != null );
@ -464,9 +458,7 @@ namespace Server.Factions
public void OnJoinAccepted( Mobile mob )
{
PlayerMobile pm = mob as PlayerMobile;
if ( pm == null )
if ( !(mob is PlayerMobile pm) )
return; // sanity
PlayerState pl = PlayerState.Find( pm );
@ -483,7 +475,7 @@ namespace Server.Factions
{
Guild guild = pm.Guild as Guild;
if ( guild.Leader != pm )
if ( guild?.Leader != pm )
pm.SendLocalizedMessage( 1005057 ); // You cannot join a faction because you are in a guild and not the guildmaster
else if ( guild.Type != GuildType.Regular )
pm.SendLocalizedMessage( 1042161 ); // You cannot join a faction because your guild is an Order or Chaos type.
@ -499,9 +491,7 @@ namespace Server.Factions
for ( int i = 0; i < members.Count; ++i )
{
PlayerMobile member = members[i] as PlayerMobile;
if ( member == null )
if ( !(members[i] is PlayerMobile member) )
continue;
JoinGuilded( member, guild );
@ -745,9 +735,9 @@ namespace Server.Factions
public static void FactionCommander_OnTarget( Mobile from, object obj )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile mobile )
{
Mobile targ = (Mobile)obj;
Mobile targ = mobile;
PlayerState pl = PlayerState.Find( targ );
if ( pl != null )
@ -774,9 +764,9 @@ namespace Server.Factions
public static void FactionElection_OnTarget( Mobile from, object obj )
{
if ( obj is FactionStone )
if ( obj is FactionStone stone )
{
Faction faction = ((FactionStone)obj).Faction;
Faction faction = stone.Faction;
if ( faction != null )
from.SendGump( new ElectionManagementGump( faction.Election ) );
@ -798,10 +788,9 @@ namespace Server.Factions
public static void FactionKick_OnTarget( Mobile from, object obj )
{
if ( obj is Mobile )
if ( obj is Mobile mob )
{
Mobile mob = (Mobile) obj;
PlayerState pl = PlayerState.Find( (Mobile) mob );
PlayerState pl = PlayerState.Find( mob );
if ( pl != null )
{
@ -1004,7 +993,7 @@ namespace Server.Factions
public bool CanHandleInflux( int influx )
{
if( !StabilityActive())
if ( !StabilityActive())
return true;
Faction smallest = FindSmallestFaction();
@ -1063,9 +1052,8 @@ namespace Server.Factions
if ( killerState == null )
return;
if ( victim is BaseCreature )
if ( victim is BaseCreature bc )
{
BaseCreature bc = (BaseCreature)victim;
Faction victimFaction = bc.FactionAllegiance;
if ( bc.Map == Faction.Facet && victimFaction != null && killerState.Faction != victimFaction )
@ -1261,17 +1249,15 @@ namespace Server.Factions
if ( pl != null )
return pl.Faction;
if ( inherit && mob is BaseCreature )
if ( inherit && mob is BaseCreature bc )
{
BaseCreature bc = (BaseCreature)mob;
if ( bc.Controlled )
return Find( bc.ControlMaster, false );
else if ( bc.Summoned )
if ( bc.Summoned )
return Find( bc.SummonMaster, false );
else if ( creatureAllegiances && mob is BaseFactionGuard )
return ((BaseFactionGuard)mob).Faction;
else if ( creatureAllegiances )
if ( creatureAllegiances && bc is BaseFactionGuard guard )
return guard.Faction;
if ( creatureAllegiances )
return bc.FactionAllegiance;
}
@ -1364,9 +1350,7 @@ namespace Server.Factions
}
case FactionKickType.Ban:
{
Account acct = mob.Account as Account;
if ( acct != null )
if ( mob.Account is Account acct )
{
if ( acct.GetTag( "FactionBanned" ) == null )
{
@ -1404,9 +1388,7 @@ namespace Server.Factions
}
case FactionKickType.Unban:
{
Account acct = mob.Account as Account;
if ( acct != null )
if ( mob.Account is Account acct )
{
if ( acct.GetTag( "FactionBanned" ) == null )
{

View file

@ -45,17 +45,16 @@ namespace Server.Factions
public void Attach()
{
if ( m_Item is IFactionItem )
((IFactionItem)m_Item).FactionItemState = this;
if ( m_Item is IFactionItem item )
item.FactionItemState = this;
if ( m_Faction != null )
m_Faction.State.FactionItems.Add( this );
m_Faction?.State.FactionItems.Add( this );
}
public void Detach()
{
if ( m_Item is IFactionItem )
((IFactionItem)m_Item).FactionItemState = null;
if ( m_Item is IFactionItem item )
item.FactionItemState = null;
if ( m_Faction != null && m_Faction.State.FactionItems.Contains( this ) )
m_Faction.State.FactionItems.Remove( this );
@ -107,11 +106,11 @@ namespace Server.Factions
public static FactionItem Find( Item item )
{
if ( item is IFactionItem )
if ( item is IFactionItem factionItem )
{
FactionItem state = ((IFactionItem)item).FactionItemState;
FactionItem state = factionItem.FactionItemState;
if ( state != null && state.HasExpired )
if ( state?.HasExpired == true )
{
state.Detach();
state = null;
@ -143,4 +142,4 @@ namespace Server.Factions
return item;
}
}
}
}

View file

@ -51,7 +51,7 @@ namespace Server.Factions
for ( int i = 0; i < members.Count; ++i )
{
PlayerState ps = members[i];
if ( ps.IsActive )
{
ps.IsActive = false;
@ -219,7 +219,7 @@ namespace Server.Factions
}
m_Faction.State = this;
m_Faction.ZeroRankOffset = m_Members.Count;
m_Members.Sort();
@ -254,9 +254,7 @@ namespace Server.Factions
for ( int i = 0; i < factionTrapCount; ++i )
{
BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap;
if ( trap != null && !trap.CheckDecay() )
if ( reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay() )
m_FactionTraps.Add( trap );
}
}
@ -309,4 +307,4 @@ namespace Server.Factions
writer.Write( (Item) m_FactionTraps[i] );
}
}
}
}

View file

@ -40,8 +40,8 @@ namespace Server.Factions
if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( town.Owner != null && from is PlayerMobile )
from.SendGump( new FinanceGump( (PlayerMobile)from, town.Owner, town ) );
else if ( town.Owner != null && from is PlayerMobile mobile )
mobile.SendGump( new FinanceGump( mobile, town.Owner, town ) );
break;
}
@ -75,7 +75,7 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find( from );
if ( pl != null && pl.Finance != null )
if ( pl?.Finance != null )
{
pl.Finance.Finance = null;
from.SendLocalizedMessage( 1005081 ); // You have been fired as Finance Minister
@ -87,7 +87,7 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find( from );
if ( pl != null && pl.Sheriff != null )
if ( pl?.Sheriff != null )
{
pl.Sheriff.Sheriff = null;
from.SendLocalizedMessage( 1010270 ); // You have been fired as Sheriff
@ -99,16 +99,16 @@ namespace Server.Factions
{
PlayerState pl = PlayerState.Find( from );
if ( pl != null && pl.IsLeaving )
if ( pl?.IsLeaving == true )
{
if ( Faction.CheckLeaveTimer( from ) )
break;
TimeSpan remaining = ( pl.Leaving + Faction.LeavePeriod ) - DateTime.UtcNow;
if( remaining.TotalDays >= 1 )
if ( remaining.TotalDays >= 1 )
from.SendLocalizedMessage( 1042743, remaining.TotalDays.ToString( "N0" ) ) ;// Your term of service will come to an end in ~1_DAYS~ days.
else if( remaining.TotalHours >= 1 )
else if ( remaining.TotalHours >= 1 )
from.SendLocalizedMessage( 1042741, remaining.TotalHours.ToString( "N0" ) ); // Your term of service will come to an end in ~1_HOURS~ hours.
else
from.SendLocalizedMessage( 1042742 ); // Your term of service will come to an end in less than one hour.
@ -156,4 +156,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -169,9 +169,8 @@ namespace Server.Factions
public void Invalidate()
{
if ( m_Mobile is PlayerMobile )
if ( m_Mobile is PlayerMobile pm )
{
PlayerMobile pm = (PlayerMobile)m_Mobile;
pm.InvalidateProperties();
pm.InvalidateMyRunUO();
}
@ -179,8 +178,8 @@ namespace Server.Factions
public void Attach()
{
if ( m_Mobile is PlayerMobile )
((PlayerMobile)m_Mobile).FactionPlayerState = this;
if ( m_Mobile is PlayerMobile mobile )
mobile.FactionPlayerState = this;
}
public PlayerState( Mobile mob, Faction faction, List<PlayerState> owner )
@ -241,10 +240,7 @@ namespace Server.Factions
public static PlayerState Find( Mobile mob )
{
if ( mob is PlayerMobile )
return ((PlayerMobile)mob).FactionPlayerState;
return null;
return mob is PlayerMobile mobile ? mobile.FactionPlayerState : null;
}
public int CompareTo( object obj )

View file

@ -59,20 +59,16 @@ namespace Server.Factions
if ( type.IsSubclassOf( typeof( Faction ) ) )
{
Faction faction = Construct( type ) as Faction;
if ( faction != null )
if ( Construct( type ) is Faction faction )
Faction.Factions.Add( faction );
}
else if ( type.IsSubclassOf( typeof( Town ) ) )
{
Town town = Construct( type ) as Town;
if ( town != null )
if ( Construct( type ) is Town town )
Town.Towns.Add( town );
}
}
}
}
}
}
}

View file

@ -30,14 +30,10 @@ namespace Server.Factions
if ( m.AccessLevel >= AccessLevel.Counselor || Contains( oldLocation ) )
return true;
if ( m is PlayerMobile ) {
PlayerMobile pm = (PlayerMobile)m;
if ( pm.DuelContext != null ) {
m.SendMessage( "You may not enter this area while participating in a duel or a tournament." );
return false;
}
if ( m is PlayerMobile pm && pm.DuelContext != null) {
pm.SendMessage( "You may not enter this area while participating in a duel or a tournament." );
return false;
}
return ( Faction.Find( m, true, true ) != null );
@ -48,4 +44,4 @@ namespace Server.Factions
return false;
}
}
}
}

View file

@ -134,13 +134,8 @@ namespace Server.Factions
foreach ( BaseMonolith monolith in monoliths )
{
if ( monolith is TownMonolith )
{
TownMonolith townMonolith = (TownMonolith)monolith;
if ( townMonolith.Town == this )
return townMonolith;
}
if ( monolith is TownMonolith townMonolith && townMonolith.Town == this )
return townMonolith;
}
return null;
@ -184,20 +179,10 @@ namespace Server.Factions
else if ( isSheriff )
type = "guard";
if ( obj is BaseFactionVendor )
{
BaseFactionVendor vendor = (BaseFactionVendor)obj;
if ( vendor.Town == this && isFinance )
vendor.Delete();
}
else if ( obj is BaseFactionGuard )
{
BaseFactionGuard guard = (BaseFactionGuard)obj;
if ( guard.Town == this && isSheriff )
guard.Delete();
}
if ( obj is BaseFactionVendor vendor && vendor.Town == this && isFinance )
vendor.Delete();
else if ( obj is BaseFactionGuard guard && guard.Town == this && isSheriff )
guard.Delete();
else
{
from.SendMessage( "That is not a {0}!", type );
@ -208,16 +193,14 @@ namespace Server.Factions
public void StartIncomeTimer()
{
if ( m_IncomeTimer != null )
m_IncomeTimer.Stop();
m_IncomeTimer?.Stop();
m_IncomeTimer = Timer.DelayCall( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( CheckIncome ) );
}
public void StopIncomeTimer()
{
if ( m_IncomeTimer != null )
m_IncomeTimer.Stop();
m_IncomeTimer?.Stop();
m_IncomeTimer = null;
}

View file

@ -28,9 +28,9 @@ namespace Server.Factions
public static FactionItemDefinition Identify( Item item )
{
if ( item is BaseArmor )
if ( item is BaseArmor armor )
{
if ( CraftResources.GetType( ((BaseArmor)item).Resource ) == CraftResourceType.Leather )
if ( CraftResources.GetType( armor.Resource ) == CraftResourceType.Leather )
return m_LeatherArmor;
return m_MetalArmor;
@ -38,14 +38,14 @@ namespace Server.Factions
if ( item is BaseRanged )
return m_RangedWeapon;
else if ( item is BaseWeapon )
if ( item is BaseWeapon )
return m_Weapon;
else if ( item is BaseClothing )
if ( item is BaseClothing )
return m_Clothing;
else if ( item is SpellScroll )
if ( item is SpellScroll )
return m_Scroll;
return null;
}
}
}
}

View file

@ -154,9 +154,9 @@ namespace Server.Factions
{
object obj = fields[j];
if ( obj is Mobile )
if ( obj is Mobile mobile )
{
AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( ((Mobile)obj).Name, LabelColor ), false, false );
AddHtml( x + 2, 140 + (idx * 20), 150, 20, Color( mobile.Name, LabelColor ), false, false );
x += 150;
}
else if ( obj is System.Net.IPAddress )
@ -164,14 +164,14 @@ namespace Server.Factions
AddHtml( x, 140 + (idx * 20), 100, 20, Color( Center( obj.ToString() ), LabelColor ), false, false );
x += 100;
}
else if ( obj is DateTime )
else if ( obj is DateTime time )
{
AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( ((DateTime)obj) - election.LastStateTime ) ), LabelColor ), false, false );
AddHtml( x, 140 + (idx * 20), 80, 20, Color( Center( FormatTimeSpan( time - election.LastStateTime ) ), LabelColor ), false, false );
x += 80;
}
else if ( obj is int )
else if ( obj is int i1 )
{
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( (int)obj + "%" ), LabelColor ), false, false );
AddHtml( x, 140 + (idx * 20), 60, 20, Color( Center( i1 + "%" ), LabelColor ), false, false );
x += 60;
}
}
@ -215,4 +215,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -20,8 +20,8 @@ namespace Server.Factions
private FactionItemDefinition m_Definition;
public FactionImbueGump( int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def ) : base( 100, 200 )
{
public FactionImbueGump( int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def ) : base( 100, 200 )
{
m_Item = item;
m_Mobile = from;
m_Faction = faction;
@ -39,13 +39,13 @@ namespace Server.Factions
AddHtmlLocalized( 20, 20, 210, 25, 1011569, false, false ); // Imbue with Faction properties?
AddHtmlLocalized( 20, 60, 170, 25, 1018302, false, false ); // Item quality:
AddHtmlLocalized( 20, 60, 170, 25, 1018302, false, false ); // Item quality:
AddHtmlLocalized( 175, 60, 100, 25, 1018305 - m_Quality, false, false ); // Exceptional, Average, Low
AddHtmlLocalized( 20, 80, 170, 25, 1011572, false, false ); // Item Cost :
AddHtmlLocalized( 20, 80, 170, 25, 1011572, false, false ); // Item Cost :
AddLabel( 175, 80, 0x34, def.SilverCost.ToString( "N0" ) ); // NOTE: Added 'N0'
AddHtmlLocalized( 20, 100, 170, 25, 1011573, false, false ); // Your Silver :
AddHtmlLocalized( 20, 100, 170, 25, 1011573, false, false ); // Your Silver :
AddLabel( 175, 100, 0x34, availableSilver.ToString( "N0" ) ); // NOTE: Added 'N0'
@ -95,10 +95,10 @@ namespace Server.Factions
if ( m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0 )
m_Mobile.SendGump( new CraftGump( m_Mobile, m_CraftSystem, m_Tool, m_Notice ) );
else if ( m_Notice is string )
m_Mobile.SendMessage( (string) m_Notice );
else if ( m_Notice is int && ((int)m_Notice) > 0 )
m_Mobile.SendLocalizedMessage( (int) m_Notice );
else if ( m_Notice is string s )
m_Mobile.SendMessage( s );
else if ( m_Notice is int i && i > 0 )
m_Mobile.SendLocalizedMessage( i );
}
}
}
}

View file

@ -20,7 +20,7 @@ namespace Server.Factions
AddBackground( 0, 0, 270, 120, 5054 );
AddBackground( 10, 10, 250, 100, 3000 );
if ( from.Guild is Guild && ((Guild)from.Guild).Leader == from )
if ( from.Guild is Guild guild && guild.Leader == from )
AddHtmlLocalized( 20, 15, 230, 60, 1018057, true, true ); // Are you sure you want your entire guild to leave this faction?
else
AddHtmlLocalized( 20, 15, 230, 60, 1018063, true, true ); // Are you sure you want to leave this faction?
@ -38,9 +38,7 @@ namespace Server.Factions
{
case 1: // continue
{
Guild guild = m_From.Guild as Guild;
if ( guild == null )
if ( !(m_From.Guild is Guild guild) )
{
PlayerState pl = PlayerState.Find( m_From );
@ -89,4 +87,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -124,9 +124,8 @@ namespace Server.Factions
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else if ( obj is Mobile )
else if ( obj is Mobile targ )
{
Mobile targ = (Mobile)obj;
PlayerState pl = PlayerState.Find( targ );
if ( pl == null )
@ -163,15 +162,13 @@ namespace Server.Factions
if ( m_Town.Owner != m_Faction || !m_Faction.IsCommander( from ) )
{
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
else if ( m_Town.Finance != null )
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}
else if ( obj is Mobile )
else if ( obj is Mobile targ )
{
Mobile targ = (Mobile)obj;
PlayerState pl = PlayerState.Find( targ );
if ( pl == null )
@ -203,4 +200,4 @@ namespace Server.Factions
}
}
}
}
}

View file

@ -48,27 +48,27 @@ namespace Server.Factions
{
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
}
else if ( from is PlayerMobile )
else if ( from is PlayerMobile mobile )
{
Faction existingFaction = Faction.Find( from );
Faction existingFaction = Faction.Find( mobile );
if ( existingFaction == m_Faction || from.AccessLevel >= AccessLevel.GameMaster )
if ( existingFaction == m_Faction || mobile.AccessLevel >= AccessLevel.GameMaster )
{
PlayerState pl = PlayerState.Find( from );
PlayerState pl = PlayerState.Find( mobile );
if ( pl != null && pl.IsLeaving )
from.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction
mobile.SendLocalizedMessage( 1005051 ); // You cannot use the faction stone until you have finished quitting your current faction
else
from.SendGump( new FactionStoneGump( (PlayerMobile) from, m_Faction ) );
mobile.SendGump( new FactionStoneGump( mobile, m_Faction ) );
}
else if ( existingFaction != null )
{
// TODO: Validate
from.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
mobile.SendLocalizedMessage( 1005053 ); // This is not your faction stone!
}
else
{
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
mobile.SendGump( new JoinStoneGump( mobile, m_Faction ) );
}
}
}

View file

@ -45,8 +45,8 @@ namespace Server.Factions
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( FactionGump.Exists( from ) )
from.SendLocalizedMessage( 1042160 ); // You already have a faction menu open.
else if ( Faction.Find( from ) == null && from is PlayerMobile )
from.SendGump( new JoinStoneGump( (PlayerMobile) from, m_Faction ) );
else if ( Faction.Find( from ) == null && from is PlayerMobile mobile )
mobile.SendGump( new JoinStoneGump( mobile, m_Faction ) );
}
public JoinStone( Serial serial ) : base( serial )

View file

@ -49,7 +49,7 @@ namespace Server {
from.PlaySound( 0x1EE );
from.AddStatMod( new StatMod( StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes( time ) ) );
Timer.DelayCall( TimeSpan.FromMinutes( time ), delegate() {
Timer.DelayCall( TimeSpan.FromMinutes( time ), delegate {
from.EndAction( typeof( ClarityPotion ) );
} );
@ -71,4 +71,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -119,16 +119,16 @@ namespace Server {
public override void OnDoubleClick( Mobile from ) {
if ( !IsChildOf( from.Backpack ) ) {
from.SendLocalizedMessage( 1042038 ); // You must have the object in your backpack to use it.
} else if ( from is PlayerMobile && ((PlayerMobile)from).DuelContext != null ) {
from.SendMessage( "You can't use that." );
} else if ( from is PlayerMobile mobile && mobile.DuelContext != null ) {
mobile.SendMessage( "You can't use that." );
} else if ( Faction.Find( from ) == null ) {
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2119, false, "The object vanishes from your hands as you touch it." );
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate {
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "You feel a strange tingling sensation throughout your body." );
} );
Timer.DelayCall( TimeSpan.FromSeconds( 4.0 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 4.0 ), delegate {
from.LocalOverheadMessage( Server.Network.MessageType.Regular, 2118, false, "Your skin begins to burn." );
} );
@ -162,4 +162,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -30,9 +30,7 @@ namespace Server {
if ( this.Movable ) {
user.BeginTarget( 12, true, Server.Targeting.TargetFlags.None, delegate( Mobile from, object obj ) {
if ( this.Movable && !this.Deleted ) {
IPoint3D pt = obj as IPoint3D;
if ( pt != null ) {
if ( obj is IPoint3D pt ) {
SpellHelper.GetSurfaceTop( ref pt );
Point3D origin = new Point3D( pt );
@ -46,7 +44,7 @@ namespace Server {
this.ItemID & 0x3FFF, 7, 0, false, false, this.Hue - 1, 0
);
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), delegate {
this.Delete();
Effects.PlaySound( origin, facet, 530 );
@ -57,7 +55,7 @@ namespace Server {
14284, 96, 1, 0, 2
);
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate {
List<Mobile> targets = new List<Mobile>();
foreach ( Mobile mob in facet.GetMobilesInRange( origin, 12 ) ) {
@ -88,7 +86,7 @@ namespace Server {
SpellHelper.Damage( TimeSpan.FromSeconds( 0.70 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
SpellHelper.Damage( TimeSpan.FromSeconds( 1.00 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
Timer.DelayCall( TimeSpan.FromSeconds( 0.50 ), delegate() {
Timer.DelayCall( TimeSpan.FromSeconds( 0.50 ), delegate {
mob.PlaySound( 0x1FB );
} );
}
@ -115,4 +113,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Factions
public static readonly TimeSpan CorruptionGrace = TimeSpan.FromMinutes( (Core.SE) ? 30.0 : 15.0 );
// Sigil must be held at a stronghold for this amount of time in order to become corrupted
public static readonly TimeSpan CorruptionPeriod = ( (Core.SE) ? TimeSpan.FromHours( 10.0 ) : TimeSpan.FromHours( 24.0 ) );
public static readonly TimeSpan CorruptionPeriod = ( (Core.SE) ? TimeSpan.FromHours( 10.0 ) : TimeSpan.FromHours( 24.0 ) );
// After a sigil has been corrupted it must be returned to the town within this period of time
public static readonly TimeSpan ReturnPeriod = TimeSpan.FromHours( 1.0 );
@ -177,11 +177,11 @@ namespace Server.Factions
private Mobile FindOwner( object parent )
{
if ( parent is Item )
return ((Item)parent).RootParent as Mobile;
if ( parent is Item item )
return item.RootParent as Mobile;
if ( parent is Mobile )
return (Mobile) parent;
if ( parent is Mobile mobile )
return mobile;
return null;
}
@ -227,7 +227,7 @@ namespace Server.Factions
{
Container pack = mob.Backpack;
return ( pack != null && pack.FindItemByType( typeof( Sigil ) ) != null );
return ( pack?.FindItemByType( typeof( Sigil ) ) != null );
}
private void BeginCorrupting( Faction faction )
@ -267,10 +267,8 @@ namespace Server.Factions
#region Give To Mobile
if ( obj is Mobile )
{
if ( obj is PlayerMobile )
if ( obj is PlayerMobile targ )
{
PlayerMobile targ = (PlayerMobile)obj;
Faction toFaction = Faction.Find( targ );
Faction fromFaction = Faction.Find( from );
@ -280,14 +278,13 @@ namespace Server.Factions
from.SendLocalizedMessage( 1005222 ); // You cannot give the sigil to someone not in your faction
else if ( Sigil.ExistsOn( targ ) )
from.SendLocalizedMessage( 1005220 ); // You cannot give this sigil to someone who already has a sigil
else if( !targ.Alive )
else if ( !targ.Alive )
from.SendLocalizedMessage( 1042248 ); // You cannot give a sigil to a dead person.
else if ( from.NetState != null && targ.NetState != null )
{
Container pack = targ.Backpack;
if ( pack != null )
pack.DropItem( this );
pack?.DropItem( this );
}
}
else
@ -299,19 +296,17 @@ namespace Server.Factions
else if ( obj is BaseMonolith )
{
#region Put in Stronghold
if ( obj is StrongholdMonolith )
if ( obj is StrongholdMonolith sm )
{
StrongholdMonolith m = (StrongholdMonolith)obj;
if ( m.Faction == null || m.Faction != Faction.Find( from ) )
if ( sm.Faction == null || sm.Faction != Faction.Find( from ) )
from.SendLocalizedMessage( 1042246 ); // You can't place that on an enemy monolith
else if ( m.Town == null || m.Town != m_Town )
else if ( sm.Town == null || sm.Town != m_Town )
from.SendLocalizedMessage( 1042247 ); // That is not the correct faction monolith
else
{
m.Sigil = this;
sm.Sigil = this;
Faction newController = m.Faction;
Faction newController = sm.Faction;
Faction oldController = m_Corrupting;
if ( oldController == null )
@ -343,17 +338,15 @@ namespace Server.Factions
#endregion
#region Put in Town
else if ( obj is TownMonolith )
else if ( obj is TownMonolith tm )
{
TownMonolith m = (TownMonolith)obj;
if ( m.Town == null || m.Town != m_Town )
if ( tm.Town == null || tm.Town != m_Town )
from.SendLocalizedMessage( 1042245 ); // This is not the correct town sigil monolith
else if ( m_Corrupted == null || m_Corrupted != Faction.Find( from ) )
from.SendLocalizedMessage( 1042244 ); // Your faction did not corrupt this sigil. Take it to your stronghold.
else
{
m.Sigil = this;
tm.Sigil = this;
m_Corrupting = null;
m_PurificationStart = DateTime.UtcNow;
@ -367,7 +360,7 @@ namespace Server.Factions
}
else
{
from.SendLocalizedMessage( 1005224 ); // You can't use the sigil on that
from.SendLocalizedMessage( 1005224 ); // You can't use the sigil on that
}
Update();
@ -419,9 +412,7 @@ namespace Server.Factions
Update();
Mobile mob = RootParent as Mobile;
if ( mob != null )
if ( RootParent is Mobile mob )
mob.SolidHueOverride = OwnershipHue;
break;
@ -468,4 +459,4 @@ namespace Server.Factions
public static List<Sigil> Sigils{ get{ return m_Sigils; } }
}
}
}

View file

@ -51,8 +51,8 @@ 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 )
from.SendGump( new TownStoneGump( (PlayerMobile)from, m_Town.Owner, m_Town ) );
else if ( @from is PlayerMobile mobile )
mobile.SendGump( new TownStoneGump( mobile, m_Town.Owner, m_Town ) );
}
public TownStone( Serial serial ) : base( serial )

View file

@ -110,7 +110,7 @@ namespace Server.Factions
public abstract void DoVisibleEffect();
public abstract void DoAttackEffect( Mobile m );
public virtual int IsValidLocation()
{
return IsValidLocation( GetWorldLocation(), Map );
@ -118,14 +118,14 @@ namespace Server.Factions
public virtual int IsValidLocation( Point3D p, Map m )
{
if( m == null )
if ( m == null )
return 502956; // You cannot place a trap on that.
if( Core.ML )
if ( Core.ML )
{
foreach( Item item in m.GetItemsInRange( p, 0 ) )
{
if( item is BaseFactionTrap && ((BaseFactionTrap)item).Faction == this.Faction )
if ( item is BaseFactionTrap trap && trap.Faction == this.Faction )
return 1075263; // There is already a trap belonging to your faction at this location.;
}
}
@ -282,8 +282,8 @@ namespace Server.Factions
Faction faction = Faction.Find( mob, true );
if ( faction == null && mob is BaseFactionGuard )
faction = ((BaseFactionGuard)mob).Faction;
if ( faction == null && mob is BaseFactionGuard guard )
faction = guard.Faction;
if ( faction == null )
return false;
@ -291,4 +291,4 @@ namespace Server.Factions
return ( faction != m_Faction );
}
}
}
}

View file

@ -54,9 +54,9 @@ namespace Server.Factions
from.SendLocalizedMessage( 1010353, "", 0x23 ); // Only faction members may place faction traps
else if ( faction != m_Faction )
from.SendLocalizedMessage( 1010354, "", 0x23 ); // You may only place faction traps created by your faction
else if( faction.Traps.Count >= faction.MaximumTraps )
else if ( faction.Traps.Count >= faction.MaximumTraps )
from.SendLocalizedMessage( 1010358, "", 0x23 ); // Your faction already has the maximum number of traps placed
else
else
{
BaseFactionTrap trap = Construct( from );
@ -109,4 +109,4 @@ namespace Server.Factions
#endregion
}
}
}

View file

@ -62,8 +62,8 @@ namespace Server.Factions
Faction ourFaction = m_Faction;
Faction theirFaction = Faction.Find( m );
if ( theirFaction == null && m is BaseFactionGuard )
theirFaction = ((BaseFactionGuard)m).Faction;
if ( theirFaction == null && m is BaseFactionGuard guard )
theirFaction = guard.Faction;
if ( ourFaction != null && theirFaction != null && ourFaction != theirFaction )
{
@ -72,22 +72,14 @@ namespace Server.Factions
if ( reactionType == ReactionType.Attack )
return true;
if ( theirFaction != null )
List<AggressorInfo> list = m.Aggressed;
for ( int i = 0; i < list.Count; ++i )
{
List<AggressorInfo> list = m.Aggressed;
AggressorInfo ai = list[i];
for ( int i = 0; i < list.Count; ++i )
{
AggressorInfo ai = list[i];
if ( ai.Defender is BaseFactionGuard )
{
BaseFactionGuard bf = (BaseFactionGuard)ai.Defender;
if ( bf.Faction == ourFaction )
return true;
}
}
if ( ai.Defender is BaseFactionGuard bf && bf.Faction == ourFaction )
return true;
}
}

View file

@ -165,9 +165,7 @@ namespace Server.Factions
if ( pack == null )
return false;
Item weapon = m_Guard.Weapon as Item;
if ( weapon != null && weapon.Parent == m_Guard && !(weapon is Fists) )
if ( m_Guard.Weapon is Item weapon && weapon.Parent == m_Guard && !(weapon is Fists) )
{
pack.DropItem( weapon );
return true;
@ -180,10 +178,7 @@ namespace Server.Factions
{
Container pack = m_Guard.Backpack;
if ( pack == null )
return false;
Item weapon = pack.FindItemByType( typeof( BaseWeapon ) );
Item weapon = pack?.FindItemByType( typeof( BaseWeapon ) );
if ( weapon == null )
return false;
@ -197,10 +192,7 @@ namespace Server.Factions
Container pack = m_Guard.Backpack;
if ( pack == null )
return false;
Item bandage = pack.FindItemByType( typeof( Bandage ) );
Item bandage = pack?.FindItemByType( typeof( Bandage ) );
if ( bandage == null )
return false;
@ -214,10 +206,7 @@ namespace Server.Factions
{
Container pack = m_Guard.Backpack;
if ( pack == null )
return false;
Item item = pack.FindItemByType( type );
Item item = pack?.FindItemByType( type );
if ( item == null )
return false;
@ -375,7 +364,7 @@ namespace Server.Factions
public bool CanDispel( Mobile m )
{
return ( m is BaseCreature && ((BaseCreature)m).Summoned && m_Mobile.CanBeHarmful( m, false ) && !((BaseCreature)m).IsAnimatedDead );
return ( m is BaseCreature creature && creature.Summoned && m_Mobile.CanBeHarmful( creature, false ) && !creature.IsAnimatedDead );
}
public void RunTo( Mobile m )
@ -606,7 +595,7 @@ namespace Server.Factions
}
else if ( IsDamaged && (m_Guard.HitsMax - m_Guard.Hits) > Utility.Random( 200 ) )
{
if( IsAllowed( GuardAI.Magic ) && ((m_Guard.Hits * 100) / Math.Max( m_Guard.HitsMax, 1 )) < 10 && m_Guard.Home != Point3D.Zero && !Utility.InRange( m_Guard.Location, m_Guard.Home, 15 ) && m_Guard.Mana >= 11 )
if ( IsAllowed( GuardAI.Magic ) && ((m_Guard.Hits * 100) / Math.Max( m_Guard.HitsMax, 1 )) < 10 && m_Guard.Home != Point3D.Zero && !Utility.InRange( m_Guard.Location, m_Guard.Home, 15 ) && m_Guard.Mana >= 11 )
{
spell = new RecallSpell( m_Guard, null, new RunebookEntry( m_Guard.Home, m_Guard.Map, "Guard's Home", null ), null );
}
@ -768,7 +757,7 @@ namespace Server.Factions
if ( spell == null || !spell.Cast() )
EquipWeapon();
}
else if ( m_Mobile.Spell is Spell && ((Spell)m_Mobile.Spell).State == SpellState.Sequencing )
else if ( m_Mobile.Spell is Spell spell && spell.State == SpellState.Sequencing )
{
EquipWeapon();
}
@ -776,4 +765,4 @@ namespace Server.Factions
return true;
}
}
}
}

View file

@ -40,7 +40,7 @@ namespace Server.Factions
AddItem( Immovable( Rehued( new ChainChest(), 2125 ) ) );
AddItem( Immovable( Rehued( new ChainLegs(), 2125 ) ) );
AddItem( Immovable( Rehued( new ChainCoif(), 2125 ) ) );
AddItem( Immovable( Rehued( new ChainCoif (), 2125 ) ) );
AddItem( Immovable( Rehued( new PlateArms(), 2125 ) ) );
AddItem( Immovable( Rehued( new PlateGloves(), 2125 ) ) );

View file

@ -36,7 +36,7 @@ namespace Server.Factions
AddItem( new ChainLegs() );
AddItem( new RingmailArms() );
AddItem( new RingmailGloves() );
AddItem( new ChainCoif() );
AddItem( new ChainCoif () );
AddItem( new Boots() );
AddItem( Newbied( new ShortSpear() ) );

View file

@ -14,7 +14,7 @@ namespace Server.Factions
{
SetSkill( SkillName.AnimalLore, 64.0, 100.0 );
SetSkill( SkillName.AnimalTaming, 90.0, 100.0 );
SetSkill( SkillName.Veterinary, 65.0, 88.0 );
SetSkill( SkillName.Veterinary, 65.0, 88.0 );
}
public override void InitSBInfo()
@ -48,8 +48,8 @@ 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 )
from.SendGump( new HorseBreederGump( (PlayerMobile) from, this.Faction ) );
else if ( @from is PlayerMobile mobile )
mobile.SendGump( new HorseBreederGump( mobile, this.Faction ) );
}
public override void VendorSell( Mobile from )
@ -80,4 +80,4 @@ namespace Server.Factions
int version = reader.ReadInt();
}
}
}
}