From 59684ce21224e6a1093c0a4e83cc0220660a8346 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 12 Aug 2024 16:21:34 +0200 Subject: [PATCH] GPR: Only show when on gatherer --- GatheringPathRenderer/GatheringPathRenderer.csproj | 1 + GatheringPathRenderer/RendererPlugin.cs | 11 ++++++++++- GatheringPathRenderer/packages.lock.json | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/GatheringPathRenderer/GatheringPathRenderer.csproj b/GatheringPathRenderer/GatheringPathRenderer.csproj index 1d3aeae5c..fc157f207 100644 --- a/GatheringPathRenderer/GatheringPathRenderer.csproj +++ b/GatheringPathRenderer/GatheringPathRenderer.csproj @@ -1,5 +1,6 @@ + diff --git a/GatheringPathRenderer/RendererPlugin.cs b/GatheringPathRenderer/RendererPlugin.cs index b82965196..e90e67b43 100644 --- a/GatheringPathRenderer/RendererPlugin.cs +++ b/GatheringPathRenderer/RendererPlugin.cs @@ -14,6 +14,7 @@ using ECommons; using ECommons.Schedulers; using ECommons.SplatoonAPI; using GatheringPathRenderer.Windows; +using LLib.GameData; using Questionable.Model; using Questionable.Model.Gathering; @@ -64,6 +65,7 @@ public sealed class RendererPlugin : IDalamudPlugin _pluginInterface.UiBuilder.Draw += _windowSystem.Draw; _clientState.TerritoryChanged += TerritoryChanged; + _clientState.ClassJobChanged += ClassJobChanged; if (_clientState.IsLoggedIn) TerritoryChanged(_clientState.TerritoryType); } @@ -174,9 +176,15 @@ public sealed class RendererPlugin : IDalamudPlugin private void TerritoryChanged(ushort territoryId) => Redraw(); - internal void Redraw() + private void ClassJobChanged(uint classJobId) => Redraw((EClassJob)classJobId); + + internal void Redraw() => Redraw((EClassJob)_clientState.LocalPlayer!.ClassJob.Id); + + private void Redraw(EClassJob classJob) { Splatoon.RemoveDynamicElements("GatheringPathRenderer"); + if (!classJob.IsGatherer()) + return; var elements = GetLocationsInTerritory(_clientState.TerritoryType) .SelectMany(location => @@ -289,6 +297,7 @@ public sealed class RendererPlugin : IDalamudPlugin public void Dispose() { + _clientState.ClassJobChanged -= ClassJobChanged; _clientState.TerritoryChanged -= TerritoryChanged; _pluginInterface.UiBuilder.Draw -= _windowSystem.Draw; diff --git a/GatheringPathRenderer/packages.lock.json b/GatheringPathRenderer/packages.lock.json index 269c43d76..f7b5b4d3d 100644 --- a/GatheringPathRenderer/packages.lock.json +++ b/GatheringPathRenderer/packages.lock.json @@ -92,6 +92,12 @@ "ecommons": { "type": "Project" }, + "llib": { + "type": "Project", + "dependencies": { + "DalamudPackager": "[2.1.13, )" + } + }, "questionable.model": { "type": "Project", "dependencies": {