GPR: Only show when on gatherer
authorLiza Carvelli <liza@carvel.li>
Mon, 12 Aug 2024 14:21:34 +0000 (16:21 +0200)
committerLiza Carvelli <liza@carvel.li>
Mon, 12 Aug 2024 14:21:34 +0000 (16:21 +0200)
GatheringPathRenderer/GatheringPathRenderer.csproj
GatheringPathRenderer/RendererPlugin.cs
GatheringPathRenderer/packages.lock.json

index 1d3aeae5c9c2acf1b7fa537f0ea68f0529903778..fc157f207141d33d98f41e64c0873d36d77dc5bb 100644 (file)
@@ -1,5 +1,6 @@
 <Project Sdk="Dalamud.NET.Sdk/10.0.0">
     <ItemGroup>
+      <ProjectReference Include="..\LLib\LLib.csproj" />
       <ProjectReference Include="..\Questionable.Model\Questionable.Model.csproj" />
       <ProjectReference Include="..\vendor\ECommons\ECommons\ECommons.csproj" />
     </ItemGroup>
index b82965196abd3e7507bff4880e0c6717429bc71d..e90e67b439658022db9de9e2252fd0d3365056bb 100644 (file)
@@ -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;
 
index 269c43d76b95de025d93b3700316e83cf395e624..f7b5b4d3d232eb7a3650f29ae8bb0dc528bf1152 100644 (file)
       "ecommons": {
         "type": "Project"
       },
+      "llib": {
+        "type": "Project",
+        "dependencies": {
+          "DalamudPackager": "[2.1.13, )"
+        }
+      },
       "questionable.model": {
         "type": "Project",
         "dependencies": {