using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using UnboundLib.Cards; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace ReDecedMods; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.ReDeced.rounds.IronWillCard", "Iron Will Card", "1.0.0")] [BepInProcess("Rounds.exe")] public class IronWillCardPlugin : BaseUnityPlugin { internal static string modInitials = "RD"; private void Awake() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)"[IronWill] Plugin Awake started"); new Harmony("com.ReDeced.rounds.IronWillCard").PatchAll(); Debug.Log((object)"[IronWill] Harmony patches applied"); } private void Start() { Debug.Log((object)"[IronWill] Calling BuildCard from Start..."); try { CustomCard.BuildCard((Action)delegate(CardInfo cardInfo) { Debug.Log((object)("[IronWill] Card callback: " + (((Object)(object)cardInfo != (Object)null) ? cardInfo.cardName : "NULL"))); }); } catch (Exception ex) { Debug.LogError((object)("[IronWill] BuildCard failed: " + ex)); } } } public class IronWillCard : CustomCard { public static List PlayersWithIronWill = new List(); public override string GetModName() { return "Iron Will Card"; } protected override string GetTitle() { return "Iron Will"; } protected override string GetDescription() { return "Allows player to use block without additional effects through silence and stun"; } protected override GameObject GetCardArt() { return null; } protected override Rarity GetRarity() { return (Rarity)2; } protected override CardThemeColorType GetTheme() { return (CardThemeColorType)2; } protected override CardInfoStat[] GetStats() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0034: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown return (CardInfoStat[])(object)new CardInfoStat[2] { new CardInfoStat { positive = true, stat = "Block disables", amount = "Ignored", simepleAmount = (SimpleAmount)0 }, new CardInfoStat { positive = true, stat = "Block cooldown", amount = "-30%", simepleAmount = (SimpleAmount)2 } }; } public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats) { if (!PlayersWithIronWill.Contains(player)) { PlayersWithIronWill.Add(player); Debug.Log((object)("[IronWill] Card added to player: " + player?.playerID)); } block.cooldown *= 0.7f; } public override void OnRemoveCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats) { PlayersWithIronWill.Remove(player); Debug.Log((object)("[IronWill] Card removed from player: " + player?.playerID)); block.cooldown /= 0.7f; ((CustomCard)this).OnRemoveCard(player, gun, gunAmmo, data, health, gravity, block, characterStats); } } [HarmonyPatch(typeof(GeneralInput), "Update")] public class Patch_GeneralInput_Update { private static void Prefix(GeneralInput __instance, out bool __state) { __state = false; Player component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !IronWillCard.PlayersWithIronWill.Contains(component)) { return; } CharacterData component2 = ((Component)component).GetComponent(); if (!((Object)(object)component2 == (Object)null) && (component2.isStunned || component2.isSilenced)) { FieldInfo field = typeof(GeneralInput).GetField("silencedInput", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = typeof(GeneralInput).GetField("stunnedInput", BindingFlags.Instance | BindingFlags.Public); bool flag = false; if (field != null && component2.isSilenced && (bool)field.GetValue(__instance)) { field.SetValue(__instance, false); flag = true; } if (field2 != null && component2.isStunned && (bool)field2.GetValue(__instance)) { field2.SetValue(__instance, false); flag = true; } __state = flag; } } private static void Postfix(GeneralInput __instance, bool __state) { if (!__state) { return; } Player component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || !IronWillCard.PlayersWithIronWill.Contains(component)) { return; } CharacterData component2 = ((Component)component).GetComponent(); if (!((Object)(object)component2 == (Object)null)) { FieldInfo field = typeof(GeneralInput).GetField("silencedInput", BindingFlags.Instance | BindingFlags.Public); FieldInfo field2 = typeof(GeneralInput).GetField("stunnedInput", BindingFlags.Instance | BindingFlags.Public); if (field != null && component2.isSilenced) { field.SetValue(__instance, true); } if (field2 != null && component2.isStunned) { field2.SetValue(__instance, true); } FieldInfo field3 = typeof(GeneralInput).GetField("shootIsPressed", BindingFlags.Instance | BindingFlags.Public); FieldInfo field4 = typeof(GeneralInput).GetField("shootWasPressed", BindingFlags.Instance | BindingFlags.Public); FieldInfo field5 = typeof(GeneralInput).GetField("shootWasReleased", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { field3.SetValue(__instance, false); } if (field4 != null) { field4.SetValue(__instance, false); } if (field5 != null) { field5.SetValue(__instance, false); } } } } [HarmonyPatch(typeof(Block), "TryBlock")] public class Patch_Block_TryBlock { private static bool Prefix(Block __instance) { //IL_010e: Unknown result type (might be due to invalid IL or missing references) CharacterData component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.player == (Object)null || !IronWillCard.PlayersWithIronWill.Contains(component.player)) { return true; } if (!component.isStunned && !component.isSilenced) { return true; } FieldInfo field = typeof(Block).GetField("counter", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = typeof(Block).GetField("cooldown", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || field2 == null) { return true; } float num = (float)field.GetValue(__instance); float num2 = (float)field2.GetValue(__instance); if (num < num2) { return true; } Debug.Log((object)"[IronWill] Clean block for stunned/silenced player!"); MethodInfo method = typeof(Block).GetMethod("RPCA_DoBlock", BindingFlags.Instance | BindingFlags.Public); if (method != null) { object obj = Enum.ToObject(typeof(BlockTrigger).GetNestedType("BlockTriggerType"), 0); method.Invoke(__instance, new object[5] { true, false, obj, Vector3.zero, false }); field.SetValue(__instance, 0f); Debug.Log((object)"[IronWill] Clean block executed! No card effects triggered."); } return false; } }