Fix IsValid logic not working if switching renders in PotD/HoH

This commit is contained in:
Liza 2023-02-08 16:24:22 +01:00
parent db89966be2
commit b13d26a731
2 changed files with 10 additions and 4 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Version>2.7</Version> <Version>2.8</Version>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -19,6 +19,7 @@ namespace Pal.Client.Rendering
internal class SplatoonRenderer : IRenderer, IDrawDebugItems, IDisposable internal class SplatoonRenderer : IRenderer, IDrawDebugItems, IDisposable
{ {
private const long ON_TERRITORY_CHANGE = -2; private const long ON_TERRITORY_CHANGE = -2;
private bool IsDisposed { get; set; } = false;
public SplatoonRenderer(DalamudPluginInterface pluginInterface, IDalamudPlugin plugin) public SplatoonRenderer(DalamudPluginInterface pluginInterface, IDalamudPlugin plugin)
{ {
@ -74,7 +75,7 @@ namespace Pal.Client.Rendering
color = color, color = color,
thicc = 2, thicc = 2,
}; };
return new SplatoonElement(element); return new SplatoonElement(this, element);
} }
public void DrawDebugItems(Vector4 trapColor, Vector4 hoardColor) public void DrawDebugItems(Vector4 trapColor, Vector4 hoardColor)
@ -123,6 +124,8 @@ namespace Pal.Client.Rendering
public void Dispose() public void Dispose()
{ {
IsDisposed = true;
ResetLayer(ELayer.TrapHoard); ResetLayer(ELayer.TrapHoard);
ResetLayer(ELayer.RegularCoffers); ResetLayer(ELayer.RegularCoffers);
@ -131,14 +134,17 @@ namespace Pal.Client.Rendering
public class SplatoonElement : IRenderElement public class SplatoonElement : IRenderElement
{ {
public SplatoonElement(Element element) private readonly SplatoonRenderer renderer;
public SplatoonElement(SplatoonRenderer renderer, Element element)
{ {
this.renderer = renderer;
Delegate = element; Delegate = element;
} }
public Element Delegate { get; } public Element Delegate { get; }
public bool IsValid => Delegate.IsValid(); public bool IsValid => !renderer.IsDisposed && Delegate.IsValid();
public uint Color public uint Color
{ {
get => Delegate.color; get => Delegate.color;