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

@ -100,9 +100,7 @@ namespace Server
public class Region : IComparable
{
private static List<Region> m_Regions = new List<Region>();
public static List<Region> Regions => m_Regions;
public static List<Region> Regions { get; } = new List<Region>();
public static Region Find( Point3D p, Map map )
{
@ -123,20 +121,11 @@ namespace Server
return map.DefaultRegion;
}
private static Type m_DefaultRegionType = typeof( Region );
public static Type DefaultRegionType{ get => m_DefaultRegionType;
set => m_DefaultRegionType = value;
}
public static Type DefaultRegionType { get; set; } = typeof( Region );
private static TimeSpan m_StaffLogoutDelay = TimeSpan.Zero;
private static TimeSpan m_DefaultLogoutDelay = TimeSpan.FromMinutes( 5.0 );
public static TimeSpan StaffLogoutDelay { get; set; } = TimeSpan.Zero;
public static TimeSpan StaffLogoutDelay{ get => m_StaffLogoutDelay;
set => m_StaffLogoutDelay = value;
}
public static TimeSpan DefaultLogoutDelay{ get => m_DefaultLogoutDelay;
set => m_DefaultLogoutDelay = value;
}
public static TimeSpan DefaultLogoutDelay { get; set; } = TimeSpan.FromMinutes( 5.0 );
public static readonly int DefaultPriority = 50;
@ -162,39 +151,35 @@ namespace Server
private string m_Name;
private Map m_Map;
private Region m_Parent;
private List<Region> m_Children = new List<Region>();
private Rectangle3D[] m_Area;
private Sector[] m_Sectors;
private bool m_Dynamic;
private int m_Priority;
private int m_ChildLevel;
private bool m_Registered;
private Point3D m_GoLocation;
private MusicName m_Music;
public string Name => m_Name;
public Map Map => m_Map;
public Region Parent => m_Parent;
public List<Region> Children => m_Children;
public Rectangle3D[] Area => m_Area;
public Sector[] Sectors => m_Sectors;
public bool Dynamic => m_Dynamic;
public Map Map { get; }
public Region Parent { get; }
public List<Region> Children { get; } = new List<Region>();
public Rectangle3D[] Area { get; }
public Sector[] Sectors { get; private set; }
public bool Dynamic { get; }
public int Priority => m_Priority;
public int ChildLevel => m_ChildLevel;
public bool Registered => m_Registered;
public int ChildLevel { get; }
public bool Registered { get; private set; }
public Point3D GoLocation{ get => m_GoLocation;
set => m_GoLocation = value;
}
public MusicName Music{ get => m_Music;
set => m_Music = value;
}
public MusicName Music { get; set; }
public bool IsDefault => m_Map.DefaultRegion == this;
public virtual MusicName DefaultMusic => m_Parent?.Music ?? MusicName.Invalid;
public bool IsDefault => Map.DefaultRegion == this;
public virtual MusicName DefaultMusic => Parent?.Music ?? MusicName.Invalid;
public Region( string name, Map map, int priority, params Rectangle2D[] area ) : this( name, map, priority, ConvertTo3D( area ) )
{
@ -212,60 +197,60 @@ namespace Server
public Region( string name, Map map, Region parent, params Rectangle3D[] area )
{
m_Name = name;
m_Map = map;
m_Parent = parent;
m_Area = area;
m_Dynamic = true;
m_Music = DefaultMusic;
Map = map;
Parent = parent;
Area = area;
Dynamic = true;
Music = DefaultMusic;
if ( m_Parent == null )
if ( Parent == null )
{
m_ChildLevel = 0;
ChildLevel = 0;
m_Priority = DefaultPriority;
}
else
{
m_ChildLevel = m_Parent.ChildLevel + 1;
m_Priority = m_Parent.Priority;
ChildLevel = Parent.ChildLevel + 1;
m_Priority = Parent.Priority;
}
}
public void Register()
{
if ( m_Registered )
if ( Registered )
return;
OnRegister();
m_Registered = true;
Registered = true;
if ( m_Parent != null )
if ( Parent != null )
{
m_Parent.m_Children.Add( this );
m_Parent.OnChildAdded( this );
Parent.Children.Add( this );
Parent.OnChildAdded( this );
}
m_Regions.Add( this );
Regions.Add( this );
m_Map.RegisterRegion( this );
Map.RegisterRegion( this );
List<Sector> sectors = new List<Sector>();
for ( int i = 0; i < m_Area.Length; i++ )
for ( int i = 0; i < Area.Length; i++ )
{
Rectangle3D rect = m_Area[i];
Rectangle3D rect = Area[i];
Point2D start = m_Map.Bound( new Point2D( rect.Start ) );
Point2D end = m_Map.Bound( new Point2D( rect.End ) );
Point2D start = Map.Bound( new Point2D( rect.Start ) );
Point2D end = Map.Bound( new Point2D( rect.End ) );
Sector startSector = m_Map.GetSector( start );
Sector endSector = m_Map.GetSector( end );
Sector startSector = Map.GetSector( start );
Sector endSector = Map.GetSector( end );
for ( int x = startSector.X; x <= endSector.X; x++ )
{
for ( int y = startSector.Y; y <= endSector.Y; y++ )
{
Sector sector = m_Map.GetRealSector( x, y );
Sector sector = Map.GetRealSector( x, y );
sector.OnEnter( this, rect );
@ -275,45 +260,45 @@ namespace Server
}
}
m_Sectors = sectors.ToArray();
Sectors = sectors.ToArray();
}
public void Unregister()
{
if ( !m_Registered )
if ( !Registered )
return;
OnUnregister();
m_Registered = false;
Registered = false;
if ( m_Children.Count > 0 )
if ( Children.Count > 0 )
Console.WriteLine( "Warning: Unregistering region '{0}' with children", this );
if ( m_Parent != null )
if ( Parent != null )
{
m_Parent.m_Children.Remove( this );
m_Parent.OnChildRemoved( this );
Parent.Children.Remove( this );
Parent.OnChildRemoved( this );
}
m_Regions.Remove( this );
Regions.Remove( this );
m_Map.UnregisterRegion( this );
Map.UnregisterRegion( this );
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
m_Sectors[i].OnLeave( this );
for ( int i = 0; i < Sectors.Length; i++ )
Sectors[i].OnLeave( this );
}
m_Sectors = null;
Sectors = null;
}
public bool Contains( Point3D p )
{
for ( int i = 0; i < m_Area.Length; i++ )
for ( int i = 0; i < Area.Length; i++ )
{
Rectangle3D rect = m_Area[i];
Rectangle3D rect = Area[i];
if ( rect.Contains( p ) )
return true;
@ -327,14 +312,14 @@ namespace Server
if ( region == null )
return false;
Region p = m_Parent;
Region p = Parent;
while ( p != null )
{
if ( p == region )
return true;
p = p.m_Parent;
p = p.Parent;
}
return false;
@ -352,7 +337,7 @@ namespace Server
if ( regionType.IsAssignableFrom( r.GetType() ) )
return r;
r = r.m_Parent;
r = r.Parent;
}
while ( r != null );
@ -371,7 +356,7 @@ namespace Server
if ( r.m_Name == regionName )
return r;
r = r.m_Parent;
r = r.Parent;
}
while ( r != null );
@ -404,8 +389,8 @@ namespace Server
if ( region == this )
return true;
if ( m_Parent != null )
return m_Parent.AcceptsSpawnsFrom( region );
if ( Parent != null )
return Parent.AcceptsSpawnsFrom( region );
return false;
}
@ -414,11 +399,11 @@ namespace Server
{
List<Mobile> list = new List<Mobile>();
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile player in sector.Players )
{
@ -435,11 +420,11 @@ namespace Server
{
int count = 0;
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile player in sector.Players )
{
@ -456,11 +441,11 @@ namespace Server
{
List<Mobile> list = new List<Mobile>();
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile mobile in sector.Mobiles )
{
@ -477,11 +462,11 @@ namespace Server
{
int count = 0;
if ( m_Sectors != null )
if ( Sectors != null )
{
for ( int i = 0; i < m_Sectors.Length; i++ )
for ( int i = 0; i < Sectors.Length; i++ )
{
Sector sector = m_Sectors[i];
Sector sector = Sectors[i];
foreach ( Mobile mobile in sector.Mobiles )
{
@ -561,97 +546,97 @@ namespace Server
public virtual void MakeGuard( Mobile focus )
{
m_Parent?.MakeGuard( focus );
Parent?.MakeGuard( focus );
}
public virtual Type GetResource( Type type )
{
if ( m_Parent != null )
return m_Parent.GetResource( type );
if ( Parent != null )
return Parent.GetResource( type );
return type;
}
public virtual bool CanUseStuckMenu( Mobile m )
{
if ( m_Parent != null )
return m_Parent.CanUseStuckMenu( m );
if ( Parent != null )
return Parent.CanUseStuckMenu( m );
return true;
}
public virtual void OnAggressed( Mobile aggressor, Mobile aggressed, bool criminal )
{
m_Parent?.OnAggressed( aggressor, aggressed, criminal );
Parent?.OnAggressed( aggressor, aggressed, criminal );
}
public virtual void OnDidHarmful( Mobile harmer, Mobile harmed )
{
m_Parent?.OnDidHarmful( harmer, harmed );
Parent?.OnDidHarmful( harmer, harmed );
}
public virtual void OnGotHarmful( Mobile harmer, Mobile harmed )
{
m_Parent?.OnGotHarmful( harmer, harmed );
Parent?.OnGotHarmful( harmer, harmed );
}
public virtual void OnLocationChanged( Mobile m, Point3D oldLocation )
{
m_Parent?.OnLocationChanged( m, oldLocation );
Parent?.OnLocationChanged( m, oldLocation );
}
public virtual bool OnTarget( Mobile m, Target t, object o )
{
if ( m_Parent != null )
return m_Parent.OnTarget( m, t, o );
if ( Parent != null )
return Parent.OnTarget( m, t, o );
return true;
}
public virtual bool OnCombatantChange( Mobile m, Mobile Old, Mobile New )
{
if ( m_Parent != null )
return m_Parent.OnCombatantChange( m, Old, New );
if ( Parent != null )
return Parent.OnCombatantChange( m, Old, New );
return true;
}
public virtual bool AllowHousing( Mobile from, Point3D p )
{
if ( m_Parent != null )
return m_Parent.AllowHousing( from, p );
if ( Parent != null )
return Parent.AllowHousing( from, p );
return true;
}
public virtual bool SendInaccessibleMessage( Item item, Mobile from )
{
if ( m_Parent != null )
return m_Parent.SendInaccessibleMessage( item, from );
if ( Parent != null )
return Parent.SendInaccessibleMessage( item, from );
return false;
}
public virtual bool CheckAccessibility( Item item, Mobile from )
{
if ( m_Parent != null )
return m_Parent.CheckAccessibility( item, from );
if ( Parent != null )
return Parent.CheckAccessibility( item, from );
return true;
}
public virtual bool OnDecay( Item item )
{
if ( m_Parent != null )
return m_Parent.OnDecay( item );
if ( Parent != null )
return Parent.OnDecay( item );
return true;
}
public virtual bool AllowHarmful( Mobile from, Mobile target )
{
if ( m_Parent != null )
return m_Parent.AllowHarmful( from, target );
if ( Parent != null )
return Parent.AllowHarmful( from, target );
if ( Mobile.AllowHarmfulHandler != null )
return Mobile.AllowHarmfulHandler( from, target );
@ -661,16 +646,16 @@ namespace Server
public virtual void OnCriminalAction( Mobile m, bool message )
{
if ( m_Parent != null )
m_Parent.OnCriminalAction( m, message );
if ( Parent != null )
Parent.OnCriminalAction( m, message );
else if ( message )
m.SendLocalizedMessage( 1005040 ); // You've committed a criminal act!!
}
public virtual bool AllowBeneficial( Mobile from, Mobile target )
{
if ( m_Parent != null )
return m_Parent.AllowBeneficial( from, target );
if ( Parent != null )
return Parent.AllowBeneficial( from, target );
if ( Mobile.AllowBeneficialHandler != null )
return Mobile.AllowBeneficialHandler( from, target );
@ -680,118 +665,118 @@ namespace Server
public virtual void OnBeneficialAction( Mobile helper, Mobile target )
{
m_Parent?.OnBeneficialAction( helper, target );
Parent?.OnBeneficialAction( helper, target );
}
public virtual void OnGotBeneficialAction( Mobile helper, Mobile target )
{
m_Parent?.OnGotBeneficialAction( helper, target );
Parent?.OnGotBeneficialAction( helper, target );
}
public virtual void SpellDamageScalar( Mobile caster, Mobile target, ref double damage )
{
m_Parent?.SpellDamageScalar( caster, target, ref damage );
Parent?.SpellDamageScalar( caster, target, ref damage );
}
public virtual void OnSpeech( SpeechEventArgs args )
{
m_Parent?.OnSpeech( args );
Parent?.OnSpeech( args );
}
public virtual bool OnSkillUse( Mobile m, int Skill )
{
if ( m_Parent != null )
return m_Parent.OnSkillUse( m, Skill );
if ( Parent != null )
return Parent.OnSkillUse( m, Skill );
return true;
}
public virtual bool OnBeginSpellCast( Mobile m, ISpell s )
{
if ( m_Parent != null )
return m_Parent.OnBeginSpellCast( m, s );
if ( Parent != null )
return Parent.OnBeginSpellCast( m, s );
return true;
}
public virtual void OnSpellCast( Mobile m, ISpell s )
{
m_Parent?.OnSpellCast( m, s );
Parent?.OnSpellCast( m, s );
}
public virtual bool OnResurrect( Mobile m )
{
if ( m_Parent != null )
return m_Parent.OnResurrect( m );
if ( Parent != null )
return Parent.OnResurrect( m );
return true;
}
public virtual bool OnBeforeDeath( Mobile m )
{
if ( m_Parent != null )
return m_Parent.OnBeforeDeath( m );
if ( Parent != null )
return Parent.OnBeforeDeath( m );
return true;
}
public virtual void OnDeath( Mobile m )
{
m_Parent?.OnDeath( m );
Parent?.OnDeath( m );
}
public virtual bool OnDamage( Mobile m, ref int Damage )
{
if ( m_Parent != null )
return m_Parent.OnDamage( m, ref Damage );
if ( Parent != null )
return Parent.OnDamage( m, ref Damage );
return true;
}
public virtual bool OnHeal( Mobile m, ref int Heal )
{
if ( m_Parent != null )
return m_Parent.OnHeal( m, ref Heal );
if ( Parent != null )
return Parent.OnHeal( m, ref Heal );
return true;
}
public virtual bool OnDoubleClick( Mobile m, object o )
{
if ( m_Parent != null )
return m_Parent.OnDoubleClick( m, o );
if ( Parent != null )
return Parent.OnDoubleClick( m, o );
return true;
}
public virtual bool OnSingleClick( Mobile m, object o )
{
if ( m_Parent != null )
return m_Parent.OnSingleClick( m, o );
if ( Parent != null )
return Parent.OnSingleClick( m, o );
return true;
}
public virtual bool AllowSpawn()
{
if ( m_Parent != null )
return m_Parent.AllowSpawn();
if ( Parent != null )
return Parent.AllowSpawn();
return true;
}
public virtual void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
m_Parent?.AlterLightLevel( m, ref global, ref personal );
Parent?.AlterLightLevel( m, ref global, ref personal );
}
public virtual TimeSpan GetLogoutDelay( Mobile m )
{
if ( m_Parent != null )
return m_Parent.GetLogoutDelay( m );
if ( Parent != null )
return Parent.GetLogoutDelay( m );
if ( m.AccessLevel > AccessLevel.Player )
return m_StaffLogoutDelay;
return m_DefaultLogoutDelay;
return StaffLogoutDelay;
return DefaultLogoutDelay;
}
@ -805,10 +790,10 @@ namespace Server
if ( !newRegion.OnMoveInto( m, d, newLocation, oldLocation ) )
return false;
if ( newRegion.m_Parent == null )
if ( newRegion.Parent == null )
return true;
newRegion = newRegion.m_Parent;
newRegion = newRegion.Parent;
}
return true;
@ -919,19 +904,19 @@ namespace Server
public Region( XmlElement xml, Map map, Region parent )
{
m_Map = map;
m_Parent = parent;
m_Dynamic = false;
Map = map;
Parent = parent;
Dynamic = false;
if ( m_Parent == null )
if ( Parent == null )
{
m_ChildLevel = 0;
ChildLevel = 0;
m_Priority = DefaultPriority;
}
else
{
m_ChildLevel = m_Parent.ChildLevel + 1;
m_Priority = m_Parent.Priority;
ChildLevel = Parent.ChildLevel + 1;
m_Priority = Parent.Priority;
}
ReadString( xml, "name", ref m_Name, false );
@ -956,21 +941,21 @@ namespace Server
area.Add( rect );
}
m_Area = area.ToArray();
Area = area.ToArray();
if ( m_Area.Length == 0 )
if ( Area.Length == 0 )
Console.WriteLine( "Empty area for region '{0}'", this );
if ( !ReadPoint3D( xml["go"], map, ref m_GoLocation, false ) && m_Area.Length > 0 )
if ( !ReadPoint3D( xml["go"], map, ref m_GoLocation, false ) && Area.Length > 0 )
{
Point3D start = m_Area[0].Start;
Point3D end = m_Area[0].End;
Point3D start = Area[0].Start;
Point3D end = Area[0].End;
int x = start.X + (end.X - start.X) / 2;
int y = start.Y + (end.Y - start.Y) / 2;
m_GoLocation = new Point3D( x, y, m_Map.GetAverageZ( x, y ) );
m_GoLocation = new Point3D( x, y, Map.GetAverageZ( x, y ) );
}
@ -978,7 +963,7 @@ namespace Server
ReadEnum( xml["music"], "name", ref music, false );
m_Music = music;
Music = music;
}
protected static string GetAttribute( XmlElement xml, string attribute, bool mandatory )