diff --git a/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs b/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs index 2ca8fa0ae..fca83853d 100644 --- a/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs +++ b/Projects/UOContent/Engines/XMLSpawner/BaseXmlSpawner.cs @@ -1382,25 +1382,23 @@ public class BaseXmlSpawner // count nearby players if (refobject is Item item) { - foreach (Mobile p in item.GetMobilesInRange(range)) + foreach (var p in item.GetMobilesInRange(range)) { if (p.Player && p.AccessLevel == AccessLevel.Player) { nplayers++; } } - ie.Free(); } else if (refobject is Mobile mobile) { - foreach (Mobile p in mobile.GetMobilesInRange(range)) + foreach (var p in mobile.GetMobilesInRange(range)) { if (p.Player && p.AccessLevel == AccessLevel.Player) { nplayers++; } } - ie.Free(); } var result = SetPropertyValue(spawner, o, arglist[0], nplayers.ToString()); @@ -1664,7 +1662,7 @@ public class BaseXmlSpawner } else if (o is Item item) { - foreach (Mobile p in item.GetMobilesInRange(range)) + foreach (var p in item.GetMobilesInRange(range)) { if (p.Player && p.AccessLevel == AccessLevel.Player) { @@ -1674,7 +1672,7 @@ public class BaseXmlSpawner } else if (o is Mobile mobile) { - foreach (Mobile p in mobile.GetMobilesInRange(range)) + foreach (var p in mobile.GetMobilesInRange(range)) { if (p.Player && p.AccessLevel == AccessLevel.Player) { diff --git a/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs b/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs index 0ed76c387..802ed50cf 100644 --- a/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs +++ b/Projects/UOContent/Engines/XMLSpawner/ItemFlags.cs @@ -24,8 +24,8 @@ public partial class ItemFlags [Description("Gets the state of the specified SavedFlag on any item")] public static void GetFlag_OnCommand(CommandEventArgs e) { - int flag=0; - bool error = false; + var flag=0; + var error = false; if (e.Arguments.Length > 0) { if (e.Arguments[0].StartsWith("0x")) @@ -62,7 +62,7 @@ public partial class ItemFlags { if (targeted is Item item) { - bool state = item.GetSavedFlag(m_flag); + var state = item.GetSavedFlag(m_flag); from.SendMessage($"Flag (0x{m_flag:X}) = {state}"); } else @@ -77,8 +77,8 @@ public partial class ItemFlags [Description("Sets/gets the stealable flag on any item")] public static void SetStealable_OnCommand(CommandEventArgs e) { - bool state = false; - bool error = false; + var state = false; + var error = false; if (e.Arguments.Length > 0) { try @@ -121,7 +121,7 @@ public partial class ItemFlags SetStealable(item, m_state); } - bool state = GetStealable(item); + var state = GetStealable(item); from.SendMessage($"Stealable = {state}"); diff --git a/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs b/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs index d8df61e43..a99f9cb44 100644 --- a/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs +++ b/Projects/UOContent/Engines/XMLSpawner/SpawnerExporter.cs @@ -43,15 +43,15 @@ public class SpawnerExporter public override void ExecuteList(CommandEventArgs e, List list) { - string filename = e.GetString(0); + var filename = e.GetString(0); - ArrayList spawners = new ArrayList(); + var spawners = new ArrayList(); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { if (list[i] is Spawner) { - Spawner spawner = (Spawner)list[i]; + var spawner = (Spawner)list[i]; if (!spawner.Deleted && spawner.Map != Map.Internal && spawner.Parent == null) { spawners.Add(spawner); @@ -87,11 +87,11 @@ public class SpawnerExporter Directory.CreateDirectory("Saves/Spawners"); } - string filePath = Path.Combine("Saves/Spawners", filename); + var filePath = Path.Combine("Saves/Spawners", filename); - using (StreamWriter op = new StreamWriter(filePath)) + using (var op = new StreamWriter(filePath)) { - XmlTextWriter xml = new XmlTextWriter(op) + var xml = new XmlTextWriter(op) { Formatting = Formatting.Indented, IndentChar = '\t', @@ -180,15 +180,15 @@ public class SpawnerExporter { if (e.Arguments.Length >= 1) { - string filename = e.GetString(0); - string filePath = Path.Combine("Saves/Spawners", filename); + var filename = e.GetString(0); + var filePath = Path.Combine("Saves/Spawners", filename); if (File.Exists(filePath)) { - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(filePath); - XmlElement root = doc["spawners"]; + var root = doc["spawners"]; int successes = 0, failures = 0; @@ -231,23 +231,23 @@ public class SpawnerExporter private static void ImportSpawner(XmlNode node) { - int count = int.Parse(GetText(node["count"], "1")); - int homeRange = int.Parse(GetText(node["homerange"], "4")); + var count = int.Parse(GetText(node["count"], "1")); + var homeRange = int.Parse(GetText(node["homerange"], "4")); - int walkingRange = int.Parse(GetText(node["walkingrange"], "-1")); + var walkingRange = int.Parse(GetText(node["walkingrange"], "-1")); - int team = int.Parse(GetText(node["team"], "0")); + var team = int.Parse(GetText(node["team"], "0")); - bool group = bool.Parse(GetText(node["group"], "False")); - TimeSpan maxDelay = TimeSpan.Parse(GetText(node["maxdelay"], "10:00")); - TimeSpan minDelay = TimeSpan.Parse(GetText(node["mindelay"], "05:00")); - IEnumerable creaturesName = LoadCreaturesName(node["creaturesname"]); + var group = bool.Parse(GetText(node["group"], "False")); + var maxDelay = TimeSpan.Parse(GetText(node["maxdelay"], "10:00")); + var minDelay = TimeSpan.Parse(GetText(node["mindelay"], "05:00")); + var creaturesName = LoadCreaturesName(node["creaturesname"]); - string name = GetText(node["name"], "Spawner"); - Point3D location = Point3D.Parse(GetText(node["location"], "Error")); - Map map = Map.Parse(GetText(node["map"], "Error")); + var name = GetText(node["name"], "Spawner"); + var location = Point3D.Parse(GetText(node["location"], "Error")); + var map = Map.Parse(GetText(node["map"], "Error")); - Spawner spawner = new Spawner(count, minDelay, maxDelay, team, homeRange, creaturesName.ToArray()); + var spawner = new Spawner(count, minDelay, maxDelay, team, homeRange, creaturesName.ToArray()); if (walkingRange >= 0) { spawner.WalkingRange = walkingRange; @@ -265,7 +265,7 @@ public class SpawnerExporter private static IEnumerable LoadCreaturesName(XmlElement node) { - List names = new List(); + var names = new List(); if (node != null) { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs index 053386ae3..aa7c4c066 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlPropsGump.cs @@ -95,7 +95,7 @@ public class XmlPropertiesGump : Gump { m_Page = page; - int count = m_List.Count - page * EntryCount; + var count = m_List.Count - page * EntryCount; if (count < 0) { @@ -106,33 +106,33 @@ public class XmlPropertiesGump : Gump count = EntryCount; } - int lastIndex = page * EntryCount + count - 1; + var lastIndex = page * EntryCount + count - 1; if (lastIndex >= 0 && lastIndex < m_List.Count && m_List[lastIndex] == null) { --count; } - int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (ColumnEntryCount + 1); + var totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (ColumnEntryCount + 1); AddPage(0); AddBackground(0, 0, TotalWidth * 3 + BorderSize * 2, BorderSize + totalHeight + BorderSize, BackGumpID); AddImageTiled(BorderSize, BorderSize + EntryHeight, (TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0)) * 3, totalHeight - EntryHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize; + var x = BorderSize + OffsetSize; + var y = BorderSize; if (m_Object is Item item) { AddLabelCropped(x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, item.Name); } - int propcount = 0; + var propcount = 0; for (int i = 0, index = page * EntryCount; i <= count && index < m_List.Count; ++i, ++index) { // do the multi column display - int column = propcount / ColumnEntryCount; + var column = propcount / ColumnEntryCount; if (propcount % ColumnEntryCount == 0) { y = BorderSize; @@ -141,7 +141,7 @@ public class XmlPropertiesGump : Gump x = BorderSize + OffsetSize + column * (ValueWidth + NameWidth + OffsetSize * 2 + SetOffsetX + SetWidth); y += EntryHeight + OffsetSize; - object o = m_List[index]; + var o = m_List[index]; if (o == null) { @@ -154,9 +154,9 @@ public class XmlPropertiesGump : Gump // look for the default value of the equivalent property in the XmlSpawnerDefaults.DefaultEntry class - int huemodifier = TextHue; - Mobiles.XmlSpawnerDefaults.DefaultEntry de = new Mobiles.XmlSpawnerDefaults.DefaultEntry(); - Type ftype = de.GetType(); + var huemodifier = TextHue; + var de = new Mobiles.XmlSpawnerDefaults.DefaultEntry(); + var ftype = de.GetType(); var finfo = ftype.GetField(prop.Name); @@ -182,7 +182,7 @@ public class XmlPropertiesGump : Gump AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); } - CPA cpa = GetCPA(prop); + var cpa = GetCPA(prop); if (prop.CanWrite && cpa != null && m_Mobile.AccessLevel >= cpa.WriteLevel) { @@ -200,7 +200,7 @@ public class XmlPropertiesGump : Gump public override void OnResponse(NetState state, RelayInfo info) { - Mobile from = state.Mobile; + var from = state.Mobile; if (!BaseCommand.IsAccessible(from, m_Object)) { @@ -214,7 +214,7 @@ public class XmlPropertiesGump : Gump { if (m_Stack != null && m_Stack.Count > 0) { - StackEntry entry = m_Stack.Pop(); + var entry = m_Stack.Pop(); from.SendGump(new XmlPropertiesGump(from, entry.m_Object, m_Stack, null)); } @@ -240,25 +240,25 @@ public class XmlPropertiesGump : Gump } default: { - int index = m_Page * EntryCount + (info.ButtonID - 3); + var index = m_Page * EntryCount + (info.ButtonID - 3); if (index >= 0 && index < m_List.Count) { - PropertyInfo prop = m_List[index] as PropertyInfo; + var prop = m_List[index] as PropertyInfo; if (prop == null) { return; } - CPA attr = GetCPA(prop); + var attr = GetCPA(prop); if (!prop.CanWrite || attr == null || from.AccessLevel < attr.WriteLevel) { return; } - Type type = prop.PropertyType; + var type = prop.PropertyType; if (IsType(type, typeofMobile) || IsType(type, typeofItem)) { @@ -311,7 +311,7 @@ public class XmlPropertiesGump : Gump } else if (HasAttribute(type, typeofPropertyObject, true)) { - object obj = prop.GetValue(m_Object, null); + var obj = prop.GetValue(m_Object, null); from.SendGump(obj != null ? new XmlPropertiesGump(from, obj, m_Stack, @@ -327,9 +327,9 @@ public class XmlPropertiesGump : Gump private static object[] GetObjects(Array a) { - object[] list = new object[a.Length]; + var list = new object[a.Length]; - for (int i = 0; i < list.Length; ++i) + for (var i = 0; i < list.Length; ++i) { list[i] = a.GetValue(i); } @@ -341,14 +341,14 @@ public class XmlPropertiesGump : Gump private static string[] GetCustomEnumNames(Type type) { - object[] attrs = type.GetCustomAttributes(typeofCustomEnum, false); + var attrs = type.GetCustomAttributes(typeofCustomEnum, false); if (attrs.Length == 0) { return new string[0]; } - CustomEnumAttribute ce = attrs[0] as CustomEnumAttribute; + var ce = attrs[0] as CustomEnumAttribute; if (ce == null) { @@ -360,7 +360,7 @@ public class XmlPropertiesGump : Gump private static bool HasAttribute(Type type, Type check, bool inherit) { - object[] objs = type.GetCustomAttributes(check, inherit); + var objs = type.GetCustomAttributes(check, inherit); return objs.Length > 0; } @@ -369,7 +369,7 @@ public class XmlPropertiesGump : Gump private static bool IsType(Type type, Type[] check) { - for (int i = 0; i < check.Length; ++i) + for (var i = 0; i < check.Length; ++i) { if (IsType(type, check[i])) { @@ -497,17 +497,17 @@ public class XmlPropertiesGump : Gump private ArrayList BuildList() { - Type type = m_Object.GetType(); + var type = m_Object.GetType(); - PropertyInfo[] props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); + var props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); - ArrayList groups = GetGroups(type, props); - ArrayList list = new ArrayList(); + var groups = GetGroups(type, props); + var list = new ArrayList(); - for (int i = 0; i < groups.Count; ++i) + for (var i = 0; i < groups.Count; ++i) { - DictionaryEntry de = (DictionaryEntry)groups[i]; - ArrayList groupList = (ArrayList)de.Value; + var de = (DictionaryEntry)groups[i]; + var groupList = (ArrayList)de.Value; if (!HasAttribute((Type)de.Key, typeofNoSort, false)) { @@ -531,7 +531,7 @@ public class XmlPropertiesGump : Gump private static CPA GetCPA(PropertyInfo prop) { - object[] attrs = prop.GetCustomAttributes(typeofCPA, false); + var attrs = prop.GetCustomAttributes(typeofCPA, false); if (attrs.Length > 0) { @@ -543,23 +543,23 @@ public class XmlPropertiesGump : Gump private ArrayList GetGroups(Type objectType, PropertyInfo[] props) { - Hashtable groups = new Hashtable(); + var groups = new Hashtable(); - for (int i = 0; i < props.Length; ++i) + for (var i = 0; i < props.Length; ++i) { - PropertyInfo prop = props[i]; + var prop = props[i]; if (prop.CanRead) { - CPA attr = GetCPA(prop); + var attr = GetCPA(prop); if (attr != null && m_Mobile.AccessLevel >= attr.ReadLevel) { - Type type = prop.DeclaringType; + var type = prop.DeclaringType; while (true) { - Type baseType = type.BaseType; + var baseType = type.BaseType; if (baseType == null || baseType == typeofObject) { @@ -576,7 +576,7 @@ public class XmlPropertiesGump : Gump } } - ArrayList list = (ArrayList)groups[type]; + var list = (ArrayList)groups[type]; if (list == null) { @@ -588,7 +588,7 @@ public class XmlPropertiesGump : Gump } } - ArrayList sorted = new ArrayList(groups); + var sorted = new ArrayList(groups); sorted.Sort(new GroupComparer(objectType)); @@ -650,8 +650,8 @@ public class XmlPropertiesGump : Gump return 1; } - PropertyInfo a = x as PropertyInfo; - PropertyInfo b = y as PropertyInfo; + var a = x as PropertyInfo; + var b = y as PropertyInfo; if (a == null || b == null) { @@ -672,7 +672,7 @@ public class XmlPropertiesGump : Gump private int GetDistance(Type type) { - Type current = m_Start; + var current = m_Start; int dist; @@ -706,8 +706,8 @@ public class XmlPropertiesGump : Gump throw new ArgumentException(); } - Type a = (Type)de1.Key; - Type b = (Type)de2.Key; + var a = (Type)de1.Key; + var b = (Type)de2.Key; return GetDistance(a).CompareTo(GetDistance(b)); } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetCustomEnumGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetCustomEnumGump.cs index a45d8f1da..bf545351a 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetCustomEnumGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetCustomEnumGump.cs @@ -17,13 +17,13 @@ public class XmlSetCustomEnumGump : XmlSetListOptionGump public override void OnResponse(NetState sender, RelayInfo relayInfo) { - int index = relayInfo.ButtonID - 1; + var index = relayInfo.ButtonID - 1; if (index >= 0 && index < m_Names.Length) { try { - MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) }); + var info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) }); CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, m_Names[index]); diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetGump.cs index e3decf23f..73ad7c6a7 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetGump.cs @@ -56,16 +56,16 @@ public class XmlSetGump : Gump m_Page = page; m_List = list; - bool canNull = !prop.PropertyType.IsValueType; - bool canDye = prop.IsDefined(typeof(HueAttribute), false); + var canNull = !prop.PropertyType.IsValueType; + var canDye = prop.IsDefined(typeof(HueAttribute), false); - int xextend = 0; + var xextend = 0; if (prop.PropertyType == typeof(string)) { xextend = 300; } - object val = prop.GetValue(m_Object, null); + var val = prop.GetValue(m_Object, null); var initialText = val == null ? "" : val.ToString(); @@ -74,8 +74,8 @@ public class XmlSetGump : Gump AddBackground(0, 0, BackWidth + xextend, BackHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0), BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth + xextend - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0), OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize; + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize; AddImageTiled(x, y, EntryWidth + xextend, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth + xextend - TextOffsetX, EntryHeight, TextHue, prop.Name); @@ -179,7 +179,7 @@ public class XmlSetGump : Gump { case 1: { - TextRelay text = info.GetTextEntry(0); + var text = info.GetTextEntry(0); if (text != null) { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetListOptionGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetListOptionGump.cs index ab7e061a1..7c40d47be 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetListOptionGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetListOptionGump.cs @@ -77,33 +77,33 @@ public class XmlSetListOptionGump : Gump m_Values = values; - int pages = (names.Length + EntryCount - 1) / EntryCount; - int index = 0; + var pages = (names.Length + EntryCount - 1) / EntryCount; + var index = 0; - for (int page = 1; page <= pages; ++page) + for (var page = 1; page <= pages; ++page) { AddPage(page); - int start = (page - 1) * EntryCount; - int count = names.Length - start; + var start = (page - 1) * EntryCount; + var count = names.Length - start; if (count > EntryCount) { count = EntryCount; } - int totalHeight = OffsetSize + (count + 2) * (EntryHeight + OffsetSize); - int backHeight = BorderSize + totalHeight + BorderSize; + var totalHeight = OffsetSize + (count + 2) * (EntryHeight + OffsetSize); + var backHeight = BorderSize + totalHeight + BorderSize; AddBackground(0, 0, BackWidth, backHeight, BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize; + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize; - int emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 - (OldStyle ? SetWidth + OffsetSize : 0); + var emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 - (OldStyle ? SetWidth + OffsetSize : 0); AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); @@ -145,7 +145,7 @@ public class XmlSetListOptionGump : Gump AddRect(0, prop.Name, 0); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { AddRect(i + 1, names[index], ++index); } @@ -154,8 +154,8 @@ public class XmlSetListOptionGump : Gump private void AddRect(int index, string str, int button) { - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize + (index + 1) * (EntryHeight + OffsetSize); + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize + (index + 1) * (EntryHeight + OffsetSize); AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str); @@ -175,13 +175,13 @@ public class XmlSetListOptionGump : Gump public override void OnResponse(NetState sender, RelayInfo info) { - int index = info.ButtonID - 1; + var index = info.ButtonID - 1; if (index >= 0 && index < m_Values.Length) { try { - object toSet = m_Values[index]; + var toSet = m_Values[index]; CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(-null-)" : toSet.ToString()); m_Property.SetValue(m_Object, toSet, null); } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs index b69949db6..d973cdf60 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetObjectGump.cs @@ -60,15 +60,15 @@ public class XmlSetObjectGump : Gump m_Page = page; m_List = list; - string initialText = XmlPropertiesGump.ValueToString(o, prop); + var initialText = XmlPropertiesGump.ValueToString(o, prop); AddPage(0); AddBackground(0, 0, BackWidth, BackHeight, BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize; + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name); @@ -252,7 +252,7 @@ public class XmlSetObjectGump : Gump { shouldSet = false; - object obj = m_Property.GetValue(m_Object, null); + var obj = m_Property.GetValue(m_Object, null); if (obj == null) { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint2DGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint2DGump.cs index eb5f634cb..ed9f30b83 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint2DGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint2DGump.cs @@ -57,15 +57,15 @@ public class XmlSetPoint2DGump : Gump m_Page = page; m_List = list; - Point2D p = (Point2D)prop.GetValue(o, null); + var p = (Point2D)prop.GetValue(o, null); AddPage(0); AddBackground(0, 0, BackWidth, BackHeight, BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize; + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name); @@ -146,7 +146,7 @@ public class XmlSetPoint2DGump : Gump protected override void OnTarget(Mobile from, object targeted) { - IPoint3D p = targeted as IPoint3D; + var p = targeted as IPoint3D; if (p != null) { @@ -195,8 +195,8 @@ public class XmlSetPoint2DGump : Gump } case 3: // Use values { - TextRelay x = info.GetTextEntry(0); - TextRelay y = info.GetTextEntry(1); + var x = info.GetTextEntry(0); + var y = info.GetTextEntry(1); toSet = new Point2D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text)); shouldSet = true; diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint3DGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint3DGump.cs index b0fa3c0a3..e6d4a99a9 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint3DGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetPoint3DGump.cs @@ -57,15 +57,15 @@ public class XmlSetPoint3DGump : Gump m_Page = page; m_List = list; - Point3D p = (Point3D)prop.GetValue(o, null); + var p = (Point3D)prop.GetValue(o, null); AddPage(0); AddBackground(0, 0, BackWidth, BackHeight, BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize; + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name); @@ -151,7 +151,7 @@ public class XmlSetPoint3DGump : Gump protected override void OnTarget(Mobile from, object targeted) { - IPoint3D p = targeted as IPoint3D; + var p = targeted as IPoint3D; if (p != null) { @@ -200,9 +200,9 @@ public class XmlSetPoint3DGump : Gump } case 3: // Use values { - TextRelay x = info.GetTextEntry(0); - TextRelay y = info.GetTextEntry(1); - TextRelay z = info.GetTextEntry(2); + var x = info.GetTextEntry(0); + var y = info.GetTextEntry(1); + var z = info.GetTextEntry(2); toSet = new Point3D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text), z == null ? 0 : Utility.ToInt32(z.Text)); shouldSet = true; diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetTimeSpanGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetTimeSpanGump.cs index 2e1c45a6e..79550de54 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetTimeSpanGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlPropsGumps/XmlSetTimeSpanGump.cs @@ -56,7 +56,7 @@ public class XmlSetTimeSpanGump : Gump m_Page = page; m_List = list; - TimeSpan ts = (TimeSpan)prop.GetValue(o, null); + var ts = (TimeSpan)prop.GetValue(o, null); AddPage(0); @@ -74,8 +74,8 @@ public class XmlSetTimeSpanGump : Gump private void AddRect(int index, string str, int button, int text) { - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize + index * (EntryHeight + OffsetSize); + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize + index * (EntryHeight + OffsetSize); AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str); @@ -103,9 +103,9 @@ public class XmlSetTimeSpanGump : Gump TimeSpan toSet; bool shouldSet, shouldSend; - TextRelay h = info.GetTextEntry(0); - TextRelay m = info.GetTextEntry(1); - TextRelay s = info.GetTextEntry(2); + var h = info.GetTextEntry(0); + var m = info.GetTextEntry(1); + var s = info.GetTextEntry(2); switch (info.ButtonID) { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs b/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs index 735ad243c..b7bcd12c2 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlSpawner.cs @@ -224,7 +224,7 @@ public class XmlSpawner : Item, ISpawner var count = 0; if (ProximityRange >= 0) { - foreach (Mobile m in GetMobilesInRange(ProximityRange)) + foreach (var m in GetMobilesInRange(ProximityRange)) { if (m?.Player == true) { @@ -7995,7 +7995,7 @@ public class XmlSpawner : Item, ISpawner if (m_ProximityRange >= 0 && CanSpawn) { // check all nearby players - foreach (Mobile p in GetMobilesInRange(m_ProximityRange)) + foreach (var p in GetMobilesInRange(m_ProximityRange)) { if (ValidPlayerTrig(p)) { @@ -9531,7 +9531,7 @@ public class XmlSpawner : Item, ISpawner if (checkitems) { // check the itemsid - foreach (Item i in map.GetItemsAt(x, y)) + foreach (var i in map.GetItemsAt(x, y)) { if (i.ItemData.Impassable) { @@ -11900,7 +11900,7 @@ public class XmlSpawner : Item, ISpawner parmstr = GetParm(s, ":CA="); // if kills needed is zero, then set CA to false by default. This maintains consistency with the // previous default behavior for old spawn specs that haven't specified CA - bool clearAdvance = killsNeeded != 0; + var clearAdvance = killsNeeded != 0; if (parmstr != null) { try { clearAdvance = int.Parse(parmstr) == 1; } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs index 7669f1bb2..9d6605b87 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerGumps.cs @@ -35,7 +35,7 @@ public class TextEntryGump : Gump AddImageTiled(23, 5, 214, 270, 0x52); AddImageTiled(24, 6, 213, 261, 0xBBC); - string label = $"{spawner.Name} entry {index}"; + var label = $"{spawner.Name} entry {index}"; AddLabel(28, 10, 0x384, label); // OK button @@ -75,8 +75,8 @@ public class TextEntryGump : Gump return; } - bool update_entry = false; - bool edit_entry = false; + var update_entry = false; + var edit_entry = false; switch (info.ButtonID) { @@ -103,26 +103,26 @@ public class TextEntryGump : Gump if (edit_entry) { // get the old text - TextRelay entry = info.GetTextEntry(1); - string oldtext = entry.Text; + var entry = info.GetTextEntry(1); + var oldtext = entry.Text; // get the new text entry = info.GetTextEntry(2); - string newtext = entry.Text; + var newtext = entry.Text; // make the substitution entry = info.GetTextEntry(0); - string origtext = entry.Text; + var origtext = entry.Text; if (origtext != null && oldtext != null && newtext != null) { try { - int firstindex = origtext.IndexOf(oldtext); + var firstindex = origtext.IndexOf(oldtext); if (firstindex >= 0) { - int secondindex = firstindex + oldtext.Length; + var secondindex = firstindex + oldtext.Length; - int lastindex = origtext.Length - 1; + var lastindex = origtext.Length - 1; string editedtext; if (firstindex > 0) @@ -154,7 +154,7 @@ public class TextEntryGump : Gump } if (update_entry) { - TextRelay entry = info.GetTextEntry(0); + var entry = info.GetTextEntry(0); if (m_index < m_Spawner.SpawnObjects.Length) { m_Spawner.SpawnObjects[m_index].TypeName = entry.Text; @@ -341,7 +341,7 @@ public class XmlSpawnerGump : Gump // add the status string AddTextEntry(38, 384, 235, 33, 33, 900, m_Spawner.status_str); // add the page buttons - for (int i = 0; i < MaxSpawnEntries / MaxEntriesPerPage; i++) + for (var i = 0; i < MaxSpawnEntries / MaxEntriesPerPage; i++) { //AddButton(38+i*30, 365, 2206, 2206, 0, GumpButtonType.Page, 1+i); AddButton(38 + i * 25, 365, 0x8B1 + i, 0x8B1 + i, 4000 + i); @@ -373,16 +373,16 @@ public class XmlSpawnerGump : Gump } - for (int i = 0; i < MaxSpawnEntries; i++) + for (var i = 0; i < MaxSpawnEntries; i++) { if (page != i / MaxEntriesPerPage) { continue; } - string str = string.Empty; - int texthue = 0; - int background = 0xBBC; + var str = string.Empty; + var texthue = 0; + var background = 0xBBC; if (i % MaxEntriesPerPage == 0) { @@ -408,7 +408,7 @@ public class XmlSpawnerGump : Gump } } - bool hasreplacement = false; + var hasreplacement = false; // check for replacement entries if (Rentry != null && Rentry.Index == i) @@ -444,10 +444,10 @@ public class XmlSpawnerGump : Gump str = m_Spawner.SpawnObjects[i].TypeName; } - int count = m_Spawner.SpawnObjects[i].SpawnedObjects.Count; - int max = m_Spawner.SpawnObjects[i].ActualMaxCount; - int subgrp = m_Spawner.SpawnObjects[i].SubGroup; - int spawnsper = m_Spawner.SpawnObjects[i].SpawnsPerTick; + var count = m_Spawner.SpawnObjects[i].SpawnedObjects.Count; + var max = m_Spawner.SpawnObjects[i].ActualMaxCount; + var subgrp = m_Spawner.SpawnObjects[i].SubGroup; + var spawnsper = m_Spawner.SpawnObjects[i].SpawnsPerTick; texthue = subgrp * 11; if (texthue < 0) @@ -482,7 +482,7 @@ public class XmlSpawnerGump : Gump string strmind = null; string strmaxd = null; string strpackrange = null; - string strspawnsper = spawnsper.ToString(); + var strspawnsper = spawnsper.ToString(); if (m_Spawner.SpawnObjects[i].SequentialResetTime > 0 && m_Spawner.SpawnObjects[i].SubGroup > 0) { @@ -529,7 +529,7 @@ public class XmlSpawnerGump : Gump strnext = m_Spawner.NextSpawn.ToString(); } - int yoff = 22 * (i % MaxEntriesPerPage) + 30; + var yoff = 22 * (i % MaxEntriesPerPage) + 30; // spawns per tick AddImageTiled(303 + xoffset, yoff, 30, 23, 0x52); @@ -585,15 +585,15 @@ public class XmlSpawnerGump : Gump public XmlSpawner.SpawnObject[] CreateArray(RelayInfo info, Mobile from) { - ArrayList SpawnObjects = new ArrayList(); + var SpawnObjects = new ArrayList(); - for (int i = 0; i < MaxSpawnEntries; i++) + for (var i = 0; i < MaxSpawnEntries; i++) { - TextRelay te = info.GetTextEntry(i); + var te = info.GetTextEntry(i); if (te != null) { - string str = te.Text; + var str = te.Text; if (str.Length > 0) { @@ -601,16 +601,16 @@ public class XmlSpawnerGump : Gump #if (BOOKTEXTENTRY) if (i < m_Spawner.SpawnObjects.Length) { - string currenttext = m_Spawner.SpawnObjects[i].TypeName; + var currenttext = m_Spawner.SpawnObjects[i].TypeName; if (currenttext != null && currenttext.Length >= 230) { str = currenttext; } } #endif - string typestr = BaseXmlSpawner.ParseObjectType(str); + var typestr = BaseXmlSpawner.ParseObjectType(str); - Type type = AssemblyHandler.FindTypeByName(typestr); + var type = AssemblyHandler.FindTypeByName(typestr); if (type != null) { @@ -639,13 +639,13 @@ public class XmlSpawnerGump : Gump public void UpdateTypeNames(Mobile from, RelayInfo info) { - for (int i = 0; i < MaxSpawnEntries; i++) + for (var i = 0; i < MaxSpawnEntries; i++) { - TextRelay te = info.GetTextEntry(i); + var te = info.GetTextEntry(i); if (te != null) { - string str = te.Text; + var str = te.Text; if (str.Length > 0) { @@ -657,7 +657,7 @@ public class XmlSpawnerGump : Gump // that could be longer than the buffer if booktextentry is used #if (BOOKTEXTENTRY) - string currentstr = m_Spawner.SpawnObjects[i].TypeName; + var currentstr = m_Spawner.SpawnObjects[i].TypeName; if (currentstr != null && currentstr.Length < 230) #endif { @@ -685,13 +685,13 @@ public class XmlSpawnerGump : Gump return; } - NetState ns = from.NetState; + var ns = from.NetState; if (ns?.Gumps != null) { - ArrayList refresh = new ArrayList(); + var refresh = new ArrayList(); - foreach (Gump g in ns.Gumps) + foreach (var g in ns.Gumps) { // clear the gump status on the spawner associated with the gump if (g is XmlSpawnerGump xg && xg.m_Spawner != null) @@ -712,7 +712,7 @@ public class XmlSpawnerGump : Gump // flag the current gump on the spawner as closed g.m_Spawner.GumpReset = true; - XmlSpawnerGump xg = new XmlSpawnerGump(g.m_Spawner, g.X, g.Y, g.m_ShowGump, g.xoffset, g.page, g.Rentry); + var xg = new XmlSpawnerGump(g.m_Spawner, g.X, g.Y, g.m_ShowGump, g.xoffset, g.page, g.Rentry); from.SendGump(xg); } @@ -763,7 +763,7 @@ public class XmlSpawnerGump : Gump } // Get the current name - TextRelay tr = info.GetTextEntry(999); + var tr = info.GetTextEntry(999); if (tr != null) { m_Spawner.Name = tr.Text; @@ -781,7 +781,7 @@ public class XmlSpawnerGump : Gump return; } - for (int i = 0; i < m_Spawner.SpawnObjects.Length; i++) + for (var i = 0; i < m_Spawner.SpawnObjects.Length; i++) { if (page != i / MaxEntriesPerPage) { @@ -789,10 +789,10 @@ public class XmlSpawnerGump : Gump } // check the max count entry - TextRelay temcnt = info.GetTextEntry(500 + i); + var temcnt = info.GetTextEntry(500 + i); if (temcnt != null) { - int maxval = 0; + var maxval = 0; try { maxval = Convert.ToInt32(temcnt.Text, 10); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (maxval < 0) @@ -806,10 +806,10 @@ public class XmlSpawnerGump : Gump if (m_ShowGump > 0) { // check the subgroup entry - TextRelay tegrp = info.GetTextEntry(600 + i); + var tegrp = info.GetTextEntry(600 + i); if (tegrp != null) { - int grpval = 0; + var grpval = 0; try { grpval = Convert.ToInt32(tegrp.Text, 10); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (grpval < 0) @@ -824,7 +824,7 @@ public class XmlSpawnerGump : Gump if (m_ShowGump > 1) { // note, while these values can be entered in any spawn entry, they will only be assigned to the subgroup leader - int subgroupindex = m_Spawner.GetCurrentSequentialSpawnIndex(m_Spawner.SpawnObjects[i].SubGroup); + var subgroupindex = m_Spawner.GetCurrentSequentialSpawnIndex(m_Spawner.SpawnObjects[i].SubGroup); TextRelay tegrp; if (subgroupindex >= 0 && subgroupindex < m_Spawner.SpawnObjects.Length) @@ -849,7 +849,7 @@ public class XmlSpawnerGump : Gump tegrp = info.GetTextEntry(1100 + i); if (tegrp?.Text != null && tegrp.Text.Length > 0) { - int grpval = 0; + var grpval = 0; try { grpval = Convert.ToInt32(tegrp.Text, 10); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (grpval < 0) @@ -863,7 +863,7 @@ public class XmlSpawnerGump : Gump tegrp = info.GetTextEntry(1200 + i); if (tegrp?.Text != null && tegrp.Text.Length > 0) { - int grpval = 0; + var grpval = 0; try { grpval = Convert.ToInt32(tegrp.Text, 10); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (grpval < 0) @@ -939,7 +939,7 @@ public class XmlSpawnerGump : Gump { if (!string.IsNullOrEmpty(tegrp.Text)) { - int grpval = 1; + var grpval = 1; try { grpval = int.Parse(tegrp.Text); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (grpval < 0) @@ -965,7 +965,7 @@ public class XmlSpawnerGump : Gump { if (!string.IsNullOrEmpty(tegrp.Text)) { - int grpval = 1; + var grpval = 1; try { grpval = int.Parse(tegrp.Text); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (grpval < 0) @@ -988,10 +988,10 @@ public class XmlSpawnerGump : Gump } // Update the maxcount - TextRelay temax = info.GetTextEntry(300); + var temax = info.GetTextEntry(300); if (temax != null) { - int maxval = 0; + var maxval = 0; try { maxval = Convert.ToInt32(temax.Text, 10); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } if (maxval < 0) @@ -1097,7 +1097,7 @@ public class XmlSpawnerGump : Gump // check the restrict kills flag if (info.ButtonID >= 300 && info.ButtonID < 300 + MaxSpawnEntries) { - int index = info.ButtonID - 300; + var index = info.ButtonID - 300; if (index < m_Spawner.SpawnObjects.Length) { m_Spawner.SpawnObjects[index].RestrictKillsToSubgroup = !m_Spawner.SpawnObjects[index].RestrictKillsToSubgroup; @@ -1105,7 +1105,7 @@ public class XmlSpawnerGump : Gump } else if (info.ButtonID >= 400 && info.ButtonID < 400 + MaxSpawnEntries) { - int index = info.ButtonID - 400; + var index = info.ButtonID - 400; if (index < m_Spawner.SpawnObjects.Length) { m_Spawner.SpawnObjects[index].ClearOnAdvance = !m_Spawner.SpawnObjects[index].ClearOnAdvance; @@ -1114,11 +1114,11 @@ public class XmlSpawnerGump : Gump else if (info.ButtonID >= 800 && info.ButtonID < 800 + MaxSpawnEntries) { // open the text entry gump - int index = info.ButtonID - 800; + var index = info.ButtonID - 800; // open a text entry gump #if (BOOKTEXTENTRY) // display a new gump - XmlSpawnerGump newgump = new XmlSpawnerGump(m_Spawner, X, Y, m_ShowGump, xoffset, page); + var newgump = new XmlSpawnerGump(m_Spawner, X, Y, m_ShowGump, xoffset, page); state.Mobile.SendGump(newgump); // is there an existing book associated with the gump? @@ -1127,7 +1127,7 @@ public class XmlSpawnerGump : Gump m_Spawner.m_TextEntryBook = new List(); } - object[] args = new object[6]; + var args = new object[6]; args[0] = m_Spawner; args[1] = index; @@ -1136,7 +1136,7 @@ public class XmlSpawnerGump : Gump args[4] = m_ShowGump; args[5] = page; - XmlTextEntryBook book = new XmlTextEntryBook(0, string.Empty, m_Spawner.Name, 20, true); + var book = new XmlTextEntryBook(0, string.Empty, m_Spawner.Name, 20, true); m_Spawner.m_TextEntryBook.Add(book); @@ -1144,7 +1144,7 @@ public class XmlSpawnerGump : Gump book.Author = m_Spawner.Name; // fill the contents of the book with the current text entry data - string text = string.Empty; + var text = string.Empty; if (m_Spawner.SpawnObjects != null && index < m_Spawner.SpawnObjects.Length) { text = m_Spawner.SpawnObjects[index].TypeName; @@ -1168,21 +1168,21 @@ public class XmlSpawnerGump : Gump { nclicks++; // find the location of the spawn at the specified index - int index = info.ButtonID - 1300; + var index = info.ButtonID - 1300; if (index < m_Spawner.SpawnObjects.Length) { - int scount = m_Spawner.SpawnObjects[index].SpawnedObjects.Count; + var scount = m_Spawner.SpawnObjects[index].SpawnedObjects.Count; if (scount > 0) { - object so = m_Spawner.SpawnObjects[index].SpawnedObjects[nclicks % scount]; + var so = m_Spawner.SpawnObjects[index].SpawnedObjects[nclicks % scount]; if (ValidGotoObject(state.Mobile, so)) { - IPoint3D o = so as IPoint3D; + var o = so as IPoint3D; if (o != null) { - Map m = m_Spawner.Map; + var m = m_Spawner.Map; if (o is Item item) { @@ -1209,7 +1209,7 @@ public class XmlSpawnerGump : Gump } else if (info.ButtonID >= 6000 && info.ButtonID < 6000 + MaxSpawnEntries) { - int index = info.ButtonID - 6000; + var index = info.ButtonID - 6000; if (index < m_Spawner.SpawnObjects.Length) { @@ -1224,18 +1224,18 @@ public class XmlSpawnerGump : Gump } else if (info.ButtonID >= 5000 && info.ButtonID < 5000 + MaxSpawnEntries) { - int i = info.ButtonID - 5000; + var i = info.ButtonID - 5000; string categorystring = null; string entrystring = null; - TextRelay te = info.GetTextEntry(i); + var te = info.GetTextEntry(i); if (te?.Text != null) { // get the string - string[] cargs = te.Text.Split(','); + var cargs = te.Text.Split(','); // parse out any comma separated args categorystring = cargs[0]; @@ -1246,7 +1246,7 @@ public class XmlSpawnerGump : Gump if (string.IsNullOrEmpty(categorystring)) { - XmlSpawnerGump newg = new XmlSpawnerGump(m_Spawner, X, Y, m_ShowGump, xoffset, page); + var newg = new XmlSpawnerGump(m_Spawner, X, Y, m_ShowGump, xoffset, page); state.Mobile.SendGump(newg); // if no string has been entered then just use the full categorized add gump @@ -1259,17 +1259,17 @@ public class XmlSpawnerGump : Gump state.Mobile.CloseGump(); //Type [] types = (Type[])XmlPartialCategorizedAddGump.Match(categorystring).ToArray(typeof(Type)); - ArrayList types = XmlPartialCategorizedAddGump.Match(categorystring); + var types = XmlPartialCategorizedAddGump.Match(categorystring); - ReplacementEntry re = new ReplacementEntry + var re = new ReplacementEntry { Typename = entrystring, Index = i, Color = 0x1436 }; - XmlSpawnerGump newg = new XmlSpawnerGump(m_Spawner, X, Y, m_ShowGump, xoffset, page, re); + var newg = new XmlSpawnerGump(m_Spawner, X, Y, m_ShowGump, xoffset, page, re); state.Mobile.SendGump(new XmlPartialCategorizedAddGump(state.Mobile, categorystring, 0, types, true, i, newg)); @@ -1281,20 +1281,20 @@ public class XmlSpawnerGump : Gump else { // up and down arrows - int buttonID = info.ButtonID - 6; - int index = buttonID / 2; - int type = buttonID % 2; + var buttonID = info.ButtonID - 6; + var index = buttonID / 2; + var type = buttonID % 2; - TextRelay entry = info.GetTextEntry(index); + var entry = info.GetTextEntry(index); if (entry != null && entry.Text.Length > 0) { - string entrystr = entry.Text; + var entrystr = entry.Text; #if (BOOKTEXTENTRY) if (index < m_Spawner.SpawnObjects.Length) { - string str = m_Spawner.SpawnObjects[index].TypeName; + var str = m_Spawner.SpawnObjects[index].TypeName; if (str != null && str.Length >= 230) { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs index fa1b2b6ed..0cf7bf50b 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlSpawnerSkillCheck.cs @@ -10,7 +10,7 @@ public class XmlSpawnerSkillCheck // alternate skillcheck hooks to replace those in SkillCheck.cs public static bool Mobile_SkillCheckLocation(Mobile from, SkillName skillName, double minSkill, double maxSkill) { - Skill skill = from.Skills[skillName]; + var skill = from.Skills[skillName]; if (skill == null) { @@ -18,7 +18,7 @@ public class XmlSpawnerSkillCheck } // call the default skillcheck handler - bool success = SkillCheck.Mobile_SkillCheckLocation( from, skillName, minSkill, maxSkill); + var success = SkillCheck.Mobile_SkillCheckLocation( from, skillName, minSkill, maxSkill); // call the xmlspawner skillcheck handler CheckSkillUse(from, skill, success); @@ -28,7 +28,7 @@ public class XmlSpawnerSkillCheck public static bool Mobile_SkillCheckDirectLocation(Mobile from, SkillName skillName, double chance) { - Skill skill = from.Skills[skillName]; + var skill = from.Skills[skillName]; if (skill == null) { @@ -36,7 +36,7 @@ public class XmlSpawnerSkillCheck } // call the default skillcheck handler - bool success = SkillCheck.Mobile_SkillCheckDirectLocation( from, skillName, chance); + var success = SkillCheck.Mobile_SkillCheckDirectLocation( from, skillName, chance); // call the xmlspawner skillcheck handler CheckSkillUse(from, skill, success); @@ -46,7 +46,7 @@ public class XmlSpawnerSkillCheck public static bool Mobile_SkillCheckTarget(Mobile from, SkillName skillName, object target, double minSkill, double maxSkill) { - Skill skill = from.Skills[skillName]; + var skill = from.Skills[skillName]; if (skill == null) { @@ -54,7 +54,7 @@ public class XmlSpawnerSkillCheck } // call the default skillcheck handler - bool success = SkillCheck.Mobile_SkillCheckTarget( from, skillName, target, minSkill, maxSkill); + var success = SkillCheck.Mobile_SkillCheckTarget( from, skillName, target, minSkill, maxSkill); // call the xmlspawner skillcheck handler CheckSkillUse(from, skill, success); @@ -64,7 +64,7 @@ public class XmlSpawnerSkillCheck public static bool Mobile_SkillCheckDirectTarget(Mobile from, SkillName skillName, object target, double chance) { - Skill skill = from.Skills[skillName]; + var skill = from.Skills[skillName]; if (skill == null) { @@ -72,7 +72,7 @@ public class XmlSpawnerSkillCheck } // call the default skillcheck handler - bool success = SkillCheck.Mobile_SkillCheckDirectTarget( from, skillName, target, chance); + var success = SkillCheck.Mobile_SkillCheckDirectTarget( from, skillName, target, chance); // call the xmlspawner skillcheck handler CheckSkillUse(from, skill, success); @@ -153,9 +153,9 @@ public class XmlSpawnerSkillCheck } // go through the list and if the spawner is not on it yet, then add it - bool found = false; + var found = false; - ArrayList skilllist = RegisteredSkill.TriggerList(s, map); + var skilllist = RegisteredSkill.TriggerList(s, map); if (skilllist == null) { @@ -175,7 +175,7 @@ public class XmlSpawnerSkillCheck // if it hasnt already been added to the list, then add it if (!found) { - RegisteredSkill newrs = new RegisteredSkill(); + var newrs = new RegisteredSkill(); newrs.target = o; newrs.sid = s; @@ -194,9 +194,9 @@ public class XmlSpawnerSkillCheck // go through the list and if the spawner is on it regardless of the skill registered, then remove it if (all) { - for(int i = 0;i 20) { length = 20; @@ -52,11 +52,11 @@ public class XmlTextEntryBook : BaseBook pagenum++; } // empty the remaining contents - for (int j = pagenum; j < PagesCount; j++) + for (var j = pagenum; j < PagesCount; j++) { if (Pages[j].Lines.Length > 0) { - for (int i = 0; i < Pages[j].Lines.Length; i++) + for (var i = 0; i < Pages[j].Lines.Length; i++) { Pages[j].Lines[i] = string.Empty; } diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs index c74c2fa30..145895cb8 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlAdd.cs @@ -83,9 +83,9 @@ public class XmlSpawnerDefaults // find the default entry corresponding to the account and username if (DefaultEntryList != null) { - for (int i = 0; i < DefaultEntryList.Count; i++) + for (var i = 0; i < DefaultEntryList.Count; i++) { - DefaultEntry entry = (DefaultEntry)DefaultEntryList[i]; + var entry = (DefaultEntry)DefaultEntryList[i]; if (entry != null && string.Compare(entry.PlayerName, name, true) == 0 && string.Compare(entry.AccountName, account, true) == 0) { return entry; @@ -93,7 +93,7 @@ public class XmlSpawnerDefaults } } // if not found then add one - DefaultEntry newentry = new DefaultEntry + var newentry = new DefaultEntry { PlayerName = name, AccountName = account @@ -187,9 +187,9 @@ public class XmlAddGump : Gump return "0"; } - System.Text.StringBuilder sb = new System.Text.StringBuilder(); + var sb = new System.Text.StringBuilder(); sb.AppendFormat("{0}", defs.NameList.Length); - for (int i = 0; i < defs.NameList.Length; i++) + for (var i = 0; i < defs.NameList.Length; i++) { sb.AppendFormat(":{0}", defs.NameList[i]); } @@ -203,9 +203,9 @@ public class XmlAddGump : Gump return "0"; } - System.Text.StringBuilder sb = new System.Text.StringBuilder(); + var sb = new System.Text.StringBuilder(); sb.AppendFormat("{0}", defs.SelectionList.Length); - for (int i = 0; i < defs.SelectionList.Length; i++) + for (var i = 0; i < defs.SelectionList.Length; i++) { sb.AppendFormat(":{0}", defs.SelectionList[i] ? 1 : 0); } @@ -214,9 +214,9 @@ public class XmlAddGump : Gump private static string[] StringToNameList(string namelist) { - string[] newlist = new string[MaxEntries]; - string[] tmplist = namelist.Split(':'); - for (int i = 1; i < tmplist.Length; i++) + var newlist = new string[MaxEntries]; + var tmplist = namelist.Split(':'); + for (var i = 1; i < tmplist.Length; i++) { if (i - 1 >= newlist.Length) { @@ -230,9 +230,9 @@ public class XmlAddGump : Gump private static bool[] StringToSelectionList(string selectionlist) { - bool[] newlist = new bool[MaxEntries]; - string[] tmplist = selectionlist.Split(':'); - for (int i = 1; i < tmplist.Length; i++) + var newlist = new bool[MaxEntries]; + var tmplist = selectionlist.Split(':'); + for (var i = 1; i < tmplist.Length; i++) { if (i - 1 >= newlist.Length) { @@ -259,7 +259,7 @@ public class XmlAddGump : Gump } // Create the data set - DataSet ds = new DataSet(DefsDataSetName); + var ds = new DataSet(DefsDataSetName); // Load the data set up ds.Tables.Add(DefsTablePointName); @@ -312,7 +312,7 @@ public class XmlAddGump : Gump ds.Tables[DefsTablePointName].Columns.Add("AutoNumberValue"); // Create a new data row - DataRow dr = ds.Tables[DefsTablePointName].NewRow(); + var dr = ds.Tables[DefsTablePointName].NewRow(); // Populate the data //dr["AccountName"] = (string)defs.AccountName; @@ -364,7 +364,7 @@ public class XmlAddGump : Gump ds.Tables[DefsTablePointName].Rows.Add(dr); // Write out the file - bool file_error = false; + var file_error = false; var dirname = Directory.Exists(DefsDir) ? $"{DefsDir}/{filename}.defs" : $"{filename}.defs"; @@ -431,11 +431,11 @@ public class XmlAddGump : Gump } // Create the data set - DataSet ds = new DataSet(DefsDataSetName); + var ds = new DataSet(DefsDataSetName); // Read in the file //ds.ReadXml(e.Arguments[0].ToString()); - bool fileerror = false; + var fileerror = false; try { ds.ReadXml(fs); @@ -460,17 +460,17 @@ public class XmlAddGump : Gump if (ds.Tables[DefsTablePointName] != null && ds.Tables[DefsTablePointName].Rows.Count > 0) { //foreach(DataRow dr in ds.Tables[DefsTablePointName].Rows){ - DataRow dr = ds.Tables[DefsTablePointName].Rows[0]; + var dr = ds.Tables[DefsTablePointName].Rows[0]; try { defs.SpawnerName = (string)dr["SpawnerName"]; } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } - double mindelay = defs.MinDelay.TotalMinutes; + var mindelay = defs.MinDelay.TotalMinutes; try { mindelay = double.Parse((string)dr["MinDelay"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.MinDelay = TimeSpan.FromMinutes(mindelay); - double maxdelay = defs.MaxDelay.TotalMinutes; + var maxdelay = defs.MaxDelay.TotalMinutes; try { maxdelay = double.Parse((string)dr["MaxDelay"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.MaxDelay = TimeSpan.FromMinutes(maxdelay); @@ -486,22 +486,22 @@ public class XmlAddGump : Gump try { defs.Team = int.Parse((string)dr["Team"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } - double minrefract = defs.RefractMin.TotalMinutes; + var minrefract = defs.RefractMin.TotalMinutes; try { minrefract = double.Parse((string)dr["MinRefractory"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.RefractMin = TimeSpan.FromMinutes(minrefract); - double maxrefract = defs.RefractMax.TotalMinutes; + var maxrefract = defs.RefractMax.TotalMinutes; try { maxrefract = double.Parse((string)dr["MaxRefractory"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.RefractMax = TimeSpan.FromMinutes(maxrefract); - double todstart = defs.TODStart.TotalMinutes; + var todstart = defs.TODStart.TotalMinutes; try { todstart = double.Parse((string)dr["TODStart"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.TODStart = TimeSpan.FromMinutes(todstart); - double todend = defs.TODEnd.TotalMinutes; + var todend = defs.TODEnd.TotalMinutes; try { todend = double.Parse((string)dr["TODEnd"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.TODEnd = TimeSpan.FromMinutes(todend); @@ -522,12 +522,12 @@ public class XmlAddGump : Gump } } - double duration = defs.Duration.TotalMinutes; + var duration = defs.Duration.TotalMinutes; try { duration = double.Parse((string)dr["Duration"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.Duration = TimeSpan.FromMinutes(duration); - double despawnTime = defs.DespawnTime.TotalHours; + var despawnTime = defs.DespawnTime.TotalHours; try { despawnTime = double.Parse((string)dr["DespawnTime"]); } catch (Exception e) { Diagnostics.ExceptionLogging.LogException(e); } defs.DespawnTime = TimeSpan.FromHours(despawnTime); @@ -613,9 +613,9 @@ public class XmlAddGump : Gump [Description("Opens a gump that can add Xmlspawners with specified default settings")] public static void XmlAdd_OnCommand(CommandEventArgs e) { - Account acct = e.Mobile.Account as Account; - int x = 440; - int y = 0; + var acct = e.Mobile.Account as Account; + var x = 440; + var y = 0; XmlSpawnerDefaults.DefaultEntry defs = null; if (acct != null) { @@ -631,7 +631,7 @@ public class XmlAddGump : Gump try { // Check if there is an argument provided (load criteria) - for (int nxtarg = 0; nxtarg < e.Arguments.Length; nxtarg++) + for (var nxtarg = 0; nxtarg < e.Arguments.Length; nxtarg++) { // is it a defaults option? if (e.Arguments[nxtarg].ToLower() == "-defaults") @@ -663,7 +663,7 @@ public class XmlAddGump : Gump m_From = from; // read the text entries for default values - Account acct = from.Account as Account; + var acct = from.Account as Account; if (acct != null) { defs = XmlSpawnerDefaults.GetDefaults(acct.ToString(), from.Name); @@ -943,10 +943,10 @@ public class XmlAddGump : Gump // display the clear all toggle AddButton(475, 5, 0xD2, 0xD3, 3999); // display the selection entries - for (int i = 0; i < MaxEntries; i++) + for (var i = 0; i < MaxEntries; i++) { - int xpos = i / MaxEntriesPerColumn * 155; - int ypos = i % MaxEntriesPerColumn * 22 + 30; + var xpos = i / MaxEntriesPerColumn * 155; + var ypos = i % MaxEntriesPerColumn * 22 + 30; // background for search results area AddImageTiled(xpos + 205, ypos, 116, 23, 0x52); @@ -954,13 +954,13 @@ public class XmlAddGump : Gump // has this been selected for category info specification? AddImageTiled(xpos + 206, ypos + 1, 114, 21, i == defs.CategorySelectionIndex ? 0x1436 : 0xBBC); - bool sel = false; + var sel = false; if (defs.SelectionList != null && i < defs.SelectionList.Length) { sel = defs.SelectionList[i]; } - int texthue = 0; + var texthue = 0; if (sel) { texthue = 68; @@ -1059,7 +1059,7 @@ public class XmlAddGump : Gump // read the text entries for default values XmlSpawnerDefaults.DefaultEntry defs = null; - Account acct = from.Account as Account; + var acct = from.Account as Account; if (acct != null) { defs = XmlSpawnerDefaults.GetDefaults(acct.ToString(), from.Name); @@ -1070,8 +1070,8 @@ public class XmlAddGump : Gump return; } - int x = defs.AddGumpX; - int y = defs.AddGumpY; + var x = defs.AddGumpX; + var y = defs.AddGumpY; if (defs.ShowExtension) { // shift the starting point @@ -1101,7 +1101,7 @@ public class XmlAddGump : Gump // read the text entries for default values defs = null; - Account acct = state.Mobile.Account as Account; + var acct = state.Mobile.Account as Account; if (acct != null) { defs = XmlSpawnerDefaults.GetDefaults(acct.ToString(), state.Mobile.Name); @@ -1123,10 +1123,10 @@ public class XmlAddGump : Gump } // assign it a unique id - Guid SpawnId = Guid.NewGuid(); + var SpawnId = Guid.NewGuid(); // count the number of entries to be added for maxcount - int maxcount = 0; - for (int i = 0; i < MaxEntries; i++) + var maxcount = 0; + for (var i = 0; i < MaxEntries; i++) { if (defs.SelectionList != null && i < defs.SelectionList.Length && defs.SelectionList[i] && defs.NameList != null && i < defs.NameList.Length && defs.NameList[i] != null && defs.NameList[i].Length > 0) @@ -1136,13 +1136,13 @@ public class XmlAddGump : Gump } // if autonumbering is enabled, name the spawner with the name+number - string sname = defs.SpawnerName; + var sname = defs.SpawnerName; if (defs.AutoNumber) { sname = $"{defs.SpawnerName}#{defs.AutoNumberValue}"; } - XmlSpawner spawner = new XmlSpawner(SpawnId, from.Location.X, from.Location.Y, 0, 0, sname, maxcount, + var spawner = new XmlSpawner(SpawnId, from.Location.X, from.Location.Y, 0, 0, sname, maxcount, defs.MinDelay, defs.MaxDelay, defs.Duration, defs.ProximityRange, defs.ProximitySound, 1, defs.Team, defs.HomeRange, defs.HomeRangeIsRelative, new XmlSpawner.SpawnObject[0], defs.RefractMin, defs.RefractMax, defs.TODStart, defs.TODEnd, null, defs.TriggerObjectProp, defs.ProximityMsg, defs.TriggerOnCarried, defs.NoTriggerOnCarried, @@ -1160,7 +1160,7 @@ public class XmlAddGump : Gump else { // place the spawner at the targeted location - IPoint3D p = targeted as IPoint3D; + var p = targeted as IPoint3D; if (p == null) { spawner.Delete(); @@ -1176,7 +1176,7 @@ public class XmlAddGump : Gump spawner.SpawnRange = defs.SpawnRange; // add entries from the name list - for (int i = 0; i < MaxEntries; i++) + for (var i = 0; i < MaxEntries; i++) { if (defs.SelectionList != null && i < defs.SelectionList.Length && defs.SelectionList[i] && defs.NameList != null && i < defs.NameList.Length && defs.NameList[i] != null && defs.NameList[i].Length > 0) @@ -1209,13 +1209,13 @@ public class XmlAddGump : Gump } // read the text entries for default values - XmlSpawnerDefaults.DefaultEntry defaults = XmlSpawnerDefaults.GetDefaults(state.Account.ToString(), state.Mobile.Name); + var defaults = XmlSpawnerDefaults.GetDefaults(state.Account.ToString(), state.Mobile.Name); if (defaults.IgnoreUpdate) { return; } - TextRelay tr = info.GetTextEntry(100); // mindelay + var tr = info.GetTextEntry(100); // mindelay if (tr?.Text != null && tr.Text.Length > 0) { try { defaults.MinDelay = TimeSpan.FromMinutes(double.Parse(tr.Text)); } @@ -1259,7 +1259,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(106); // Speech trigger if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1333,7 +1333,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(117); // trigger on carried if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1345,7 +1345,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(118); // no trigger on carried if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1357,7 +1357,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(119); // proximity message if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1369,7 +1369,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(120); // player trig prop if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1388,7 +1388,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(122); // trig object prop if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1407,7 +1407,7 @@ public class XmlAddGump : Gump tr = info.GetTextEntry(124); // Skill trigger if (tr != null) { - string txt = tr.Text; + var txt = tr.Text; if (txt != null && txt.Length == 0) { txt = null; @@ -1426,7 +1426,7 @@ public class XmlAddGump : Gump // fill the NameList from the text entries if (defaults.ShowExtension) { - for (int i = 0; i < MaxEntries; i++) + for (var i = 0; i < MaxEntries; i++) { tr = info.GetTextEntry(1000 + i); if (defaults.NameList != null && i < defaults.NameList.Length && tr != null) @@ -1579,7 +1579,7 @@ public class XmlAddGump : Gump { if (info.ButtonID >= 4000 && info.ButtonID < 4000 + MaxEntries) { - int i = info.ButtonID - 4000; + var i = info.ButtonID - 4000; if (defaults.SelectionList != null && i >= 0 && i < defaults.SelectionList.Length) { defaults.SelectionList[i] = !defaults.SelectionList[i]; @@ -1587,10 +1587,10 @@ public class XmlAddGump : Gump } if (info.ButtonID >= 5000 && info.ButtonID < 5000 + MaxEntries) { - int i = info.ButtonID - 5000; + var i = info.ButtonID - 5000; defaults.CategorySelectionIndex = i; - XmlAddGump newg = new XmlAddGump(state.Mobile, defaults.StartingLoc, defaults.StartingMap, false, defaults.ShowExtension, 0, 0); + var newg = new XmlAddGump(state.Mobile, defaults.StartingLoc, defaults.StartingMap, false, defaults.ShowExtension, 0, 0); state.Mobile.SendGump(newg); @@ -1606,7 +1606,7 @@ public class XmlAddGump : Gump state.Mobile.CloseGump(); //Type [] types = (Type[])XmlPartialCategorizedAddGump.Match(defs.NameList[i]).ToArray(typeof(Type)); - ArrayList types = XmlPartialCategorizedAddGump.Match(defaults.NameList[i]); + var types = XmlPartialCategorizedAddGump.Match(defaults.NameList[i]); state.Mobile.SendGump(new XmlPartialCategorizedAddGump(state.Mobile, defaults.NameList[i], 0, types, true, i, newg)); } @@ -1625,7 +1625,7 @@ public class XmlAddGump : Gump public XmlAddOptionsGump(Mobile from) : base(0, 0) { // read the text entries for default values - Account acct = from.Account as Account; + var acct = from.Account as Account; XmlSpawnerDefaults.DefaultEntry defs = null; if (acct != null) @@ -1680,13 +1680,13 @@ public class XmlAddGump : Gump } // read the text entries for default values - XmlSpawnerDefaults.DefaultEntry defs = XmlSpawnerDefaults.GetDefaults(state.Account.ToString(), state.Mobile.Name); + var defs = XmlSpawnerDefaults.GetDefaults(state.Account.ToString(), state.Mobile.Name); if (defs == null) { return; } - TextRelay tr = info.GetTextEntry(100); // AddGumpX + var tr = info.GetTextEntry(100); // AddGumpX if (tr?.Text != null && tr.Text.Length > 0) { try { defs.AddGumpX = int.Parse(tr.Text); } @@ -1752,7 +1752,7 @@ public class XmlAddGump : Gump return; } - int radiostate = -1; + var radiostate = -1; if (info.Switches.Length > 0) { radiostate = info.Switches[0]; diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlCategorizedAddGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlCategorizedAddGump.cs index f8077e55a..9f2d863a2 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlCategorizedAddGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlCategorizedAddGump.cs @@ -42,11 +42,11 @@ public class XmlAddCAGObject : XmlAddCAGNode } else if (gump is XmlSpawnerGump spawnerGump) { - XmlSpawner m_Spawner = spawnerGump.m_Spawner; + var m_Spawner = spawnerGump.m_Spawner; if (m_Spawner != null) { - XmlSpawnerGump xg = m_Spawner.SpawnerGump; + var xg = m_Spawner.SpawnerGump; if (xg != null) { @@ -130,7 +130,7 @@ public class XmlAddCAGCategory : XmlAddCAGNode } else { - ArrayList nodes = new ArrayList(); + var nodes = new ArrayList(); try { @@ -170,7 +170,7 @@ public class XmlAddCAGCategory : XmlAddCAGNode { if (File.Exists(path)) { - XmlTextReader xml = new XmlTextReader(path) + var xml = new XmlTextReader(path) { WhitespaceHandling = WhitespaceHandling.None }; @@ -179,7 +179,7 @@ public class XmlAddCAGCategory : XmlAddCAGNode { if (xml.Name == "category" && xml.NodeType == XmlNodeType.Element) { - XmlAddCAGCategory cat = new XmlAddCAGCategory(null, xml); + var cat = new XmlAddCAGCategory(null, xml); xml.Close(); @@ -285,9 +285,9 @@ public class XmlCategorizedAddGump : Gump { m_Page = page; - XmlAddCAGNode[] nodes = m_Category.Nodes; + var nodes = m_Category.Nodes; - int count = nodes.Length - page * EntryCount; + var count = nodes.Length - page * EntryCount; if (count < 0) { @@ -298,15 +298,15 @@ public class XmlCategorizedAddGump : Gump count = EntryCount; } - int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1); + var totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1); AddPage(0); AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID); AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; - int y = BorderSize + OffsetSize; + var x = BorderSize + OffsetSize; + var y = BorderSize + OffsetSize; if (OldStyle) { @@ -329,7 +329,7 @@ public class XmlCategorizedAddGump : Gump x += PrevWidth + OffsetSize; - int emptyWidth = TotalWidth - PrevWidth * 2 - NextWidth - OffsetSize * 5 - (OldStyle ? SetWidth + OffsetSize : 0); + var emptyWidth = TotalWidth - PrevWidth * 2 - NextWidth - OffsetSize * 5 - (OldStyle ? SetWidth + OffsetSize : 0); if (!OldStyle) { @@ -382,7 +382,7 @@ public class XmlCategorizedAddGump : Gump x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; - XmlAddCAGNode node = nodes[index]; + var node = nodes[index]; AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); AddLabelCropped(x + TextOffsetX, y + (EntryHeight - 20) / 2, EntryWidth - TextOffsetX, EntryHeight, TextHue, node.Caption); @@ -398,9 +398,9 @@ public class XmlCategorizedAddGump : Gump if (node is XmlAddCAGObject obj) { - int itemID = obj.ItemID; + var itemID = obj.ItemID; - Rectangle2D bounds = ItemBounds.Table[itemID]; + var bounds = ItemBounds.Table[itemID]; if (itemID != 1 && bounds.Height < EntryHeight * 2) { @@ -419,7 +419,7 @@ public class XmlCategorizedAddGump : Gump public override void OnResponse(NetState state, RelayInfo info) { - Mobile from = m_Owner; + var from = m_Owner; switch (info.ButtonID) { @@ -431,7 +431,7 @@ public class XmlCategorizedAddGump : Gump { if (m_Category.Parent != null) { - int index = Array.IndexOf(m_Category.Parent.Nodes, m_Category) / EntryCount; + var index = Array.IndexOf(m_Category.Parent.Nodes, m_Category) / EntryCount; if (index < 0) { @@ -463,7 +463,7 @@ public class XmlCategorizedAddGump : Gump } default: { - int index = m_Page * EntryCount + (info.ButtonID - 4); + var index = m_Page * EntryCount + (info.ButtonID - 4); if (index >= 0 && index < m_Category.Nodes.Length) { diff --git a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlPartialCategorizedAddGump.cs b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlPartialCategorizedAddGump.cs index 00de759ff..641714baf 100644 --- a/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlPartialCategorizedAddGump.cs +++ b/Projects/UOContent/Engines/XMLSpawner/XmlUtils/XmlPartialCategorizedAddGump.cs @@ -55,17 +55,17 @@ public class XmlPartialCategorizedAddGump : Gump if (searchResults.Count > 0) { - for (int i = page * 10; i < (page + 1) * 10 && i < searchResults.Count; ++i) + for (var i = page * 10; i < (page + 1) * 10 && i < searchResults.Count; ++i) { - int index = i % 10; + var index = i % 10; - SearchEntry se = (SearchEntry)searchResults[i]; + var se = (SearchEntry)searchResults[i]; - string labelstr = se.EntryType.Name; + var labelstr = se.EntryType.Name; if (se.Parameters.Length > 0) { - for (int j = 0; j < se.Parameters.Length; j++) + for (var j = 0; j < se.Parameters.Length; j++) { labelstr += $", {se.Parameters[j].Name}"; } @@ -122,19 +122,19 @@ public class XmlPartialCategorizedAddGump : Gump match = match.ToLower(); - for (int i = 0; i < types.Count; ++i) + for (var i = 0; i < types.Count; ++i) { - Type t = types[i]; + var t = types[i]; if ((typeofMobile.IsAssignableFrom(t) || typeofItem.IsAssignableFrom(t)) && t.Name.ToLower().IndexOf(match) >= 0 && !results.Contains(t)) { - ConstructorInfo[] ctors = t.GetConstructors(); + var ctors = t.GetConstructors(); - for (int j = 0; j < ctors.Length; ++j) + for (var j = 0; j < ctors.Length; ++j) { if (/*ctors[j].GetParameters().Length == 0 && */ ctors[j].IsDefined(typeof(ConstructibleAttribute), false)) { - SearchEntry s = new SearchEntry + var s = new SearchEntry { EntryType = t, Parameters = ctors[j].GetParameters() @@ -150,12 +150,12 @@ public class XmlPartialCategorizedAddGump : Gump public static ArrayList Match(string match) { - ArrayList results = new ArrayList(); + var results = new ArrayList(); Type[] types; - Assembly[] asms = AssemblyHandler.Assemblies; + var asms = AssemblyHandler.Assemblies; - for (int i = 0; i < asms.Length; ++i) + for (var i = 0; i < asms.Length; ++i) { types = AssemblyHandler.GetTypeCache(asms[i]).Types; Match(match, types, results); @@ -173,8 +173,8 @@ public class XmlPartialCategorizedAddGump : Gump { public int Compare(object x, object y) { - SearchEntry a = x as SearchEntry; - SearchEntry b = y as SearchEntry; + var a = x as SearchEntry; + var b = y as SearchEntry; return a.EntryType.Name.CompareTo(b.EntryType.Name); } @@ -183,14 +183,14 @@ public class XmlPartialCategorizedAddGump : Gump public override void OnResponse(Network.NetState sender, RelayInfo info) { - Mobile from = sender.Mobile; + var from = sender.Mobile; switch (info.ButtonID) { case 1: // Search { - TextRelay te = info.GetTextEntry(0); - string match = te == null ? "" : te.Text.Trim(); + var te = info.GetTextEntry(0); + var match = te == null ? "" : te.Text.Trim(); if (match.Length < 3) { @@ -224,11 +224,11 @@ public class XmlPartialCategorizedAddGump : Gump } default: { - int index = info.ButtonID - 4; + var index = info.ButtonID - 4; if (index >= 0 && index < m_SearchResults.Count) { - Type type = ((SearchEntry)m_SearchResults[index]).EntryType; + var type = ((SearchEntry)m_SearchResults[index]).EntryType; if (m_Gump is XmlAddGump mXmlAddGump && type != null) { @@ -240,7 +240,7 @@ public class XmlPartialCategorizedAddGump : Gump } else if (m_Spawner != null && type != null) { - XmlSpawnerGump xg = m_Spawner.SpawnerGump; + var xg = m_Spawner.SpawnerGump; if (xg != null) {