using System;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
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+83d4963580fc4f5bb8c23f38049995dca8727c4a")]
[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.0.0";
}
[BepInPlugin("io.github.crossstitchmadness", "Cross Stitch Madness", "1.0.0")]
public class CrossStitchMadnessPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(ToolHudIcon), "GetIsEmpty")]
public class ToolHudIconPatch
{
[HarmonyPrefix]
private static bool Prefix(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(typeof(HeroController), "CanThrowTool", new Type[]
{
typeof(ToolItem),
typeof(AttackToolBinding),
typeof(bool)
})]
public class HeroControllerPatch
{
[HarmonyPrefix]
private static bool Prefix(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;
}
}
[HarmonyPatch(typeof(HeroController), "Awake")]
public class HeroControllerAwakePatch
{
[HarmonyPostfix]
private static void Postfix(HeroController __instance)
{
if (parryAlwaysUnlocked.Value && Object.op_Implicit((Object)(object)PARRY) && !PARRY.IsUnlocked)
{
PARRY.Unlock((Action)null, (PopupFlags)3);
ToolItemManager.AutoEquip(PARRY);
}
}
}
[HarmonyPatch(typeof(ToolItemManager), "AutoEquip", new Type[] { typeof(ToolItem) })]
public class AutoEquipToolPatch
{
[HarmonyPrefix]
private static bool Prefix(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;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public class SilkSkillCostPatch
{
[HarmonyPrefix]
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;
}
}
[HarmonyPatch(typeof(HeroController), "ThrowTool")]
public class HeroControllerThrowToolPatch
{
[HarmonyPrefix]
private static void Prefix(HeroController __instance, ref ToolItem ___willThrowTool)
{
TOOL_FOR_COST = ___willThrowTool;
}
[HarmonyPostfix]
private static void Postfix(HeroController __instance, ref ToolItem ___willThrowTool)
{
if (GetSilkCost(TOOL_FOR_COST).HasValue)
{
EventRegister.SendEvent("SILK REFRESHED", (GameObject)null);
}
TOOL_FOR_COST = null;
}
}
[HarmonyPatch(typeof(HeroController), "SilkGain", new Type[] { typeof(HitInstance) })]
public class HeroControllerSilkGainPatch
{
[HarmonyPrefix]
private static bool Prefix(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;
}
}
[HarmonyPatch(typeof(HealthManager), "TakeDamage", new Type[] { typeof(HitInstance) })]
public class HealthManagerTakeDamagePatch
{
[HarmonyPostfix]
private static void Postfix(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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Invalid comparison between Unknown and I4
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Invalid comparison between Unknown and I4
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
if (!parryGivesSilk.Value)
{
return;
}
HitInstance val = hitInstance;
if (!__instance.IsImmuneTo(val, true) && Object.op_Implicit((Object)(object)val.Source) && Object.op_Implicit((Object)(object)val.Source.transform.parent) && ((Object)((Component)val.Source.transform.parent).gameObject).name.StartsWith("Hornet_parry_stab_cross_slash_style"))
{
bool flag = val.DamageDealt <= 0 && (int)val.HitEffectsType != 2;
if ((int)val.SilkGeneration == 2)
{
val.SilkGeneration = (HitSilkGeneration)(val.IsFirstHit ? 1 : 0);
}
if (!flag)
{
HeroController.instance.SilkGain(val);
}
}
}
}
[HarmonyPatch(typeof(PlayerData), "TakeHealth")]
public class PlayerDataTakeHealthPatch
{
[HarmonyPrefix]
private static void Prefix(ref int amount)
{
if (extraDamage.Value)
{
amount++;
}
}
}
[HarmonyPatch(typeof(HeroController), "GetWillThrowTool")]
public class GetWillThrowToolPatch
{
[HarmonyPrefix]
private static bool Prefix(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;
}
}
[HarmonyPatch(typeof(ToolItemManager), "GetAttackToolBinding")]
public class GetAttackToolBindingPatch
{
[HarmonyPrefix]
private static bool Prefix(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 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);
}
}
[HarmonyPatch(typeof(HeroController), "FixedUpdate")]
public class HeroControllerFixedUpdatePatch
{
[HarmonyPostfix]
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(typeof(InventoryToolCrestList), "Awake")]
public class InventoryToolCrestListAwakePatch
{
[HarmonyPrefix]
private static void Prefix(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 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 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);
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;
}
}
}