Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Wisplings Compat InventorySlots v1.0.0
Wisplings_Compat_InventorySlots.dll
Decompiled 2 days agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Wisplings_Compat_InventorySlots")] [assembly: AssemblyCompany("2711 Studios")] [assembly: AssemblyProduct("Wisplings_Compat_InventorySlots")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WisplingsCompatInventorySlots { [BepInPlugin("com.studio2711.wisplings.compat.inventoryslots", "Wisplings_Compat_InventorySlots", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private sealed class Widened { private readonly Func<ItemData, bool> _original; public Widened(Func<ItemData, bool> original) { _original = original; } public bool Accepts(ItemData item) { if (_original == null || !_original(item)) { return IsWispling(item); } return true; } } public const string Guid = "com.studio2711.wisplings.compat.inventoryslots"; public const string Name = "Wisplings_Compat_InventorySlots"; public const string Version = "1.0.0"; private const string WisplingsGuid = "com.studio2711.wisplings"; private const string InventorySlotsGuid = "sighsorry.InventorySlots"; private const string DemisterSlotId = "demister"; private static ManualLogSource _log; private static Assembly _wisplings; private static PropertyInfo _slotList; private static PropertyInfo _slotId; private static FieldInfo _slotAccepts; private static MethodInfo _invalidate; private static bool _missingSlotLogged; private void Awake() { //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown _log = ((BaseUnityPlugin)this).Logger; try { _wisplings = ((object)Chainloader.PluginInfos["com.studio2711.wisplings"].Instance).GetType().Assembly; Type type = AccessTools.TypeByName("InventorySlots.InventorySlotsPlugin"); Type type2 = AccessTools.TypeByName("InventorySlots.SlotDefinition"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "RebuildSlotDefinitions", (Type[])null, (Type[])null)); _slotList = ((type == null) ? null : AccessTools.Property(type, "SlotDefinitions")); _invalidate = ((type == null) ? null : AccessTools.Method(type, "InvalidateSlotDefinitionCaches", (Type[])null, (Type[])null)); _slotId = ((type2 == null) ? null : AccessTools.Property(type2, "Id")); _slotAccepts = ((type2 == null) ? null : AccessTools.Field(type2, "_accepts")); string text = ((methodInfo == null) ? "RebuildSlotDefinitions" : ((_slotList == null) ? "SlotDefinitions" : ((_slotId == null) ? "SlotDefinition.Id" : ((_slotAccepts == null || _slotAccepts.FieldType != typeof(Func<ItemData, bool>)) ? "SlotDefinition._accepts" : null)))); if (text != null) { _log.LogWarning((object)("event=compat_unavailable missing=" + text + " inventorySlots=" + VersionOf("sighsorry.InventorySlots") + " note=\"This InventorySlots version isn't supported yet; the Demister slot is left as it is.\"")); } else { new Harmony("com.studio2711.wisplings.compat.inventoryslots").Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AfterRebuild", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _log.LogInfo((object)("event=compat_ready wisplings=" + VersionOf("com.studio2711.wisplings") + " inventorySlots=" + VersionOf("sighsorry.InventorySlots"))); AfterRebuild(); } } catch (Exception ex) { _log.LogError((object)("event=compat_failed type=" + ex.GetType().Name + " message=\"" + ex.Message + "\"")); } } private static void AfterRebuild() { try { if (!(_slotList.GetValue(null) is IList list)) { return; } foreach (object item in list) { if (string.Equals(_slotId.GetValue(item) as string, "demister", StringComparison.OrdinalIgnoreCase)) { Func<ItemData, bool> func = (Func<ItemData, bool>)_slotAccepts.GetValue(item); if (!(func?.Target is Widened)) { _slotAccepts.SetValue(item, new Func<ItemData, bool>(new Widened(func).Accepts)); _invalidate?.Invoke(null, null); _missingSlotLogged = false; _log.LogInfo((object)"event=demister_slot_widened"); } return; } } if (!_missingSlotLogged) { _log.LogInfo((object)"event=demister_slot_absent"); } _missingSlotLogged = true; } catch (Exception ex) { _log.LogError((object)("event=widen_failed type=" + ex.GetType().Name + " message=\"" + ex.Message + "\"")); } } internal static bool IsWispling(ItemData item) { StatusEffect val = item?.m_shared?.m_equipStatusEffect; if ((Object)(object)val != (Object)null && val is SE_Demister) { return ((object)val).GetType().Assembly == _wisplings; } return false; } private static string VersionOf(string guid) { if (!Chainloader.PluginInfos.TryGetValue(guid, out var value)) { return "?"; } return value.Metadata.Version.ToString(); } } }