using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using AALUND13Cards.Core; using AALUND13Cards.Core.Cards; using AALUND13Cards.Core.Cards.Effects; using AALUND13Cards.Core.Extensions; using AALUND13Cards.Core.Handlers; using AALUND13Cards.Core.Utils; using AALUND13Cards.Devil.Cards; using AALUND13Cards.Devil.Handlers; using AALUND13Cards.Devil.Handlers.ExtraPickHandlers; using AALUND13Cards.Devil.Patches; using BepInEx; using BepInEx.Logging; using DrawNCards; using HarmonyLib; using JARL.Bases; using Microsoft.CodeAnalysis; using ModdingUtils.GameModes; using ModdingUtils.MonoBehaviours; using ModdingUtils.Utils; using PickPhaseImprovements; using RarityLib.Utils; using TabInfo.Utils; using UnboundLib; using UnboundLib.GameModes; 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(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: AssemblyVersion("0.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 AALUND13Cards.Devil { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("AALUND13.Cards.Devil", "AALUND13 Devil Cards", "1.3.1")] [BepInProcess("Rounds.exe")] internal class AAC_Devil : BaseUnityPlugin { internal const string ModId = "AALUND13.Cards.Devil"; internal const string ModName = "AALUND13 Devil Cards"; internal const string Version = "1.3.1"; private static AssetBundle assets; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) assets = AssetsUtils.LoadAssetBundle("aac_devil_assets", typeof(AAC_Devil).Assembly); if ((Object)(object)assets != (Object)null) { new Harmony("AALUND13.Cards.Devil").PatchAll(); } RarityUtils.AddRarity("Devil", 0.01f, new Color(57f / 106f, 0f, 0f), new Color(0.4f, 0f, 0f)); ((Component)this).gameObject.AddComponent(); } private void Start() { if ((Object)(object)assets == (Object)null) { Unbound.BuildModal("AALUND13 Cards Error", "The mod \"AALUND13 Devil Cards\" assets failled to load, All the cards will be disable in this mod"); throw new NullReferenceException("Failled to load \"AALUND13 Devil Cards\" assets"); } if (AAC_Core.Plugins.Exists((BaseUnityPlugin plugin) => plugin.Info.Metadata.GUID == "com.willuwontu.rounds.tabinfo")) { TabinfoInterface.Setup(); } CardResgester cardResgester = assets.LoadAsset("DevilModCards").GetComponent(); cardResgester.RegisterCards(); PickManager.RegisterHandFinalizationAction((Action)delegate { GuaranteedCardOfRarityHandler.GeneratedGuaranteedCardOfRaritesSlots = false; }); PickManager.RegisterDrawValidationFunction((Func)GuaranteedCardOfRarityHandler.GuaranteedCardOfRarites); AACMenu.OnMenuRegister = (Action)Delegate.Combine(AACMenu.OnMenuRegister, (Action)delegate { AACMenu.CreateModuleMenuWithReadmeGenerator("AALUND13 Devil Cards", "1.3.1", cardResgester); }); } } internal class TabinfoInterface { public static void Setup() { StatCategory orCreateCategory = TabinfoInterface.GetOrCreateCategory("AA Stats", 6); TabInfoManager.RegisterStat(orCreateCategory, "Disable Block Cooldown", (Func)((Player p) => GetDevilStatsFromPlayer(p).DisbaleBlockTime), (Func)((Player p) => $"{GetDevilStatsFromPlayer(p).DisbaleBlockTime}")); TabInfoManager.RegisterStat(orCreateCategory, "Fixed Block Cooldown", (Func)((Player p) => GetDevilStatsFromPlayer(p).FixedBlockCooldown != 0f), (Func)((Player p) => $"{GetDevilStatsFromPlayer(p).FixedBlockCooldown}s")); TabInfoManager.RegisterStat(orCreateCategory, "Guarantees Rarites", (Func)((Player p) => GetDevilStatsFromPlayer(p).GuaranteedRarities.Count != 0), (Func)((Player p) => string.Join(", ", GetDevilStatsFromPlayer(p).GuaranteedRarities.Select((Rarity r) => r.name)) ?? "")); } private static DevilCardsStats GetDevilStatsFromPlayer(Player player) { return CharacterDataExtensions.GetCustomStatsRegistry(player.data).GetOrCreate(); } } } namespace AALUND13Cards.Devil.Patches { [HarmonyPatch(typeof(Block))] internal class BlockPatch { [HarmonyPostfix] [HarmonyPriority(0)] [HarmonyPatch("IsBlocking")] public static void DisableBlockTime(Block __instance, ref bool __result, CharacterData ___data) { if (CharacterDataExtensions.GetCustomStatsRegistry(___data).GetOrCreate().DisbaleBlockTime) { __result = false; } } [HarmonyPrefix] [HarmonyPatch("Cooldown")] public static bool FixedBlockCooldown(Block __instance, ref float __result, CharacterData ___data) { if ((Object)(object)___data != (Object)null && CharacterDataExtensions.GetCustomStatsRegistry(___data).GetOrCreate().FixedBlockCooldown != 0f) { __result = CharacterDataExtensions.GetCustomStatsRegistry(___data).GetOrCreate().FixedBlockCooldown; return false; } return true; } } [HarmonyPatch(typeof(Gun))] public class GunPatch { private static Dictionary registeredShootActions = new Dictionary(); public static void RegisterShootAction(Player player, Action onShoot) { if (registeredShootActions.TryGetValue(player, out var value)) { value = (Action)Delegate.Combine(value, onShoot); } else { registeredShootActions.Add(player, onShoot); } } public static void DeregisterShootAction(Player player, Action onShoot) { if (registeredShootActions.TryGetValue(player, out var value)) { value = (Action)Delegate.Remove(value, onShoot); } } [HarmonyPatch("DoAttack")] [HarmonyPostfix] public static void TriggerShootAction(Gun __instance) { if (registeredShootActions.TryGetValue(__instance.player, out var value)) { value?.Invoke(); } } } } namespace AALUND13Cards.Devil.MonoBehaviours.CardsEffects { public class CorruptedGrowthEffect : MonoBehaviour, IBattleStartHookHandler, IPointEndHookHandler { public float HealthPerCardsMultiplier = 1.05f; public float DamagePerCardsMultiplier = 1.05f; public float ReloadTimePerCardsMultiplier = 1.05f; public float BlockCooldownCardsMultiplier = 0.95f; private PerCardEffect perCardEffect; private Player player; private void Start() { player = ((Component)this).GetComponentInParent(); InterfaceGameModeHooksManager.instance.RegisterHooks((object)this); } private void OnDestroy() { InterfaceGameModeHooksManager.instance.RemoveHooks((object)this); } public void OnBattleStart() { perCardEffect = ((Component)player).gameObject.AddComponent(); perCardEffect.Initialize(this); } public void OnPointEnd() { if ((Object)(object)perCardEffect != (Object)null) { Object.Destroy((Object)(object)perCardEffect); } } } public class PerCardEffect : ReversibleEffect { public CorruptedGrowthEffect corruptedGrowthEffect; public void Initialize(CorruptedGrowthEffect stats) { corruptedGrowthEffect = stats; } public override void OnAwake() { ((ReversibleEffect)this).SetLivesToEffect(int.MaxValue); } public override void OnStart() { base.characterDataModifier.maxHealth_mult = (corruptedGrowthEffect.HealthPerCardsMultiplier - 1f) * (float)base.player.data.currentCards.Count + 1f; base.gunStatModifier.damage_mult = (corruptedGrowthEffect.DamagePerCardsMultiplier - 1f) * (float)base.player.data.currentCards.Count + 1f; base.gunAmmoStatModifier.reloadTimeMultiplier_mult = (corruptedGrowthEffect.ReloadTimePerCardsMultiplier - 1f) * (float)base.player.data.currentCards.Count + 1f; base.blockModifier.cdMultiplier_mult = (corruptedGrowthEffect.BlockCooldownCardsMultiplier - 1f) * (float)base.player.data.currentCards.Count + 1f; } } public class DevilSoulEffect : MonoBehaviour { public float HealthOnDeathMultiplier = 0.65f; public float DamageOnDeathMultiplier = 0.65f; private List statChanges = new List(); private Player player; private void Start() { player = ((Component)this).GetComponentInParent(); DeathActionHandler.Instance.RegisterReviveAction(player, (Action)OnDeath); DeathActionHandler.Instance.RegisterTrueDeathAction(player, (Action)OnTrueDeath); } private void OnDestroy() { DeathActionHandler.Instance.DeregisterReviveAction(player, (Action)OnDeath); DeathActionHandler.Instance.DeregisterTrueDeathAction(player, (Action)OnTrueDeath); } private void OnDeath() { DevilSoulDebuffEffect devilSoulDebuffEffect = ((Component)player).gameObject.AddComponent(); devilSoulDebuffEffect.Initialize(this); statChanges.Add(devilSoulDebuffEffect); } private void OnTrueDeath() { foreach (DevilSoulDebuffEffect statChange in statChanges) { Object.Destroy((Object)(object)statChange); } statChanges.Clear(); } } internal class DevilSoulDebuffEffect : ReversibleEffect { public DevilSoulEffect devilSoulEffect; public void Initialize(DevilSoulEffect stats) { devilSoulEffect = stats; } public override void OnAwake() { ((ReversibleEffect)this).SetLivesToEffect(int.MaxValue); } public override void OnStart() { base.characterDataModifier.maxHealth_mult = devilSoulEffect.HealthOnDeathMultiplier; base.gunStatModifier.damage_mult = devilSoulEffect.DamageOnDeathMultiplier; } } public class HellfireSpeedEffect : MonoBehaviour, IPointEndHookHandler { public float AttackSpeedPerShootMultiplier = 1.025f; public float ReloadTimePerShootMultiplier = 1.025f; private List statChanges = new List(); private Player player; private void Start() { player = ((Component)this).GetComponentInParent(); GunPatch.RegisterShootAction(player, OnShoot); InterfaceGameModeHooksManager.instance.RegisterHooks((object)player); } private void OnDestroy() { GunPatch.DeregisterShootAction(player, OnShoot); InterfaceGameModeHooksManager.instance.RemoveHooks((object)player); } private void OnShoot() { HellfireDebuffEffect hellfireDebuffEffect = ((Component)player).gameObject.AddComponent(); hellfireDebuffEffect.Initialize(this); statChanges.Add(hellfireDebuffEffect); } public void OnPointEnd() { foreach (HellfireDebuffEffect statChange in statChanges) { if (!((Object)(object)statChange == (Object)null)) { Object.Destroy((Object)(object)statChange); } } statChanges.Clear(); } } internal class HellfireDebuffEffect : ReversibleEffect { public HellfireSpeedEffect HellfireSpeedEffect; public void Initialize(HellfireSpeedEffect stats) { HellfireSpeedEffect = stats; } public override void OnStart() { base.gunStatModifier.attackSpeed_mult = HellfireSpeedEffect.AttackSpeedPerShootMultiplier; base.gunAmmoStatModifier.reloadTimeMultiplier_mult = HellfireSpeedEffect.ReloadTimePerShootMultiplier; } } } namespace AALUND13Cards.Devil.Handlers { public class DevilCardsHandler : MonoBehaviour { public bool AllowDevilCards = false; public static DevilCardsHandler Instance { get; private set; } private void Start() { Instance = this; GameModeManager.AddHook("GameStart", (Func)OnGameStarted); Cards.instance.AddCardValidationFunction((Func)delegate(Player player, CardInfo card) { //IL_000a: 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_0032: 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 (AllowDevilCards && card.rarity != RarityUtils.GetRarity("Devil")) { return false; } return (AllowDevilCards || card.rarity != RarityUtils.GetRarity("Devil")) ? true : false; }); } private IEnumerator OnGameStarted(IGameModeHandler gameModeHandler) { AllowDevilCards = false; yield break; } } public static class GuaranteedCardOfRarityHandler { private static readonly Dictionary GuaranteedCardSlots = new Dictionary(); internal static bool GeneratedGuaranteedCardOfRaritesSlots = false; internal static void GetGuaranteedCardOfRaritesSlots(Player player) { GuaranteedCardSlots.Clear(); Queue queue = new Queue(CharacterDataExtensions.GetCustomStatsRegistry(player.data).GetOrCreate().GuaranteedRarities); int pickerDraws = DrawNCards.GetPickerDraws(player.playerID); List list = new List(queue.Count); for (int i = 0; i < queue.Count; i++) { Rarity val = queue.Dequeue(); int takenSlot = Random.Range(0, pickerDraws); while (list.Any((int s) => s == takenSlot)) { takenSlot = Random.Range(0, pickerDraws); } list.Add(takenSlot); GuaranteedCardSlots.Add(takenSlot, val); LoggerUtils.Log((LogLevel)16, $"Guaranteed card of rarity {val.name} in slot {takenSlot}", false); } } public static ValidationResult GuaranteedCardOfRarites(CardInfo[] currentCards, CardInfo thisCard) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (!GeneratedGuaranteedCardOfRaritesSlots) { Player player = (((int)(PickerType)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "pickerType") != 0) ? PlayerManager.instance.players[CardChoice.instance.pickrID] : PlayerManager.instance.GetPlayersInTeam(CardChoice.instance.pickrID)[0]); GetGuaranteedCardOfRaritesSlots(player); GeneratedGuaranteedCardOfRaritesSlots = true; } int num = currentCards.Length; LoggerUtils.Log((LogLevel)16, $"Validating card {thisCard.cardName} in slot {num}", false); LoggerUtils.Log((LogLevel)32, $"Current Cards Amount: {currentCards.Length}", false); if (GuaranteedCardSlots.TryGetValue(num, out var value) && IsBelowRarity(value.value, thisCard.rarity)) { return (ValidationResult)1; } return (ValidationResult)0; } private static bool IsBelowRarity(Rarity rarity, Rarity otherRarity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Rarity rarityData = RarityUtils.GetRarityData(rarity); Rarity rarityData2 = RarityUtils.GetRarityData(otherRarity); return rarityData.relativeRarity < rarityData2.relativeRarity; } } } namespace AALUND13Cards.Devil.Handlers.ExtraPickHandlers { public class DevilCardsPickHandler : ExtraPickHandler { public override int HandSize => 3; public override void OnPickStart(Player player) { DevilCardsHandler.Instance.AllowDevilCards = true; } public override void OnPickEnd(Player player, CardInfo card) { DevilCardsHandler.Instance.AllowDevilCards = false; } } } namespace AALUND13Cards.Devil.Cards { public class DevilCardsStats : ICustomStats { public float FixedBlockCooldown = 0f; public bool DisbaleBlockTime = false; public List GuaranteedRarities = new List(); public void ResetStats() { FixedBlockCooldown = 0f; DisbaleBlockTime = false; GuaranteedRarities.Clear(); } } } namespace AALUND13Cards.Devil.Cards.StatModifers { public class DevilStatsModifers : CustomStatModifers { [Header("Blocks")] public bool DisbaleBlockTime = false; public float FixedBlockCooldown = 0f; [Header("Cards Stats")] public int DevilPicks = 0; public bool SetGuaranteedRarity = false; public CardRarity GuaranteesRarity; public override void Apply(Player player) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) CharacterData data = player.data; DevilCardsStats orCreate = CharacterDataExtensions.GetCustomStatsRegistry(data).GetOrCreate(); if (DisbaleBlockTime) { orCreate.DisbaleBlockTime = true; } if (orCreate.FixedBlockCooldown < FixedBlockCooldown) { orCreate.FixedBlockCooldown = FixedBlockCooldown; } if (SetGuaranteedRarity) { Rarity rarity = RarityUtils.GetRarity(((object)Unsafe.As(ref GuaranteesRarity)/*cast due to .constrained prefix*/).ToString()); orCreate.GuaranteedRarities.Add(RarityUtils.GetRarityData(rarity)); } if (DevilPicks > 0 && player.data.view.IsMine) { ExtraCardPickHandler.AddExtraPick(player, DevilPicks); } } } } namespace AALUND13Cards.Devil.Cards.Effects { public class CardsDrawsMultiplierAddedEffect : OnAddedEffect { [Range(0f, 2f)] public float CardsDrawsMultiplier = 1f; public override void OnAdded(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats) { ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)AAC_Core.Instance, 1, (Action)delegate { int num = Mathf.RoundToInt((float)DrawNCards.GetPickerDraws(player.playerID) * CardsDrawsMultiplier); DrawNCards.SetPickerDraws(player.playerID, num); }); } } public class SetPlayerDrawsAddedEffect : OnAddedEffect { [Range(0f, 30f)] public int NumberOfDrawToSet = 5; public override void OnAdded(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats) { ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)AAC_Core.Instance, 0.5f, (Action)delegate { DrawNCards.SetPickerDraws(player.playerID, NumberOfDrawToSet); }); } } }