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

@ -65,27 +65,12 @@ namespace Server.Items
public class Corpse : Container, ICarvable
{
private Mobile m_Owner; // Whos corpse is this?
private Mobile m_Killer; // Who killed the owner?
private CorpseFlag m_Flags; // @see CorpseFlag
private List<Mobile> m_Looters; // Who's looted this corpse?
private List<Item> m_EquipItems; // List of dropped equipment when the owner died. Ingame, these items display /on/ the corpse, not just inside
private List<Item> m_RestoreEquip; // List of items equipped when the owner died. Includes insured and blessed items.
private List<Mobile> m_Aggressors; // Anyone from this list will be able to loot this corpse; we attacked them, or they attacked us when we were freely attackable
private string m_CorpseName; // Value of the CorpseNameAttribute attached to the owner when he died -or- null if the owner had no CorpseNameAttribute; use "the remains of ~name~"
private IDevourer m_Devourer; // The creature that devoured this corpse
// For notoriety:
private AccessLevel m_AccessLevel; // Which AccessLevel the owner had when he died
private Guild m_Guild; // Which Guild the owner was in when he died
private int m_Kills; // How many kills the owner had when he died
private DateTime m_TimeOfDeath; // What time was this corpse created?
private HairInfo m_Hair; // This contains the hair of the owner
private FacialHairInfo m_FacialHair; // This contains the facial hair of the owner
// For Forensics Evaluation
public string m_Forensicist; // Name of the first PlayerMobile who used Forensic Evaluation on the corpse
@ -102,7 +87,7 @@ namespace Server.Items
if ( !Core.SE )
return false;
return ( DateTime.UtcNow < (m_TimeOfDeath + InstancedCorpseTime) );
return ( DateTime.UtcNow < (TimeOfDeath + InstancedCorpseTime) );
}
}
@ -113,10 +98,7 @@ namespace Server.Items
private Mobile m_Mobile;
private Item m_Item;
private bool m_Perpetual; //Needed for Rummaged stuff. CONTRARY to the Patchlog, cause a later FoF contradicts it. Verify on OSI.
public bool Perpetual { get => m_Perpetual;
set => m_Perpetual = value;
}
public bool Perpetual { get; set; }
public InstancedItemInfo( Item i, Mobile m )
{
@ -159,7 +141,7 @@ namespace Server.Items
private void AssignInstancedLoot()
{
if ( m_Aggressors.Count == 0 || Items.Count == 0 )
if ( Aggressors.Count == 0 || Items.Count == 0 )
return;
if ( m_InstancedItems == null )
@ -181,7 +163,7 @@ namespace Server.Items
}
}
List<Mobile> attackers = new List<Mobile>( m_Aggressors );
List<Mobile> attackers = new List<Mobile>( Aggressors );
for ( int i = 1; i < attackers.Count -1; i++ ) //randomize
{
@ -254,16 +236,13 @@ namespace Server.Items
public override bool IsDecoContainer => false;
[CommandProperty( AccessLevel.GameMaster )]
public DateTime TimeOfDeath
{
get => m_TimeOfDeath;
set => m_TimeOfDeath = value;
}
public DateTime TimeOfDeath { get; set; }
public override bool DisplayWeight => false;
public HairInfo Hair => m_Hair;
public FacialHairInfo FacialHair => m_FacialHair;
public HairInfo Hair { get; }
public FacialHairInfo FacialHair { get; }
[CommandProperty( AccessLevel.GameMaster )]
public bool IsBones => GetFlag( CorpseFlag.IsBones );
@ -307,31 +286,23 @@ namespace Server.Items
}
[CommandProperty( AccessLevel.GameMaster )]
public AccessLevel AccessLevel => m_AccessLevel;
public AccessLevel AccessLevel { get; private set; }
public List<Mobile> Aggressors => m_Aggressors;
public List<Mobile> Aggressors { get; private set; }
public List<Mobile> Looters => m_Looters;
public List<Mobile> Looters { get; private set; }
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Killer => m_Killer;
public Mobile Killer { get; private set; }
public List<Item> EquipItems => m_EquipItems;
public List<Item> EquipItems { get; private set; }
public List<Item> RestoreEquip
{
get => m_RestoreEquip;
set => m_RestoreEquip = value;
}
public List<Item> RestoreEquip { get; set; }
public Guild Guild => m_Guild;
public Guild Guild { get; }
[CommandProperty( AccessLevel.GameMaster )]
public int Kills
{
get => m_Kills;
set => m_Kills = value;
}
public int Kills { get; set; }
[CommandProperty( AccessLevel.GameMaster )]
public bool Criminal
@ -341,7 +312,7 @@ namespace Server.Items
}
[CommandProperty( AccessLevel.GameMaster )]
public Mobile Owner => m_Owner;
public Mobile Owner { get; private set; }
public void TurnToBones()
{
@ -488,27 +459,27 @@ namespace Server.Items
Direction = owner.Direction;
Name = owner.Name;
m_Owner = owner;
Owner = owner;
m_CorpseName = GetCorpseName( owner );
m_TimeOfDeath = DateTime.UtcNow;
TimeOfDeath = DateTime.UtcNow;
m_AccessLevel = owner.AccessLevel;
m_Guild = owner.Guild as Guild;
m_Kills = owner.Kills;
AccessLevel = owner.AccessLevel;
Guild = owner.Guild as Guild;
Kills = owner.Kills;
SetFlag( CorpseFlag.Criminal, owner.Criminal );
m_Hair = hair;
m_FacialHair = facialhair;
Hair = hair;
FacialHair = facialhair;
// This corpse does not turn to bones if: the owner is not a player
SetFlag( CorpseFlag.NoBones, !owner.Player );
m_Looters = new List<Mobile>();
m_EquipItems = equipItems;
Looters = new List<Mobile>();
EquipItems = equipItems;
m_Aggressors = new List<Mobile>( owner.Aggressors.Count + owner.Aggressed.Count );
Aggressors = new List<Mobile>( owner.Aggressors.Count + owner.Aggressed.Count );
//bool addToAggressors = !( owner is BaseCreature );
bool isBaseCreature = (owner is BaseCreature);
@ -521,12 +492,12 @@ namespace Server.Items
if ( (DateTime.UtcNow - info.LastCombatTime) < lastTime )
{
m_Killer = info.Attacker;
Killer = info.Attacker;
lastTime = (DateTime.UtcNow - info.LastCombatTime);
}
if ( !isBaseCreature && !info.CriminalAggression )
m_Aggressors.Add( info.Attacker );
Aggressors.Add( info.Attacker );
}
for ( int i = 0; i < owner.Aggressed.Count; ++i )
@ -535,12 +506,12 @@ namespace Server.Items
if ( (DateTime.UtcNow - info.LastCombatTime) < lastTime )
{
m_Killer = info.Defender;
Killer = info.Defender;
lastTime = (DateTime.UtcNow - info.LastCombatTime);
}
if ( !isBaseCreature )
m_Aggressors.Add( info.Defender );
Aggressors.Add( info.Defender );
}
if ( isBaseCreature )
@ -549,7 +520,7 @@ namespace Server.Items
Mobile master = bc.GetMaster();
if ( master != null )
m_Aggressors.Add( master );
Aggressors.Add( master );
List<DamageStore> rights = BaseCreature.GetLootingRights( bc.DamageEntries, bc.HitsMax );
for ( int i = 0; i < rights.Count; ++i )
@ -557,7 +528,7 @@ namespace Server.Items
DamageStore ds = rights[i];
if ( ds.m_HasRight )
m_Aggressors.Add( ds.m_Mobile );
Aggressors.Add( ds.m_Mobile );
}
}
@ -586,19 +557,19 @@ namespace Server.Items
writer.Write( (int) 12 ); // version
if ( m_RestoreEquip == null )
if ( RestoreEquip == null )
{
writer.Write( false );
}
else
{
writer.Write( true );
writer.Write( m_RestoreEquip );
writer.Write( RestoreEquip );
}
writer.Write( (int)m_Flags );
writer.WriteDeltaTime( m_TimeOfDeath );
writer.WriteDeltaTime( TimeOfDeath );
List<KeyValuePair<Item, Point3D>> list = ( m_RestoreTable == null ? null : new List<KeyValuePair<Item, Point3D>>( m_RestoreTable ) );
int count = list?.Count ?? 0;
@ -629,20 +600,20 @@ namespace Server.Items
if ( m_DecayTimer != null )
writer.WriteDeltaTime( m_DecayTime );
writer.Write( m_Looters );
writer.Write( m_Killer );
writer.Write( Looters );
writer.Write( Killer );
writer.Write( m_Aggressors );
writer.Write( Aggressors );
writer.Write( m_Owner );
writer.Write( Owner );
writer.Write( (string) m_CorpseName );
writer.Write( (int) m_AccessLevel );
writer.Write( (Guild) m_Guild );
writer.Write( (int) m_Kills );
writer.Write( (int) AccessLevel );
writer.Write( (Guild) Guild );
writer.Write( (int) Kills );
writer.Write( m_EquipItems );
writer.Write( EquipItems );
}
public override void Deserialize( GenericReader reader )
@ -656,7 +627,7 @@ namespace Server.Items
case 12:
{
if ( reader.ReadBool() )
m_RestoreEquip = reader.ReadStrongItemList();
RestoreEquip = reader.ReadStrongItemList();
goto case 11;
}
@ -665,7 +636,7 @@ namespace Server.Items
// Version 11, we move all bools to a CorpseFlag
m_Flags = (CorpseFlag)reader.ReadInt();
m_TimeOfDeath = reader.ReadDeltaTime();
TimeOfDeath = reader.ReadDeltaTime();
int count = reader.ReadInt();
@ -682,24 +653,24 @@ namespace Server.Items
if ( reader.ReadBool() )
BeginDecay( reader.ReadDeltaTime() - DateTime.UtcNow );
m_Looters = reader.ReadStrongMobileList();
m_Killer = reader.ReadMobile();
Looters = reader.ReadStrongMobileList();
Killer = reader.ReadMobile();
m_Aggressors = reader.ReadStrongMobileList();
m_Owner = reader.ReadMobile();
Aggressors = reader.ReadStrongMobileList();
Owner = reader.ReadMobile();
m_CorpseName = reader.ReadString();
m_AccessLevel = (AccessLevel)reader.ReadInt();
AccessLevel = (AccessLevel)reader.ReadInt();
reader.ReadInt(); // guild reserve
m_Kills = reader.ReadInt();
Kills = reader.ReadInt();
m_EquipItems = reader.ReadStrongItemList();
EquipItems = reader.ReadStrongItemList();
break;
}
case 10:
{
m_TimeOfDeath = reader.ReadDeltaTime();
TimeOfDeath = reader.ReadDeltaTime();
goto case 9;
}
@ -734,8 +705,8 @@ namespace Server.Items
}
case 6:
{
m_Looters = reader.ReadStrongMobileList();
m_Killer = reader.ReadMobile();
Looters = reader.ReadStrongMobileList();
Killer = reader.ReadMobile();
goto case 5;
}
@ -747,13 +718,13 @@ namespace Server.Items
}
case 4:
{
m_Aggressors = reader.ReadStrongMobileList();
Aggressors = reader.ReadStrongMobileList();
goto case 3;
}
case 3:
{
m_Owner = reader.ReadMobile();
Owner = reader.ReadMobile();
goto case 2;
}
@ -772,23 +743,23 @@ namespace Server.Items
case 0:
{
if ( version < 10 )
m_TimeOfDeath = DateTime.UtcNow;
TimeOfDeath = DateTime.UtcNow;
if ( version < 7 )
BeginDecay( m_DefaultDecayTime );
if ( version < 6 )
m_Looters = new List<Mobile>();
Looters = new List<Mobile>();
if ( version < 4 )
m_Aggressors = new List<Mobile>();
Aggressors = new List<Mobile>();
m_AccessLevel = (AccessLevel)reader.ReadInt();
AccessLevel = (AccessLevel)reader.ReadInt();
reader.ReadInt(); // guild reserve
m_Kills = reader.ReadInt();
Kills = reader.ReadInt();
SetFlag( CorpseFlag.Criminal, reader.ReadBool() );
m_EquipItems = reader.ReadStrongItemList();
EquipItems = reader.ReadStrongItemList();
break;
}
@ -797,10 +768,10 @@ namespace Server.Items
public bool DevourCorpse()
{
if ( Devoured || Deleted || m_Killer == null || m_Killer.Deleted || !m_Killer.Alive || !(m_Killer is IDevourer) || m_Owner == null || m_Owner.Deleted )
if ( Devoured || Deleted || Killer == null || Killer.Deleted || !Killer.Alive || !(Killer is IDevourer) || Owner == null || Owner.Deleted )
return false;
m_Devourer = (IDevourer)m_Killer; // Set the devourer the killer
m_Devourer = (IDevourer)Killer; // Set the devourer the killer
return m_Devourer.Devour( this ); // Devour the corpse if it hasn't
}
@ -825,14 +796,14 @@ namespace Server.Items
public bool IsCriminalAction( Mobile from )
{
if ( from == m_Owner || from.AccessLevel >= AccessLevel.GameMaster )
if ( from == Owner || from.AccessLevel >= AccessLevel.GameMaster )
return false;
Party p = Party.Get( m_Owner );
Party p = Party.Get( Owner );
if ( p != null && p.Contains( from ) )
{
PartyMemberInfo pmi = p[m_Owner];
PartyMemberInfo pmi = p[Owner];
if ( pmi != null && pmi.CanLoot )
return false;
@ -870,8 +841,8 @@ namespace Server.Items
if ( item != this && IsCriminalAction( from ) )
from.CriminalAction( true );
if ( !m_Looters.Contains( from ) )
m_Looters.Add( from );
if ( !Looters.Contains( from ) )
Looters.Add( from );
if ( m_InstancedItems != null && m_InstancedItems.ContainsKey( item ) )
m_InstancedItems.Remove( item );
@ -881,14 +852,14 @@ namespace Server.Items
{
base.OnItemLifted( from, item );
if ( item != this && from != m_Owner )
if ( item != this && from != Owner )
from.RevealingAction();
if ( item != this && IsCriminalAction( from ) )
from.CriminalAction( true );
if ( !m_Looters.Contains( from ) )
m_Looters.Add( from );
if ( !Looters.Contains( from ) )
Looters.Add( from );
if ( m_InstancedItems != null && m_InstancedItems.ContainsKey( item ) )
m_InstancedItems.Remove( item );
@ -911,7 +882,7 @@ namespace Server.Items
{
base.GetContextMenuEntries( from, list );
if ( Core.AOS && m_Owner == from && from.Alive )
if ( Core.AOS && Owner == from && from.Alive )
list.Add( new OpenCorpseEntry() );
}
@ -964,7 +935,7 @@ namespace Server.Items
{
if ( !CanLoot( from, item ) )
{
if ( m_Owner == null || !m_Owner.Player )
if ( Owner == null || !Owner.Player )
from.SendLocalizedMessage( 1005035 ); // You did not earn the right to loot this creature!
else
from.SendLocalizedMessage( 1010049 ); // You may not loot this corpse.
@ -974,7 +945,7 @@ namespace Server.Items
if ( IsCriminalAction( from ) )
{
if ( m_Owner == null || !m_Owner.Player )
if ( Owner == null || !Owner.Player )
from.SendLocalizedMessage( 1005036 ); // Looting this monster corpse will be a criminal act!
else
from.SendLocalizedMessage( 1005038 ); // Looting this corpse will be a criminal act!
@ -988,7 +959,7 @@ namespace Server.Items
if ( from.AccessLevel > AccessLevel.Player || from.InRange( GetWorldLocation(), 2 ) )
{
#region Self Looting
if ( checkSelfLoot && from == m_Owner && !GetFlag( CorpseFlag.SelfLooted ) && Items.Count != 0 )
if ( checkSelfLoot && from == Owner && !GetFlag( CorpseFlag.SelfLooted ) && Items.Count != 0 )
{
if ( from.FindItemOnLayer( Layer.OuterTorso ) is DeathRobe robe )
{
@ -1003,7 +974,7 @@ namespace Server.Items
Container pack = from.Backpack;
if ( m_RestoreEquip != null && pack != null )
if ( RestoreEquip != null && pack != null )
{
List<Item> packItems = new List<Item>( pack.Items ); // Only items in the top-level pack are re-equipped
@ -1011,7 +982,7 @@ namespace Server.Items
{
Item packItem = packItems[i];
if ( m_RestoreEquip.Contains( packItem ) && packItem.Movable )
if ( RestoreEquip.Contains( packItem ) && packItem.Movable )
from.EquipItem( packItem );
}
}
@ -1033,7 +1004,7 @@ namespace Server.Items
item.Location = loc;
pack.AddItem( item );
if ( m_RestoreEquip != null && m_RestoreEquip.Contains( item ) )
if ( RestoreEquip != null && RestoreEquip.Contains( item ) )
from.EquipItem( item );
}
else
@ -1189,7 +1160,7 @@ namespace Server.Items
{
if ( IsCriminalAction( from ) && Map != null && (Map.Rules & MapRules.HarmfulRestrictions) != 0 )
{
if ( m_Owner == null || !m_Owner.Player )
if ( Owner == null || !Owner.Player )
from.SendLocalizedMessage( 1005035 ); // You did not earn the right to loot this creature!
else
from.SendLocalizedMessage( 1010049 ); // You may not loot this corpse.
@ -1197,7 +1168,7 @@ namespace Server.Items
return;
}
Mobile dead = m_Owner;
Mobile dead = Owner;
if ( GetFlag( CorpseFlag.Carved ) || dead == null )
{

View file

@ -5,13 +5,11 @@ namespace Server
[AttributeUsage( AttributeTargets.Class )]
public class CorpseNameAttribute : Attribute
{
private string m_Name;
public string Name => m_Name;
public string Name { get; }
public CorpseNameAttribute( string name )
{
m_Name = name;
Name = name;
}
}
}