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
|
|
@ -229,9 +229,7 @@ namespace Server.Mobiles
|
|||
return false;
|
||||
}
|
||||
|
||||
private static Hashtable m_EscortTable = new Hashtable();
|
||||
|
||||
public static Hashtable EscortTable => m_EscortTable;
|
||||
public static Hashtable EscortTable { get; } = new Hashtable();
|
||||
|
||||
public virtual bool AcceptEscorter(Mobile m)
|
||||
{
|
||||
|
|
@ -245,7 +243,7 @@ namespace Server.Mobiles
|
|||
if (escorter != null || !m.Alive)
|
||||
return false;
|
||||
|
||||
BaseEscortable escortable = (BaseEscortable)m_EscortTable[m];
|
||||
BaseEscortable escortable = (BaseEscortable)EscortTable[m];
|
||||
|
||||
if (escortable != null && !escortable.Deleted && escortable.GetEscorter() == m)
|
||||
{
|
||||
|
|
@ -268,7 +266,7 @@ namespace Server.Mobiles
|
|||
((PlayerMobile)m).LastEscortTime = DateTime.UtcNow;
|
||||
|
||||
Say("Lead on! Payment will be made when we arrive in {0}.", (dest.Name == "Ocllo" && m.Map == Map.Trammel) ? "Haven" : dest.Name);
|
||||
m_EscortTable[m] = this;
|
||||
EscortTable[m] = this;
|
||||
StartFollow();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -387,7 +385,7 @@ namespace Server.Mobiles
|
|||
Say(1005653); // Hmmm. I seem to have lost my master.
|
||||
|
||||
SetControlMaster(null);
|
||||
m_EscortTable.Remove(master);
|
||||
EscortTable.Remove(master);
|
||||
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(5.0), Delete);
|
||||
return null;
|
||||
|
|
@ -449,7 +447,7 @@ namespace Server.Mobiles
|
|||
|
||||
StopFollow();
|
||||
SetControlMaster(null);
|
||||
m_EscortTable.Remove(escorter);
|
||||
EscortTable.Remove(escorter);
|
||||
BeginDelete();
|
||||
|
||||
Misc.Titles.AwardFame(escorter, 10, true);
|
||||
|
|
@ -645,13 +643,11 @@ namespace Server.Mobiles
|
|||
|
||||
public class EscortDestinationInfo
|
||||
{
|
||||
private string m_Name;
|
||||
private Region m_Region;
|
||||
//private Rectangle2D[] m_Bounds;
|
||||
|
||||
public string Name => m_Name;
|
||||
public string Name { get; }
|
||||
|
||||
public Region Region => m_Region;
|
||||
public Region Region { get; }
|
||||
|
||||
/*public Rectangle2D[] Bounds
|
||||
{
|
||||
|
|
@ -660,13 +656,13 @@ namespace Server.Mobiles
|
|||
|
||||
public bool Contains(Point3D p)
|
||||
{
|
||||
return m_Region.Contains(p);
|
||||
return Region.Contains(p);
|
||||
}
|
||||
|
||||
public EscortDestinationInfo(string name, Region region)
|
||||
{
|
||||
m_Name = name;
|
||||
m_Region = region;
|
||||
Name = name;
|
||||
Region = region;
|
||||
}
|
||||
|
||||
private static Hashtable m_Table;
|
||||
|
|
|
|||
|
|
@ -44,46 +44,44 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public bool IsEmpty => ( m_Entries == null || m_Entries.Count == 0 );
|
||||
public bool IsEmpty => ( Entries == null || Entries.Count == 0 );
|
||||
|
||||
public GlobalTownCrierEntryList()
|
||||
{
|
||||
}
|
||||
|
||||
private List<TownCrierEntry> m_Entries;
|
||||
|
||||
public List<TownCrierEntry> Entries => m_Entries;
|
||||
public List<TownCrierEntry> Entries { get; private set; }
|
||||
|
||||
public TownCrierEntry GetRandomEntry()
|
||||
{
|
||||
if ( m_Entries == null || m_Entries.Count == 0 )
|
||||
if ( Entries == null || Entries.Count == 0 )
|
||||
return null;
|
||||
|
||||
for ( int i = m_Entries.Count - 1; m_Entries != null && i >= 0; --i )
|
||||
for ( int i = Entries.Count - 1; Entries != null && i >= 0; --i )
|
||||
{
|
||||
if ( i >= m_Entries.Count )
|
||||
if ( i >= Entries.Count )
|
||||
continue;
|
||||
|
||||
TownCrierEntry tce = m_Entries[i];
|
||||
TownCrierEntry tce = Entries[i];
|
||||
|
||||
if ( tce.Expired )
|
||||
RemoveEntry( tce );
|
||||
}
|
||||
|
||||
if ( m_Entries == null || m_Entries.Count == 0 )
|
||||
if ( Entries == null || Entries.Count == 0 )
|
||||
return null;
|
||||
|
||||
return m_Entries[Utility.Random( m_Entries.Count )];
|
||||
return Entries[Utility.Random( Entries.Count )];
|
||||
}
|
||||
|
||||
public TownCrierEntry AddEntry( string[] lines, TimeSpan duration )
|
||||
{
|
||||
if ( m_Entries == null )
|
||||
m_Entries = new List<TownCrierEntry>();
|
||||
if ( Entries == null )
|
||||
Entries = new List<TownCrierEntry>();
|
||||
|
||||
TownCrierEntry tce = new TownCrierEntry( lines, duration );
|
||||
|
||||
m_Entries.Add( tce );
|
||||
Entries.Add( tce );
|
||||
|
||||
List<TownCrier> instances = TownCrier.Instances;
|
||||
|
||||
|
|
@ -95,35 +93,34 @@ namespace Server.Mobiles
|
|||
|
||||
public void RemoveEntry( TownCrierEntry tce )
|
||||
{
|
||||
if ( m_Entries == null )
|
||||
if ( Entries == null )
|
||||
return;
|
||||
|
||||
m_Entries.Remove( tce );
|
||||
Entries.Remove( tce );
|
||||
|
||||
if ( m_Entries.Count == 0 )
|
||||
m_Entries = null;
|
||||
if ( Entries.Count == 0 )
|
||||
Entries = null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TownCrierEntry
|
||||
{
|
||||
private string[] m_Lines;
|
||||
private DateTime m_ExpireTime;
|
||||
public string[] Lines { get; }
|
||||
|
||||
public string[] Lines => m_Lines;
|
||||
public DateTime ExpireTime => m_ExpireTime;
|
||||
public bool Expired => ( DateTime.UtcNow >= m_ExpireTime );
|
||||
public DateTime ExpireTime { get; }
|
||||
|
||||
public bool Expired => ( DateTime.UtcNow >= ExpireTime );
|
||||
|
||||
public TownCrierEntry( string[] lines, TimeSpan duration )
|
||||
{
|
||||
m_Lines = lines;
|
||||
Lines = lines;
|
||||
|
||||
if ( duration < TimeSpan.Zero )
|
||||
duration = TimeSpan.Zero;
|
||||
else if ( duration > TimeSpan.FromDays( 365.0 ) )
|
||||
duration = TimeSpan.FromDays( 365.0 );
|
||||
|
||||
m_ExpireTime = DateTime.UtcNow + duration;
|
||||
ExpireTime = DateTime.UtcNow + duration;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -318,35 +315,34 @@ namespace Server.Mobiles
|
|||
|
||||
public class TownCrier : Mobile, ITownCrierEntryList
|
||||
{
|
||||
private List<TownCrierEntry> m_Entries;
|
||||
private Timer m_NewsTimer;
|
||||
private Timer m_AutoShoutTimer;
|
||||
|
||||
public List<TownCrierEntry> Entries => m_Entries;
|
||||
public List<TownCrierEntry> Entries { get; private set; }
|
||||
|
||||
public TownCrierEntry GetRandomEntry()
|
||||
{
|
||||
if ( m_Entries == null || m_Entries.Count == 0 )
|
||||
if ( Entries == null || Entries.Count == 0 )
|
||||
return GlobalTownCrierEntryList.Instance.GetRandomEntry();
|
||||
|
||||
for ( int i = m_Entries.Count - 1; m_Entries != null && i >= 0; --i )
|
||||
for ( int i = Entries.Count - 1; Entries != null && i >= 0; --i )
|
||||
{
|
||||
if ( i >= m_Entries.Count )
|
||||
if ( i >= Entries.Count )
|
||||
continue;
|
||||
|
||||
TownCrierEntry tce = m_Entries[i];
|
||||
TownCrierEntry tce = Entries[i];
|
||||
|
||||
if ( tce.Expired )
|
||||
RemoveEntry( tce );
|
||||
}
|
||||
|
||||
if ( m_Entries == null || m_Entries.Count == 0 )
|
||||
if ( Entries == null || Entries.Count == 0 )
|
||||
return GlobalTownCrierEntryList.Instance.GetRandomEntry();
|
||||
|
||||
TownCrierEntry entry = GlobalTownCrierEntryList.Instance.GetRandomEntry();
|
||||
|
||||
if ( entry == null || Utility.RandomBool() )
|
||||
entry = m_Entries[Utility.Random( m_Entries.Count )];
|
||||
entry = Entries[Utility.Random( Entries.Count )];
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
|
@ -359,12 +355,12 @@ namespace Server.Mobiles
|
|||
|
||||
public TownCrierEntry AddEntry( string[] lines, TimeSpan duration )
|
||||
{
|
||||
if ( m_Entries == null )
|
||||
m_Entries = new List<TownCrierEntry>();
|
||||
if ( Entries == null )
|
||||
Entries = new List<TownCrierEntry>();
|
||||
|
||||
TownCrierEntry tce = new TownCrierEntry( lines, duration );
|
||||
|
||||
m_Entries.Add( tce );
|
||||
Entries.Add( tce );
|
||||
|
||||
if ( m_AutoShoutTimer == null )
|
||||
m_AutoShoutTimer = Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromMinutes( 1.0 ), AutoShout_Callback );
|
||||
|
|
@ -374,15 +370,15 @@ namespace Server.Mobiles
|
|||
|
||||
public void RemoveEntry( TownCrierEntry tce )
|
||||
{
|
||||
if ( m_Entries == null )
|
||||
if ( Entries == null )
|
||||
return;
|
||||
|
||||
m_Entries.Remove( tce );
|
||||
Entries.Remove( tce );
|
||||
|
||||
if ( m_Entries.Count == 0 )
|
||||
m_Entries = null;
|
||||
if ( Entries.Count == 0 )
|
||||
Entries = null;
|
||||
|
||||
if ( m_Entries == null && GlobalTownCrierEntryList.Instance.IsEmpty )
|
||||
if ( Entries == null && GlobalTownCrierEntryList.Instance.IsEmpty )
|
||||
{
|
||||
m_AutoShoutTimer?.Stop();
|
||||
|
||||
|
|
@ -461,14 +457,12 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
private static List<TownCrier> m_Instances = new List<TownCrier>();
|
||||
|
||||
public static List<TownCrier> Instances => m_Instances;
|
||||
public static List<TownCrier> Instances { get; } = new List<TownCrier>();
|
||||
|
||||
[Constructible]
|
||||
public TownCrier()
|
||||
{
|
||||
m_Instances.Add( this );
|
||||
Instances.Add( this );
|
||||
|
||||
InitStats( 100, 100, 25 );
|
||||
|
||||
|
|
@ -525,13 +519,13 @@ namespace Server.Mobiles
|
|||
|
||||
public override void OnDelete()
|
||||
{
|
||||
m_Instances.Remove( this );
|
||||
Instances.Remove( this );
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public TownCrier( Serial serial ) : base( serial )
|
||||
{
|
||||
m_Instances.Add( this );
|
||||
Instances.Add( this );
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue