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

@ -528,16 +528,14 @@ namespace Server.Engines.ConPVP
{
private CTFTeamInfo 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; }
string IRankedCTF.Name => m_Player.Name;
string IRankedCTF.Name => Player.Name;
public int Kills
{
@ -575,65 +573,31 @@ namespace Server.Engines.ConPVP
public CTFPlayerInfo( CTFTeamInfo teamInfo, Mobile player )
{
m_TeamInfo = teamInfo;
m_Player = player;
Player = player;
}
}
[PropertyObject]
public sealed class CTFTeamInfo : IRankedCTF
{
private CTFGame m_Game;
private int m_TeamID;
string IRankedCTF.Name => $"{Name} Team";
private int m_Color;
private string m_Name;
public CTFGame Game { get; set; }
private CTFBoard m_Board;
public int TeamID { get; }
private CTFFlag m_Flag;
private Point3D m_Origin;
public int Kills { get; set; }
private int m_Kills;
private int m_Captures;
public int Captures { get; set; }
private int m_Score;
public int Score { get; set; }
private Dictionary<Mobile, CTFPlayerInfo> m_Players;
string IRankedCTF.Name => $"{m_Name} Team";
public CTFGame Game { get => m_Game;
set => m_Game = value;
}
public int TeamID => m_TeamID;
public int Kills { get => m_Kills;
set => m_Kills = value;
}
public int Captures { get => m_Captures;
set => m_Captures = value;
}
public int Score { get => m_Score;
set => m_Score = value;
}
private CTFPlayerInfo m_Leader;
public CTFPlayerInfo Leader
{
get => m_Leader;
set => m_Leader = value;
}
public CTFPlayerInfo Leader { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public CTFBoard Board
{
get => m_Board;
set => m_Board = value;
}
public CTFBoard Board { get; set; }
public Dictionary<Mobile, CTFPlayerInfo> Players => m_Players;
public Dictionary<Mobile, CTFPlayerInfo> Players { get; }
public CTFPlayerInfo this[Mobile mob]
{
@ -642,73 +606,57 @@ namespace Server.Engines.ConPVP
if ( mob == null )
return null;
if (!m_Players.TryGetValue( mob, out CTFPlayerInfo val ))
m_Players[mob] = val = new CTFPlayerInfo( this, mob );
if (!Players.TryGetValue( mob, out CTFPlayerInfo val ))
Players[mob] = val = new CTFPlayerInfo( 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 Name
{
get => m_Name;
set => m_Name = value;
}
public string Name { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public CTFFlag Flag
{
get => m_Flag;
set => m_Flag = value;
}
public CTFFlag Flag { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public Point3D Origin
{
get => m_Origin;
set => m_Origin = value;
}
public Point3D Origin { get; set; }
public CTFTeamInfo( int teamID )
{
m_TeamID = teamID;
m_Players = new Dictionary<Mobile, CTFPlayerInfo>();
TeamID = teamID;
Players = new Dictionary<Mobile, CTFPlayerInfo>();
}
public void Reset()
{
m_Kills = 0;
m_Captures = 0;
Kills = 0;
Captures = 0;
m_Score = 0;
Score = 0;
m_Leader = null;
Leader = null;
m_Players.Clear();
Players.Clear();
if ( m_Flag != null )
if ( Flag != null )
{
m_Flag.m_TeamInfo = this;
m_Flag.Hue = m_Color;
m_Flag.SendHome();
Flag.m_TeamInfo = this;
Flag.Hue = Color;
Flag.SendHome();
}
if ( m_Board != null )
m_Board.m_TeamInfo = this;
if ( Board != null )
Board.m_TeamInfo = this;
}
public CTFTeamInfo( int teamID, GenericReader ip )
{
m_TeamID = teamID;
m_Players = new Dictionary<Mobile, CTFPlayerInfo>();
TeamID = teamID;
Players = new Dictionary<Mobile, CTFPlayerInfo>();
int version = ip.ReadEncodedInt();
@ -716,22 +664,22 @@ namespace Server.Engines.ConPVP
{
case 2:
{
m_Board = ip.ReadItem() as CTFBoard;
Board = ip.ReadItem() as CTFBoard;
goto case 1;
}
case 1:
{
m_Name = ip.ReadString();
Name = ip.ReadString();
goto case 0;
}
case 0:
{
m_Color = ip.ReadEncodedInt();
Color = ip.ReadEncodedInt();
m_Flag = ip.ReadItem() as CTFFlag;
m_Origin = ip.ReadPoint3D();
Flag = ip.ReadItem() as CTFFlag;
Origin = ip.ReadPoint3D();
break;
}
}
@ -741,14 +689,14 @@ namespace Server.Engines.ConPVP
{
op.WriteEncodedInt( 2 ); // version
op.Write( m_Board );
op.Write( Board );
op.Write( m_Name );
op.Write( Name );
op.WriteEncodedInt( m_Color );
op.WriteEncodedInt( Color );
op.Write( m_Flag );
op.Write( m_Origin );
op.Write( Flag );
op.Write( Origin );
}
public override string ToString()
@ -759,56 +707,48 @@ namespace Server.Engines.ConPVP
public sealed class CTFController : EventController
{
private CTFTeamInfo[] m_TeamInfo;
private TimeSpan m_Duration;
public CTFTeamInfo[] TeamInfo => m_TeamInfo;
public CTFTeamInfo[] TeamInfo { get; private set; }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team1 { get => m_TeamInfo[0];
public CTFTeamInfo Team1 { get => TeamInfo[0];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team2 { get => m_TeamInfo[1];
public CTFTeamInfo Team2 { get => TeamInfo[1];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team3 { get => m_TeamInfo[2];
public CTFTeamInfo Team3 { get => TeamInfo[2];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team4 { get => m_TeamInfo[3];
public CTFTeamInfo Team4 { get => TeamInfo[3];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team5 { get => m_TeamInfo[4];
public CTFTeamInfo Team5 { get => TeamInfo[4];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team6 { get => m_TeamInfo[5];
public CTFTeamInfo Team6 { get => TeamInfo[5];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team7 { get => m_TeamInfo[6];
public CTFTeamInfo Team7 { get => TeamInfo[6];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public CTFTeamInfo Team8 { get => m_TeamInfo[7];
public CTFTeamInfo Team8 { get => TeamInfo[7];
set { } }
[CommandProperty( AccessLevel.GameMaster )]
public TimeSpan Duration
{
get => m_Duration;
set => m_Duration = value;
}
public TimeSpan Duration { get; set; }
public override string Title => "CTF";
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 )
@ -822,12 +762,12 @@ namespace Server.Engines.ConPVP
Visible = false;
Movable = false;
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
m_TeamInfo = new CTFTeamInfo[8];
TeamInfo = new CTFTeamInfo[8];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new CTFTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new CTFTeamInfo( i );
}
public CTFController( Serial serial )
@ -841,12 +781,12 @@ namespace Server.Engines.ConPVP
writer.Write( (int) 2 );
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 )
@ -859,32 +799,32 @@ namespace Server.Engines.ConPVP
{
case 2:
{
m_Duration = reader.ReadTimeSpan();
Duration = reader.ReadTimeSpan();
goto case 1;
}
case 1:
{
m_TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()];
TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new CTFTeamInfo( i, reader );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new CTFTeamInfo( i, reader );
break;
}
case 0:
{
m_TeamInfo = new CTFTeamInfo[8];
TeamInfo = new CTFTeamInfo[8];
for ( int i = 0; i < m_TeamInfo.Length; ++i )
m_TeamInfo[i] = new CTFTeamInfo( i );
for ( int i = 0; i < TeamInfo.Length; ++i )
TeamInfo[i] = new CTFTeamInfo( i );
break;
}
}
if ( version < 2 )
m_Duration = TimeSpan.FromMinutes( 30.0 );
Duration = TimeSpan.FromMinutes( 30.0 );
}
}
@ -896,9 +836,7 @@ namespace Server.Engines.ConPVP
TileData.ItemTable[i].Flags |= TileFlag.NoShoot;
}
private CTFController m_Controller;
public CTFController Controller => m_Controller;
public CTFController Controller { get; }
public void Alert( string text )
{
@ -923,7 +861,7 @@ namespace Server.Engines.ConPVP
public CTFGame( CTFController controller, DuelContext context ) : base( context )
{
m_Controller = controller;
Controller = controller;
}
public Map Facet
@ -933,7 +871,7 @@ namespace Server.Engines.ConPVP
if ( m_Context.Arena != null )
return m_Context.Arena.Facet;
return m_Controller.Map;
return Controller.Map;
}
}
@ -942,7 +880,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;
}
@ -1052,15 +990,15 @@ namespace Server.Engines.ConPVP
if ( mob.InRange( teamInfo.Origin, 24 ) && mob.Map == Facet )
playerInfo.Score += 1; // fragged in base -- guarding
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
{
if ( m_Controller.TeamInfo[i] == teamInfo )
if ( Controller.TeamInfo[i] == teamInfo )
continue;
Mobile ourFlagCarrier = null;
if ( m_Controller.TeamInfo[i].Flag != null )
ourFlagCarrier = m_Controller.TeamInfo[i].Flag.RootParent as Mobile;
if ( Controller.TeamInfo[i].Flag != null )
ourFlagCarrier = Controller.TeamInfo[i].Flag.RootParent as Mobile;
if ( ourFlagCarrier != null && GetTeamInfo( ourFlagCarrier ) == teamInfo )
{
@ -1094,20 +1032,20 @@ 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 )
{
CTFTeamInfo teamInfo = m_Controller.TeamInfo[i];
CTFTeamInfo 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 % 8].Color );
ApplyHues( m_Context.Participants[i] as Participant, Controller.TeamInfo[i % 8].Color );
m_FinishTimer?.Stop();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, Finish_Callback );
m_FinishTimer = Timer.DelayCall( Controller.Duration, Finish_Callback );
}
private void Finish_Callback()
@ -1116,7 +1054,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
CTFTeamInfo teamInfo = m_Controller.TeamInfo[i % 8];
CTFTeamInfo teamInfo = Controller.TeamInfo[i % 8];
if ( teamInfo?.Flag == null )
continue;
@ -1163,8 +1101,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();
@ -1277,9 +1215,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 )
{
CTFTeamInfo teamInfo = m_Controller.TeamInfo[i];
CTFTeamInfo teamInfo = Controller.TeamInfo[i];
if ( teamInfo.Flag != null )
{