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

@ -38,23 +38,15 @@ namespace Server.Engines.Plants
*/
private static readonly bool ShowContainerType = true;
private PlantSystem m_PlantSystem;
private PlantStatus m_PlantStatus;
private PlantType m_PlantType;
private PlantHue m_PlantHue;
private bool m_ShowType;
private SecureLevel m_Level;
[CommandProperty( AccessLevel.GameMaster )]
public SecureLevel Level
{
get => m_Level;
set => m_Level = value;
}
public SecureLevel Level { get; set; }
public PlantSystem PlantSystem => m_PlantSystem;
public PlantSystem PlantSystem { get; private set; }
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
@ -80,8 +72,8 @@ namespace Server.Engines.Plants
return;
double ratio;
if ( m_PlantSystem != null )
ratio = (double) m_PlantSystem.Hits / m_PlantSystem.MaxHits;
if ( PlantSystem != null )
ratio = (double) PlantSystem.Hits / PlantSystem.MaxHits;
else
ratio = 1.0;
@ -89,19 +81,19 @@ namespace Server.Engines.Plants
if ( m_PlantStatus >= PlantStatus.DecorativePlant )
{
m_PlantSystem = null;
PlantSystem = null;
}
else
{
if ( m_PlantSystem == null )
m_PlantSystem = new PlantSystem( this, false );
if ( PlantSystem == null )
PlantSystem = new PlantSystem( this, false );
int hits = (int)( m_PlantSystem.MaxHits * ratio );
int hits = (int)( PlantSystem.MaxHits * ratio );
if ( hits == 0 && m_PlantStatus > PlantStatus.BowlOfDirt )
m_PlantSystem.Hits = hits + 1;
PlantSystem.Hits = hits + 1;
else
m_PlantSystem.Hits = hits;
PlantSystem.Hits = hits;
}
Update();
@ -173,9 +165,7 @@ namespace Server.Engines.Plants
[CommandProperty( AccessLevel.GameMaster )]
public bool Reproduces => PlantHueInfo.CanReproduce( PlantHue ) && PlantTypeInfo.CanReproduce( PlantType );
private static ArrayList m_Instances = new ArrayList();
public static ArrayList Plants => m_Instances;
public static ArrayList Plants { get; } = new ArrayList();
[Constructible]
public PlantItem() : this( false )
@ -188,10 +178,10 @@ namespace Server.Engines.Plants
Weight = 1.0;
m_PlantStatus = PlantStatus.BowlOfDirt;
m_PlantSystem = new PlantSystem( this, fertileDirt );
m_Level = SecureLevel.Owner;
PlantSystem = new PlantSystem( this, fertileDirt );
Level = SecureLevel.Owner;
m_Instances.Add( this );
Plants.Add( this );
}
public PlantItem( Serial serial ) : base( serial )
@ -257,9 +247,9 @@ namespace Server.Engines.Plants
string args;
if ( ShowContainerType )
args = $"#{GetLocalizedContainerType()}\t#{m_PlantSystem.GetLocalizedDirtStatus()}";
args = $"#{GetLocalizedContainerType()}\t#{PlantSystem.GetLocalizedDirtStatus()}";
else
args = $"#{m_PlantSystem.GetLocalizedDirtStatus()}";
args = $"#{PlantSystem.GetLocalizedDirtStatus()}";
list.Add( 1060830, args ); // a ~1_val~ of ~2_val~ dirt
}
@ -275,7 +265,7 @@ namespace Server.Engines.Plants
else if ( m_PlantStatus >= PlantStatus.FullGrownPlant )
{
list.Add( typeInfo.GetPlantLabelFullGrown( hueInfo ),
$"#{m_PlantSystem.GetLocalizedHealth()}\t#{hueInfo.Name}\t#{typeInfo.Name}");
$"#{PlantSystem.GetLocalizedHealth()}\t#{hueInfo.Name}\t#{typeInfo.Name}");
}
else
{
@ -283,9 +273,9 @@ namespace Server.Engines.Plants
if ( ShowContainerType )
args =
$"#{GetLocalizedContainerType()}\t#{m_PlantSystem.GetLocalizedDirtStatus()}\t#{m_PlantSystem.GetLocalizedHealth()}";
$"#{GetLocalizedContainerType()}\t#{PlantSystem.GetLocalizedDirtStatus()}\t#{PlantSystem.GetLocalizedHealth()}";
else
args = $"#{m_PlantSystem.GetLocalizedDirtStatus()}\t#{m_PlantSystem.GetLocalizedHealth()}";
args = $"#{PlantSystem.GetLocalizedDirtStatus()}\t#{PlantSystem.GetLocalizedHealth()}";
if ( m_ShowType )
{
@ -348,7 +338,7 @@ namespace Server.Engines.Plants
{
from.SendLocalizedMessage( 1080389, "#" + GetLocalizedPlantStatus().ToString() ); // This bowl of dirt already has a ~1_val~ in it!
}
else if ( m_PlantSystem.Water < 2 )
else if ( PlantSystem.Water < 2 )
{
LabelTo( from, 1061920 ); // The dirt needs to be softened first.
}
@ -362,7 +352,7 @@ namespace Server.Engines.Plants
PlantStatus = PlantStatus.Seed;
m_PlantSystem.Reset( false );
PlantSystem.Reset( false );
LabelTo( from, 1061922 ); // You plant the seed in the bowl of dirt.
}
@ -377,7 +367,7 @@ namespace Server.Engines.Plants
else
{
PlantStatus = PlantStatus.BowlOfDirt;
m_PlantSystem.Reset( true );
PlantSystem.Reset( true );
}
}
@ -410,7 +400,7 @@ namespace Server.Engines.Plants
return;
beverage.Quantity--;
m_PlantSystem.Water++;
PlantSystem.Water++;
from.PlaySound( 0x4E );
LabelTo( from, 1061858 ); // You soften the dirt with water.
@ -464,31 +454,31 @@ namespace Server.Engines.Plants
if ( effect == PotionEffect.PoisonGreater || effect == PotionEffect.PoisonDeadly )
{
if ( m_PlantSystem.IsFullPoisonPotion )
if ( PlantSystem.IsFullPoisonPotion )
full = true;
else if ( !testOnly )
m_PlantSystem.PoisonPotion++;
PlantSystem.PoisonPotion++;
}
else if ( effect == PotionEffect.CureGreater )
{
if ( m_PlantSystem.IsFullCurePotion )
if ( PlantSystem.IsFullCurePotion )
full = true;
else if ( !testOnly )
m_PlantSystem.CurePotion++;
PlantSystem.CurePotion++;
}
else if ( effect == PotionEffect.HealGreater )
{
if ( m_PlantSystem.IsFullHealPotion )
if ( PlantSystem.IsFullHealPotion )
full = true;
else if ( !testOnly )
m_PlantSystem.HealPotion++;
PlantSystem.HealPotion++;
}
else if ( effect == PotionEffect.StrengthGreater )
{
if ( m_PlantSystem.IsFullStrengthPotion )
if ( PlantSystem.IsFullStrengthPotion )
full = true;
else if ( !testOnly )
m_PlantSystem.StrengthPotion++;
PlantSystem.StrengthPotion++;
}
else if ( effect == PotionEffect.PoisonLesser || effect == PotionEffect.Poison || effect == PotionEffect.CureLesser || effect == PotionEffect.Cure ||
effect == PotionEffect.HealLesser || effect == PotionEffect.Heal || effect == PotionEffect.Strength )
@ -518,7 +508,7 @@ namespace Server.Engines.Plants
writer.Write( (int) 2 ); // version
writer.Write( (int) m_Level );
writer.Write( (int) Level );
writer.Write( (int) m_PlantStatus );
writer.Write( (int) m_PlantType );
@ -526,7 +516,7 @@ namespace Server.Engines.Plants
writer.Write( (bool) m_ShowType );
if ( m_PlantStatus < PlantStatus.DecorativePlant )
m_PlantSystem.Save( writer );
PlantSystem.Save( writer );
}
public override void Deserialize( GenericReader reader )
@ -540,13 +530,13 @@ namespace Server.Engines.Plants
case 2:
case 1:
{
m_Level = (SecureLevel)reader.ReadInt();
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
if ( version < 1 )
m_Level = SecureLevel.CoOwners;
Level = SecureLevel.CoOwners;
m_PlantStatus = (PlantStatus)reader.ReadInt();
m_PlantType = (PlantType)reader.ReadInt();
@ -554,7 +544,7 @@ namespace Server.Engines.Plants
m_ShowType = reader.ReadBool();
if ( m_PlantStatus < PlantStatus.DecorativePlant )
m_PlantSystem = new PlantSystem( this, reader );
PlantSystem = new PlantSystem( this, reader );
if ( version < 2 && PlantHueInfo.IsCrossable( m_PlantHue ) )
m_PlantHue |= PlantHue.Reproduces;
@ -563,14 +553,14 @@ namespace Server.Engines.Plants
}
}
m_Instances.Add( this );
Plants.Add( this );
}
public override void OnAfterDelete()
{
base.OnAfterDelete();
m_Instances.Remove( this );
Plants.Remove( this );
}
}
}