C# 9 Cleanup (#325)

- [X] Removes EventArgs - not needed
- [X] Merges sequential checks
- [X] Removes redundant type declarations
This commit is contained in:
Kamron Batman 2020-11-27 00:29:21 -08:00 committed by GitHub
parent 351611a23a
commit 3551d962f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
417 changed files with 2209 additions and 2213 deletions

View file

@ -16,7 +16,7 @@ namespace Server.Items
{
public static readonly int SecureRange = 7;
private static readonly Dictionary<Mobile, CampfireEntry> m_Table = new Dictionary<Mobile, CampfireEntry>();
private static readonly Dictionary<Mobile, CampfireEntry> m_Table = new();
private readonly List<CampfireEntry> m_Entries;

View file

@ -10,13 +10,13 @@ namespace Server.Items
{
private static readonly TrophyInfo[] m_Table =
{
new TrophyInfo(typeof(BrownBear), 0x1E60, 1041093, 1041107),
new TrophyInfo(typeof(GreatHart), 0x1E61, 1041095, 1041109),
new TrophyInfo(typeof(BigFish), 0x1E62, 1041096, 1041110),
new TrophyInfo(typeof(Gorilla), 0x1E63, 1041091, 1041105),
new TrophyInfo(typeof(Orc), 0x1E64, 1041090, 1041104),
new TrophyInfo(typeof(PolarBear), 0x1E65, 1041094, 1041108),
new TrophyInfo(typeof(Troll), 0x1E66, 1041092, 1041106)
new(typeof(BrownBear), 0x1E60, 1041093, 1041107),
new(typeof(GreatHart), 0x1E61, 1041095, 1041109),
new(typeof(BigFish), 0x1E62, 1041096, 1041110),
new(typeof(Gorilla), 0x1E63, 1041091, 1041105),
new(typeof(Orc), 0x1E64, 1041090, 1041104),
new(typeof(PolarBear), 0x1E65, 1041094, 1041108),
new(typeof(Troll), 0x1E66, 1041092, 1041106)
};
[Constructible]

View file

@ -12,12 +12,12 @@ namespace Server.Items
0x0136, 0x0137
};
private static readonly Rectangle2D[] m_BritRegions = { new Rectangle2D(0, 0, 5120, 4096) };
private static readonly Rectangle2D[] m_BritRegions = { new(0, 0, 5120, 4096) };
private static readonly Rectangle2D[] m_IlshRegions =
{ new Rectangle2D(1472, 272, 304, 240), new Rectangle2D(1240, 1000, 312, 160) };
{ new(1472, 272, 304, 240), new(1240, 1000, 312, 160) };
private static readonly Rectangle2D[] m_MalasRegions = { new Rectangle2D(1376, 1520, 464, 280) };
private static readonly Rectangle2D[] m_MalasRegions = { new(1376, 1520, 464, 280) };
private int m_Level;
@ -331,62 +331,62 @@ namespace Server.Items
public static MessageEntry[] Entries { get; } =
{
new MessageEntry(
new(
280,
180,
"...Ar! {0} and a fair wind! No chance... storms, though--ar! Is that a sea serp...<br><br>uh oh."
),
new MessageEntry(
new(
280,
215,
"...been inside this whale for three days now. I've run out of food I can pick out of his teeth. I took a sextant reading through the blowhole: {0}. I'll never see my treasure again..."
),
new MessageEntry(
new(
280,
285,
"...grand adventure! Captain Quacklebush had me swab down the decks daily...<br> ...pirates came, I was in the rigging practicing with my sextant. {0} if I am not mistaken...<br> ....scuttled the ship, and our precious cargo went with her and the screaming pirates, down to the bottom of the sea..."
),
new MessageEntry(
new(
280,
180,
"Help! Ship going dow...n heavy storms...precious cargo...st reach dest...current coordinates {0}...ve any survivors... ease!"
),
new MessageEntry(
new(
280,
215,
"...know that the wreck is near {0} but have not found it. Could the message passed down in my family for generations be wrong? No... I swear on the soul of my grandfather, I will find..."
),
new MessageEntry(
new(
280,
195,
"...never expected an iceberg...silly woman on bow crushed instantly...send help to {0}...ey'll never forget the tragedy of the sinking of the Miniscule..."
),
new MessageEntry(
new(
280,
265,
"...nobody knew I was a girl. They just assumed I was another sailor...then we met the undine. {0}. It was demanded sacrifice...I was youngset, they figured...<br> ...grabbed the captain's treasure, screamed, 'It'll go down with me!'<br> ...they took me up on it."
),
new MessageEntry(
new(
280,
230,
"...so I threw the treasure overboard, before the curse could get me too. But I was too late. Now I am doomed to wander these seas, a ghost forever. Join me: seek ye at {0} if thou wishest my company..."
),
new MessageEntry(
new(
280,
285,
"...then the ship exploded. A dragon swooped by. The slime swallowed Bertie whole--he screamed, it was amazing. The sky glowed orange. A sextant reading put us at {0}. Norma was chattering about sailing over the edge of the world. I looked at my hands and saw through them..."
),
new MessageEntry(
new(
280,
285,
"...trapped on a deserted island, with a magic fountain supplying wood, fresh water springs, gorgeous scenery, and my lovely young wife. I know the ship with all our life's earnings sank at {0} but I don't know what our coordinates are... someone has GOT to rescue me before Sunday's finals game or I'll go mad..."
),
new MessageEntry(
new(
280,
160,
"WANTED: divers exp...d in shipwre...overy. Must have own vess...pply at {0}<br>...good benefits, flexible hours..."
),
new MessageEntry(
new(
280,
250,
"...was a cad and a boor, no matter what momma s...rew him overboard! Oh, Anna, 'twas so exciting!<br> Unfort...y he grabbe...est, and all his riches went with him!<br> ...sked the captain, and he says we're at {0}<br>...so maybe..."

View file

@ -7,8 +7,8 @@ namespace Server.Items
{
public abstract class BaseConflagrationPotion : BasePotion
{
private static readonly Dictionary<Mobile, Timer> m_Delay = new Dictionary<Mobile, Timer>();
private readonly List<Mobile> m_Users = new List<Mobile>();
private static readonly Dictionary<Mobile, Timer> m_Delay = new();
private readonly List<Mobile> m_Users = new();
public BaseConflagrationPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x489;

View file

@ -9,8 +9,8 @@ namespace Server.Items
{
public abstract class BaseConfusionBlastPotion : BasePotion
{
private static readonly Dictionary<Mobile, Timer> m_Delay = new Dictionary<Mobile, Timer>();
private readonly List<Mobile> m_Users = new List<Mobile>();
private static readonly Dictionary<Mobile, Timer> m_Delay = new();
private readonly List<Mobile> m_Users = new();
public BaseConfusionBlastPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x48D;

View file

@ -4,19 +4,19 @@ namespace Server.Items
{
private static readonly CureLevelInfo[] m_OldLevelInfo =
{
new CureLevelInfo(Poison.Lesser, 1.00), // 100% chance to cure lesser poison
new CureLevelInfo(Poison.Regular, 0.75), // 75% chance to cure regular poison
new CureLevelInfo(Poison.Greater, 0.50), // 50% chance to cure greater poison
new CureLevelInfo(Poison.Deadly, 0.15) // 15% chance to cure deadly poison
new(Poison.Lesser, 1.00), // 100% chance to cure lesser poison
new(Poison.Regular, 0.75), // 75% chance to cure regular poison
new(Poison.Greater, 0.50), // 50% chance to cure greater poison
new(Poison.Deadly, 0.15) // 15% chance to cure deadly poison
};
private static readonly CureLevelInfo[] m_AosLevelInfo =
{
new CureLevelInfo(Poison.Lesser, 1.00),
new CureLevelInfo(Poison.Regular, 0.95),
new CureLevelInfo(Poison.Greater, 0.75),
new CureLevelInfo(Poison.Deadly, 0.50),
new CureLevelInfo(Poison.Lethal, 0.25)
new(Poison.Lesser, 1.00),
new(Poison.Regular, 0.95),
new(Poison.Greater, 0.75),
new(Poison.Deadly, 0.50),
new(Poison.Lethal, 0.25)
};
[Constructible]

View file

@ -4,20 +4,20 @@ namespace Server.Items
{
private static readonly CureLevelInfo[] m_OldLevelInfo =
{
new CureLevelInfo(Poison.Lesser, 1.00), // 100% chance to cure lesser poison
new CureLevelInfo(Poison.Regular, 1.00), // 100% chance to cure regular poison
new CureLevelInfo(Poison.Greater, 1.00), // 100% chance to cure greater poison
new CureLevelInfo(Poison.Deadly, 0.75), // 75% chance to cure deadly poison
new CureLevelInfo(Poison.Lethal, 0.25) // 25% chance to cure lethal poison
new(Poison.Lesser, 1.00), // 100% chance to cure lesser poison
new(Poison.Regular, 1.00), // 100% chance to cure regular poison
new(Poison.Greater, 1.00), // 100% chance to cure greater poison
new(Poison.Deadly, 0.75), // 75% chance to cure deadly poison
new(Poison.Lethal, 0.25) // 25% chance to cure lethal poison
};
private static readonly CureLevelInfo[] m_AosLevelInfo =
{
new CureLevelInfo(Poison.Lesser, 1.00),
new CureLevelInfo(Poison.Regular, 1.00),
new CureLevelInfo(Poison.Greater, 1.00),
new CureLevelInfo(Poison.Deadly, 0.95),
new CureLevelInfo(Poison.Lethal, 0.75)
new(Poison.Lesser, 1.00),
new(Poison.Regular, 1.00),
new(Poison.Greater, 1.00),
new(Poison.Deadly, 0.95),
new(Poison.Lethal, 0.75)
};
[Constructible]

View file

@ -4,16 +4,16 @@ namespace Server.Items
{
private static readonly CureLevelInfo[] m_OldLevelInfo =
{
new CureLevelInfo(Poison.Lesser, 0.75), // 75% chance to cure lesser poison
new CureLevelInfo(Poison.Regular, 0.50), // 50% chance to cure regular poison
new CureLevelInfo(Poison.Greater, 0.15) // 15% chance to cure greater poison
new(Poison.Lesser, 0.75), // 75% chance to cure lesser poison
new(Poison.Regular, 0.50), // 50% chance to cure regular poison
new(Poison.Greater, 0.15) // 15% chance to cure greater poison
};
private static readonly CureLevelInfo[] m_AosLevelInfo =
{
new CureLevelInfo(Poison.Lesser, 0.75),
new CureLevelInfo(Poison.Regular, 0.50),
new CureLevelInfo(Poison.Greater, 0.25)
new(Poison.Lesser, 0.75),
new(Poison.Regular, 0.50),
new(Poison.Greater, 0.25)
};
[Constructible]

View file

@ -191,7 +191,7 @@ namespace Server.Items
Consume();
for (var i = 0; Users != null && i < Users.Count; ++i)
for (var i = 0; i < Users?.Count; ++i)
{
var m = Users[i];

View file

@ -5,7 +5,7 @@ namespace Server.Items
{
public class InvisibilityPotion : BasePotion
{
private static readonly Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
private static readonly Dictionary<Mobile, Timer> m_Table = new();
[Constructible]
public InvisibilityPotion() : base(0xF0A, PotionEffect.Invisibility) => Hue = 0x48D;

View file

@ -87,7 +87,7 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public int MaxCharges { get; set; }
public List<Mobile> Openers { get; set; } = new List<Mobile>();
public List<Mobile> Openers { get; set; } = new();
public override int LabelNumber => 1041267; // runebook

View file

@ -30,7 +30,7 @@ namespace Server.Items
public class Spellbook : Item, ICraftable, ISlayer
{
private static readonly Dictionary<Mobile, List<Spellbook>> m_Table = new Dictionary<Mobile, List<Spellbook>>();
private static readonly Dictionary<Mobile, List<Spellbook>> m_Table = new();
private static readonly int[] m_LegendPropertyCounts =
{

View file

@ -157,7 +157,7 @@ namespace Server.Items
public class BandageContext
{
private static readonly Dictionary<Mobile, BandageContext> m_Table = new Dictionary<Mobile, BandageContext>();
private static readonly Dictionary<Mobile, BandageContext> m_Table = new();
public BandageContext(Mobile healer, Mobile patient, TimeSpan delay)
{
@ -295,7 +295,7 @@ namespace Server.Items
var friends = petPatient.Friends;
for (var i = 0; friends != null && i < friends.Count; ++i)
for (var i = 0; i < friends?.Count; ++i)
{
var friend = friends[i];

View file

@ -253,11 +253,11 @@ namespace Server.Items
public static RepairSkillInfo[] Table { get; } =
{
new RepairSkillInfo(DefBlacksmithy.CraftSystem, typeof(Blacksmith), 1047013, 1023015),
new RepairSkillInfo(DefTailoring.CraftSystem, typeof(Tailor), 1061132, 1022981),
new RepairSkillInfo(DefTinkering.CraftSystem, typeof(Tinker), 1061166, 1022983),
new RepairSkillInfo(DefCarpentry.CraftSystem, typeof(Carpenter), 1061135, 1060774),
new RepairSkillInfo(DefBowFletching.CraftSystem, typeof(Bowyer), 1061134, 1023005)
new(DefBlacksmithy.CraftSystem, typeof(Blacksmith), 1047013, 1023015),
new(DefTailoring.CraftSystem, typeof(Tailor), 1061132, 1022981),
new(DefTinkering.CraftSystem, typeof(Tinker), 1061166, 1022983),
new(DefCarpentry.CraftSystem, typeof(Carpenter), 1061135, 1060774),
new(DefBowFletching.CraftSystem, typeof(Bowyer), 1061134, 1023005)
};
public static RepairSkillInfo GetInfo(RepairSkillType type)

View file

@ -18,7 +18,7 @@ namespace Server.Items
public abstract class BaseInstrument : Item, ICraftable, ISlayer
{
private static readonly Dictionary<Mobile, BaseInstrument> m_Instruments = new Dictionary<Mobile, BaseInstrument>();
private static readonly Dictionary<Mobile, BaseInstrument> m_Instruments = new();
private Mobile m_Crafter;
private DateTime m_LastReplenished;

View file

@ -26,7 +26,7 @@ namespace Server.Items
public class CustomHuePicker
{
public static readonly CustomHuePicker SpecialDyeTub = new CustomHuePicker(
public static readonly CustomHuePicker SpecialDyeTub = new(
new[]
{
/* Violet */
@ -50,7 +50,7 @@ namespace Server.Items
1018344
);
public static readonly CustomHuePicker LeatherDyeTub = new CustomHuePicker(
public static readonly CustomHuePicker LeatherDyeTub = new(
new[]
{
/* Dull Copper */

View file

@ -44,7 +44,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(1042001);
}
else if (pm == null || pm.NpcGuild != NpcGuild.ThievesGuild)
else if (pm?.NpcGuild != NpcGuild.ThievesGuild)
{
from.SendLocalizedMessage(501702);
}
@ -93,28 +93,28 @@ namespace Server.Items
{
private static readonly DisguiseEntry[] m_HairEntries =
{
new DisguiseEntry(8251, 50700, 0, 5, 1011052), // Short
new DisguiseEntry(8261, 60710, 0, 3, 1011047), // Pageboy
new DisguiseEntry(8252, 60708, 0, -5, 1011053), // Long
new DisguiseEntry(8264, 60901, 0, 5, 1011048), // Receding
new DisguiseEntry(8253, 60702, 0, -5, 1011054), // Ponytail
new DisguiseEntry(8265, 60707, 0, -5, 1011049), // 2-tails
new DisguiseEntry(8260, 50703, 0, 5, 1011055), // Mohawk
new DisguiseEntry(8266, 60713, 0, 10, 1011050), // Topknot
new(8251, 50700, 0, 5, 1011052), // Short
new(8261, 60710, 0, 3, 1011047), // Pageboy
new(8252, 60708, 0, -5, 1011053), // Long
new(8264, 60901, 0, 5, 1011048), // Receding
new(8253, 60702, 0, -5, 1011054), // Ponytail
new(8265, 60707, 0, -5, 1011049), // 2-tails
new(8260, 50703, 0, 5, 1011055), // Mohawk
new(8266, 60713, 0, 10, 1011050), // Topknot
null,
new DisguiseEntry(0, 0, 0, 0, 1011051) // None
new(0, 0, 0, 0, 1011051) // None
};
private static readonly DisguiseEntry[] m_BeardEntries =
{
new DisguiseEntry(8269, 50906, 0, 0, 1011401), // Vandyke
new DisguiseEntry(8257, 50808, 0, -2, 1011062), // Mustache
new DisguiseEntry(8255, 50802, 0, 0, 1011060), // Short beard
new DisguiseEntry(8268, 50905, 0, -10, 1011061), // Long beard
new DisguiseEntry(8267, 50904, 0, 0, 1011060), // Short beard
new DisguiseEntry(8254, 50801, 0, -10, 1011061), // Long beard
new(8269, 50906, 0, 0, 1011401), // Vandyke
new(8257, 50808, 0, -2, 1011062), // Mustache
new(8255, 50802, 0, 0, 1011060), // Short beard
new(8268, 50905, 0, -10, 1011061), // Long beard
new(8267, 50904, 0, 0, 1011060), // Short beard
new(8254, 50801, 0, -10, 1011061), // Long beard
null,
new DisguiseEntry(0, 0, 0, 0, 1011051) // None
new(0, 0, 0, 0, 1011051) // None
};
private readonly Mobile m_From;
@ -285,7 +285,7 @@ namespace Server.Items
public static class DisguiseTimers
{
public static Dictionary<Mobile, Timer> Timers { get; } = new Dictionary<Mobile, Timer>();
public static Dictionary<Mobile, Timer> Timers { get; } = new();
public static void Initialize()
{

View file

@ -20,7 +20,7 @@ namespace Server.Items
public const double SecondsPerUOMinute = 5.0;
public const double MinutesPerUODay = SecondsPerUOMinute * 24;
private static readonly DateTime WorldStart = new DateTime(1997, 9, 1);
private static readonly DateTime WorldStart = new(1997, 9, 1);
[Constructible]
public Clock(int itemID = 0x104B) : base(itemID) => Weight = 3.0;

View file

@ -51,7 +51,7 @@ namespace Server.Items
SkillName.MagicResist
};
private static readonly BitArray m_Props = new BitArray(MaxProperties);
private static readonly BitArray m_Props = new(MaxProperties);
private static readonly int[] m_Possible = new int[MaxProperties];
private CraftResource m_Resource;