Fixes casting checks
This commit is contained in:
parent
7ea00fbf4f
commit
03dd5f1926
431 changed files with 5616 additions and 6250 deletions
|
|
@ -24,11 +24,11 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
@ -282,8 +282,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if ( obj is Mobile )
|
||||
pt.Z += 10;
|
||||
else if ( obj is Item )
|
||||
pt.Z += ((Item)obj).ItemData.CalcHeight + 1;
|
||||
else if ( obj is Item item )
|
||||
pt.Z += item.ItemData.CalcHeight + 1;
|
||||
|
||||
m_Flying = true;
|
||||
this.Visible = false;
|
||||
|
|
@ -317,12 +317,12 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
if ( zdiff < 0 )
|
||||
return false;
|
||||
else if ( zdiff < 12 )
|
||||
if ( zdiff < 12 )
|
||||
return true;
|
||||
else if ( zdiff < 16 )
|
||||
if ( zdiff < 16 )
|
||||
return Utility.RandomBool(); // 50% chance
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DoAnim( Point3D start, Point3D end, Map map )
|
||||
|
|
@ -604,10 +604,10 @@ namespace Server.Engines.ConPVP
|
|||
continue;
|
||||
|
||||
area.Free();
|
||||
if ( i is BRGoal )
|
||||
if ( i is BRGoal goal )
|
||||
{
|
||||
Point3D oldLoc = new Point3D( this.GetWorldLocation() );
|
||||
if ( CheckScore( (BRGoal)i, m_Thrower, 3 ) )
|
||||
if ( CheckScore( goal, m_Thrower, 3 ) )
|
||||
DoAnim( oldLoc, point, this.Map );
|
||||
else
|
||||
HitObject( point, loc.Z, height );
|
||||
|
|
@ -939,9 +939,7 @@ namespace Server.Engines.ConPVP
|
|||
else
|
||||
this.Hue = 0x84C;
|
||||
|
||||
BRBomb b = m.Backpack.FindItemByType( typeof( BRBomb ), true ) as BRBomb;
|
||||
|
||||
if ( b != null )
|
||||
if ( m.Backpack.FindItemByType( typeof( BRBomb ), true ) is BRBomb b )
|
||||
b.CheckScore( this, m, 7 );
|
||||
|
||||
return true;
|
||||
|
|
@ -1321,9 +1319,7 @@ namespace Server.Engines.ConPVP
|
|||
if ( mob == null )
|
||||
return null;
|
||||
|
||||
BRPlayerInfo val = m_Players[mob] as BRPlayerInfo;
|
||||
|
||||
if ( val == null )
|
||||
if ( !(m_Players[mob] is BRPlayerInfo val) )
|
||||
m_Players[mob] = val = new BRPlayerInfo( this, mob );
|
||||
|
||||
return val;
|
||||
|
|
@ -1623,15 +1619,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetTeamID( Mobile mob )
|
||||
{
|
||||
PlayerMobile pm = mob as PlayerMobile;
|
||||
|
||||
if ( pm == null )
|
||||
{
|
||||
if ( mob is BaseCreature )
|
||||
return ((BaseCreature)mob).Team - 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
if ( !(mob is PlayerMobile pm) )
|
||||
return mob is BaseCreature creature ? creature.Team - 1 : -1;
|
||||
|
||||
if ( pm.DuelContext == null || pm.DuelContext != m_Context )
|
||||
return -1;
|
||||
|
|
@ -1644,12 +1633,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetColor( Mobile mob )
|
||||
{
|
||||
BRTeamInfo teamInfo = GetTeamInfo( mob );
|
||||
|
||||
if ( teamInfo != null )
|
||||
return teamInfo.Color;
|
||||
|
||||
return -1;
|
||||
return GetTeamInfo( mob )?.Color ?? -1;
|
||||
}
|
||||
|
||||
private void ApplyHues( Participant p, int hueOverride )
|
||||
|
|
@ -1674,8 +1658,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
DuelPlayer dp = null;
|
||||
|
||||
if ( mob is PlayerMobile )
|
||||
dp = ( mob as PlayerMobile ).DuelPlayer;
|
||||
if ( mob is PlayerMobile mobile )
|
||||
dp = mobile.DuelPlayer;
|
||||
|
||||
m_Context.RemoveAggressions( mob );
|
||||
|
||||
|
|
@ -1896,9 +1880,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
for ( int i = 0; i < m_Context.Participants.Count; ++i )
|
||||
{
|
||||
Participant p = m_Context.Participants[i] as Participant;
|
||||
|
||||
if ( p == null || p.Players == null )
|
||||
if ( !(m_Context.Participants[i] is Participant p) || p.Players == null )
|
||||
continue;
|
||||
|
||||
for ( int j = 0; j < p.Players.Length; ++j )
|
||||
|
|
@ -1915,7 +1897,7 @@ namespace Server.Engines.ConPVP
|
|||
if ( i == winner.TeamID )
|
||||
continue;
|
||||
|
||||
if ( p != null && p.Players != null )
|
||||
if ( p.Players != null )
|
||||
{
|
||||
for ( int j = 0; j < p.Players.Length; ++j )
|
||||
{
|
||||
|
|
@ -1942,15 +1924,12 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
ReturnBomb();
|
||||
|
||||
if( m_Bomb != null )
|
||||
m_Bomb.Delete();
|
||||
m_Bomb?.Delete();
|
||||
|
||||
for ( int i = 0; i < m_Context.Participants.Count; ++i )
|
||||
ApplyHues( m_Context.Participants[i] as Participant, -1 );
|
||||
|
||||
if ( m_FinishTimer != null )
|
||||
m_FinishTimer.Stop();
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -448,10 +448,8 @@ namespace Server.Engines.ConPVP
|
|||
from.LocalOverheadMessage( MessageType.Regular, 0x26, false, "Those are not my cookies." );
|
||||
}
|
||||
}
|
||||
else if ( obj is Mobile )
|
||||
else if ( obj is Mobile passTo )
|
||||
{
|
||||
Mobile passTo = obj as Mobile;
|
||||
|
||||
CTFTeamInfo passTeam = m_TeamInfo.Game.GetTeamInfo( passTo );
|
||||
|
||||
if ( passTo == from )
|
||||
|
|
@ -481,11 +479,11 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
@ -969,9 +967,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetTeamID( Mobile mob )
|
||||
{
|
||||
PlayerMobile pm = mob as PlayerMobile;
|
||||
|
||||
if ( pm == null )
|
||||
if ( !(mob is PlayerMobile pm) )
|
||||
return -1;
|
||||
|
||||
if ( pm.DuelContext == null || pm.DuelContext != m_Context )
|
||||
|
|
@ -1015,8 +1011,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
DuelPlayer dp = null;
|
||||
|
||||
if ( mob is PlayerMobile )
|
||||
dp = ( mob as PlayerMobile ).DuelPlayer;
|
||||
if ( mob is PlayerMobile mobile )
|
||||
dp = mobile.DuelPlayer;
|
||||
|
||||
m_Context.RemoveAggressions( mob );
|
||||
|
||||
|
|
@ -1088,9 +1084,7 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
for ( int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j )
|
||||
{
|
||||
AggressorInfo aggr = ourFlagCarrier.Aggressors[j] as AggressorInfo;
|
||||
|
||||
if ( aggr == null || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob )
|
||||
if ( !(ourFlagCarrier.Aggressors[j] is AggressorInfo aggr) || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob )
|
||||
continue;
|
||||
|
||||
playerInfo.Score += 2; // helped defend guy capturing enemy flag
|
||||
|
|
|
|||
|
|
@ -604,9 +604,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetTeamID( Mobile mob )
|
||||
{
|
||||
PlayerMobile pm = mob as PlayerMobile;
|
||||
|
||||
if ( pm == null )
|
||||
if ( !(mob is PlayerMobile pm) )
|
||||
return -1;
|
||||
|
||||
if ( pm.DuelContext == null || pm.DuelContext != m_Context )
|
||||
|
|
@ -620,12 +618,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetColor( Mobile mob )
|
||||
{
|
||||
DDTeamInfo teamInfo = GetTeamInfo( mob );
|
||||
|
||||
if ( teamInfo != null )
|
||||
return teamInfo.Color;
|
||||
|
||||
return -1;
|
||||
return GetTeamInfo( mob )?.Color ?? -1;
|
||||
}
|
||||
|
||||
private void ApplyHues( Participant p, int hueOverride )
|
||||
|
|
@ -650,8 +643,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
DuelPlayer dp = null;
|
||||
|
||||
if ( mob is PlayerMobile )
|
||||
dp = ( mob as PlayerMobile ).DuelPlayer;
|
||||
if ( mob is PlayerMobile mobile )
|
||||
dp = mobile.DuelPlayer;
|
||||
|
||||
m_Context.RemoveAggressions( mob );
|
||||
|
||||
|
|
@ -748,9 +741,7 @@ namespace Server.Engines.ConPVP
|
|||
for ( int i = 0; i < m_Context.Participants.Count; ++i )
|
||||
ApplyHues( m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length].Color );
|
||||
|
||||
if ( m_FinishTimer != null )
|
||||
m_FinishTimer.Stop();
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, new TimerCallback( Finish_Callback ) );
|
||||
}
|
||||
|
||||
|
|
@ -766,10 +757,7 @@ namespace Server.Engines.ConPVP
|
|||
teams.Add( teamInfo );
|
||||
}
|
||||
|
||||
teams.Sort( delegate( DDTeamInfo a, DDTeamInfo b )
|
||||
{
|
||||
return b.Score - a.Score;
|
||||
} );
|
||||
teams.Sort((a, b) => b.Score - a.Score);
|
||||
|
||||
Tournament tourny = m_Context.m_Tournament;
|
||||
|
||||
|
|
@ -897,7 +885,7 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
DuelPlayer dp = p.Players[j];
|
||||
|
||||
if ( dp != null && dp.Mobile != null )
|
||||
if ( dp?.Mobile != null )
|
||||
{
|
||||
dp.Mobile.CloseGump( typeof( DDBoardGump ) );
|
||||
dp.Mobile.SendGump( new DDBoardGump( dp.Mobile, this ) );
|
||||
|
|
@ -952,9 +940,7 @@ namespace Server.Engines.ConPVP
|
|||
for ( int i = 0; i < m_Context.Participants.Count; ++i )
|
||||
ApplyHues( m_Context.Participants[i] as Participant, -1 );
|
||||
|
||||
if ( m_FinishTimer != null )
|
||||
m_FinishTimer.Stop();
|
||||
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = null;
|
||||
}
|
||||
|
||||
|
|
@ -981,14 +967,9 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
Alert( "Domination averted!" );
|
||||
|
||||
if ( m_Controller.PointA != null )
|
||||
m_Controller.PointA.SetNonCaptureHue();
|
||||
|
||||
if ( m_Controller.PointB != null )
|
||||
m_Controller.PointB.SetNonCaptureHue();
|
||||
|
||||
if ( m_CaptureTimer != null )
|
||||
m_CaptureTimer.Stop();
|
||||
m_Controller.PointA?.SetNonCaptureHue();
|
||||
m_Controller.PointB?.SetNonCaptureHue();
|
||||
m_CaptureTimer?.Stop();
|
||||
m_CaptureTimer = null;
|
||||
}
|
||||
|
||||
|
|
@ -1012,8 +993,7 @@ namespace Server.Engines.ConPVP
|
|||
if ( team == null )
|
||||
{
|
||||
m_Capturable = true;
|
||||
if ( m_CaptureTimer != null )
|
||||
m_CaptureTimer.Stop();
|
||||
m_CaptureTimer?.Stop();
|
||||
m_CaptureTimer = null;
|
||||
return;
|
||||
}
|
||||
|
|
@ -1022,11 +1002,8 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
Alert( "{0} is dominating... {1}", team.Name, 10 - m_CapStage );
|
||||
|
||||
if ( m_Controller.PointA != null )
|
||||
m_Controller.PointA.SetCaptureHue( m_CapStage );
|
||||
|
||||
if ( m_Controller.PointB != null )
|
||||
m_Controller.PointB.SetCaptureHue( m_CapStage );
|
||||
m_Controller.PointA?.SetCaptureHue( m_CapStage );
|
||||
m_Controller.PointB?.SetCaptureHue( m_CapStage );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -673,9 +673,7 @@ namespace Server.Engines.ConPVP
|
|||
if (mob == null)
|
||||
return null;
|
||||
|
||||
KHPlayerInfo val = m_Players[mob] as KHPlayerInfo;
|
||||
|
||||
if (val == null)
|
||||
if (!(m_Players[mob] is KHPlayerInfo val))
|
||||
m_Players[mob] = val = new KHPlayerInfo(this, mob);
|
||||
|
||||
return val;
|
||||
|
|
@ -978,15 +976,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetTeamID(Mobile mob)
|
||||
{
|
||||
PlayerMobile pm = mob as PlayerMobile;
|
||||
|
||||
if (pm == null)
|
||||
{
|
||||
if (mob is BaseCreature)
|
||||
return ((BaseCreature)mob).Team - 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
if (!(mob is PlayerMobile pm))
|
||||
return mob is BaseCreature creature ? creature.Team - 1 : -1;
|
||||
|
||||
if (pm.DuelContext == null || pm.DuelContext != m_Context)
|
||||
return -1;
|
||||
|
|
@ -999,12 +990,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public int GetColor(Mobile mob)
|
||||
{
|
||||
KHTeamInfo teamInfo = GetTeamInfo(mob);
|
||||
|
||||
if (teamInfo != null)
|
||||
return teamInfo.Color;
|
||||
|
||||
return -1;
|
||||
return GetTeamInfo(mob)?.Color ?? -1;
|
||||
}
|
||||
|
||||
private void ApplyHues(Participant p, int hueOverride)
|
||||
|
|
@ -1029,8 +1015,8 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
DuelPlayer dp = null;
|
||||
|
||||
if (mob is PlayerMobile)
|
||||
dp = (mob as PlayerMobile).DuelPlayer;
|
||||
if (mob is PlayerMobile mobile)
|
||||
dp = mobile.DuelPlayer;
|
||||
|
||||
m_Context.RemoveAggressions(mob);
|
||||
|
||||
|
|
@ -1252,16 +1238,14 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
for (int i = 0; i < m_Context.Participants.Count; ++i)
|
||||
{
|
||||
Participant p = m_Context.Participants[i] as Participant;
|
||||
|
||||
if (p == null || p.Players == null)
|
||||
if (!(m_Context.Participants[i] is Participant p) || p.Players == null)
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < p.Players.Length; ++j)
|
||||
{
|
||||
DuelPlayer dp = p.Players[j];
|
||||
|
||||
if (dp != null && dp.Mobile != null)
|
||||
if (dp?.Mobile != null)
|
||||
{
|
||||
dp.Mobile.CloseGump(typeof(KHBoardGump));
|
||||
dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this));
|
||||
|
|
@ -1271,7 +1255,7 @@ namespace Server.Engines.ConPVP
|
|||
if (i == winner.TeamID)
|
||||
continue;
|
||||
|
||||
if (p != null && p.Players != null)
|
||||
if (p?.Players != null)
|
||||
{
|
||||
for (int j = 0; j < p.Players.Length; ++j)
|
||||
{
|
||||
|
|
@ -1304,9 +1288,8 @@ namespace Server.Engines.ConPVP
|
|||
for (int i = 0; i < m_Context.Participants.Count; ++i)
|
||||
ApplyHues(m_Context.Participants[i] as Participant, -1);
|
||||
|
||||
if (m_FinishTimer != null)
|
||||
m_FinishTimer.Stop();
|
||||
m_FinishTimer = null;
|
||||
m_FinishTimer?.Stop();
|
||||
m_FinishTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue