diff --git a/Pal.Client/Commands/PalNearCommand.cs b/Pal.Client/Commands/PalNearCommand.cs index 7fba1fe..ec3f449 100644 --- a/Pal.Client/Commands/PalNearCommand.cs +++ b/Pal.Client/Commands/PalNearCommand.cs @@ -50,7 +50,7 @@ internal sealed class PalNearCommand : ISubCommand var nearbyMarkers = state.Locations .Where(m => predicate(m)) - .Where(m => m.RenderElement != null && m.RenderElement.Color != RenderData.ColorInvisible) + .Where(m => m.RenderElement != null && m.RenderElement.Enabled) .Select(m => new { m, distance = (playerPosition.Value - m.Position).Length() }) .OrderBy(m => m.distance) .Take(5) diff --git a/Pal.Client/Floors/FrameworkService.cs b/Pal.Client/Floors/FrameworkService.cs index 1d6b32b..49e89ee 100644 --- a/Pal.Client/Floors/FrameworkService.cs +++ b/Pal.Client/Floors/FrameworkService.cs @@ -175,12 +175,12 @@ internal sealed class FrameworkService : IDisposable { foreach (var location in memoryTerritory.Locations) { - uint desiredColor = DetermineColor(location, visibleLocations); + bool isEnabled = DetermineVisibility(location, visibleLocations); if (location.RenderElement == null || !location.RenderElement.IsValid) return true; - if (location.RenderElement.Color != desiredColor) - location.RenderElement.Color = desiredColor; + if (location.RenderElement.Enabled != isEnabled) + location.RenderElement.Enabled = isEnabled; } } catch (Exception e) @@ -225,12 +225,12 @@ internal sealed class FrameworkService : IDisposable { if (location.Type == MemoryLocation.EType.Trap) { - CreateRenderElement(location, elements, DetermineColor(location, visibleMarkers), + CreateRenderElement(location, elements, DetermineVisibility(location, visibleMarkers), _configuration.DeepDungeons.Traps); } else if (location.Type == MemoryLocation.EType.Hoard) { - CreateRenderElement(location, elements, DetermineColor(location, visibleMarkers), + CreateRenderElement(location, elements, DetermineVisibility(location, visibleMarkers), _configuration.DeepDungeons.HoardCoffers); } } @@ -251,14 +251,12 @@ internal sealed class FrameworkService : IDisposable if (location.Type == MemoryLocation.EType.SilverCoffer && _configuration.DeepDungeons.SilverCoffers.Show) { - CreateRenderElement(location, elements, DetermineColor(location), - _configuration.DeepDungeons.SilverCoffers); + CreateRenderElement(location, elements, true, _configuration.DeepDungeons.SilverCoffers); } else if (location.Type == MemoryLocation.EType.GoldCoffer && _configuration.DeepDungeons.GoldCoffers.Show) { - CreateRenderElement(location, elements, DetermineColor(location), - _configuration.DeepDungeons.GoldCoffers); + CreateRenderElement(location, elements, true, _configuration.DeepDungeons.GoldCoffers); } } @@ -268,7 +266,7 @@ internal sealed class FrameworkService : IDisposable _renderAdapter.SetLayer(ELayer.RegularCoffers, elements); } - private uint DetermineColor(PersistentLocation location, IReadOnlyList visibleLocations) + private bool DetermineVisibility(PersistentLocation location, IReadOnlyList visibleLocations) { switch (location.Type) { @@ -276,34 +274,25 @@ internal sealed class FrameworkService : IDisposable when _territoryState.PomanderOfSight == PomanderState.Inactive || !_configuration.DeepDungeons.Traps.OnlyVisibleAfterPomander || visibleLocations.Any(x => x == location): - return _configuration.DeepDungeons.Traps.Color; + return true; case MemoryLocation.EType.Hoard when _territoryState.PomanderOfIntuition == PomanderState.Inactive || !_configuration.DeepDungeons.HoardCoffers.OnlyVisibleAfterPomander || visibleLocations.Any(x => x == location): - return _configuration.DeepDungeons.HoardCoffers.Color; + return true; default: - return RenderData.ColorInvisible; + return false; } } - private uint DetermineColor(EphemeralLocation location) - { - return location.Type switch - { - MemoryLocation.EType.SilverCoffer => _configuration.DeepDungeons.SilverCoffers.Color, - MemoryLocation.EType.GoldCoffer => _configuration.DeepDungeons.GoldCoffers.Color, - _ => RenderData.ColorInvisible - }; - } - - private void CreateRenderElement(MemoryLocation location, List elements, uint color, + private void CreateRenderElement(MemoryLocation location, List elements, bool enabled, MarkerConfiguration config) { if (!config.Show) return; - var element = _renderAdapter.CreateElement(location.Type, location.Position, color, config.Fill); + var element = + _renderAdapter.CreateElement(location.Type, location.Position, enabled, config.Color, config.Fill); location.RenderElement = element; elements.Add(element); } diff --git a/Pal.Client/Rendering/IRenderElement.cs b/Pal.Client/Rendering/IRenderElement.cs index 6424fda..f22ad5a 100644 --- a/Pal.Client/Rendering/IRenderElement.cs +++ b/Pal.Client/Rendering/IRenderElement.cs @@ -4,5 +4,5 @@ public interface IRenderElement { bool IsValid { get; } - uint Color { get; set; } + bool Enabled { get; set; } } diff --git a/Pal.Client/Rendering/IRenderer.cs b/Pal.Client/Rendering/IRenderer.cs index 17da135..28cf7df 100644 --- a/Pal.Client/Rendering/IRenderer.cs +++ b/Pal.Client/Rendering/IRenderer.cs @@ -13,7 +13,7 @@ internal interface IRenderer void ResetLayer(ELayer layer); - IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, uint color, bool fill = false); + IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, bool enabled, uint color, bool fill = false); void DrawDebugItems(uint trapColor, uint hoardColor); } diff --git a/Pal.Client/Rendering/RenderAdapter.cs b/Pal.Client/Rendering/RenderAdapter.cs index 09c36bd..14a878a 100644 --- a/Pal.Client/Rendering/RenderAdapter.cs +++ b/Pal.Client/Rendering/RenderAdapter.cs @@ -60,8 +60,9 @@ internal sealed class RenderAdapter : IRenderer, IDisposable public void ResetLayer(ELayer layer) => _implementation.ResetLayer(layer); - public IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, uint color, bool fill = false) - => _implementation.CreateElement(type, pos, color, fill); + public IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, bool enabled, uint color, + bool fill = false) + => _implementation.CreateElement(type, pos, enabled, color, fill); public ERenderer GetConfigValue() => throw new NotImplementedException(); diff --git a/Pal.Client/Rendering/RenderData.cs b/Pal.Client/Rendering/RenderData.cs index a8f0e57..0a20849 100644 --- a/Pal.Client/Rendering/RenderData.cs +++ b/Pal.Client/Rendering/RenderData.cs @@ -2,6 +2,5 @@ internal static class RenderData { - public static readonly uint ColorInvisible = 0; public static readonly long TestLayerTimeout = 10_000; } diff --git a/Pal.Client/Rendering/SimpleRenderer.cs b/Pal.Client/Rendering/SimpleRenderer.cs index 9bafc26..a4acfc9 100644 --- a/Pal.Client/Rendering/SimpleRenderer.cs +++ b/Pal.Client/Rendering/SimpleRenderer.cs @@ -52,13 +52,15 @@ internal sealed class SimpleRenderer : IRenderer, IDisposable l.Dispose(); } - public IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, uint color, bool fill = false) + public IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, bool enabled, uint color, + bool fill = false) { var config = MarkerConfig.ForType(type); return new SimpleElement { Type = type, Position = pos + new Vector3(0, config.OffsetY, 0), + Enabled = enabled, Color = color, Radius = config.Radius, Fill = fill, @@ -75,10 +77,12 @@ internal sealed class SimpleRenderer : IRenderer, IDisposable (SimpleElement)CreateElement( MemoryLocation.EType.Trap, _clientState.LocalPlayer?.Position ?? default, + true, trapColor), (SimpleElement)CreateElement( MemoryLocation.EType.Hoard, _clientState.LocalPlayer?.Position ?? default, + true, hoardColor) }, ExpiresAt = Environment.TickCount64 + RenderData.TestLayerTimeout @@ -118,7 +122,7 @@ internal sealed class SimpleRenderer : IRenderer, IDisposable private void Draw(SimpleElement e) { - if (e.Color == RenderData.ColorInvisible) + if (!e.Enabled) return; switch (e.Type) @@ -194,6 +198,7 @@ internal sealed class SimpleRenderer : IRenderer, IDisposable public bool IsValid { get; set; } = true; public required MemoryLocation.EType Type { get; init; } public required Vector3 Position { get; init; } + public required bool Enabled { get; set; } public required uint Color { get; set; } public required float Radius { get; init; } public required bool Fill { get; init; } diff --git a/Pal.Client/Rendering/SplatoonRenderer.cs b/Pal.Client/Rendering/SplatoonRenderer.cs index df23641..ea3ae72 100644 --- a/Pal.Client/Rendering/SplatoonRenderer.cs +++ b/Pal.Client/Rendering/SplatoonRenderer.cs @@ -80,7 +80,7 @@ internal sealed class SplatoonRenderer : IRenderer, IDisposable private string ToLayerName(ELayer layer) => $"PalacePal.{layer}"; - public IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, uint color, bool fill = false) + public IRenderElement CreateElement(MemoryLocation.EType type, Vector3 pos, bool enabled, uint color, bool fill = false) { MarkerConfig config = MarkerConfig.ForType(type); Element element = new Element(ElementType.CircleAtFixedCoordinates) @@ -96,6 +96,7 @@ internal sealed class SplatoonRenderer : IRenderer, IDisposable FillStep = 1, color = color, thicc = 2, + Enabled = enabled, }; return new SplatoonElement(this, element); } @@ -111,8 +112,8 @@ internal sealed class SplatoonRenderer : IRenderer, IDisposable var elements = new List { - CreateElement(MemoryLocation.EType.Trap, pos.Value, trapColor), - CreateElement(MemoryLocation.EType.Hoard, pos.Value, hoardColor), + CreateElement(MemoryLocation.EType.Trap, pos.Value, true, trapColor), + CreateElement(MemoryLocation.EType.Hoard, pos.Value, true, hoardColor), }; if (!Splatoon.AddDynamicElements(ToLayerName(ELayer.Test), @@ -186,10 +187,10 @@ internal sealed class SplatoonRenderer : IRenderer, IDisposable public bool IsValid => !_renderer.IsDisposed && Delegate.IsValid(); - public uint Color + public bool Enabled { - get => Delegate.color; - set => Delegate.color = value; + get => Delegate.Enabled; + set => Delegate.Enabled = value; } } }