소스 검색

Add settings.stylecop and apply style changes

Dragon 4 년 전
부모
커밋
65dc77e336
10개의 변경된 파일211개의 추가작업 그리고 171개의 파일을 삭제
  1. 1 1
      Attributes/AliasesAttribute.cs
  2. 1 1
      Attributes/CommandAttribute.cs
  3. 1 1
      Attributes/HelpMessageAttribute.cs
  4. 84 73
      Interface.cs
  5. 4 3
      Ipc/TeleportConsumer.cs
  6. 26 20
      Location.cs
  7. 11 1
      MobHuntEntry.cs
  8. 54 48
      Plugin.cs
  9. 29 23
      PluginCommandManager.cs
  10. BIN
      settings.stylecop

+ 1 - 1
Attributes/AliasesAttribute.cs

@@ -9,7 +9,7 @@ namespace HuntBuddy.Attributes
 
 		public AliasesAttribute(params string[] aliases)
 		{
-			Aliases = aliases;
+			this.Aliases = aliases;
 		}
 	}
 }

+ 1 - 1
Attributes/CommandAttribute.cs

@@ -9,7 +9,7 @@ namespace HuntBuddy.Attributes
 
 		public CommandAttribute(string command)
 		{
-			Command = command;
+			this.Command = command;
 		}
 	}
 }

+ 1 - 1
Attributes/HelpMessageAttribute.cs

@@ -9,7 +9,7 @@ namespace HuntBuddy.Attributes
 
 		public HelpMessageAttribute(string helpMessage)
 		{
-			HelpMessage = helpMessage;
+			this.HelpMessage = helpMessage;
 		}
 	}
 }

+ 84 - 73
Interface.cs

@@ -1,42 +1,35 @@
-using System;
-using System.Linq;
+using System.Linq;
 using System.Numerics;
 using System.Threading.Tasks;
-using Dalamud.Game.Text.SeStringHandling.Payloads;
 using Dalamud.Interface;
-using Dalamud.Logging;
-using HuntBuddy.Structs;
 using ImGuiNET;
