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
|
|
@ -6,31 +6,26 @@ namespace Server.Factions
|
|||
{
|
||||
public class PlayerState : IComparable
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
private Faction m_Faction;
|
||||
private List<PlayerState> m_Owner;
|
||||
private int m_KillPoints;
|
||||
private DateTime m_Leaving;
|
||||
private MerchantTitle m_MerchantTitle;
|
||||
private RankDefinition m_Rank;
|
||||
private List<SilverGivenEntry> m_SilverGiven;
|
||||
private bool m_IsActive;
|
||||
|
||||
private Town m_Sheriff;
|
||||
private Town m_Finance;
|
||||
|
||||
private DateTime m_LastHonorTime;
|
||||
public Mobile Mobile { get; }
|
||||
|
||||
public Faction Faction { get; }
|
||||
|
||||
public List<PlayerState> Owner { get; }
|
||||
|
||||
public Mobile Mobile => m_Mobile;
|
||||
public Faction Faction => m_Faction;
|
||||
public List<PlayerState> Owner => m_Owner;
|
||||
public MerchantTitle MerchantTitle{ get => m_MerchantTitle;
|
||||
set{ m_MerchantTitle = value; Invalidate(); } }
|
||||
public Town Sheriff{ get => m_Sheriff;
|
||||
set{ m_Sheriff = value; Invalidate(); } }
|
||||
public Town Finance{ get => m_Finance;
|
||||
set{ m_Finance = value; Invalidate(); } }
|
||||
public List<SilverGivenEntry> SilverGiven => m_SilverGiven;
|
||||
public List<SilverGivenEntry> SilverGiven { get; private set; }
|
||||
|
||||
public int KillPoints {
|
||||
get => m_KillPoints;
|
||||
|
|
@ -44,17 +39,17 @@ namespace Server.Factions
|
|||
return;
|
||||
}
|
||||
|
||||
m_Owner.Remove( this );
|
||||
m_Owner.Insert( m_Faction.ZeroRankOffset, this );
|
||||
Owner.Remove( this );
|
||||
Owner.Insert( Faction.ZeroRankOffset, this );
|
||||
|
||||
m_RankIndex = m_Faction.ZeroRankOffset;
|
||||
m_Faction.ZeroRankOffset++;
|
||||
m_RankIndex = Faction.ZeroRankOffset;
|
||||
Faction.ZeroRankOffset++;
|
||||
}
|
||||
while ( ( m_RankIndex - 1 ) >= 0 ) {
|
||||
PlayerState p = m_Owner[m_RankIndex-1] as PlayerState;
|
||||
PlayerState p = Owner[m_RankIndex-1] as PlayerState;
|
||||
if ( value > p.KillPoints ) {
|
||||
m_Owner[m_RankIndex] = p;
|
||||
m_Owner[m_RankIndex-1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
Owner[m_RankIndex-1] = this;
|
||||
RankIndex--;
|
||||
p.RankIndex++;
|
||||
}
|
||||
|
|
@ -70,23 +65,23 @@ namespace Server.Factions
|
|||
return;
|
||||
}
|
||||
|
||||
while ( ( m_RankIndex + 1 ) < m_Faction.ZeroRankOffset ) {
|
||||
PlayerState p = m_Owner[m_RankIndex+1] as PlayerState;
|
||||
m_Owner[m_RankIndex+1] = this;
|
||||
m_Owner[m_RankIndex] = p;
|
||||
while ( ( m_RankIndex + 1 ) < Faction.ZeroRankOffset ) {
|
||||
PlayerState p = Owner[m_RankIndex+1] as PlayerState;
|
||||
Owner[m_RankIndex+1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
|
||||
m_RankIndex = -1;
|
||||
m_Faction.ZeroRankOffset--;
|
||||
Faction.ZeroRankOffset--;
|
||||
}
|
||||
else {
|
||||
while ( ( m_RankIndex + 1 ) < m_Faction.ZeroRankOffset ) {
|
||||
PlayerState p = m_Owner[m_RankIndex+1] as PlayerState;
|
||||
while ( ( m_RankIndex + 1 ) < Faction.ZeroRankOffset ) {
|
||||
PlayerState p = Owner[m_RankIndex+1] as PlayerState;
|
||||
if ( value < p.KillPoints ) {
|
||||
m_Owner[m_RankIndex+1] = this;
|
||||
m_Owner[m_RankIndex] = p;
|
||||
Owner[m_RankIndex+1] = this;
|
||||
Owner[m_RankIndex] = p;
|
||||
RankIndex++;
|
||||
p.RankIndex--;
|
||||
}
|
||||
|
|
@ -111,15 +106,15 @@ namespace Server.Factions
|
|||
public RankDefinition Rank {
|
||||
get {
|
||||
if ( m_InvalidateRank ) {
|
||||
RankDefinition[] ranks = m_Faction.Definition.Ranks;
|
||||
RankDefinition[] ranks = Faction.Definition.Ranks;
|
||||
int percent;
|
||||
|
||||
if ( m_Owner.Count == 1 )
|
||||
if ( Owner.Count == 1 )
|
||||
percent = 1000;
|
||||
else if ( m_RankIndex == -1 )
|
||||
percent = 0;
|
||||
else
|
||||
percent = ( ( m_Faction.ZeroRankOffset - m_RankIndex ) * 1000 ) / m_Faction.ZeroRankOffset;
|
||||
percent = ( ( Faction.ZeroRankOffset - m_RankIndex ) * 1000 ) / Faction.ZeroRankOffset;
|
||||
|
||||
for ( int i = 0; i < ranks.Length; i++ ) {
|
||||
RankDefinition check = ranks[i];
|
||||
|
|
@ -138,29 +133,25 @@ namespace Server.Factions
|
|||
}
|
||||
}
|
||||
|
||||
public DateTime LastHonorTime{ get => m_LastHonorTime;
|
||||
set => m_LastHonorTime = value;
|
||||
}
|
||||
public DateTime Leaving{ get => m_Leaving;
|
||||
set => m_Leaving = value;
|
||||
}
|
||||
public bool IsLeaving => ( m_Leaving > DateTime.MinValue );
|
||||
public DateTime LastHonorTime { get; set; }
|
||||
|
||||
public bool IsActive{ get => m_IsActive;
|
||||
set => m_IsActive = value;
|
||||
}
|
||||
public DateTime Leaving { get; set; }
|
||||
|
||||
public bool IsLeaving => ( Leaving > DateTime.MinValue );
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public bool CanGiveSilverTo( Mobile mob )
|
||||
{
|
||||
if ( m_SilverGiven == null )
|
||||
if ( SilverGiven == null )
|
||||
return true;
|
||||
|
||||
for ( int i = 0; i < m_SilverGiven.Count; ++i )
|
||||
for ( int i = 0; i < SilverGiven.Count; ++i )
|
||||
{
|
||||
SilverGivenEntry sge = m_SilverGiven[i];
|
||||
SilverGivenEntry sge = SilverGiven[i];
|
||||
|
||||
if ( sge.IsExpired )
|
||||
m_SilverGiven.RemoveAt( i-- );
|
||||
SilverGiven.RemoveAt( i-- );
|
||||
else if ( sge.GivenTo == mob )
|
||||
return false;
|
||||
}
|
||||
|
|
@ -170,15 +161,15 @@ namespace Server.Factions
|
|||
|
||||
public void OnGivenSilverTo( Mobile mob )
|
||||
{
|
||||
if ( m_SilverGiven == null )
|
||||
m_SilverGiven = new List<SilverGivenEntry>();
|
||||
if ( SilverGiven == null )
|
||||
SilverGiven = new List<SilverGivenEntry>();
|
||||
|
||||
m_SilverGiven.Add( new SilverGivenEntry( mob ) );
|
||||
SilverGiven.Add( new SilverGivenEntry( mob ) );
|
||||
}
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
if ( m_Mobile is PlayerMobile pm )
|
||||
if ( Mobile is PlayerMobile pm )
|
||||
{
|
||||
pm.InvalidateProperties();
|
||||
pm.InvalidateMyRunUO();
|
||||
|
|
@ -187,15 +178,15 @@ namespace Server.Factions
|
|||
|
||||
public void Attach()
|
||||
{
|
||||
if ( m_Mobile is PlayerMobile mobile )
|
||||
if ( Mobile is PlayerMobile mobile )
|
||||
mobile.FactionPlayerState = this;
|
||||
}
|
||||
|
||||
public PlayerState( Mobile mob, Faction faction, List<PlayerState> owner )
|
||||
{
|
||||
m_Mobile = mob;
|
||||
m_Faction = faction;
|
||||
m_Owner = owner;
|
||||
Mobile = mob;
|
||||
Faction = faction;
|
||||
Owner = owner;
|
||||
|
||||
Attach();
|
||||
Invalidate();
|
||||
|
|
@ -203,8 +194,8 @@ namespace Server.Factions
|
|||
|
||||
public PlayerState( GenericReader reader, Faction faction, List<PlayerState> owner )
|
||||
{
|
||||
m_Faction = faction;
|
||||
m_Owner = owner;
|
||||
Faction = faction;
|
||||
Owner = owner;
|
||||
|
||||
int version = reader.ReadEncodedInt();
|
||||
|
||||
|
|
@ -212,18 +203,18 @@ namespace Server.Factions
|
|||
{
|
||||
case 1:
|
||||
{
|
||||
m_IsActive = reader.ReadBool();
|
||||
m_LastHonorTime = reader.ReadDateTime();
|
||||
IsActive = reader.ReadBool();
|
||||
LastHonorTime = reader.ReadDateTime();
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
m_Mobile = reader.ReadMobile();
|
||||
Mobile = reader.ReadMobile();
|
||||
|
||||
m_KillPoints = reader.ReadEncodedInt();
|
||||
m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt();
|
||||
|
||||
m_Leaving = reader.ReadDateTime();
|
||||
Leaving = reader.ReadDateTime();
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -236,15 +227,15 @@ namespace Server.Factions
|
|||
{
|
||||
writer.WriteEncodedInt( (int) 1 ); // version
|
||||
|
||||
writer.Write( m_IsActive );
|
||||
writer.Write( m_LastHonorTime );
|
||||
writer.Write( IsActive );
|
||||
writer.Write( LastHonorTime );
|
||||
|
||||
writer.Write( (Mobile) m_Mobile );
|
||||
writer.Write( (Mobile) Mobile );
|
||||
|
||||
writer.WriteEncodedInt( (int) m_KillPoints );
|
||||
writer.WriteEncodedInt( (int) m_MerchantTitle );
|
||||
|
||||
writer.Write( (DateTime) m_Leaving );
|
||||
writer.Write( (DateTime) Leaving );
|
||||
}
|
||||
|
||||
public static PlayerState Find( Mobile mob )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue