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

@ -66,7 +66,6 @@ namespace Server.Mobiles
}
private Mobile m_SculptedBy;
private DateTime m_SculptedOn;
[CommandProperty( AccessLevel.GameMaster )]
public Mobile SculptedBy
@ -76,28 +75,12 @@ namespace Server.Mobiles
}
[CommandProperty( AccessLevel.GameMaster )]
public DateTime SculptedOn
{
get => m_SculptedOn;
set => m_SculptedOn = value;
}
public DateTime SculptedOn { get; set; }
private CharacterStatuePlinth m_Plinth;
public CharacterStatuePlinth Plinth
{
get => m_Plinth;
set => m_Plinth = value;
}
private bool m_IsRewardItem;
public CharacterStatuePlinth Plinth { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public bool IsRewardItem
{
get => m_IsRewardItem;
set => m_IsRewardItem = value;
}
public bool IsRewardItem { get; set; }
public CharacterStatue( Mobile from, StatueType type )
{
@ -155,24 +138,24 @@ namespace Server.Mobiles
{
base.OnAfterDelete();
if ( m_Plinth != null && !m_Plinth.Deleted )
m_Plinth.Delete();
if ( Plinth != null && !Plinth.Deleted )
Plinth.Delete();
}
protected override void OnMapChange( Map oldMap )
{
InvalidatePose();
if ( m_Plinth != null )
m_Plinth.Map = Map;
if ( Plinth != null )
Plinth.Map = Map;
}
protected override void OnLocationChange( Point3D oldLocation )
{
InvalidatePose();
if ( m_Plinth != null )
m_Plinth.Location = new Point3D( X, Y, Z - 5 );
if ( Plinth != null )
Plinth.Location = new Point3D( X, Y, Z - 5 );
}
public override bool CanBeRenamedBy( Mobile from )
@ -205,10 +188,10 @@ namespace Server.Mobiles
writer.Write( (int) m_Material );
writer.Write( (Mobile) m_SculptedBy );
writer.Write( (DateTime) m_SculptedOn );
writer.Write( (DateTime) SculptedOn );
writer.Write( (Item) m_Plinth );
writer.Write( (bool) m_IsRewardItem );
writer.Write( (Item) Plinth );
writer.Write( (bool) IsRewardItem );
}
public override void Deserialize( GenericReader reader )
@ -222,10 +205,10 @@ namespace Server.Mobiles
m_Material = (StatueMaterial) reader.ReadInt();
m_SculptedBy = reader.ReadMobile();
m_SculptedOn = reader.ReadDateTime();
SculptedOn = reader.ReadDateTime();
m_Plinth = reader.ReadItem() as CharacterStatuePlinth;
m_IsRewardItem = reader.ReadBool();
Plinth = reader.ReadItem() as CharacterStatuePlinth;
IsRewardItem = reader.ReadBool();
InvalidatePose();
@ -240,7 +223,7 @@ namespace Server.Mobiles
public void Sculpt( Mobile by )
{
m_SculptedBy = by;
m_SculptedOn = DateTime.UtcNow;
SculptedOn = DateTime.UtcNow;
InvalidateProperties();
}
@ -255,9 +238,9 @@ namespace Server.Mobiles
deed.Statue = this;
deed.StatueType = m_Type;
deed.IsRewardItem = m_IsRewardItem;
deed.IsRewardItem = IsRewardItem;
m_Plinth?.Delete();
Plinth?.Delete();
return true;
}
@ -329,7 +312,7 @@ namespace Server.Mobiles
for ( int i = Items.Count - 1; i >= 0; i -- )
Items[ i ].Hue = Hue;
m_Plinth?.InvalidateHue();
Plinth?.InvalidateHue();
}
private int m_Animation;
@ -416,9 +399,9 @@ namespace Server.Mobiles
{
StatueType t = m_Type;
if ( m_Statue != null )
if ( Statue != null )
{
t = m_Statue.StatueType;
t = Statue.StatueType;
}
switch ( t )
@ -431,24 +414,19 @@ namespace Server.Mobiles
}
}
private CharacterStatue m_Statue;
private StatueType m_Type;
private bool m_IsRewardItem;
[CommandProperty( AccessLevel.GameMaster )]
public CharacterStatue Statue
{
get => m_Statue;
set => m_Statue = value;
}
public CharacterStatue Statue { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public StatueType StatueType
{
get
{
if ( m_Statue != null )
return m_Statue.StatueType;
if ( Statue != null )
return Statue.StatueType;
return m_Type;
}
@ -464,7 +442,7 @@ namespace Server.Mobiles
public CharacterStatueDeed( CharacterStatue statue ) : base( 0x14F0 )
{
m_Statue = statue;
Statue = statue;
if ( statue != null )
{
@ -487,8 +465,8 @@ namespace Server.Mobiles
if ( m_IsRewardItem )
list.Add( 1076222 ); // 6th Year Veteran Reward
if ( m_Statue != null )
list.Add( 1076231, m_Statue.Name ); // Statue of ~1_Name~
if ( Statue != null )
list.Add( 1076231, Statue.Name ); // Statue of ~1_Name~
}
public override void OnDoubleClick( Mobile from )
@ -522,7 +500,7 @@ namespace Server.Mobiles
{
base.OnDelete();
m_Statue?.Delete();
Statue?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -533,7 +511,7 @@ namespace Server.Mobiles
writer.Write( (int) m_Type );
writer.Write( (Mobile) m_Statue );
writer.Write( (Mobile) Statue );
writer.Write( (bool) m_IsRewardItem );
}
@ -547,7 +525,7 @@ namespace Server.Mobiles
m_Type = (StatueType) reader.ReadInt();
}
m_Statue = reader.ReadMobile() as CharacterStatue;
Statue = reader.ReadMobile() as CharacterStatue;
m_IsRewardItem = reader.ReadBool();
}
}

View file

@ -4,24 +4,22 @@ namespace Server.Engines.VeteranRewards
{
public class RewardCategory
{
private int m_Name;
private string m_NameString;
private List<RewardEntry> m_Entries;
public int Name { get; }
public int Name => m_Name;
public string NameString => m_NameString;
public List<RewardEntry> Entries => m_Entries;
public string NameString { get; }
public List<RewardEntry> Entries { get; }
public RewardCategory( int name )
{
m_Name = name;
m_Entries = new List<RewardEntry>();
Name = name;
Entries = new List<RewardEntry>();
}
public RewardCategory( string name )
{
m_NameString = name;
m_Entries = new List<RewardEntry>();
NameString = name;
Entries = new List<RewardEntry>();
}
}
}

View file

@ -4,29 +4,25 @@ namespace Server.Engines.VeteranRewards
{
public class RewardEntry
{
private RewardList m_List;
private RewardCategory m_Category;
private Type m_ItemType;
private Expansion m_RequiredExpansion;
private int m_Name;
private string m_NameString;
private object[] m_Args;
public RewardList List { get; set; }
public RewardList List{ get => m_List;
set => m_List = value;
}
public RewardCategory Category => m_Category;
public Type ItemType => m_ItemType;
public Expansion RequiredExpansion => m_RequiredExpansion;
public int Name => m_Name;
public string NameString => m_NameString;
public object[] Args => m_Args;
public RewardCategory Category { get; }
public Type ItemType { get; }
public Expansion RequiredExpansion { get; }
public int Name { get; }
public string NameString { get; }
public object[] Args { get; }
public Item Construct()
{
try
{
Item item = Activator.CreateInstance( m_ItemType, m_Args ) as Item;
Item item = Activator.CreateInstance( ItemType, Args ) as Item;
if ( item is IRewardItem rewardItem )
rewardItem.IsRewardItem = true;
@ -42,41 +38,41 @@ namespace Server.Engines.VeteranRewards
public RewardEntry( RewardCategory category, int name, Type itemType, params object[] args )
{
m_Category = category;
m_ItemType = itemType;
m_RequiredExpansion = Expansion.None;
m_Name = name;
m_Args = args;
Category = category;
ItemType = itemType;
RequiredExpansion = Expansion.None;
Name = name;
Args = args;
category.Entries.Add( this );
}
public RewardEntry( RewardCategory category, string name, Type itemType, params object[] args )
{
m_Category = category;
m_ItemType = itemType;
m_RequiredExpansion = Expansion.None;
m_NameString = name;
m_Args = args;
Category = category;
ItemType = itemType;
RequiredExpansion = Expansion.None;
NameString = name;
Args = args;
category.Entries.Add( this );
}
public RewardEntry( RewardCategory category, int name, Type itemType, Expansion requiredExpansion, params object[] args )
{
m_Category = category;
m_ItemType = itemType;
m_RequiredExpansion = requiredExpansion;
m_Name = name;
m_Args = args;
Category = category;
ItemType = itemType;
RequiredExpansion = requiredExpansion;
Name = name;
Args = args;
category.Entries.Add( this );
}
public RewardEntry( RewardCategory category, string name, Type itemType, Expansion requiredExpansion, params object[] args )
{
m_Category = category;
m_ItemType = itemType;
m_RequiredExpansion = requiredExpansion;
m_NameString = name;
m_Args = args;
Category = category;
ItemType = itemType;
RequiredExpansion = requiredExpansion;
NameString = name;
Args = args;
category.Entries.Add( this );
}
}

View file

@ -4,16 +4,14 @@ namespace Server.Engines.VeteranRewards
{
public class RewardList
{
private TimeSpan m_Age;
private RewardEntry[] m_Entries;
public TimeSpan Age { get; }
public TimeSpan Age => m_Age;
public RewardEntry[] Entries => m_Entries;
public RewardEntry[] Entries { get; }
public RewardList( TimeSpan interval, int index, RewardEntry[] entries )
{
m_Age = TimeSpan.FromDays( interval.TotalDays * index );
m_Entries = entries;
Age = TimeSpan.FromDays( interval.TotalDays * index );
Entries = entries;
for ( int i = 0; i < entries.Length; ++i )
entries[i].List = this;

View file

@ -72,16 +72,14 @@ namespace Server.Gumps
public class RewardOption
{
private int m_ID;
private int m_Cliloc;
public int ID { get; }
public int ID => m_ID;
public int Cliloc => m_Cliloc;
public int Cliloc { get; }
public RewardOption( int id, int cliloc )
{
m_ID = id;
m_Cliloc = cliloc;
ID = id;
Cliloc = cliloc;
}
}