From 9cb021dc743f6289b25f4f49fcfcc25f9ffbcfe1 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Fri, 16 Aug 2024 14:33:22 -0400 Subject: [PATCH] is modded/vanillla extensions --- Winch/Util/WinchExtensions.cs | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Winch/Util/WinchExtensions.cs b/Winch/Util/WinchExtensions.cs index 88ad3a29..f95ac15f 100644 --- a/Winch/Util/WinchExtensions.cs +++ b/Winch/Util/WinchExtensions.cs @@ -17,15 +17,54 @@ using UnityEngine.Localization.Tables; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; +using Winch.Components; using Winch.Core; +using Winch.Data.Abilities; using Winch.Data.Character; using Winch.Data.Item; +using Winch.Data.WorldEvent; using Winch.Util; using static ActiveAbilityInfoPanel; public static class WinchExtensions { #region DREDGE + /// + /// Check if the object is modded + /// + /// Whether this object is modded or not + public static bool IsModded(this ItemData item) => ItemUtil.ModdedItemDataDict.ContainsKey(item.id); + /// + public static bool IsModded(this GridConfiguration gridConfiguration) => GridConfigUtil.ModdedGridConfigDict.ContainsKey(gridConfiguration.name); + /// + public static bool IsModded(this SpeakerData speakerData) => speakerData is AdvancedSpeakerData; + /// + public static bool IsModded(this Ability ability) => ability is ModdedAbility || ability.AbilityData.IsModded(); + /// + public static bool IsModded(this AbilityData ability) => ability is ModdedAbilityData; + /// + public static bool IsModded(this WorldEvent worldEvent) => worldEvent is ModdedWorldEvent || worldEvent.worldEventData.IsModded(); + /// + public static bool IsModded(this WorldEventData worldEvent) => worldEvent is ModdedWorldEventData; + + /// + /// Check if the object is vanilla + /// + /// Whether this object is vanilla or not + public static bool IsVanilla(this ItemData item) => !item.IsModded(); + /// + public static bool IsVanilla(this GridConfiguration gridConfiguration) => !gridConfiguration.IsModded(); + /// + public static bool IsVanilla(this SpeakerData speakerData) => !speakerData.IsModded(); + /// + public static bool IsVanilla(this Ability ability) => !ability.IsModded(); + /// + public static bool IsVanilla(this AbilityData ability) => !ability.IsModded(); + /// + public static bool IsVanilla(this WorldEvent worldEvent) => !worldEvent.IsModded(); + /// + public static bool IsVanilla(this WorldEventData worldEvent) => !worldEvent.IsModded(); + /// /// Converts a spatial item instances to a spatial item data. ///