-using Lumina.Excel.GeneratedSheets;
 
 namespace HuntBuddy
 {
 	public class Interface
 	{
-		private readonly Plugin _plugin;
+		private readonly Plugin plugin;
 
 		public bool DrawInterface;
-		private bool _drawConfigurationInterface;
+		private bool drawConfigurationInterface;
 
 		public Interface(Plugin plugin)
 		{
-			this._plugin = plugin;
+			this.plugin = plugin;
 		}
 
 		public unsafe bool Draw()
 		{
 			var draw = true;
 
-			var fontGlobalScale = ImGui.GetIO().FontGlobalScale;
-
 			ImGui.SetNextWindowSize(new Vector2(400 * ImGui.GetIO().FontGlobalScale, 500), ImGuiCond.Once);
 
-			if (!ImGui.Begin($"{this._plugin.Name}", ref draw, ImGuiWindowFlags.NoDocking))
+			if (!ImGui.Begin($"{this.plugin.Name}", ref draw, ImGuiWindowFlags.NoDocking))
 			{
 				return draw;
 			}
 
-			if (!this._plugin.MobHuntEntriesReady)
+			if (!this.plugin.MobHuntEntriesReady)
 			{
 				ImGui.Text("Reloading data ...");
 				ImGui.End();
@@ -46,8 +39,8 @@ namespace HuntBuddy
 			if (Interface.IconButton(FontAwesomeIcon.Redo, "Reload"))
 			{
 				ImGui.End();
-				this._plugin.MobHuntEntriesReady = false;
-				Task.Run(() => this._plugin.ReloadData());
+				this.plugin.MobHuntEntriesReady = false;
+				Task.Run(() => this.plugin.ReloadData());
 				return draw;
 			}
 
@@ -57,36 +50,41 @@ namespace HuntBuddy
 				ImGui.Text("Click this button to reload daily hunt data");
 				ImGui.EndTooltip();
 			}
-			
+
 			ImGui.SameLine();
 
 			if (Interface.IconButton(FontAwesomeIcon.Cog, "Config"))
 			{
-				this._drawConfigurationInterface = !this._drawConfigurationInterface;
+				this.drawConfigurationInterface = !this.drawConfigurationInterface;
 			}
 
-			foreach (var expansionEntry in this._plugin.MobHuntEntries.Where(expansionEntry =>
-				         ImGui.TreeNode(expansionEntry.Key)))
+			foreach (var expansionEntry in this.plugin.MobHuntEntries.Where(
+				         expansionEntry =>
+					         ImGui.TreeNode(expansionEntry.Key)))
 			{
-				foreach (var entry in expansionEntry.Value.Where(entry =>
-				         {
-					         var treeOpen = ImGui.TreeNodeEx(entry.Key.Value, ImGuiTreeNodeFlags.AllowItemOverlap);
-					         ImGui.SameLine();
-					         var killedCount = entry.Value.Count(x =>
-						         this._plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills);
-
-					         if (killedCount != entry.Value.Count)
-					         {
-						         ImGui.Text($"({killedCount}/{entry.Value.Count})");
-					         }
-					         else
+				foreach (var entry in expansionEntry.Value.Where(
+					         entry =>
 					         {
-						         ImGui.TextColored(new Vector4(0f, 1f, 0f, 1f),
-							         $"({killedCount}/{entry.Value.Count})");
-					         }
-
-					         return treeOpen;
-				         }))
+						         var treeOpen = ImGui.TreeNodeEx(entry.Key.Value, ImGuiTreeNodeFlags.AllowItemOverlap);
+						         ImGui.SameLine();
+						         var killedCount = entry.Value.Count(
+							         x =>
+								         this.plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] ==
+								         x.NeededKills);
+
+						         if (killedCount != entry.Value.Count)
+						         {
+							         ImGui.Text($"({killedCount}/{entry.Value.Count})");
+						         }
+						         else
+						         {
+							         ImGui.TextColored(
+								         new Vector4(0f, 1f, 0f, 1f),
+								         $"({killedCount}/{entry.Value.Count})");
+						         }
+
+						         return treeOpen;
+					         }))
 				{
 					ImGui.Indent();
 					foreach (var mobHuntEntry in entry.Value)
@@ -95,7 +93,9 @@ namespace HuntBuddy
 						{
 							if (Interface.IconButton(FontAwesomeIcon.MapMarked, $"##{mobHuntEntry.MobHuntId}"))
 							{
-								Location.OpenMapLink(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
+								Location.OpenMapLink(
+									mobHuntEntry.TerritoryType,
+									mobHuntEntry.MapId,
 									mobHuntEntry.MobHuntId);
 							}
 
@@ -112,7 +112,9 @@ namespace HuntBuddy
 							{
 								if (Interface.IconButton(FontAwesomeIcon.StreetView, $"t##{mobHuntEntry.MobHuntId}"))
 								{
-									Location.TeleportToNearestAetheryte(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
+									Location.TeleportToNearestAetheryte(
+										mobHuntEntry.TerritoryType,
+										mobHuntEntry.MapId,
 										mobHuntEntry.MobHuntId);
 								}
 
@@ -127,7 +129,7 @@ namespace HuntBuddy
 							}
 						}
 
-						var currentKills = this._plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
+						var currentKills = this.plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
 						ImGui.Text(mobHuntEntry.Name);
 						if (ImGui.IsItemHovered())
 						{
@@ -145,7 +147,8 @@ namespace HuntBuddy
 						}
 						else
 						{
-							ImGui.TextColored(new Vector4(0f, 1f, 0f, 1f),
+							ImGui.TextColored(
+								new Vector4(0f, 1f, 0f, 1f),
 								$"({currentKills}/{mobHuntEntry.NeededKills})");
 						}
 					}
@@ -159,7 +162,7 @@ namespace HuntBuddy
 
 			ImGui.End();
 
-			if (this._drawConfigurationInterface)
+			if (this.drawConfigurationInterface)
 			{
 				this.DrawConfiguration();
 			}
@@ -169,22 +172,21 @@ namespace HuntBuddy
 
 		public unsafe void DrawLocalHunts()
 		{
-			if (!this._plugin.Configuration.ShowLocalHunts ||
-			    this._plugin.CurrentAreaMobHuntEntries.IsEmpty ||
-			    this._plugin.CurrentAreaMobHuntEntries.Count(x =>
-				    this._plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills) ==
-			    this._plugin.CurrentAreaMobHuntEntries.Count)
+			if (!this.plugin.Configuration.ShowLocalHunts ||
+			    this.plugin.CurrentAreaMobHuntEntries.IsEmpty ||
+			    this.plugin.CurrentAreaMobHuntEntries.Count(
+				    x =>
+					    this.plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills) ==
+			    this.plugin.CurrentAreaMobHuntEntries.Count)
 			{
 				return;
 			}
 
-			var fontGlobalScale = ImGui.GetIO().FontGlobalScale;
-
 			ImGui.SetNextWindowSize(Vector2.Zero, ImGuiCond.Always);
 
 			var windowFlags = ImGuiWindowFlags.NoNavInputs | ImGuiWindowFlags.NoDocking;
 
-			if (this._plugin.Configuration.HideLocalHuntBackground)
+			if (this.plugin.Configuration.HideLocalHuntBackground)
 			{
 				windowFlags |= ImGuiWindowFlags.NoBackground;
 			}
@@ -194,11 +196,11 @@ namespace HuntBuddy
 				return;
 			}
 
-			foreach (var mobHuntEntry in this._plugin.CurrentAreaMobHuntEntries)
+			foreach (var mobHuntEntry in this.plugin.CurrentAreaMobHuntEntries)
 			{
-				var currentKills = this._plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
+				var currentKills = this.plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
 
-				if (this._plugin.Configuration.HideCompletedHunts && currentKills == mobHuntEntry.NeededKills)
+				if (this.plugin.Configuration.HideCompletedHunts && currentKills == mobHuntEntry.NeededKills)
 				{
 					continue;
 				}
@@ -207,7 +209,9 @@ namespace HuntBuddy
 				{
 					if (Interface.IconButton(FontAwesomeIcon.MapMarked, $"##{mobHuntEntry.MobHuntId}"))
 					{
-						Location.OpenMapLink(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
+						Location.OpenMapLink(
+							mobHuntEntry.TerritoryType,
+							mobHuntEntry.MapId,
 							mobHuntEntry.MobHuntId);
 					}
 
@@ -216,7 +220,7 @@ namespace HuntBuddy
 
 				ImGui.Text($"{mobHuntEntry.Name} ({currentKills}/{mobHuntEntry.NeededKills})");
 
-				if (!this._plugin.Configuration.ShowLocalHuntIcons)
+				if (!this.plugin.Configuration.ShowLocalHuntIcons)
 				{
 					continue;
 				}
@@ -231,33 +235,36 @@ namespace HuntBuddy
 		{
 			ImGui.SetNextWindowSize(Vector2.Zero, ImGuiCond.Always);
 
-			if (!ImGui.Begin($"{this._plugin.Name} settings", ImGuiWindowFlags.NoDocking))
+			if (!ImGui.Begin($"{this.plugin.Name} settings", ImGuiWindowFlags.NoDocking))
 			{
 				return;
 			}
 
 			var save = false;
 
-			save |= ImGui.Checkbox("Show hunts in local area", ref this._plugin.Configuration.ShowLocalHunts);
-			save |= ImGui.Checkbox("Show icons of hunts in local area", ref this._plugin.Configuration.ShowLocalHuntIcons);
-			save |= ImGui.Checkbox("Hide background of local hunts window",
-				ref this._plugin.Configuration.HideLocalHuntBackground);
-			save |= ImGui.Checkbox("Hide completed targets in local hunts window",
-				ref this._plugin.Configuration.HideCompletedHunts);
-			save |= ImGui.SliderFloat("Hunt icon scale", ref this._plugin.Configuration.IconScale, 0.2f, 2f, "%.2f");
-			if (ImGui.ColorEdit4("Hunt icon background colour", ref this._plugin.Configuration.IconBackgroundColour))
+			save |= ImGui.Checkbox("Show hunts in local area", ref this.plugin.Configuration.ShowLocalHunts);
+			save |= ImGui.Checkbox(
+				"Show icons of hunts in local area",
+				ref this.plugin.Configuration.ShowLocalHuntIcons);
+			save |= ImGui.Checkbox(
+				"Hide background of local hunts window",
+				ref this.plugin.Configuration.HideLocalHuntBackground);
+			save |= ImGui.Checkbox(
+				"Hide completed targets in local hunts window",
+				ref this.plugin.Configuration.HideCompletedHunts);
+			save |= ImGui.SliderFloat("Hunt icon scale", ref this.plugin.Configuration.IconScale, 0.2f, 2f, "%.2f");
+			if (ImGui.ColorEdit4("Hunt icon background colour", ref this.plugin.Configuration.IconBackgroundColour))
 			{
-				this._plugin.Configuration.IconBackgroundColourU32 =
-					ImGui.ColorConvertFloat4ToU32(this._plugin.Configuration.IconBackgroundColour);
+				this.plugin.Configuration.IconBackgroundColourU32 =
+					ImGui.ColorConvertFloat4ToU32(this.plugin.Configuration.IconBackgroundColour);
 				save = true;
 			}
 
 			if (save)
 			{
-				this._plugin.Configuration.Save();
+				this.plugin.Configuration.Save();
 			}
 
-
 			ImGui.End();
 		}
 
@@ -282,20 +289,24 @@ namespace HuntBuddy
 		{
 			var cursorPos = ImGui.GetCursorScreenPos();
 			var imageSize = mobHuntEntry.ExpansionId < 3 ? new Vector2(192f, 128f) : new Vector2(210f);
-			imageSize *= ImGui.GetIO().FontGlobalScale * this._plugin.Configuration.IconScale;
+			imageSize *= ImGui.GetIO().FontGlobalScale * this.plugin.Configuration.IconScale;
 
 			ImGui.InvisibleButton("canvas", imageSize);
 
 			var drawList = ImGui.GetWindowDrawList();
 			if (mobHuntEntry.ExpansionId == 4 && !mobHuntEntry.IsEliteMark) // Endwalker uses circle for non elite mobs
 			{
-				drawList.AddCircleFilled(cursorPos + imageSize / 2f, imageSize.X / 2f,
-					this._plugin.Configuration.IconBackgroundColourU32);
+				drawList.AddCircleFilled(
+					cursorPos + (imageSize / 2f),
+					imageSize.X / 2f,
+					this.plugin.Configuration.IconBackgroundColourU32);
 			}
 			else
 			{
-				drawList.AddRectFilled(cursorPos, cursorPos + imageSize,
-					this._plugin.Configuration.IconBackgroundColourU32);
+				drawList.AddRectFilled(
+					cursorPos,
+					cursorPos + imageSize,
+					this.plugin.Configuration.IconBackgroundColourU32);
 			}
 
 			drawList.AddImage(mobHuntEntry.Icon.ImGuiHandle, cursorPos, cursorPos + imageSize);

+ 4 - 3
Ipc/TeleportConsumer.cs

@@ -7,13 +7,14 @@ namespace HuntBuddy.Ipc
 	public class TeleportConsumer
 	{
 		public bool Subscribed { get; private set; }
-		private ICallGateSubscriber<uint, byte, bool> _consumerTeleport = null!;
+
+		private ICallGateSubscriber<uint, byte, bool> consumerTeleport = null!;
 
 		private void Subscribe()
 		{
 			try
 			{
-				this._consumerTeleport = Plugin.PluginInterface.GetIpcSubscriber<uint, byte, bool>("Teleport");
+				this.consumerTeleport = Plugin.PluginInterface.GetIpcSubscriber<uint, byte, bool>("Teleport");
 
 				this.Subscribed = true;
 			}
@@ -30,7 +31,7 @@ namespace HuntBuddy.Ipc
 		{
 			try
 			{
-				return this._consumerTeleport.InvokeFunc(aetheryteId, 0);
+				return this.consumerTeleport.InvokeFunc(aetheryteId, 0);
 			}
 			catch
 			{

+ 26 - 20
Location.cs

@@ -10,9 +10,11 @@ namespace HuntBuddy
 	{
 		public class PositionInfo
 		{
-			public float X { get; set; }
-			public float Y { get; set; }
-			public Vector2 Coordinate => new (this.X, this.Y);
+			public float X { get; init; }
+
+			public float Y { get; init; }
+
+			public Vector2 Coordinate => new(this.X, this.Y);
 		}
 
 		// MobHuntId as key
@@ -346,7 +348,6 @@ namespace HuntBuddy
 			{ 08630, new PositionInfo { X = 29.0f, Y = 21.0f } }, // Tempest Swallow
 			{ 08631, new PositionInfo { X = 35.8f, Y = 07.2f } }, // Blue Swimmer
 
-
 			// Endwalker
 			// Labyrinthos
 			{ 10668, new PositionInfo { X = 28.8f, Y = 08.8f } }, // Troll
@@ -455,21 +456,22 @@ namespace HuntBuddy
 			var mapLinkPayload = new MapLinkPayload(territoryType, mapId, Database[mobHuntId].X, Database[mobHuntId].Y);
 			Plugin.GameGui.OpenMapWithMapLink(mapLinkPayload);
 		}
-		
+
 		private static Vector2 ConvertPixelPositionToMapCoordinate(int x, int y, float scale)
 		{
 			var num = scale / 100f;
-			return new Vector2(ConvertRawPositionToMapCoordinate((int)((x - 1024) * num * 1000f), scale),
+			return new Vector2(
+				ConvertRawPositionToMapCoordinate((int)((x - 1024) * num * 1000f), scale),
 				ConvertRawPositionToMapCoordinate((int)((y - 1024) * num * 1000f), scale));
 		}
-		
+
 		private static float ConvertRawPositionToMapCoordinate(int pos, float scale)
 		{
 			var num1 = scale / 100f;
-			var num2 = (float) (pos * (double) num1 / 1000.0f);
-			return (float) (40.96f / num1 * ((num2 + 1024.0f) / 2048.0f) + 1.0f);
+			var num2 = (float)(pos * (double)num1 / 1000.0f);
+			return (40.96f / num1 * ((num2 + 1024.0f) / 2048.0f)) + 1.0f;
 		}
-		
+
 		public static void TeleportToNearestAetheryte(uint territoryType, uint mapId, uint mobHuntId)
 		{
 			var mapRow = Plugin.DataManager.Excel.GetSheet<Map>()?.GetRow(mapId);
@@ -481,19 +483,23 @@ namespace HuntBuddy
 
 			var nearestAetheryteId = Plugin.DataManager.Excel.GetSheet<MapMarker>()
 				?.Where(x => x.DataType == 3 && x.RowId == mapRow.MapMarkerRange)
-				.Select(x => new
-				{
-					distance = Vector2.DistanceSquared(Database[mobHuntId].Coordinate,
-						ConvertPixelPositionToMapCoordinate(x.X, x.Y, mapRow.SizeFactor)),
-					rowId = x.DataKey
-				})
+				.Select(
+					x => new
+					{
+						distance = Vector2.DistanceSquared(
+							Database[mobHuntId].Coordinate,
+							ConvertPixelPositionToMapCoordinate(x.X, x.Y, mapRow.SizeFactor)),
+						rowId = x.DataKey
+					})
 				.OrderBy(x => x.distance)
 				.FirstOrDefault()?.rowId;
 
-			var nearestAetheryte = territoryType == 399 // Support the unique case of aetheryte not being in the same map
-				? mapRow.TerritoryType?.Value?.Aetheryte.Value
-				: Plugin.DataManager.Excel.GetSheet<Aetheryte>()?.FirstOrDefault(x =>
-					x.IsAetheryte && x.Territory.Row == territoryType && x.RowId == nearestAetheryteId);
+			var nearestAetheryte =
+				territoryType == 399 // Support the unique case of aetheryte not being in the same map
+					? mapRow.TerritoryType?.Value?.Aetheryte.Value
+					: Plugin.DataManager.Excel.GetSheet<Aetheryte>()?.FirstOrDefault(
+						x =>
+							x.IsAetheryte && x.Territory.Row == territoryType && x.RowId == nearestAetheryteId);
 
 			if (nearestAetheryte == null)
 			{

+ 11 - 1
MobHuntEntry.cs

@@ -6,20 +6,30 @@ namespace HuntBuddy
 	public class MobHuntEntry : IDisposable
 	{
 		public string? Name { get; init; }
+
 		public string? TerritoryName { get; init; }
+
 		public string? ExpansionName { get; init; }
+
 		public uint ExpansionId { get; init; }
+
 		public uint MapId { get; init; }
+
 		public uint TerritoryType { get; init; }
+
 		public uint MobHuntId { get; init; }
+
 		public bool IsEliteMark { get; init; }
+
 		public uint CurrentKillsOffset { get; init; }
+
 		public uint NeededKills { get; set; }
+
 		public TextureWrap Icon { get; init; } = null!;
 
 		public void Dispose()
 		{
-			Icon.Dispose();
+			this.Icon.Dispose();
 		}
 	}
 }

+ 54 - 48
Plugin.cs

@@ -10,11 +10,9 @@ using Dalamud.Game.ClientState;
 using Dalamud.Game.Command;
 using Dalamud.Game.Gui;
 using Dalamud.IoC;
-using Dalamud.Logging;
 using Dalamud.Plugin;
 using Dalamud.Utility;
 using Lumina.Excel.GeneratedSheets;
-using FFXIVClientStructs.FFXIV.Client.Game;
 using HuntBuddy.Attributes;
 using HuntBuddy.Ipc;
 using HuntBuddy.Structs;
@@ -43,15 +41,15 @@ namespace HuntBuddy
 		[PluginService]
 		[RequiredVersion("1.0")]
 		public static DataManager DataManager { get; set; } = null!;
-		
+
 		[PluginService]
 		[RequiredVersion("1.0")]
 		public static SigScanner SigScanner { get; set; } = null!;
-		
+
 		[PluginService]
 		[RequiredVersion("1.0")]
 		public static GameGui GameGui { get; set; } = null!;
-		
+
 		[PluginService]
 		[RequiredVersion("1.0")]
 		public static ClientState ClientState { get; set; } = null!;
@@ -60,9 +58,9 @@ namespace HuntBuddy
 		[RequiredVersion("1.0")]
 		public static Framework Framework { get; set; } = null!;
 
-		private readonly PluginCommandManager<Plugin> _commandManager;
-		private readonly Interface _interface;
-		private ObtainedBillEnum _lastState;
+		private readonly PluginCommandManager<Plugin> commandManager;
+		private readonly Interface pluginInterface;
+		private ObtainedBillEnum lastState;
 		public readonly Dictionary<string, Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>> MobHuntEntries;
 		public readonly ConcurrentBag<MobHuntEntry> CurrentAreaMobHuntEntries;
 		public bool MobHuntEntriesReady = true;
@@ -72,8 +70,8 @@ namespace HuntBuddy
 
 		public Plugin()
 		{
-			this._commandManager = new PluginCommandManager<Plugin>(this, Commands);
-			this._interface = new Interface(this);
+			this.commandManager = new PluginCommandManager<Plugin>(this, Commands);
+			this.pluginInterface = new Interface(this);
 			this.MobHuntEntries = new Dictionary<string, Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>>();
 			this.CurrentAreaMobHuntEntries = new ConcurrentBag<MobHuntEntry>();
 			this.Configuration = (Configuration)(PluginInterface.GetPluginConfig() ?? new Configuration());
@@ -88,31 +86,32 @@ namespace HuntBuddy
 			}
 
 			Plugin.TeleportConsumer = new TeleportConsumer();
-			Plugin.ClientState.TerritoryChanged += ClientStateOnTerritoryChanged;
-			Plugin.PluginInterface.UiBuilder.Draw += DrawInterface;
-			Plugin.PluginInterface.UiBuilder.Draw += _interface.DrawLocalHunts;
-			Plugin.PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
-			Plugin.Framework.Update += FrameworkOnUpdate;
+			Plugin.ClientState.TerritoryChanged += this.ClientStateOnTerritoryChanged;
+			Plugin.PluginInterface.UiBuilder.Draw += this.DrawInterface;
+			Plugin.PluginInterface.UiBuilder.Draw += this.pluginInterface.DrawLocalHunts;
+			Plugin.PluginInterface.UiBuilder.OpenConfigUi += this.OpenConfigUi;
+			Plugin.Framework.Update += this.FrameworkOnUpdate;
 		}
 
 		private unsafe void FrameworkOnUpdate(Framework framework)
 		{
-			if (this._lastState == this.MobHuntStruct->ObtainedBillEnumFlags)
+			if (this.lastState == this.MobHuntStruct->ObtainedBillEnumFlags)
 			{
 				return;
 			}
 
-			this._lastState = this.MobHuntStruct->ObtainedBillEnumFlags;
-			PluginCommand(string.Empty, "reload");
+			this.lastState = this.MobHuntStruct->ObtainedBillEnumFlags;
+			this.PluginCommand(string.Empty, "reload");
 		}
 
 		private void ClientStateOnTerritoryChanged(object? sender, ushort e)
 		{
 			this.CurrentAreaMobHuntEntries.Clear();
 
-			foreach (var mobHuntEntry in this.MobHuntEntries.SelectMany(expansionEntry => expansionEntry.Value
-				         .Where(entry => entry.Key.Key == Plugin.ClientState.TerritoryType)
-				         .SelectMany(entry => entry.Value)))
+			foreach (var mobHuntEntry in this.MobHuntEntries.SelectMany(
+				         expansionEntry => expansionEntry.Value
+					         .Where(entry => entry.Key.Key == Plugin.ClientState.TerritoryType)
+					         .SelectMany(entry => entry.Value)))
 			{
 				this.CurrentAreaMobHuntEntries.Add(mobHuntEntry);
 			}
@@ -120,12 +119,12 @@ namespace HuntBuddy
 
 		private void OpenConfigUi()
 		{
-			this._interface.DrawInterface = !this._interface.DrawInterface;
+			this.pluginInterface.DrawInterface = !this.pluginInterface.DrawInterface;
 		}
 
 		private void DrawInterface()
 		{
-			this._interface.DrawInterface = this._interface.DrawInterface && this._interface.Draw();
+			this.pluginInterface.DrawInterface = this.pluginInterface.DrawInterface && this.pluginInterface.Draw();
 		}
 
 		private void Dispose(bool disposing)
@@ -136,12 +135,12 @@ namespace HuntBuddy
 			}
 
 			this.MobHuntEntriesReady = false;
-			Plugin.Framework.Update -= FrameworkOnUpdate;
+			Plugin.Framework.Update -= this.FrameworkOnUpdate;
 			Plugin.PluginInterface.UiBuilder.Draw -= this.DrawInterface;
-			Plugin.PluginInterface.UiBuilder.Draw -= this._interface.DrawLocalHunts;
+			Plugin.PluginInterface.UiBuilder.Draw -= this.pluginInterface.DrawLocalHunts;
 			Plugin.PluginInterface.UiBuilder.OpenConfigUi -= this.OpenConfigUi;
 
-			this._commandManager.Dispose();
+			this.commandManager.Dispose();
 		}
 
 		[Command("/phb")]
@@ -164,7 +163,7 @@ namespace HuntBuddy
 			this.MobHuntEntries.Clear();
 			var mobHuntList = new List<MobHuntEntry>();
 			var mobHuntOrderSheet = Plugin.DataManager.Excel.GetSheet<MobHuntOrder>()!;
-			
+
 			foreach (var billNumber in Enum.GetValues<BillEnum>())
 			{
 				if (!this.MobHuntStruct->ObtainedBillEnumFlags.HasFlag((ObtainedBillEnum)(1 << (int)billNumber)))
@@ -172,8 +171,9 @@ namespace HuntBuddy
 					continue;
 				}
 
-				var mobHuntOrderTypeRow = Plugin.DataManager.Excel.GetSheet<MobHuntOrderType>()!.GetRow((uint)billNumber)!;
-					
+				var mobHuntOrderTypeRow =
+					Plugin.DataManager.Excel.GetSheet<MobHuntOrderType>()!.GetRow((uint)billNumber)!;
+
 				var rowId = mobHuntOrderTypeRow.OrderStart.Value!.RowId +
 				            (uint)(this.MobHuntStruct->BillOffset[mobHuntOrderTypeRow.RowId] - 1);
 
@@ -191,20 +191,26 @@ namespace HuntBuddy
 
 					if (mobHuntEntry == null)
 					{
-						mobHuntList.Add(new MobHuntEntry
-						{
-							Name = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(mobHuntOrderRow.Target.Value!.Name.Value!.Singular),
-							TerritoryName = mobHuntOrderRow.Target.Value!.TerritoryType.Value!.PlaceName.Value!.Name,
-							ExpansionName = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Value!.ExVersion.Value!.Name,
-							ExpansionId = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Value!.ExVersion.Row,
-							MapId = mobHuntOrderRow.Target.Value!.TerritoryType.Row,
-							TerritoryType = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Row,
-							MobHuntId = mobHuntOrderRow.Target.Value!.Name.Row,
-							IsEliteMark = billNumber is BillEnum.ArrElite or BillEnum.HwElite or BillEnum.SbElite or BillEnum.ShbElite or BillEnum.EwElite,
-							CurrentKillsOffset = 5 * (uint)billNumber + mobHuntOrderRow.SubRowId,
-							NeededKills = mobHuntOrderRow.NeededKills,
-							Icon = Plugin.LoadIcon(mobHuntOrderRow.Target.Value.Icon)
-						});
+						mobHuntList.Add(
+							new MobHuntEntry
+							{
+								Name = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(
+									mobHuntOrderRow.Target.Value!.Name.Value!.Singular),
+								TerritoryName =
+									mobHuntOrderRow.Target.Value!.TerritoryType.Value!.PlaceName.Value!.Name,
+								ExpansionName = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Value!
+									.ExVersion.Value!.Name,
+								ExpansionId = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Value!
+									.ExVersion.Row,
+								MapId = mobHuntOrderRow.Target.Value!.TerritoryType.Row,
+								TerritoryType = mobHuntOrderRow.Target.Value!.TerritoryType.Value.TerritoryType.Row,
+								MobHuntId = mobHuntOrderRow.Target.Value!.Name.Row,
+								IsEliteMark = billNumber is BillEnum.ArrElite or BillEnum.HwElite or BillEnum.SbElite
+									or BillEnum.ShbElite or BillEnum.EwElite,
+								CurrentKillsOffset = (5 * (uint)billNumber) + mobHuntOrderRow.SubRowId,
+								NeededKills = mobHuntOrderRow.NeededKills,
+								Icon = Plugin.LoadIcon(mobHuntOrderRow.Target.Value.Icon)
+							});
 					}
 					else
 					{
@@ -215,12 +221,12 @@ namespace HuntBuddy
 					}
 				}
 			}
-			
+
 			foreach (var entry in mobHuntList)
 			{
 				var key = entry.ExpansionName ?? "Unknown";
 				var subKey = new KeyValuePair<uint, string>(entry.TerritoryType, entry.TerritoryName ?? "Unknown");
-					
+
 				if (!this.MobHuntEntries.ContainsKey(key))
 				{
 					this.MobHuntEntries[key] = new Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>();
@@ -230,7 +236,7 @@ namespace HuntBuddy
 				{
 					this.MobHuntEntries[key][subKey] = new List<MobHuntEntry>();
 				}
-					
+
 				this.MobHuntEntries[key][subKey].Add(entry);
 			}
 
@@ -238,7 +244,7 @@ namespace HuntBuddy
 
 			this.MobHuntEntriesReady = true;
 		}
-		
+
 		private static TexFile? GetHdIcon(uint id)
 		{
 			var path = $"ui/icon/{id / 1000 * 1000:000000}/{id:000000}_hr1.tex";
@@ -247,7 +253,7 @@ namespace HuntBuddy
 
 		private static TextureWrap LoadIcon(uint id)
 		{
-			var icon     = Plugin.GetHdIcon(id) ?? Plugin.DataManager.GetIcon(id)!;
+			var icon = Plugin.GetHdIcon(id) ?? Plugin.DataManager.GetIcon(id)!;
 			var iconData = icon.GetRgbaImageData();
 
 			return Plugin.PluginInterface.UiBuilder.LoadImageRaw(iconData, icon.Header.Width, icon.Header.Height, 4);

+ 29 - 23
PluginCommandManager.cs

@@ -9,22 +9,23 @@ namespace HuntBuddy
 {
 	public class PluginCommandManager<THost> : IDisposable
 	{
-		private readonly CommandManager _commandManager;
-		private readonly (string, CommandInfo)[] _pluginCommands;
-		private readonly THost _host;
+		private readonly CommandManager commandManager;
+		private readonly (string, CommandInfo)[] pluginCommands;
+		private readonly THost host;
 
 		public PluginCommandManager(THost host, CommandManager commandManager)
 		{
-			this._commandManager = commandManager;
-			this._host = host;
+			this.commandManager = commandManager;
+			this.host = host;
 
-			this._pluginCommands = host!.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public |
-			                                                BindingFlags.Static | BindingFlags.Instance)
+			this.pluginCommands = host!.GetType().GetMethods(
+					BindingFlags.NonPublic | BindingFlags.Public |
+					BindingFlags.Static | BindingFlags.Instance)
 				.Where(method => method.GetCustomAttribute<CommandAttribute>() != null)
-				.SelectMany(GetCommandInfoTuple)
+				.SelectMany(this.GetCommandInfoTuple)
 				.ToArray();
 
-			AddCommandHandlers();
+			this.AddCommandHandlers();
 		}
 
 		// http://codebetter.com/patricksmacchia/2008/11/19/an-easy-and-efficient-way-to-improve-net-code-performances/
@@ -33,25 +34,28 @@ namespace HuntBuddy
 		// It's usually sub-1 millisecond anyways, though. It probably doesn't matter at all.
 		private void AddCommandHandlers()
 		{
-			for (var i = 0; i < this._pluginCommands.Length; i++)
+			foreach (var t in this.pluginCommands)
 			{
-				var (command, commandInfo) = this._pluginCommands[i];
-				this._commandManager.AddHandler(command, commandInfo);
+				var (command, commandInfo) = t;
+				this.commandManager.AddHandler(command, commandInfo);
 			}
 		}
 
 		private void RemoveCommandHandlers()
 		{
-			for (var i = 0; i < this._pluginCommands.Length; i++)
+			foreach (var t in this.pluginCommands)
 			{
-				var (command, _) = this._pluginCommands[i];
-				this._commandManager.RemoveHandler(command);
+				var (command, _) = t;
+				this.commandManager.RemoveHandler(command);
 			}
 		}
 
 		private IEnumerable<(string, CommandInfo)> GetCommandInfoTuple(MethodInfo method)
 		{
-			var handlerDelegate = (CommandInfo.HandlerDelegate)Delegate.CreateDelegate(typeof(CommandInfo.HandlerDelegate), this._host, method);
+			var handlerDelegate = (CommandInfo.HandlerDelegate)Delegate.CreateDelegate(
+				typeof(CommandInfo.HandlerDelegate),
+				this.host,
+				method);
 
 			var command = handlerDelegate.Method.GetCustomAttribute<CommandAttribute>();
 			var aliases = handlerDelegate.Method.GetCustomAttribute<AliasesAttribute>();
@@ -66,13 +70,15 @@ namespace HuntBuddy
 
 			// Create list of tuples that will be filled with one tuple per alias, in addition to the base command tuple.
 			var commandInfoTuples = new List<(string, CommandInfo)> { (command!.Command, commandInfo) };
-			if (aliases != null)
+			if (aliases == null)
 			{
-				// ReSharper disable once LoopCanBeConvertedToQuery
-				for (var i = 0; i < aliases.Aliases.Length; i++)
-				{
-					commandInfoTuples.Add((aliases.Aliases[i], commandInfo));
-				}
+				return commandInfoTuples;
+			}
+
+			// ReSharper disable once LoopCanBeConvertedToQuery
+			foreach (var t in aliases.Aliases)
+			{
+				commandInfoTuples.Add((t, commandInfo));
 			}
 
 			return commandInfoTuples;
@@ -80,7 +86,7 @@ namespace HuntBuddy
 
 		public void Dispose()
 		{
-			RemoveCommandHandlers();
+			this.RemoveCommandHandlers();
 			GC.SuppressFinalize(this);
 		}
 	}

BIN
settings.stylecop