Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 • committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -5,7 +5,7 @@ namespace Server.Engines.Plants
{
public class EmptyTheBowlGump : Gump
{
private PlantItem m_Plant;
private readonly PlantItem m_Plant;
public EmptyTheBowlGump(PlantItem plant) : base(20, 20)
{
@ -68,53 +68,53 @@ namespace Server.Engines.Plants
switch (info.ButtonID)
{
case 1: // Cancel
{
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 2: // Help
{
from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL
from.SendGump(new EmptyTheBowlGump(m_Plant));
break;
}
case 3: // Ok
{
PlantBowl bowl = new PlantBowl();
if (!from.PlaceInBackpack(bowl))
{
bowl.Delete();
m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack!
from.SendGump(new MainPlantGump(m_Plant));
break;
}
if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant)
case 2: // Help
{
Seed seed = new Seed(m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType);
from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL
if (!from.PlaceInBackpack(seed))
from.SendGump(new EmptyTheBowlGump(m_Plant));
break;
}
case 3: // Ok
{
PlantBowl bowl = new PlantBowl();
if (!from.PlaceInBackpack(bowl))
{
bowl.Delete();
seed.Delete();
m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack!
from.SendGump(new MainPlantGump(m_Plant));
break;
}
if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant)
{
Seed seed = new Seed(m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType);
if (!from.PlaceInBackpack(seed))
{
bowl.Delete();
seed.Delete();
m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack!
from.SendGump(new MainPlantGump(m_Plant));
break;
}
}
m_Plant.Delete();
break;
}
m_Plant.Delete();
break;
}
}
}
}

View file

