Minor touch ups

This commit is contained in:
Liza 2024-05-29 01:23:54 +02:00
parent 40a3e6c202
commit 63553e2326
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 25 additions and 30 deletions

View File

@ -13,16 +13,15 @@ namespace ZodiacFinder
{ {
public class Plugin : IDalamudPlugin public class Plugin : IDalamudPlugin
{ {
private readonly DalamudPluginInterface pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly IChatGui chat; private readonly IClientState _clientState;
private readonly IClientState clientState; private readonly IObjectTable _objectTable;
private readonly IObjectTable objectTable; private readonly IDataManager _dataManager;
private readonly IDataManager dataManager; private readonly IGameGui _gameGui;
private readonly IGameGui gameGui;
private readonly IDictionary<uint, Book> books = new Dictionary<uint, Book>(); private readonly IDictionary<uint, Book> _books = new Dictionary<uint, Book>();
private ISet<uint> atmaWeapons = new HashSet<uint> { private readonly ISet<uint> _atmaWeapons = new HashSet<uint> {
7824, // Curtana Atma 7824, // Curtana Atma
7825, // Sphairai Atma 7825, // Sphairai Atma
7826, // Bravura Atma 7826, // Bravura Atma
@ -36,25 +35,21 @@ namespace ZodiacFinder
9251, // Yoshimitsu Atma 9251, // Yoshimitsu Atma
}; };
public string Name => "ZodiacFinder";
public Plugin( public Plugin(
DalamudPluginInterface pi, DalamudPluginInterface pi,
ICommandManager commands,
IChatGui chat, IChatGui chat,
IClientState clientState, IClientState clientState,
IObjectTable objectTable, IObjectTable objectTable,
IDataManager dataManager, IDataManager dataManager,
IGameGui gameGui) IGameGui gameGui)
{ {
this.pluginInterface = pi; this._pluginInterface = pi;
this.chat = chat; this._clientState = clientState;
this.clientState = clientState; this._objectTable = objectTable;
this.objectTable = objectTable; this._dataManager = dataManager;
this.dataManager = dataManager; this._gameGui = gameGui;
this.gameGui = gameGui;
this.pluginInterface.UiBuilder.Draw += this.Draw; this._pluginInterface.UiBuilder.Draw += this.Draw;
this.PopulateBooks(); this.PopulateBooks();
} }
@ -64,7 +59,7 @@ namespace ZodiacFinder
{ {
if (!disposing) return; if (!disposing) return;
this.pluginInterface.UiBuilder.Draw -= this.Draw; this._pluginInterface.UiBuilder.Draw -= this.Draw;
} }
public void Dispose() public void Dispose()
@ -76,7 +71,7 @@ namespace ZodiacFinder
private unsafe void Draw() private unsafe void Draw()
{ {
if (!clientState.IsLoggedIn || clientState.IsPvP || objectTable == null || !HasAtmaWeaponEquipped()) if (!_clientState.IsLoggedIn || _clientState.IsPvP || _objectTable == null || !HasAtmaWeaponEquipped())
return; return;
var bookId = GetCurrentBook(); var bookId = GetCurrentBook();
@ -87,10 +82,10 @@ namespace ZodiacFinder
if (relicNote == null) if (relicNote == null)
return; return;
var book = books[bookId]; var book = _books[bookId];
for (int index = 0; index < objectTable.Length; ++index) for (int index = 0; index < _objectTable.Length; ++index)
{ {
GameObject obj = objectTable[index]; GameObject obj = _objectTable[index];
if (!(obj is BattleNpc npc) || npc.CurrentHp == 0) if (!(obj is BattleNpc npc) || npc.CurrentHp == 0)
continue; continue;
@ -101,7 +96,7 @@ namespace ZodiacFinder
if (relicNote->GetMonsterProgress(indexInBook) >= 3) if (relicNote->GetMonsterProgress(indexInBook) >= 3)
continue; continue;
if (!gameGui.WorldToScreen(new Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z), out var pos)) if (!_gameGui.WorldToScreen(new Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z), out var pos))
continue; continue;
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0)); ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
@ -122,7 +117,7 @@ namespace ZodiacFinder
private bool HasAtmaWeaponEquipped() private bool HasAtmaWeaponEquipped()
{ {
return atmaWeapons.Contains(GetEquippedItem(0)) || atmaWeapons.Contains(GetEquippedItem(1)); return _atmaWeapons.Contains(GetEquippedItem(0)) || _atmaWeapons.Contains(GetEquippedItem(1));
} }
private unsafe uint GetCurrentBook() private unsafe uint GetCurrentBook()
@ -139,7 +134,7 @@ namespace ZodiacFinder
continue; continue;
uint itemId = slot->ItemID; uint itemId = slot->ItemID;
if (books.ContainsKey(itemId)) if (_books.ContainsKey(itemId))
return itemId; return itemId;
} }
@ -165,7 +160,7 @@ namespace ZodiacFinder
private void PopulateBooks() private void PopulateBooks()
{ {
var relicNoteSheet = this.dataManager.GetExcelSheet<Excel.RelicNote>()!; var relicNoteSheet = this._dataManager.GetExcelSheet<Excel.RelicNote>()!;
foreach (var row in relicNoteSheet) foreach (var row in relicNoteSheet)
{ {
if (row.EventItem == null || row.EventItem.Row == 0) if (row.EventItem == null || row.EventItem.Row == 0)
@ -177,7 +172,7 @@ namespace ZodiacFinder
book.Enemies.Add(row.MonsterNoteTargetCommon[i].MonsterNoteTargetCommon.Value!.BNpcName.Row); book.Enemies.Add(row.MonsterNoteTargetCommon[i].MonsterNoteTargetCommon.Value!.BNpcName.Row);
} }
//chat.Print($"{row.EventItem.Row} - {book}"); //chat.Print($"{row.EventItem.Row} - {book}");
books.Add(row.EventItem.Row, book); _books.Add(row.EventItem.Row, book);
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<LangVersion>9.0</LangVersion> <LangVersion>9.0</LangVersion>
<Version>2.0.0.0</Version> <Version>2.0.0.0</Version>
<DebugType>none</DebugType> <DebugType>none</DebugType>
@ -14,7 +14,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.8" /> <PackageReference Include="DalamudPackager" Version="2.1.12" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>