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 CrossStitchMadness v1.1.1
CrossStitchMadness.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GlobalSettings; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using Silksong.FsmUtil; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CrossStitchMadness")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+f8389b6ad13d05c5560d296cc1b9d84382370d39")] [assembly: AssemblyProduct("CrossStitchMadness")] [assembly: AssemblyTitle("CrossStitchMadness")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace CrossStitchMadness { public static class CrossStitchMadnessInfo { public const string PLUGIN_GUID = "io.github.crossstitchmadness"; public const string PLUGIN_NAME = "Cross Stitch Madness"; public const string PLUGIN_VERSION = "1.1.0"; } [BepInPlugin("io.github.crossstitchmadness", "Cross Stitch Madness", "1.1.0")] public class CrossStitchMadnessPlugin : BaseUnityPlugin { [HarmonyPatch] public class ToolHudIconPatch { [HarmonyPrefix] [HarmonyPatch(typeof(ToolHudIcon), "GetIsEmpty")] private static bool GetIsEmptyPrefix(ToolHudIcon __instance, ref bool __result) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 PlayerData instance = PlayerData.instance; if ((int)__instance.CurrentTool.Type == 3) { int? silkCost = GetSilkCost(__instance.CurrentTool); if (silkCost.HasValue) { __result = instance.silk < silkCost; return false; } } return true; } } [HarmonyPatch] public class HeroControllerPatch { [HarmonyPrefix] [HarmonyPatch(typeof(HeroController), "CanThrowTool", new Type[] { typeof(ToolItem), typeof(AttackToolBinding), typeof(bool) })] private static bool CanThrowToolPrefix(HeroController __instance, ToolItem tool, ref bool __result) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if ((int)tool.Type == 3) { int? silkCost = GetSilkCost(tool); if (silkCost.HasValue && __instance.playerData.silk >= silkCost) { __result = true; return false; } } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(HeroController), "Awake")] private static void AwakePostfix(HeroController __instance) { if (parryAlwaysUnlocked.Value && Object.op_Implicit((Object)(object)PARRY) && !PARRY.IsUnlocked) { PARRY.Unlock((Action)null, (PopupFlags)3); ToolItemManager.AutoEquip(PARRY); } Wait val = FsmUtil.GetState(__instance.silkSpecialFSM, "Parry Stance").actions.OfType<Wait>().FirstOrDefault(); val.time = FsmFloat.op_Implicit(parryTimeOverride.Value); ((FsmStateAction)val).enabled = true; } [HarmonyPrefix] [HarmonyPatch(typeof(HeroController), "SilkGain", new Type[] { typeof(HitInstance) })] private static bool SilkGainPrefix(HitInstance hitInstance) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (noSilkFromNormalAttack.Value && (int)hitInstance.AttackType == 0 && (!Object.op_Implicit((Object)(object)hitInstance.Source) || (!((Object)hitInstance.Source).name.StartsWith("Harpoon Damager") && !((Object)hitInstance.Source).name.StartsWith("Harpoon Dash Damager")))) { return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(HeroController), "ThrowTool")] private static void ThrowToolPrefix(HeroController __instance, ref ToolItem ___willThrowTool) { TOOL_FOR_COST = ___willThrowTool; } [HarmonyPostfix] [HarmonyPatch(typeof(HeroController), "ThrowTool")] private static void ThrowToolPostfix(HeroController __instance, ref ToolItem ___willThrowTool) { if (GetSilkCost(TOOL_FOR_COST).HasValue) { EventRegister.SendEvent("SILK REFRESHED", (GameObject)null); } TOOL_FOR_COST = null; } [HarmonyPrefix] [HarmonyPatch(typeof(HeroController), "GetWillThrowTool")] private static bool GetWillThrowToolPrefix(HeroController __instance, ref ToolItem ___willThrowTool, ref bool __result) { if (SILK_SPEAR.IsUnlocked && ToolItemManager.IsToolEquipped(PARRY, (ToolEquippedReadSource)0) && SILK_SPEAR_OVERRIDE) { ___willThrowTool = SILK_SPEAR; __result = true; return false; } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(HeroController), "FixedUpdate")] private static void Postfix(HeroController __instance) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (SILK_SPEAR.IsUnlocked && ToolItemManager.IsToolEquipped(PARRY, (ToolEquippedReadSource)0) && !ToolItemManager.IsToolEquipped(SILK_SPEAR, (ToolEquippedReadSource)0)) { bool flag = IsNearThickSilkVine(((Component)__instance).gameObject); bool flag2 = SILK_SPEAR_OVERRIDE != flag; SILK_SPEAR_OVERRIDE = flag; if (flag2) { EventRegister.SendEvent("SILK REFRESHED", (GameObject)null); ((AudioEvent)(ref inventoryToolCrestList.CurrentCrest.crestSubmitAudio)).SpawnAndPlayOneShot(Audio.DefaultUIAudioSourcePrefab, __instance.transform.position, (Action)null); } } } } [HarmonyPatch] public class ToolItemManagerPatch { [HarmonyPrefix] [HarmonyPatch(typeof(ToolItemManager), "AutoEquip", new Type[] { typeof(ToolItem) })] private static bool AutoEquipPrefix(ToolItem tool) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if ((Object)(object)tool != (Object)(object)PARRY && (int)tool.Type == 3) { return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(ToolItemManager), "GetAttackToolBinding")] private static bool GetAttackToolBindingPrefix(ToolItemManager __instance, ToolItem tool, ref AttackToolBinding? __result) { if (SILK_SPEAR_OVERRIDE && (Object)(object)tool == (Object)(object)SILK_SPEAR) { __result = ToolItemManager.GetAttackToolBinding(PARRY); return false; } return true; } } [HarmonyPatch] public class PlayerDataPatch { [HarmonyPrefix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static bool Prefix(ref int __result) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 if ((Object)(object)TOOL_FOR_COST != (Object)null && (int)TOOL_FOR_COST.Type == 3) { int? silkCost = GetSilkCost(TOOL_FOR_COST); if (silkCost.HasValue) { __result = silkCost.Value; return false; } } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerData), "TakeHealth")] private static void TakeHealthPrefix(ref int amount) { if (extraDamage.Value) { amount++; } } } [HarmonyPatch] public class HealthManagerPatch { [HarmonyPrefix] [HarmonyPatch(typeof(HealthManager), "TakeDamage", new Type[] { typeof(HitInstance) })] private static void TakeDamagePrefix(HealthManager __instance, ref HitInstance hitInstance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (IsCrossStitchDamage(hitInstance)) { hitInstance.DamageDealt = (int)Math.Ceiling((float)hitInstance.DamageDealt * counterattackDamageMult.Value); } } [HarmonyPostfix] [HarmonyPatch(typeof(HealthManager), "TakeDamage", new Type[] { typeof(HitInstance) })] private static void TakeDamagePostfix(HealthManager __instance, HitInstance hitInstance) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected I4, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!parryGivesSilk.Value) { return; } HitInstance val = hitInstance; if (__instance.IsImmuneTo(val, true) || !IsCrossStitchDamage(val)) { return; } bool flag = val.DamageDealt <= 0 && (int)val.HitEffectsType != 2; if ((int)val.SilkGeneration == 2) { val.SilkGeneration = (HitSilkGeneration)(val.IsFirstHit ? 1 : 0); } if (flag) { return; } HeroController instance = HeroController.instance; HitSilkGeneration silkGeneration = val.SilkGeneration; HitSilkGeneration val2 = silkGeneration; switch ((int)val2) { case 0: instance.AddSilkParts(silkPartsFromParry.Value); break; case 1: if (val.IsFirstHit) { instance.AddSilkParts(silkPartsFromParry.Value); } break; case 2: break; default: throw new ArgumentOutOfRangeException(); } } } [HarmonyPatch] public class ToolItemManagerGetBoundAttackToolPatch { [HarmonyPostfix] private static void Postfix(AttackToolBinding binding, ToolEquippedReadSource readSource, ref AttackToolBinding usedBinding, ref ToolItem __result) { if ((Object)(object)__result == (Object)(object)PARRY && SILK_SPEAR_OVERRIDE) { __result = SILK_SPEAR; } } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(ToolItemManager), "GetBoundAttackTool", new Type[3] { typeof(AttackToolBinding), typeof(ToolEquippedReadSource), typeof(AttackToolBinding).MakeByRefType() }, (Type[])null); } } public class InventoryToolCrestListPatch { [HarmonyPrefix] [HarmonyPatch(typeof(InventoryToolCrestList), "Awake")] private static void AwakePrefix(InventoryToolCrestList __instance) { inventoryToolCrestList = __instance; } } internal static ManualLogSource Logger; public static int PARRY_COST; private Harmony harmony; public static ToolItem TOOL_FOR_COST; private static ConfigEntry<bool>? freeParry; private static ConfigEntry<bool>? parryAlwaysUnlocked; private static ConfigEntry<bool>? parryGivesSilk; private static ConfigEntry<bool>? extraDamage; private static ConfigEntry<bool>? noSilkFromNormalAttack; private static ConfigEntry<int>? silkPartsFromParry; private static ConfigEntry<float>? counterattackDamageMult; private static ConfigEntry<float>? parryTimeOverride; private static bool SILK_SPEAR_OVERRIDE; private static InventoryToolCrestList inventoryToolCrestList; public static ToolItem PARRY => ToolItemManager.GetToolByName("Parry"); public static ToolItem SILK_SPEAR => ToolItemManager.GetToolByName("Silk Spear"); private static bool IsCrossStitchDamage(HitInstance hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)hit.Source) && Object.op_Implicit((Object)(object)hit.Source.transform.parent)) { string[] array = new string[2] { "Hornet_parry_stab_cross_slash_style", "Hornet_parry_stab_cross_slash_zap_style" }; string[] array2 = array; foreach (string value in array2) { if (((Object)((Component)hit.Source.transform.parent).gameObject).name.StartsWith(value)) { return true; } } } return false; } private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin io.github.crossstitchmadness is loaded!"); harmony = new Harmony("io.github.crossstitchmadness"); harmony.PatchAll(); freeParry = ((BaseUnityPlugin)this).Config.Bind<bool>("Parrying", "No Cost", true, (ConfigDescription)null); parryAlwaysUnlocked = ((BaseUnityPlugin)this).Config.Bind<bool>("Parrying", "Always Unlocked", true, (ConfigDescription)null); parryGivesSilk = ((BaseUnityPlugin)this).Config.Bind<bool>("Parrying", "Gives Silk", true, (ConfigDescription)null); silkPartsFromParry = ((BaseUnityPlugin)this).Config.Bind<int>("Parrying", "Silk Parts From Parrying", 2, (ConfigDescription)null); counterattackDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Parrying", "Counterattack Damage Mult", 0.75f, (ConfigDescription)null); parryTimeOverride = ((BaseUnityPlugin)this).Config.Bind<float>("Parrying", "Parry Time Override", 0.25f, (ConfigDescription)null); extraDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra Balance", "Increased Enemy Damage", true, (ConfigDescription)null); noSilkFromNormalAttack = ((BaseUnityPlugin)this).Config.Bind<bool>("Extra Balance", "No Silk From Normal Attacking", true, (ConfigDescription)null); } public static bool FreeParryEnabled() { return freeParry.Value; } public static int? GetSilkCost(ToolItem tool) { if (FreeParryEnabled() && (Object)(object)tool == (Object)(object)PARRY) { return PARRY_COST; } return null; } public static bool IsNearThickSilkVine(GameObject obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) bool result = false; Collider2D[] array = Physics2D.OverlapBoxAll(Vector2.op_Implicit(obj.transform.position), new Vector2(6f, 3f), 0f); Collider2D[] array2 = array; foreach (Collider2D val in array2) { PlayMakerFSM component = ((Component)val).GetComponent<PlayMakerFSM>(); if (Object.op_Implicit((Object)(object)component) && component.FsmName == "thick_silk_vine") { result = true; break; } } return result; } } }