Changes properties to use automatic property initializers

This commit is contained in:
Kamron Batman 2018-09-14 15:23:29 -07:00
parent f0a48ad431
commit 06fa31a7bf
623 changed files with 13072 additions and 19304 deletions

View file

@ -15,7 +15,6 @@ namespace Server.Engines.ConPVP
public override string DefaultName => "da bomb";
private BRGame m_Game;
private Mobile m_Thrower;
private EffectTimer m_Timer;
private bool m_Flying;
@ -287,7 +286,7 @@ namespace Server.Engines.ConPVP
m_Flying = true;
Visible = false;
m_Thrower = from;
Thrower = from;
MoveToWorld( GetWorldLocation(), from.Map );
BeginFlight( pt );
@ -348,7 +347,7 @@ namespace Server.Engines.ConPVP
string verb = "caught";
if ( m_Thrower != null && m_Game.GetTeamInfo( m_Thrower ) != useTeam )
if ( Thrower != null && m_Game.GetTeamInfo( Thrower ) != useTeam )
verb = "intercepted";
if ( !TakeBomb( m, useTeam, verb ) )
@ -607,7 +606,7 @@ namespace Server.Engines.ConPVP
if ( i is BRGoal goal )
{
Point3D oldLoc = new Point3D( GetWorldLocation() );
if ( CheckScore( goal, m_Thrower, 3 ) )
if ( CheckScore( goal, Thrower, 3 ) )
DoAnim( oldLoc, point, Map );
else
HitObject( point, loc.Z, height );
@ -626,7 +625,7 @@ namespace Server.Engines.ConPVP
{
Mobile m = ns.Mobile;
if ( m == null || m == m_Thrower )
if ( m == null || m == Thrower )
continue;
Point3D point;
@ -705,7 +704,7 @@ namespace Server.Engines.ConPVP
}
}
public Mobile Thrower => m_Thrower;
public Mobile Thrower { get; private set; }
public bool CheckScore( BRGoal goal, Mobile m, int points )
{
@ -1165,14 +1164,12 @@ namespace Server.Engines.ConPVP
{
private BRTeamInfo m_TeamInfo;
private Mobile m_Player;
private int m_Kills;
private int m_Captures;
private int m_Score;
public Mobile Player => m_Player;
public Mobile Player { get; }
public int CompareTo( object obj )
{
@ -1188,7 +1185,7 @@ namespace Server.Engines.ConPVP
return res;
}
public string Name => m_Player.Name;
public string Name => Player.Name;
public int Kills
{
@ -1226,29 +1223,15 @@ namespace Server.Engines.ConPVP
public BRPlayerInfo( BRTeamInfo teamInfo, Mobile player )
{
m_TeamInfo = teamInfo;
m_Player = player;
Player = player;
}
}
[PropertyObject]
public sealed class BRTeamInfo : IRankedCTF, IComparable
{
private BRGame m_Game;
private int m_TeamID;
private int m_Color;
private string m_Name;
private BRBoard m_Board;
private BRGoal m_Goal;
private int m_Kills;
private int m_Captures;
private int m_Score;
private Hashtable m_Players;
public int CompareTo( object obj )
{
BRTeamInfo ti = (BRTeamInfo)obj;
@ -1263,40 +1246,24 @@ namespace Server.Engines.ConPVP
return res;
}
public string Name => $"{m_Name} Team";
public string Name => $"{TeamName} Team";
public BRGame Game { get => m_Game;
set => m_Game = value;
}
public int TeamID => m_TeamID;
public BRGame Game { get; set; }
public int Kills { get => m_Kills;
set => m_Kills = value;
}
public int Captures { get => m_Captures;
set => m_Captures = value;
}
public int TeamID { get; }
public int Score { get => m_Score;
set => m_Score = value;
}
public int Kills { get; set; }
private BRPlayerInfo m_Leader;
public int Captures { get; set; }
public BRPlayerInfo Leader
{
get => m_Leader;
set => m_Leader = value;
}
public int Score { get; set; }
public BRPlayerInfo Leader { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public BRBoard Board
{
get => m_Board;
set => m_Board = value;
}
public BRBoard Board { get; set; }
public Hashtable Players => m_Players;
public Hashtable Players { get; }
public BRPlayerInfo this[Mobile mob]
{
@ -1305,26 +1272,18 @@ namespace Server.Engines.ConPVP
if ( mob == null )
return null;
if ( !(m_Players[mob] is BRPlayerInfo val) )
m_Players[mob] = val = new BRPlayerInfo( this, mob );
if ( !(Players[mob] is BRPlayerInfo val) )
Players[mob] = val = new BRPlayerInfo( this, mob );
return val;
}
}
[CommandProperty( AccessLevel.GameMaster )]
public int Color
{
get => m_Color;
set => m_Color = value;
}
public int Color { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public string TeamName
{
get => m_Name;
set => m_Name = value;
}
public string TeamName { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public BRGoal Goal
@ -1340,30 +1299,30 @@ namespace Server.Engines.ConPVP
public BRTeamInfo( int teamID )
{
m_TeamID = teamID;
m_Players = new Hashtable();
TeamID = teamID;
Players = new Hashtable();
}
public void Reset()
{
m_Kills = 0;
m_Captures = 0;
m_Score = 0;
Kills = 0;
Captures = 0;
Score = 0;
m_Leader = null;
Leader = null;
m_Players.Clear();
Players.Clear();
if ( m_Board != null )
m_Board.m_TeamInfo = this;
if ( Board != null )
Board.m_TeamInfo = this;
if ( m_Goal != null )
m_Goal.Team = this;
}
public BRTeamInfo( int teamID, GenericReader ip )
{
m_TeamID = teamID;
m_Players = new Hashtable();
TeamID = teamID;
Players = new Hashtable();
int version = ip.ReadEncodedInt();
@ -1371,9 +1330,9 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Board = ip.ReadItem() as BRBoard;
m_Name = ip.ReadString();
m_Color = ip.ReadEncodedInt();
Board = ip.ReadItem() as BRBoard;
TeamName = ip.ReadString();
Color = ip.ReadEncodedInt();
m_Goal = ip.ReadItem() as BRGoal;
break;
}
@ -1384,18 +1343,18 @@ namespace Server.Engines.ConPVP
{
op.WriteEncodedInt( 0 ); // version
op.Write( m_Board );
op.Write( Board );
op.Write( m_Name );
op.Write( TeamName );
op.WriteEncodedInt( m_Color );
op.WriteEncodedInt( Color );
op.Write( m_Goal );
}
public override string ToString()
{
if ( m_Name != null )
if ( TeamName != null )
return $"({Name}) ...";
return "...";
}
@ -1403,48 +1362,36 @@ namespace Server.Engines.ConPVP
public sealed class BRController : EventController
{
private BRTeamInfo[] m_TeamInfo;
private TimeSpan m_Duration;
private Point3D m_BombHome;
public BRTeamInfo[] TeamInfo => m_TeamInfo;
public BRTeamInfo[] TeamInfo { get; private set; }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team1 { get => m_TeamInfo[0];
public BRTeamInfo Team1 { get => TeamInfo[0];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team2 { get => m_TeamInfo[1];
public BRTeamInfo Team2 { get => TeamInfo[1];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team3 { get => m_TeamInfo[2];
public BRTeamInfo Team3 { get => TeamInfo[2];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public BRTeamInfo Team4 { get => m_TeamInfo[3];
public BRTeamInfo Team4 { get => TeamInfo[3];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan Duration
{
get => m_Duration;
set => m_Duration = value;
}
public TimeSpan Duration { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public Point3D BombHome
{
get => m_BombHome;
set => m_BombHome = value;
}
public Point3D BombHome { get; set; }
public override string Title => "Bombing Run";
public override string DefaultName => "Bombing Run Controller";
public override string GetTeamName( int teamID )
{
return m_TeamInfo[teamID % m_TeamInfo.Length].Name;
return TeamInfo[teamID % TeamInfo.Length].Name;
}
public override EventGame Construct( DuelContext context )
@ -1458,14 +1405,14 @@ namespace Server.Engines.ConPVP
Visible = false;
Movable = false;
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
m_BombHome = Point3D.Zero;
BombHome = Point3D.Zero;
m_TeamInfo = new BRTeamInfo[4];
TeamInfo = new BRTeamInfo[4];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new BRTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new BRTeamInfo( i );
}
public BRController( Serial serial )
@ -1479,14 +1426,14 @@ namespace Server.Engines.ConPVP
writer.Write( (int) 0 );
writer.Write( m_BombHome );
writer.Write( BombHome );
writer.Write( m_Duration );
writer.Write( Duration );
writer.WriteEncodedInt( m_TeamInfo.Length );
writer.WriteEncodedInt( TeamInfo.Length );
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i].Serialize( writer );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i].Serialize( writer );
}
public override void Deserialize( GenericReader reader )
@ -1499,14 +1446,14 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_BombHome = reader.ReadPoint3D();
BombHome = reader.ReadPoint3D();
m_Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
m_TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()];
TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new BRTeamInfo( i, reader );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new BRTeamInfo( i, reader );
break;
}
@ -1535,12 +1482,12 @@ namespace Server.Engines.ConPVP
public void ReturnBomb()
{
if ( m_Bomb != null && m_Controller != null )
if ( m_Bomb != null && Controller != null )
{
if ( m_UnhideCallback == null )
m_UnhideCallback = UnhideBomb;
m_Bomb.Visible = false;
m_Bomb.MoveToWorld( m_Controller.BombHome, m_Controller.Map );
m_Bomb.MoveToWorld( Controller.BombHome, Controller.Map );
Timer.DelayCall( TimeSpan.FromSeconds( Utility.RandomMinMax( 5, 15 ) ), m_UnhideCallback );
}
}
@ -1554,9 +1501,7 @@ namespace Server.Engines.ConPVP
}
}
private BRController m_Controller;
public BRController Controller => m_Controller;
public BRController Controller { get; }
public void Alert( string text )
{
@ -1581,7 +1526,7 @@ namespace Server.Engines.ConPVP
public BRGame( BRController controller, DuelContext context ) : base( context )
{
m_Controller = controller;
Controller = controller;
}
public Map Facet
@ -1591,7 +1536,7 @@ namespace Server.Engines.ConPVP
if ( m_Context.Arena != null )
return m_Context.Arena.Facet;
return m_Controller.Map;
return Controller.Map;
}
}
@ -1600,7 +1545,7 @@ namespace Server.Engines.ConPVP
int teamID = GetTeamID( mob );
if ( teamID >= 0 )
return m_Controller.TeamInfo[teamID % m_Controller.TeamInfo.Length];
return Controller.TeamInfo[teamID % Controller.TeamInfo.Length];
return null;
}
@ -1718,23 +1663,23 @@ namespace Server.Engines.ConPVP
public override void OnStart()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
BRTeamInfo teamInfo = m_Controller.TeamInfo[i];
BRTeamInfo teamInfo = Controller.TeamInfo[i];
teamInfo.Game = this;
teamInfo.Reset();
}
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 );
ApplyHues( m_Context.Participants[i] as Participant, Controller.TeamInfo[i % Controller.TeamInfo.Length].Color );
m_FinishTimer?.Stop();
m_Bomb = new BRBomb( this );
ReturnBomb();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, Finish_Callback );
m_FinishTimer = Timer.DelayCall( Controller.Duration, Finish_Callback );
}
private void Finish_Callback()
@ -1743,7 +1688,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
BRTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length];
BRTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
if ( teamInfo == null )
continue;
@ -1787,8 +1732,8 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Controller != null )
sb.Append( ' ' ).Append( m_Controller.Title );
if ( Controller != null )
sb.Append( ' ' ).Append( Controller.Title );
string title = sb.ToString();
@ -1899,9 +1844,9 @@ namespace Server.Engines.ConPVP
public override void OnStop()
{
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
BRTeamInfo teamInfo = m_Controller.TeamInfo[i];
BRTeamInfo teamInfo = Controller.TeamInfo[i];
if ( teamInfo.Board != null )
teamInfo.Board.m_TeamInfo = null;