@ -7,7 +7,7 @@ namespace Server.Engines.Plants
{
public class MainPlantGump : Gump
{
private PlantItem m_Plant;
private readonly PlantItem m_Plant;
public MainPlantGump(PlantItem plant) : base(20, 20)
{
@ -138,41 +138,41 @@ namespace Server.Engines.Plants
switch (m_Plant.PlantSystem.Health)
{
case PlantHealth.Dying:
{
AddItem(92, 167, 0x1B9D);
AddItem(161, 167, 0x1B9D);
{
AddItem(92, 167, 0x1B9D);
AddItem(161, 167, 0x1B9D);
AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00);
AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00);
break;
}
break;
}
case PlantHealth.Wilted:
{
AddItem(91, 164, 0x18E6);
AddItem(161, 164, 0x18E6);
{
AddItem(91, 164, 0x18E6);
AddItem(161, 164, 0x18E6);
AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207);
AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207);
break;
}
break;
}
case PlantHealth.Healthy:
{
AddItem(96, 168, 0xC61);
AddItem(162, 168, 0xC61);
{
AddItem(96, 168, 0xC61);
AddItem(162, 168, 0xC61);
AddHtmlLocalized(129, 167, 42, 20, message, 0x008200);
AddHtmlLocalized(129, 167, 42, 20, message, 0x008200);
break;
}
break;
}
case PlantHealth.Vibrant:
{
AddItem(93, 162, 0x1A99);
AddItem(162, 162, 0x1A99);
{
AddItem(93, 162, 0x1A99);
AddItem(162, 162, 0x1A99);
AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0);
AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0);
break;
}
break;
}
}
}
}
@ -246,7 +246,7 @@ namespace Server.Engines.Plants
if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant)
return;
if ((info.ButtonID >= 6 && info.ButtonID <= 10 || info.ButtonID == 12) &&
if (((info.ButtonID >= 6 && info.ButtonID <= 10) || info.ButtonID == 12) &&
!from.InRange(m_Plant.GetWorldLocation(), 3))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
@ -262,110 +262,110 @@ namespace Server.Engines.Plants
switch (info.ButtonID)
{
case 1: // Reproduction menu
{
if (m_Plant.PlantStatus > PlantStatus.BowlOfDirt)
{
from.SendGump(new ReproductionGump(m_Plant));
if (m_Plant.PlantStatus > PlantStatus.BowlOfDirt)
{
from.SendGump(new ReproductionGump(m_Plant));
}
else
{
from.SendLocalizedMessage(1061885); // You need to plant a seed in the bowl first.
from.SendGump(new MainPlantGump(m_Plant));
}
break;
}
else
case 2: // Infestation
{
from.SendLocalizedMessage(1061885); // You need to plant a seed in the bowl first.
from.Send(new DisplayHelpTopic(54, true)); // INFESTATION LEVEL
from.SendGump(new MainPlantGump(m_Plant));
break;
}
break;
}
case 2: // Infestation
{
from.Send(new DisplayHelpTopic(54, true)); // INFESTATION LEVEL
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 3: // Fungus
{
from.Send(new DisplayHelpTopic(56, true)); // FUNGUS LEVEL
{
from.Send(new DisplayHelpTopic(56, true)); // FUNGUS LEVEL
from.SendGump(new MainPlantGump(m_Plant));
from.SendGump(new MainPlantGump(m_Plant));
break;
}
break;
}
case 4: // Poison
{
from.Send(new DisplayHelpTopic(58, true)); // POISON LEVEL
{
from.Send(new DisplayHelpTopic(58, true)); // POISON LEVEL
from.SendGump(new MainPlantGump(m_Plant));
from.SendGump(new MainPlantGump(m_Plant));
break;
}
break;
}
case 5: // Disease
{
from.Send(new DisplayHelpTopic(60, true)); // DISEASE LEVEL
{
from.Send(new DisplayHelpTopic(60, true)); // DISEASE LEVEL
from.SendGump(new MainPlantGump(m_Plant));
from.SendGump(new MainPlantGump(m_Plant));
break;
}
break;
}
case 6: // Water
{
BaseBeverage bev = from.Backpack.FindItemsByType<BaseBeverage>().Find(beverage =>
beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water);
if (bev == null)
{
from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808,
$"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~.
}
else
{
m_Plant.Pour(from, bev);
}
BaseBeverage bev = from.Backpack.FindItemsByType<BaseBeverage>().Find(beverage =>
beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water);
from.SendGump(new MainPlantGump(m_Plant));
if (bev == null)
{
from.Target = new PlantPourTarget(m_Plant);
from.SendLocalizedMessage(1060808,
$"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~.
}
else
{
m_Plant.Pour(from, bev);
}
break;
}
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 7: // Poison potion
{
AddPotion(from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly);
{
AddPotion(from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly);
break;
}
break;
}
case 8: // Cure potion
{
AddPotion(from, PotionEffect.CureGreater);
{
AddPotion(from, PotionEffect.CureGreater);
break;
}
break;
}
case 9: // Heal potion
{
AddPotion(from, PotionEffect.HealGreater);
{
AddPotion(from, PotionEffect.HealGreater);
break;
}
break;
}
case 10: // Strength potion
{
AddPotion(from, PotionEffect.StrengthGreater);
{
AddPotion(from, PotionEffect.StrengthGreater);
break;
}
break;
}
case 11: // Help
{
from.Send(new DisplayHelpTopic(48, true)); // PLANT GROWING
{
from.Send(new DisplayHelpTopic(48, true)); // PLANT GROWING
from.SendGump(new MainPlantGump(m_Plant));
from.SendGump(new MainPlantGump(m_Plant));
break;
}
break;
}
case 12: // Empty the bowl
{
from.SendGump(new EmptyTheBowlGump(m_Plant));
{
from.SendGump(new EmptyTheBowlGump(m_Plant));
break;
}
break;
}
}
}

View file

@ -58,7 +58,7 @@ namespace Server.Items
private class InternalTarget : Target
{
private GreenThorns m_Thorn;
private readonly GreenThorns m_Thorn;
public InternalTarget(GreenThorns thorn) : base(3, true, TargetFlags.None) => m_Thorn = thorn;
@ -126,7 +126,7 @@ namespace Server.Items
private class EndActionTimer : Timer
{
private Mobile m_From;
private readonly Mobile m_From;
public EndActionTimer(Mobile from) : base(TimeSpan.FromMinutes(3.0))
{
@ -143,7 +143,7 @@ namespace Server.Items
public abstract class GreenThornsEffect : Timer
{
private static TilesAndEffect[] m_Table =
private static readonly TilesAndEffect[] m_Table =
{
new TilesAndEffect(new[]
{
@ -258,11 +258,11 @@ namespace Server.Items
Priority = TimerPriority.TwoFiftyMS;
}
public Point3D Location{ get; }
public Point3D Location { get; }
public Map Map{ get; }
public Map Map { get; }
public Mobile From{ get; }
public Mobile From { get; }
public static GreenThornsEffect Create(Mobile from, LandTarget land)
{
@ -361,9 +361,9 @@ namespace Server.Items
Effect = effect;
}
public int[] Tiles{ get; }
public int[] Tiles { get; }
public Type Effect{ get; }
public Type Effect { get; }
}
}
@ -378,65 +378,65 @@ namespace Server.Items
switch (step)
{
case 0:
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 1:
{
Effects.PlaySound(Location, Map, 0x222);
{
Effects.PlaySound(Location, Map, 0x222);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 2:
{
Effects.PlaySound(Location, Map, 0x21F);
{
Effects.PlaySound(Location, Map, 0x21F);
return TimeSpan.FromSeconds(5.0);
}
return TimeSpan.FromSeconds(5.0);
}
case 3:
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* The ground erupts with chaotic growth! *");
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* The ground erupts with chaotic growth! *");
Effects.PlaySound(Location, Map, 0x12D);
Effects.PlaySound(Location, Map, 0x12D);
SpawnReagents();
SpawnReagents();
SpawnReagents();
SpawnReagents();
return TimeSpan.FromSeconds(2.0);
}
return TimeSpan.FromSeconds(2.0);
}
case 4:
{
Effects.PlaySound(Location, Map, 0x12D);
{
Effects.PlaySound(Location, Map, 0x12D);
SpawnReagents();
SpawnReagents();
SpawnReagents();
SpawnReagents();
return TimeSpan.FromSeconds(2.0);
}
return TimeSpan.FromSeconds(2.0);
}
case 5:
{
Effects.PlaySound(Location, Map, 0x12D);
{
Effects.PlaySound(Location, Map, 0x12D);
SpawnReagents();
SpawnReagents();
SpawnReagents();
SpawnReagents();
return TimeSpan.FromSeconds(3.0);
}
return TimeSpan.FromSeconds(3.0);
}
default:
{
Effects.PlaySound(Location, Map, 0x12D);
{
Effects.PlaySound(Location, Map, 0x12D);
SpawnReagents();
SpawnReagents();
SpawnReagents();
SpawnReagents();
return TimeSpan.Zero;
}
return TimeSpan.Zero;
}
}
}
@ -474,40 +474,40 @@ namespace Server.Items
switch (step)
{
case 0:
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 1:
{
EffectItem hole = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(10.0));
hole.ItemID = 0x913;
{
EffectItem hole = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(10.0));
hole.ItemID = 0x913;
Effects.PlaySound(Location, Map, 0x222);
Effects.PlaySound(Location, Map, 0x222);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 2:
{
Effects.PlaySound(Location, Map, 0x21F);
{
Effects.PlaySound(Location, Map, 0x21F);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
default:
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* A magical bunny leaps out of its hole, disturbed by the thorn's effect! *");
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* A magical bunny leaps out of its hole, disturbed by the thorn's effect! *");
BaseCreature spawn = new VorpalBunny();
if (!SpawnCreature(spawn))
spawn.Delete();
BaseCreature spawn = new VorpalBunny();
if (!SpawnCreature(spawn))
spawn.Delete();
return TimeSpan.Zero;
}
return TimeSpan.Zero;
}
}
}
}
@ -523,38 +523,38 @@ namespace Server.Items
switch (step)
{
case 0:
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 1:
{
Effects.PlaySound(Location, Map, 0x222);
{
Effects.PlaySound(Location, Map, 0x222);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 2:
{
Effects.PlaySound(Location, Map, 0x21F);
{
Effects.PlaySound(Location, Map, 0x21F);
return TimeSpan.FromSeconds(1.0);
}
return TimeSpan.FromSeconds(1.0);
}
default:
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* Strange green tendrils rise from the ground, whipping wildly! *");
Effects.PlaySound(Location, Map, 0x2B0);
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* Strange green tendrils rise from the ground, whipping wildly! *");
Effects.PlaySound(Location, Map, 0x2B0);
BaseCreature spawn = new WhippingVine();
if (!SpawnCreature(spawn))
spawn.Delete();
BaseCreature spawn = new WhippingVine();
if (!SpawnCreature(spawn))
spawn.Delete();
return TimeSpan.Zero;
}
return TimeSpan.Zero;
}
}
}
}
@ -570,44 +570,44 @@ namespace Server.Items
switch (step)
{
case 0:
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
return TimeSpan.FromSeconds(4.0);
}
case 1:
{
Effects.PlaySound(Location, Map, 0x222);
return TimeSpan.FromSeconds(4.0);
}
case 2:
{
Effects.PlaySound(Location, Map, 0x21F);
return TimeSpan.FromSeconds(4.0);
}
default:
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* Slithering ice serpents rise to the surface to investigate the disturbance! *");
BaseCreature spawn = new GiantIceWorm();
if (!SpawnCreature(spawn))
spawn.Delete();
for (int i = 0; i < 3; i++)
{
BaseCreature snake = new IceSnake();
if (!SpawnCreature(snake))
snake.Delete();
}
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
return TimeSpan.Zero;
}
return TimeSpan.FromSeconds(4.0);
}
case 1:
{
Effects.PlaySound(Location, Map, 0x222);
return TimeSpan.FromSeconds(4.0);
}
case 2:
{
Effects.PlaySound(Location, Map, 0x21F);
return TimeSpan.FromSeconds(4.0);
}
default:
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* Slithering ice serpents rise to the surface to investigate the disturbance! *");
BaseCreature spawn = new GiantIceWorm();
if (!SpawnCreature(spawn))
spawn.Delete();
for (int i = 0; i < 3; i++)
{
BaseCreature snake = new IceSnake();
if (!SpawnCreature(snake))
snake.Delete();
}
return TimeSpan.Zero;
}
}
}
}
@ -623,35 +623,35 @@ namespace Server.Items
switch (step)
{
case 0:
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
{
Effects.PlaySound(Location, Map, 0x106);
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1,
182, 0xBE3);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 1:
{
Effects.PlaySound(Location, Map, 0x222);
{
Effects.PlaySound(Location, Map, 0x222);
return TimeSpan.FromSeconds(4.0);
}
return TimeSpan.FromSeconds(4.0);
}
case 2:
{
Effects.PlaySound(Location, Map, 0x21F);
{
Effects.PlaySound(Location, Map, 0x21F);
return TimeSpan.FromSeconds(5.0);
}
return TimeSpan.FromSeconds(5.0);
}
default:
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* The sand collapses, revealing a dark hole. *");
{
EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0));
dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true,
"* The sand collapses, revealing a dark hole. *");
GreenThornsSHTeleporter.Create(Location, Map);
GreenThornsSHTeleporter.Create(Location, Map);
return TimeSpan.Zero;
}
return TimeSpan.Zero;
}
}
}
}
@ -713,7 +713,7 @@ namespace Server.Items
private class InternalTimer : Timer
{
private GreenThornsSHTeleporter m_Teleporter;
private readonly GreenThornsSHTeleporter m_Teleporter;
public InternalTimer(GreenThornsSHTeleporter teleporter) : base(TimeSpan.FromMinutes(1.0))
{

View file

@ -6,7 +6,7 @@ namespace Server.Items
{
public class OrangePetals : Item
{
private static Dictionary<Mobile, OrangePetalsContext> m_Table = new Dictionary<Mobile, OrangePetalsContext>();
private static readonly Dictionary<Mobile, OrangePetalsContext> m_Table = new Dictionary<Mobile, OrangePetalsContext>();
[Constructible]
public OrangePetals(int amount = 1) : base(0x1021)
@ -103,7 +103,7 @@ namespace Server.Items
private class OrangePetalsTimer : Timer
{
private Mobile m_Mobile;
private readonly Mobile m_Mobile;
public OrangePetalsTimer(Mobile from) : base(TimeSpan.FromMinutes(5.0)) => m_Mobile = from;
@ -121,7 +121,7 @@ namespace Server.Items
{
public OrangePetalsContext(Timer timer) => Timer = timer;
public Timer Timer{ get; }
public Timer Timer { get; }
}
}
}

View file

@ -48,7 +48,7 @@ namespace Server.Items
private class InternalTarget : Target
{
private RedLeaves m_RedLeaves;
private readonly RedLeaves m_RedLeaves;
public InternalTarget(RedLeaves redLeaves) : base(3, false, TargetFlags.None) => m_RedLeaves = redLeaves;

View file

@ -6,10 +6,10 @@ namespace Server.Network
{
EnsureCapacity(11);
m_Stream.Write((short)0x17);
m_Stream.Write((byte)1);
m_Stream.Write(topicID);
m_Stream.Write(display);
Stream.Write((short)0x17);
Stream.Write((byte)1);
Stream.Write(topicID);
Stream.Write(display);
}
}
}

View file

@ -6,7 +6,7 @@ namespace Server.Engines.Plants
{
public class PlantBowl : Item
{
private static int[] m_DirtPatchTiles =
private static readonly int[] m_DirtPatchTiles =
{
0x9, 0x15,
0x71, 0x7C,
@ -105,7 +105,7 @@ namespace Server.Engines.Plants
private class InternalTarget : Target
{
private PlantBowl m_PlantBowl;
private readonly PlantBowl m_PlantBowl;
public InternalTarget(PlantBowl plantBowl) : base(3, true, TargetFlags.None) => m_PlantBowl = plantBowl;

View file

@ -39,7 +39,7 @@ namespace Server.Engines.Plants
public class PlantHueInfo
{
private static Dictionary<PlantHue, PlantHueInfo> m_Table;
private static readonly Dictionary<PlantHue, PlantHueInfo> m_Table;
static PlantHueInfo() =>
m_Table = new Dictionary<PlantHue, PlantHueInfo>
@ -77,13 +77,13 @@ namespace Server.Engines.Plants
GumpHue = gumpHue;
}
public int Hue{ get; }
public int Hue { get; }
public int Name{ get; }
public int Name { get; }
public PlantHue PlantHue{ get; }
public PlantHue PlantHue { get; }
public int GumpHue{ get; }
public int GumpHue { get; }
public static PlantHueInfo GetInfo(PlantHue plantHue) => m_Table.TryGetValue(plantHue, out PlantHueInfo info) ? info : m_Table[PlantHue.Plain];

View file

@ -57,7 +57,7 @@ namespace Server.Engines.Plants
{
}
public PlantSystem PlantSystem{ get; private set; }
public PlantSystem PlantSystem { get; private set; }
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
@ -139,7 +139,6 @@ namespace Server.Engines.Plants
if (IsLockedDown && RootParent == null)
return true;
if (!(RootParent is Mobile owner))
return false;
@ -156,10 +155,10 @@ namespace Server.Engines.Plants
[CommandProperty(AccessLevel.GameMaster)]
public bool Reproduces => PlantHueInfo.CanReproduce(PlantHue) && PlantTypeInfo.CanReproduce(PlantType);
public static List<PlantItem> Plants{ get; } = new List<PlantItem>();
public static List<PlantItem> Plants { get; } = new List<PlantItem>();
[CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level{ get; set; }
public SecureLevel Level { get; set; }
public override void OnSingleClick(Mobile from)
{
@ -281,8 +280,8 @@ namespace Server.Engines.Plants
}
public bool IsUsableBy(Mobile from) =>
IsChildOf(from.Backpack) || IsChildOf(from.FindBankNoCreate()) || IsLockedDown && IsAccessibleTo(from) ||
RootParent is Item root && root.IsSecure && root.IsAccessibleTo(from);
IsChildOf(from.Backpack) || IsChildOf(from.FindBankNoCreate()) || (IsLockedDown && IsAccessibleTo(from)) ||
(RootParent is Item root && root.IsSecure && root.IsAccessibleTo(from));
public override void OnDoubleClick(Mobile from)
{
@ -515,28 +514,28 @@ namespace Server.Engines.Plants
{
case 2:
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
if (version < 1)
Level = SecureLevel.CoOwners;
{
if (version < 1)
Level = SecureLevel.CoOwners;
m_PlantStatus = (PlantStatus)reader.ReadInt();
m_PlantType = (PlantType)reader.ReadInt();
m_PlantHue = (PlantHue)reader.ReadInt();
m_ShowType = reader.ReadBool();
m_PlantStatus = (PlantStatus)reader.ReadInt();
m_PlantType = (PlantType)reader.ReadInt();
m_PlantHue = (PlantHue)reader.ReadInt();
m_ShowType = reader.ReadBool();
if (m_PlantStatus < PlantStatus.DecorativePlant)
PlantSystem = new PlantSystem(this, reader);
if (m_PlantStatus < PlantStatus.DecorativePlant)
PlantSystem = new PlantSystem(this, reader);
if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue))
m_PlantHue |= PlantHue.Reproduces;
if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue))
m_PlantHue |= PlantHue.Reproduces;
break;
}
break;
}
}
Plants.Add(this);

View file

@ -4,7 +4,7 @@ namespace Server.Engines.Plants
{
public class PlantPourTarget : Target
{
private PlantItem m_Plant;
private readonly PlantItem m_Plant;
public PlantPourTarget(PlantItem plant) : base(3, true, TargetFlags.None) => m_Plant = plant;

View file

@ -6,7 +6,7 @@ namespace Server.Engines.Plants
{
public class PlantResourceInfo
{
private static PlantResourceInfo[] m_ResourceList =
private static readonly PlantResourceInfo[] m_ResourceList =
{
new PlantResourceInfo(PlantType.ElephantEarPlant, PlantHue.BrightRed, typeof(RedLeaves)),
new PlantResourceInfo(PlantType.PonytailPalm, PlantHue.BrightRed, typeof(RedLeaves)),
@ -26,11 +26,11 @@ namespace Server.Engines.Plants
ResourceType = resourceType;
}
public PlantType PlantType{ get; }
public PlantType PlantType { get; }
public PlantHue PlantHue{ get; }
public PlantHue PlantHue { get; }
public Type ResourceType{ get; }
public Type ResourceType { get; }
public static PlantResourceInfo GetInfo(PlantType plantType, PlantHue plantHue)
{

View file

@ -98,13 +98,13 @@ namespace Server.Engines.Plants
m_SeedHue |= PlantHue.Reproduces;
}
public PlantItem Plant{ get; }
public PlantItem Plant { get; }
public bool FertileDirt{ get; set; }
public bool FertileDirt { get; set; }
public DateTime NextGrowth{ get; private set; }
public DateTime NextGrowth { get; private set; }
public PlantGrowthIndicator GrowthIndicator{ get; private set; }
public PlantGrowthIndicator GrowthIndicator { get; private set; }
public bool IsFullWater => m_Water >= 4;
@ -288,7 +288,7 @@ namespace Server.Engines.Plants
public bool PollenProducing => Plant.IsCrossable && Plant.PlantStatus >= PlantStatus.FullGrownPlant;
public bool Pollinated{ get; set; }
public bool Pollinated { get; set; }
public PlantType SeedType
{
@ -624,7 +624,6 @@ namespace Server.Engines.Plants
if (Utility.RandomDouble() < infestationChance)
Infestation++;
double fungusChance = 0.15 - StrengthPotion * 0.075 + (Water - 2) * 0.10;
if (Utility.RandomDouble() < fungusChance)

View file

@ -61,7 +61,7 @@ namespace Server.Engines.Plants
public class PlantTypeInfo
{
private static PlantTypeInfo[] m_Table =
private static readonly PlantTypeInfo[] m_Table =
{
new PlantTypeInfo(0xC83, 0, 0, PlantType.CampionFlowers, false, true, true, true, PlantCategory.Default),
new PlantTypeInfo(0xC86, 0, 0, PlantType.Poppies, false, true, true, true, PlantCategory.Default),
@ -115,14 +115,14 @@ namespace Server.Engines.Plants
1080536, 1080536, 1080534, 1080531, 1080533, 1113716)
};
private int m_PlantLabelDecorative;
private int m_PlantLabelFullGrown;
private int m_PlantLabelPlant;
private readonly int m_PlantLabelDecorative;
private readonly int m_PlantLabelFullGrown;
private readonly int m_PlantLabelPlant;
// Cliloc overrides
private int m_PlantLabelSeed;
private int m_SeedLabel;
private int m_SeedLabelPlural;
private readonly int m_PlantLabelSeed;
private readonly int m_SeedLabel;
private readonly int m_SeedLabelPlural;
private PlantTypeInfo(int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery,
bool crossable, bool reproduces, PlantCategory plantCategory, int plantLabelSeed = -1, int plantLabelPlant = -1,
@ -145,25 +145,25 @@ namespace Server.Engines.Plants
m_SeedLabelPlural = seedLabelPlural;
}
public int ItemID{ get; }
public int ItemID { get; }
public int OffsetX{ get; }
public int OffsetX { get; }
public int OffsetY{ get; }
public int OffsetY { get; }
public PlantType PlantType{ get; }
public PlantType PlantType { get; }
public PlantCategory PlantCategory{ get; }
public PlantCategory PlantCategory { get; }
public int Name => ItemID < 0x4000 ? 1020000 + ItemID : 1078872 + ItemID;
public bool ContainsPlant{ get; }
public bool ContainsPlant { get; }
public bool Flowery{ get; }
public bool Flowery { get; }
public bool Crossable{ get; }
public bool Crossable { get; }
public bool Reproduces{ get; }
public bool Reproduces { get; }
public static PlantTypeInfo GetInfo(PlantType plantType)
{

View file

@ -4,7 +4,7 @@ namespace Server.Engines.Plants
{
public class PollinateTarget : Target
{
private PlantItem m_Plant;
private readonly PlantItem m_Plant;
public PollinateTarget(PlantItem plant) : base(3, true, TargetFlags.None) => m_Plant = plant;

View file

@ -5,7 +5,7 @@ namespace Server.Engines.Plants
{
public class ReproductionGump : Gump
{
private PlantItem m_Plant;
private readonly PlantItem m_Plant;
public ReproductionGump(PlantItem plant) : base(20, 20)
{
@ -125,138 +125,138 @@ namespace Server.Engines.Plants
switch (info.ButtonID)
{
case 1: // Main menu
{
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 2: // Set to decorative
{
if (m_Plant.PlantStatus == PlantStatus.Stage9) from.SendGump(new SetToDecorativeGump(m_Plant));
break;
}
case 3: // Pollination
{
from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 4: // Resources
{
from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 5: // Seeds
{
from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 6: // Gather pollen
{
if (!m_Plant.IsCrossable)
{
m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant!
}
else if (!m_Plant.PlantSystem.PollenProducing)
{
m_Plant.LabelTo(from,
1053051); // You cannot gather pollen from a plant in this stage of development!
}
else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy)
{
m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant!
}
else
{
from.Target = new PollinateTarget(m_Plant);
from.SendLocalizedMessage(1053054); // Target the plant you wish to cross-pollinate to.
from.SendGump(new MainPlantGump(m_Plant));
break;
}
case 2: // Set to decorative
{
if (m_Plant.PlantStatus == PlantStatus.Stage9) from.SendGump(new SetToDecorativeGump(m_Plant));
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 3: // Pollination
{
from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE
break;
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 4: // Resources
{
from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 5: // Seeds
{
from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 6: // Gather pollen
{
if (!m_Plant.IsCrossable)
{
m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant!
}
else if (!m_Plant.PlantSystem.PollenProducing)
{
m_Plant.LabelTo(from,
1053051); // You cannot gather pollen from a plant in this stage of development!
}
else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy)
{
m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant!
}
else
{
from.Target = new PollinateTarget(m_Plant);
from.SendLocalizedMessage(1053054); // Target the plant you wish to cross-pollinate to.
break;
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 7: // Gather resources
{
PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);
PlantSystem system = m_Plant.PlantSystem;
if (resInfo == null)
{
if (m_Plant.IsCrossable)
PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);
PlantSystem system = m_Plant.PlantSystem;
if (resInfo == null)
{
if (m_Plant.IsCrossable)
m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather!
else
m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources!
}
else if (system.AvailableResources == 0)
{
m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather!
else
m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources!
}
else if (system.AvailableResources == 0)
{
m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather!
}
else
{
Item resource = resInfo.CreateResource();
if (from.PlaceInBackpack(resource))
{
system.AvailableResources--;
m_Plant.LabelTo(from, 1053059); // You gather resources from the plant.
}
else
{
resource.Delete();
m_Plant.LabelTo(from,
1053058); // You attempt to gather as many resources as you can hold, but your backpack is full.
Item resource = resInfo.CreateResource();
if (from.PlaceInBackpack(resource))
{
system.AvailableResources--;
m_Plant.LabelTo(from, 1053059); // You gather resources from the plant.
}
else
{
resource.Delete();
m_Plant.LabelTo(from,
1053058); // You attempt to gather as many resources as you can hold, but your backpack is full.
}
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
case 8: // Gather seeds
{
PlantSystem system = m_Plant.PlantSystem;
{
PlantSystem system = m_Plant.PlantSystem;
if (!m_Plant.Reproduces)
{
m_Plant.LabelTo(from, 1053060); // Mutated plants do not produce seeds!
}
else if (system.AvailableSeeds == 0)
{
m_Plant.LabelTo(from, 1053061); // This plant has no seeds to gather!
}
else
{
Seed seed = new Seed(system.SeedType, system.SeedHue, true);
if (from.PlaceInBackpack(seed))
if (!m_Plant.Reproduces)
{
system.AvailableSeeds--;
m_Plant.LabelTo(from, 1053063); // You gather seeds from the plant.
m_Plant.LabelTo(from, 1053060); // Mutated plants do not produce seeds!
}
else if (system.AvailableSeeds == 0)
{
m_Plant.LabelTo(from, 1053061); // This plant has no seeds to gather!
}
else
{
seed.Delete();
m_Plant.LabelTo(from,
1053062); // You attempt to gather as many seeds as you can hold, but your backpack is full.
Seed seed = new Seed(system.SeedType, system.SeedHue, true);
if (from.PlaceInBackpack(seed))
{
system.AvailableSeeds--;
m_Plant.LabelTo(from, 1053063); // You gather seeds from the plant.
}
else
{
seed.Delete();
m_Plant.LabelTo(from,
1053062); // You attempt to gather as many seeds as you can hold, but your backpack is full.
}
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
from.SendGump(new ReproductionGump(m_Plant));
break;
}
}
}
}

View file

@ -186,7 +186,7 @@ namespace Server.Engines.Plants
private class InternalTarget : Target
{
private Seed m_Seed;
private readonly Seed m_Seed;
public InternalTarget(Seed seed) : base(-1, false, TargetFlags.None)
{

View file

@ -5,7 +5,7 @@ namespace Server.Engines.Plants
{
public class SetToDecorativeGump : Gump
{
private PlantItem m_Plant;
private readonly PlantItem m_Plant;
public SetToDecorativeGump(PlantItem plant) : base(20, 20)
{
@ -57,27 +57,27 @@ namespace Server.Engines.Plants
switch (info.ButtonID)
{
case 1: // Cancel
{
from.SendGump(new ReproductionGump(m_Plant));
{
from.SendGump(new ReproductionGump(m_Plant));
break;
}
break;
}
case 2: // Help
{
from.Send(new DisplayHelpTopic(70, true)); // DECORATIVE MODE
{
from.Send(new DisplayHelpTopic(70, true)); // DECORATIVE MODE
from.SendGump(new SetToDecorativeGump(m_Plant));
from.SendGump(new SetToDecorativeGump(m_Plant));
break;
}
break;
}
case 3: // Ok
{
m_Plant.PlantStatus = PlantStatus.DecorativePlant;
m_Plant.LabelTo(from,
1053077); // You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep.
{
m_Plant.PlantStatus = PlantStatus.DecorativePlant;
m_Plant.LabelTo(from,
1053077); // You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep.
break;
}
break;
}
}
}
}