From 7840165872fd0cae2505046b0554c00e835bf1c6 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sun, 25 Aug 2024 17:17:36 -0400 Subject: [PATCH] make an interface to connect these --- Winch/Assets/Textures/MaterialsIcon.png | Bin 0 -> 8016 bytes Winch/Data/Item/CrabPotItemData.cs | 6 ++- Winch/Data/Item/IAbilityItemData.cs | 17 +++++++ Winch/Data/Item/TrawlNetItemData.cs | 6 ++- .../API/ActiveAbilityInfoPanelPatcher.cs | 43 +++++------------- Winch/Util/WinchExtensions.cs | 6 +-- 6 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 Winch/Assets/Textures/MaterialsIcon.png create mode 100644 Winch/Data/Item/IAbilityItemData.cs diff --git a/Winch/Assets/Textures/MaterialsIcon.png b/Winch/Assets/Textures/MaterialsIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..f517f6ee5d4e1cae575fbdff5e118d4ee0ab3b9b GIT binary patch literal 8016 zcmai3c|4R~)E^9nLC887vL#E>G)0K96S8ENC9=#|lbsmCFN{H@$i8KnVPZxqYl_Hj z3`Vw;eHW7Loj&jX@B7E|d7g9cx%Zyu+z@6vEXA@Mw-kLU|<&n0C05td+56SE8GD9 z=r2PZ#N9Bb^*oIwjc&WHkrc5@9FoAF1jCDbW56Nt1bxo9QcfRvtsF7OV9b9Ad1HS3 z@E7rM1F;0#&*B-^#z0BBtWQ5n1e7aZcuP=UjGl%bP0d7xE*!#O18cYZ!!nNZj~*}7 ztEvtZWKT>Dyt#F})gfsJWra%{?yyxT8D@HFVhl6Y7?8%9KLyR)G9?FMAh{o?fu5W9RGyI^1>AqCUAF(n6b_mdXkI`I9jq zUlj>vd(V03QlWJCMB|d0$(dc-zEt`7*#p*s%Y;)yz9h&qtfsYbGY@@7D7f+692N}X zz-?yg7IywDd8j;k83%X4p!Xhd3m}a@)%?-tqwv@|OQVZAlb-e0p8t#4^Q6^8U7_&C zL_yC1i-bEn5U*ewmkJ5DOz5>S=f12Qleh&^l3gYv9Q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5 zr_Z|9)CGA#)0c_ITTl00tMjcae*odq7X(z`E;Hwd*`iv!U#P}3?#56?-c)Aj7N-lo ztHJ!~?IP=i9|GZ(GHl}+g6$ctVg^qQVK4I$6gz;vvtvVl@Lu zda+{Yq|D)Mf0~6@plMnxV0ccH{{Lrx|4*WrCF)P*8H0lJo!6qko+KIz4lvX;)v3{P GiTfYc@i+7U literal 0 HcmV?d00001 diff --git a/Winch/Data/Item/CrabPotItemData.cs b/Winch/Data/Item/CrabPotItemData.cs index 52e8c55c..09baec93 100644 --- a/Winch/Data/Item/CrabPotItemData.cs +++ b/Winch/Data/Item/CrabPotItemData.cs @@ -3,7 +3,7 @@ namespace Winch.Data.Item { - public class CrabPotItemData : GridConfigDeployableItemData + public class CrabPotItemData : GridConfigDeployableItemData, IAbilityItemData { [SerializeField] public AbilityMode abilityMode = AbilityMode.POT; @@ -13,6 +13,10 @@ public class CrabPotItemData : GridConfigDeployableItemData [SerializeField] public Sprite qualityIcon; + + public AbilityMode AbilityMode => abilityMode; + + public Sprite QualityIcon => qualityIcon; } public enum PotType diff --git a/Winch/Data/Item/IAbilityItemData.cs b/Winch/Data/Item/IAbilityItemData.cs new file mode 100644 index 00000000..c69aa9e7 --- /dev/null +++ b/Winch/Data/Item/IAbilityItemData.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static ActiveAbilityInfoPanel; +using UnityEngine; + +namespace Winch.Data.Item +{ + public interface IAbilityItemData + { + public AbilityMode AbilityMode { get; } + + public Sprite QualityIcon { get; } + } +} diff --git a/Winch/Data/Item/TrawlNetItemData.cs b/Winch/Data/Item/TrawlNetItemData.cs index 5a6c6dda..e1d1c390 100644 --- a/Winch/Data/Item/TrawlNetItemData.cs +++ b/Winch/Data/Item/TrawlNetItemData.cs @@ -4,7 +4,7 @@ namespace Winch.Data.Item { - public class TrawlNetItemData : GridConfigDeployableItemData + public class TrawlNetItemData : GridConfigDeployableItemData, IAbilityItemData { [SerializeField] public AbilityMode abilityMode = AbilityMode.TRAWL; @@ -17,5 +17,9 @@ public class TrawlNetItemData : GridConfigDeployableItemData [SerializeField] public Sprite qualityIcon; + + public AbilityMode AbilityMode => abilityMode; + + public Sprite QualityIcon => qualityIcon; } } \ No newline at end of file diff --git a/Winch/Patches/API/ActiveAbilityInfoPanelPatcher.cs b/Winch/Patches/API/ActiveAbilityInfoPanelPatcher.cs index 31cfdb7f..841699e1 100644 --- a/Winch/Patches/API/ActiveAbilityInfoPanelPatcher.cs +++ b/Winch/Patches/API/ActiveAbilityInfoPanelPatcher.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using Winch.Data.Item; +using static ActiveAbilityInfoPanel; namespace Winch.Patches.API { @@ -15,43 +16,21 @@ internal static class ActiveAbilityInfoPanelPatcher [HarmonyPatch(nameof(ActiveAbilityInfoPanel.RefreshUI))] public static bool ActiveAbilityInfoPanel_RefreshUI_Prefix(ActiveAbilityInfoPanel __instance, SpatialItemData spatialItemData, AbilityData abilityData) { - if (abilityData.name == __instance.potAbility.name) + if (spatialItemData != null && spatialItemData is IAbilityItemData abilityItemData) { - if (spatialItemData != null && spatialItemData is CrabPotItemData potData) + __instance.abilityMode = abilityItemData.AbilityMode; + if (abilityItemData.QualityIcon != null) { - __instance.abilityMode = potData.abilityMode; - if (potData.qualityIcon != null) - { - __instance.qualityIcon.sprite = potData.qualityIcon; - } - else - { - __instance.qualityIcon.sprite = __instance.GetSpriteForAbilityMode(potData.abilityMode); - } - __instance.Show(); - __instance.RefreshItemNameField(potData); - __instance.UpdateCatchableSpecies(); - return false; + __instance.qualityIcon.sprite = abilityItemData.QualityIcon; } - } - else if (abilityData.name == __instance.trawlAbility.name) - { - if (spatialItemData != null && spatialItemData is TrawlNetItemData trawlNetData) + else { - __instance.abilityMode = trawlNetData.abilityMode; - if (trawlNetData.qualityIcon != null) - { - __instance.qualityIcon.sprite = trawlNetData.qualityIcon; - } - else - { - __instance.qualityIcon.sprite = __instance.GetSpriteForAbilityMode(trawlNetData.abilityMode); - } - __instance.Show(); - __instance.RefreshItemNameField(trawlNetData); - __instance.UpdateCatchableSpecies(); - return false; + __instance.qualityIcon.sprite = __instance.GetSpriteForAbilityMode(abilityItemData.AbilityMode); } + __instance.Show(); + __instance.RefreshItemNameField(spatialItemData); + __instance.UpdateCatchableSpecies(); + return false; } return true; } diff --git a/Winch/Util/WinchExtensions.cs b/Winch/Util/WinchExtensions.cs index 5e07bac5..1b25a8ca 100644 --- a/Winch/Util/WinchExtensions.cs +++ b/Winch/Util/WinchExtensions.cs @@ -306,10 +306,8 @@ public static bool IsItemHarvestable(this PlayerZoneDetector playerZoneDetector, public static AbilityMode GetAbilityModeFromItemData(this SpatialItemData data) { - if (data is TrawlNetItemData netData) - return netData.abilityMode; - else if (data is CrabPotItemData potData) - return potData.abilityMode; + if (data is IAbilityItemData abilityItemData) + return abilityItemData.AbilityMode; else if (data.id == "tir-pot1") return AbilityMode.POT_MATERIAL; else if (data.itemSubtype == ItemSubtype.POT)