Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -223,16 +223,14 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
private DDTeamInfo 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 string Name => m_Player.Name;
|
||||
public string Name => Player.Name;
|
||||
|
||||
public int Kills
|
||||
{
|
||||
|
|
@ -270,64 +268,31 @@ namespace Server.Engines.ConPVP
|
|||
public DDPlayerInfo( DDTeamInfo teamInfo, Mobile player )
|
||||
{
|
||||
m_TeamInfo = teamInfo;
|
||||
m_Player = player;
|
||||
Player = player;
|
||||
}
|
||||
}
|
||||
|
||||
[PropertyObject]
|
||||
public sealed class DDTeamInfo : IRankedCTF
|
||||
{
|
||||
private DDGame m_Game;
|
||||
private int m_TeamID;
|
||||
public string Name => $"{TeamName} Team";
|
||||
|
||||
private int m_Color;
|
||||
private string m_Name;
|
||||
public DDGame Game { get; set; }
|
||||
|
||||
private DDBoard m_Board;
|
||||
public int TeamID { get; }
|
||||
|
||||
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, DDPlayerInfo> m_Players;
|
||||
|
||||
public string Name => $"{m_Name} Team";
|
||||
|
||||
public DDGame 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 DDPlayerInfo m_Leader;
|
||||
|
||||
public DDPlayerInfo Leader
|
||||
{
|
||||
get => m_Leader;
|
||||
set => m_Leader = value;
|
||||
}
|
||||
public DDPlayerInfo Leader { get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DDBoard Board
|
||||
{
|
||||
get => m_Board;
|
||||
set => m_Board = value;
|
||||
}
|
||||
public DDBoard Board { get; set; }
|
||||
|
||||
public Dictionary<Mobile, DDPlayerInfo> Players => m_Players;
|
||||
public Dictionary<Mobile, DDPlayerInfo> Players { get; }
|
||||
|
||||
public DDPlayerInfo this[Mobile mob]
|
||||
{
|
||||
|
|
@ -336,59 +301,47 @@ namespace Server.Engines.ConPVP
|
|||
if ( mob == null )
|
||||
return null;
|
||||
|
||||
if (!m_Players.TryGetValue( mob, out DDPlayerInfo val ))
|
||||
m_Players[mob] = val = new DDPlayerInfo( this, mob );
|
||||
if (!Players.TryGetValue( mob, out DDPlayerInfo val ))
|
||||
Players[mob] = val = new DDPlayerInfo( 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 Point3D Origin
|
||||
{
|
||||
get => m_Origin;
|
||||
set => m_Origin = value;
|
||||
}
|
||||
public Point3D Origin { get; set; }
|
||||
|
||||
public DDTeamInfo( int teamID )
|
||||
{
|
||||
m_TeamID = teamID;
|
||||
m_Players = new Dictionary<Mobile, DDPlayerInfo>();
|
||||
TeamID = teamID;
|
||||
Players = new Dictionary<Mobile, DDPlayerInfo>();
|
||||
}
|
||||
|
||||
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_Board != null )
|
||||
m_Board.m_TeamInfo = this;
|
||||
if ( Board != null )
|
||||
Board.m_TeamInfo = this;
|
||||
}
|
||||
|
||||
public DDTeamInfo( int teamID, GenericReader ip )
|
||||
{
|
||||
m_TeamID = teamID;
|
||||
m_Players = new Dictionary<Mobile, DDPlayerInfo>();
|
||||
TeamID = teamID;
|
||||
Players = new Dictionary<Mobile, DDPlayerInfo>();
|
||||
|
||||
int version = ip.ReadEncodedInt();
|
||||
|
||||
|
|
@ -396,10 +349,10 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
case 0:
|
||||
{
|
||||
m_Board = ip.ReadItem() as DDBoard;
|
||||
m_Name = ip.ReadString();
|
||||
m_Color = ip.ReadEncodedInt();
|
||||
m_Origin = ip.ReadPoint3D();
|
||||
Board = ip.ReadItem() as DDBoard;
|
||||
TeamName = ip.ReadString();
|
||||
Color = ip.ReadEncodedInt();
|
||||
Origin = ip.ReadPoint3D();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -409,10 +362,10 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
op.WriteEncodedInt( 0 ); // version
|
||||
|
||||
op.Write( m_Board );
|
||||
op.Write( m_Name );
|
||||
op.WriteEncodedInt( m_Color );
|
||||
op.Write( m_Origin );
|
||||
op.Write( Board );
|
||||
op.Write( TeamName );
|
||||
op.WriteEncodedInt( Color );
|
||||
op.Write( Origin );
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
@ -423,44 +376,30 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public sealed class DDController : EventController
|
||||
{
|
||||
private DDTeamInfo[] m_TeamInfo;
|
||||
|
||||
private TimeSpan m_Duration;
|
||||
|
||||
public DDTeamInfo[] TeamInfo => m_TeamInfo;
|
||||
public DDTeamInfo[] TeamInfo { get; private set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DDTeamInfo Team1 { get => m_TeamInfo[0];
|
||||
public DDTeamInfo Team1 { get => TeamInfo[0];
|
||||
set { } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DDTeamInfo Team2 { get => m_TeamInfo[1];
|
||||
public DDTeamInfo Team2 { get => TeamInfo[1];
|
||||
set { } }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DDWayPoint PointA { get => m_PointA;
|
||||
set => m_PointA = value;
|
||||
}
|
||||
public DDWayPoint PointA { get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public DDWayPoint PointB { get => m_PointB;
|
||||
set => m_PointB = value;
|
||||
}
|
||||
|
||||
private DDWayPoint m_PointA, m_PointB;
|
||||
public DDWayPoint PointB { get; set; }
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public TimeSpan Duration
|
||||
{
|
||||
get => m_Duration;
|
||||
set => m_Duration = value;
|
||||
}
|
||||
public TimeSpan Duration { get; set; }
|
||||
|
||||
public override string Title => "DoubleDom";
|
||||
|
||||
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 )
|
||||
|
|
@ -476,12 +415,12 @@ namespace Server.Engines.ConPVP
|
|||
Visible = false;
|
||||
Movable = false;
|
||||
|
||||
m_Duration = TimeSpan.FromMinutes( 30.0 );
|
||||
Duration = TimeSpan.FromMinutes( 30.0 );
|
||||
|
||||
m_TeamInfo = new DDTeamInfo[2];
|
||||
TeamInfo = new DDTeamInfo[2];
|
||||
|
||||
for ( int i = 0; i < m_TeamInfo.Length; ++i )
|
||||
m_TeamInfo[i] = new DDTeamInfo( i );
|
||||
for ( int i = 0; i < TeamInfo.Length; ++i )
|
||||
TeamInfo[i] = new DDTeamInfo( i );
|
||||
}
|
||||
|
||||
public DDController( Serial serial )
|
||||
|
|
@ -495,15 +434,15 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
writer.Write( (int)0 );
|
||||
|
||||
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 );
|
||||
|
||||
writer.Write( m_PointA );
|
||||
writer.Write( m_PointB );
|
||||
writer.Write( PointA );
|
||||
writer.Write( PointB );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
|
|
@ -516,14 +455,14 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
case 0:
|
||||
{
|
||||
m_Duration = reader.ReadTimeSpan();
|
||||
m_TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()];
|
||||
Duration = reader.ReadTimeSpan();
|
||||
TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()];
|
||||
|
||||
for ( int i = 0; i < m_TeamInfo.Length; ++i )
|
||||
m_TeamInfo[i] = new DDTeamInfo( i, reader );
|
||||
for ( int i = 0; i < TeamInfo.Length; ++i )
|
||||
TeamInfo[i] = new DDTeamInfo( i, reader );
|
||||
|
||||
m_PointA = reader.ReadItem() as DDWayPoint;
|
||||
m_PointB = reader.ReadItem() as DDWayPoint;
|
||||
PointA = reader.ReadItem() as DDWayPoint;
|
||||
PointB = reader.ReadItem() as DDWayPoint;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -533,9 +472,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public sealed class DDGame : EventGame
|
||||
{
|
||||
private DDController m_Controller;
|
||||
|
||||
public DDController Controller => m_Controller;
|
||||
public DDController Controller { get; }
|
||||
|
||||
public void Alert( string text )
|
||||
{
|
||||
|
|
@ -560,7 +497,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
public DDGame( DDController controller, DuelContext context ) : base( context )
|
||||
{
|
||||
m_Controller = controller;
|
||||
Controller = controller;
|
||||
}
|
||||
|
||||
public Map Facet
|
||||
|
|
@ -570,7 +507,7 @@ namespace Server.Engines.ConPVP
|
|||
if ( m_Context.Arena != null )
|
||||
return m_Context.Arena.Facet;
|
||||
|
||||
return m_Controller.Map;
|
||||
return Controller.Map;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -579,7 +516,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;
|
||||
}
|
||||
|
|
@ -706,25 +643,25 @@ namespace Server.Engines.ConPVP
|
|||
m_UncaptureTimer = null;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
|
||||
for ( int i = 0; i < Controller.TeamInfo.Length; ++i )
|
||||
{
|
||||
DDTeamInfo teamInfo = m_Controller.TeamInfo[i];
|
||||
DDTeamInfo teamInfo = Controller.TeamInfo[i];
|
||||
|
||||
teamInfo.Game = this;
|
||||
teamInfo.Reset();
|
||||
}
|
||||
|
||||
if ( m_Controller.PointA != null )
|
||||
m_Controller.PointA.Game = this;
|
||||
if ( Controller.PointA != null )
|
||||
Controller.PointA.Game = this;
|
||||
|
||||
if ( m_Controller.PointB != null )
|
||||
m_Controller.PointB.Game = this;
|
||||
if ( Controller.PointB != null )
|
||||
Controller.PointB.Game = this;
|
||||
|
||||
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_FinishTimer = Timer.DelayCall( m_Controller.Duration, Finish_Callback );
|
||||
m_FinishTimer = Timer.DelayCall( Controller.Duration, Finish_Callback );
|
||||
}
|
||||
|
||||
private void Finish_Callback()
|
||||
|
|
@ -733,7 +670,7 @@ namespace Server.Engines.ConPVP
|
|||
|
||||
for ( int i = 0; i < m_Context.Participants.Count; ++i )
|
||||
{
|
||||
DDTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length];
|
||||
DDTeamInfo teamInfo = Controller.TeamInfo[i % Controller.TeamInfo.Length];
|
||||
|
||||
if ( teamInfo != null )
|
||||
teams.Add( teamInfo );
|
||||
|
|
@ -775,8 +712,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();
|
||||
|
||||
|
|
@ -889,9 +826,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 )
|
||||
{
|
||||
DDTeamInfo teamInfo = m_Controller.TeamInfo[i];
|
||||
DDTeamInfo teamInfo = Controller.TeamInfo[i];
|
||||
|
||||
if ( teamInfo.Board != null )
|
||||
teamInfo.Board.m_TeamInfo = null;
|
||||
|
|
@ -899,11 +836,11 @@ namespace Server.Engines.ConPVP
|
|||
teamInfo.Game = null;
|
||||
}
|
||||
|
||||
if ( m_Controller.PointA != null )
|
||||
m_Controller.PointA.Game = null;
|
||||
if ( Controller.PointA != null )
|
||||
Controller.PointA.Game = null;
|
||||
|
||||
if ( m_Controller.PointB != null )
|
||||
m_Controller.PointB.Game = null;
|
||||
if ( Controller.PointB != null )
|
||||
Controller.PointB.Game = null;
|
||||
|
||||
m_Capturable = false;
|
||||
|
||||
|
|
@ -936,21 +873,21 @@ namespace Server.Engines.ConPVP
|
|||
if ( point == null || from == null || team == null || !m_Capturable )
|
||||
return;
|
||||
|
||||
bool wasDom = ( m_Controller.PointA != null && m_Controller.PointB != null &&
|
||||
m_Controller.PointA.TeamOwner == m_Controller.PointB.TeamOwner && m_Controller.PointA.TeamOwner != null );
|
||||
bool wasDom = ( Controller.PointA != null && Controller.PointB != null &&
|
||||
Controller.PointA.TeamOwner == Controller.PointB.TeamOwner && Controller.PointA.TeamOwner != null );
|
||||
|
||||
point.TeamOwner = team;
|
||||
Alert( "{0} has captured {1}!", team.Name, point.Name );
|
||||
|
||||
bool isDom = ( m_Controller.PointA != null && m_Controller.PointB != null &&
|
||||
m_Controller.PointA.TeamOwner == m_Controller.PointB.TeamOwner && m_Controller.PointA.TeamOwner != null );
|
||||
bool isDom = ( Controller.PointA != null && Controller.PointB != null &&
|
||||
Controller.PointA.TeamOwner == Controller.PointB.TeamOwner && Controller.PointA.TeamOwner != null );
|
||||
|
||||
if ( wasDom && !isDom )
|
||||
{
|
||||
Alert( "Domination averted!" );
|
||||
|
||||
m_Controller.PointA?.SetNonCaptureHue();
|
||||
m_Controller.PointB?.SetNonCaptureHue();
|
||||
Controller.PointA?.SetNonCaptureHue();
|
||||
Controller.PointB?.SetNonCaptureHue();
|
||||
m_CaptureTimer?.Stop();
|
||||
m_CaptureTimer = null;
|
||||
}
|
||||
|
|
@ -967,10 +904,10 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
DDTeamInfo team = null;
|
||||
|
||||
if ( m_Controller.PointA?.TeamOwner != null )
|
||||
team = m_Controller.PointA.TeamOwner;
|
||||
else if ( m_Controller.PointB?.TeamOwner != null )
|
||||
team = m_Controller.PointB.TeamOwner;
|
||||
if ( Controller.PointA?.TeamOwner != null )
|
||||
team = Controller.PointA.TeamOwner;
|
||||
else if ( Controller.PointB?.TeamOwner != null )
|
||||
team = Controller.PointB.TeamOwner;
|
||||
|
||||
if ( team == null )
|
||||
{
|
||||
|
|
@ -984,8 +921,8 @@ namespace Server.Engines.ConPVP
|
|||
{
|
||||
Alert( "{0} is dominating... {1}", team.Name, 10 - m_CapStage );
|
||||
|
||||
m_Controller.PointA?.SetCaptureHue( m_CapStage );
|
||||
m_Controller.PointB?.SetCaptureHue( m_CapStage );
|
||||
Controller.PointA?.SetCaptureHue( m_CapStage );
|
||||
Controller.PointB?.SetCaptureHue( m_CapStage );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -999,16 +936,16 @@ namespace Server.Engines.ConPVP
|
|||
m_CaptureTimer.Stop();
|
||||
m_CaptureTimer = null;
|
||||
|
||||
if ( m_Controller.PointA != null )
|
||||
if ( Controller.PointA != null )
|
||||
{
|
||||
m_Controller.PointA.TeamOwner = null;
|
||||
m_Controller.PointA.SetUncapturableHue();
|
||||
Controller.PointA.TeamOwner = null;
|
||||
Controller.PointA.SetUncapturableHue();
|
||||
}
|
||||
|
||||
if ( m_Controller.PointB != null )
|
||||
if ( Controller.PointB != null )
|
||||
{
|
||||
m_Controller.PointB.TeamOwner = null;
|
||||
m_Controller.PointB.SetUncapturableHue();
|
||||
Controller.PointB.TeamOwner = null;
|
||||
Controller.PointB.SetUncapturableHue();
|
||||
}
|
||||
|
||||
m_UncaptureTimer = Timer.DelayCall( TimeSpan.FromSeconds( 30.0 ), UncaptureTick );
|
||||
|
|
@ -1032,16 +969,16 @@ namespace Server.Engines.ConPVP
|
|||
m_UncaptureTimer = null;
|
||||
}
|
||||
|
||||
if ( m_Controller.PointA != null )
|
||||
if ( Controller.PointA != null )
|
||||
{
|
||||
m_Controller.PointA.TeamOwner = null;
|
||||
m_Controller.PointA.SetNonCaptureHue();
|
||||
Controller.PointA.TeamOwner = null;
|
||||
Controller.PointA.SetNonCaptureHue();
|
||||
}
|
||||
|
||||
if ( m_Controller.PointB != null )
|
||||
if ( Controller.PointB != null )
|
||||
{
|
||||
m_Controller.PointB.TeamOwner = null;
|
||||
m_Controller.PointB.SetNonCaptureHue();
|
||||
Controller.PointB.TeamOwner = null;
|
||||
Controller.PointB.SetNonCaptureHue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue