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 CardChoiceSpawnUniqueCardPatch.CustomCategories;
using DrawNCards;
using HarmonyLib;
using JARL.Bases;
using Microsoft.CodeAnalysis;
using ModdingUtils.GameModes;
using ModdingUtils.MonoBehaviours;
using ModdingUtils.Utils;
using RarityLib.Utils;
using TabInfo.Utils;
using UnboundLib;
using UnboundLib.GameModes;
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: AssemblyVersion("0.0.0.0")]
[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.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.1.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.1.1";
private static AssetBundle assets;
private void Awake()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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<DevilCardsHandler>();
}
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<GameObject>("DevilModCards").GetComponent<CardResgester>();
cardResgester.RegisterCards();
AACMenu.OnMenuRegister = (Action)Delegate.Combine(AACMenu.OnMenuRegister, (Action)delegate
{
AACMenu.CreateModuleMenuWithReadmeGenerator("AALUND13 Devil Cards", "1.1.1", cardResgester);
});
}
}
internal class TabinfoInterface
{
public static void Setup()
{
StatCategory orCreateCategory = TabinfoInterface.GetOrCreateCategory("AA Stats", 6);
TabInfoManager.RegisterStat(orCreateCategory, "Disable Block Cooldown", (Func<Player, bool>)((Player p) => GetDevilStatsFromPlayer(p).DisbaleBlockTime), (Func<Player, string>)((Player p) => $"{GetDevilStatsFromPlayer(p).DisbaleBlockTime}"));
TabInfoManager.RegisterStat(orCreateCategory, "Fixed Block Cooldown", (Func<Player, bool>)((Player p) => GetDevilStatsFromPlayer(p).FixedBlockCooldown != 0f), (Func<Player, string>)((Player p) => $"{GetDevilStatsFromPlayer(p).FixedBlockCooldown}s"));
}
private static DevilCardsStats GetDevilStatsFromPlayer(Player player)
{
return CharacterDataExtensions.GetCustomStatsRegistry(player.data).GetOrCreate<DevilCardsStats>();
}
}
}
namespace AALUND13Cards.Devil.Patches
{
[HarmonyPatch(typeof(Cards), "PlayerIsAllowedCard")]
internal class AllowedCardPatch
{
private static void Postfix(Player player, CardInfo card, ref bool __result)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player == (Object)null) && !((Object)(object)card == (Object)null))
{
List<GameObject> list = (List<GameObject>)ExtensionMethods.GetFieldValue((object)CardChoice.instance, "spawnedCards");
if (CharacterDataExtensions.GetCustomStatsRegistry(player.data).GetOrCreate<DevilCardsStats>().GuaranteedRarity != null && CardChoicePatch.GuaranteedCardSlot == list.Count && IsBelowRarity(CharacterDataExtensions.GetCustomStatsRegistry(player.data).GetOrCreate<DevilCardsStats>().GuaranteedRarity.value, card.rarity))
{
__result = false;
}
}
}
private static bool IsBelowRarity(Rarity rarity, Rarity otherRarity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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;
}
}
[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<DevilCardsStats>().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<DevilCardsStats>().FixedBlockCooldown != 0f)
{
__result = CharacterDataExtensions.GetCustomStatsRegistry(___data).GetOrCreate<DevilCardsStats>().FixedBlockCooldown;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(CardChoice))]
public class CardChoicePatch
{
internal static int GuaranteedCardSlot;
[HarmonyPrefix]
[HarmonyPatch("StartPick")]
private static void GuaranteedCardOfRarity(CardChoice __instance, int pickerIDToSet)
{
int pickerDraws = DrawNCards.GetPickerDraws(pickerIDToSet);
GuaranteedCardSlot = Random.Range(0, pickerDraws);
}
}
[HarmonyPatch(typeof(Gun))]
public class GunPatch
{
private static Dictionary<Player, Action> registeredShootActions = new Dictionary<Player, Action>();
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<Player>();
InterfaceGameModeHooksManager.instance.RegisterHooks((object)this);
}
private void OnDestroy()
{
InterfaceGameModeHooksManager.instance.RemoveHooks((object)this);
}
public void OnBattleStart()
{
perCardEffect = ((Component)player).gameObject.AddComponent<PerCardEffect>();
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<DevilSoulDebuffEffect> statChanges = new List<DevilSoulDebuffEffect>();
private Player player;
private void Start()
{
player = ((Component)this).GetComponentInParent<Player>();
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>();
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<HellfireDebuffEffect> statChanges = new List<HellfireDebuffEffect>();
private Player player;
private void Start()
{
player = ((Component)this).GetComponentInParent<Player>();
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>();
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
{
[CompilerGenerated]
private sealed class <OnGameStarted>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DevilCardsHandler <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OnGameStarted>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
DevilCardsHandler devilCardsHandler = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
devilCardsHandler.AllowDevilCards = false;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public bool AllowDevilCards;
public static DevilCardsHandler Instance { get; private set; }
private void Start()
{
Instance = this;
GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)OnGameStarted);
Cards.instance.AddCardValidationFunction((Func<Player, CardInfo, bool>)((Player player, CardInfo card) => (AllowDevilCards || !card.categories.Contains(CustomCardCategories.instance.CardCategory("DevilCard"))) ? true : false));
}
[IteratorStateMachine(typeof(<OnGameStarted>d__6))]
private IEnumerator OnGameStarted(IGameModeHandler gameModeHandler)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OnGameStarted>d__6(0)
{
<>4__this = this
};
}
}
}
namespace AALUND13Cards.Devil.Handlers.ExtraPickHandlers
{
public class DevilCardsPickHandler : ExtraPickHandler
{
private int oldNumberOfDraws;
public override bool PickConditions(Player player, CardInfo card)
{
return card.categories.Contains(CustomCardCategories.instance.CardCategory("DevilCard"));
}
public override void OnPickStart(Player player)
{
oldNumberOfDraws = DrawNCards.GetPickerDraws(player.playerID);
DrawNCards.RPCA_SetPickerDraws(player.playerID, 3);
DevilCardsHandler.Instance.AllowDevilCards = true;
}
public override void OnPickEnd(Player player, CardInfo card)
{
DrawNCards.RPCA_SetPickerDraws(player.playerID, oldNumberOfDraws);
DevilCardsHandler.Instance.AllowDevilCards = false;
}
}
}
namespace AALUND13Cards.Devil.Cards
{
public class DevilCardsStats : ICustomStats
{
public float FixedBlockCooldown;
public bool DisbaleBlockTime;
public Rarity GuaranteedRarity;
public void ResetStats()
{
FixedBlockCooldown = 0f;
DisbaleBlockTime = false;
GuaranteedRarity = null;
}
}
}
namespace AALUND13Cards.Devil.Cards.StatModifers
{
public class DevilStatsModifers : CustomStatModifers
{
[Header("Blocks")]
public bool DisbaleBlockTime;
public float FixedBlockCooldown;
[Header("Cards Stats")]
public int DevilPicks;
public bool SetGuaranteedRarity;
public CardRarity GuaranteesRarity;
public override void Apply(Player player)
{
//IL_0053: 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_005a: Unknown result type (might be due to invalid IL or missing references)
DevilCardsStats orCreate = CharacterDataExtensions.GetCustomStatsRegistry(player.data).GetOrCreate<DevilCardsStats>();
if (DisbaleBlockTime)
{
orCreate.DisbaleBlockTime = true;
}
if (orCreate.FixedBlockCooldown < FixedBlockCooldown)
{
orCreate.FixedBlockCooldown = FixedBlockCooldown;
}
if (SetGuaranteedRarity)
{
Rarity rarity = RarityUtils.GetRarity(((object)(CardRarity)(ref GuaranteesRarity)).ToString());
orCreate.GuaranteedRarity = RarityUtils.GetRarityData(rarity);
}
if (DevilPicks > 0 && player.data.view.IsMine)
{
ExtraCardPickHandler.AddExtraPick<DevilCardsPickHandler>(player, DevilPicks, (ExtraPickPhaseTrigger)0);
}
}
}
}
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.ExecuteAfterSeconds((MonoBehaviour)(object)AAC_Core.Instance, 0.5f, (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);
});
}
}
}