using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using UnboundLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Serialization;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[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(/*Could not decode attribute arguments.*/)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CardReplacer
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("NightHunters.rounds.plugins.cardreplacer", "CardReplacer", "0.1.0")]
[BepInProcess("Rounds.exe")]
public class CardReplacer : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <>c__DisplayClass6_0 : Object
{
public CardInfo oldcard;
internal bool <SwapCard>b__0(CardInfo card)
{
return card.cardName == oldcard.cardName;
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass7_0 : Object
{
public Player player;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass7_1 : Object
{
public CardInfo card;
public <>c__DisplayClass7_0 CS$<>8__locals1;
internal void <HookCards>b__0()
{
((MonoBehaviour)Unbound.Instance).StartCoroutine(instance.SwapCard(CS$<>8__locals1.player, card));
}
}
[CompilerGenerated]
private sealed class <>c__DisplayClass8_0 : Object
{
public Player player;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass8_1 : Object
{
public CardInfo card;
public <>c__DisplayClass8_0 CS$<>8__locals1;
internal void <NewCardAdd>b__0()
{
((MonoBehaviour)Unbound.Instance).StartCoroutine(instance.SwapCard(CS$<>8__locals1.player, card));
}
}
[CompilerGenerated]
private sealed class <SwapCard>d__6 : Object, IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Player player;
public CardInfo oldcard;
public CardReplacer <>4__this;
private <>c__DisplayClass6_0 <>8__1;
private int <idx>5__2;
private CardInfo <card>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SwapCard>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<card>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass6_0();
<>8__1.oldcard = oldcard;
if ((Object)(object)<>8__1.oldcard == (Object)null)
{
return false;
}
MonoBehaviour.print((object)String.Concat(((Object)player).name, " ", <>8__1.oldcard.cardName));
<idx>5__2 = player.data.currentCards.FindIndex((Predicate<CardInfo>)((CardInfo card) => card.cardName == <>8__1.oldcard.cardName));
<card>5__3 = Cards.instance.NORARITY_GetRandomCardWithCondition(player, (Gun)null, (GunAmmo)null, (CharacterData)null, (HealthHandler)null, (Gravity)null, (Block)null, (CharacterStatModifiers)null, (Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool>)((CardInfo card, Player player, Gun g, GunAmmo ga, CharacterData d, HealthHandler h, Gravity gr, Block b, CharacterStatModifiers s) => true), 1000);
MonoBehaviour.print((object)String.Concat("Swapping ", <>8__1.oldcard.cardName, " with ", <card>5__3.cardName));
<>2__current = Cards.instance.ReplaceCard(player, <idx>5__2, <card>5__3, "", 2f, 2f, true);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
MonoBehaviour.print((object)String.Concat("Swapped ", <>8__1.oldcard.cardName, " with ", <card>5__3.cardName));
instance.HookCards();
return false;
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
throw new NotSupportedException();
}
}
private const string ModId = "NightHunters.rounds.plugins.cardreplacer";
private const string ModName = "CardReplacer";
public static CardReplacer instance;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
new Harmony("NightHunters.rounds.plugins.cardreplacer").PatchAll();
}
private void Start()
{
instance = this;
}
private void Update()
{
}
[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
private IEnumerator SwapCard(Player player, CardInfo oldcard)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return (IEnumerator)(object)new <SwapCard>d__6(0)
{
<>4__this = this,
player = player,
oldcard = oldcard
};
}
private void HookCards()
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Expected O, but got Unknown
CardBar[] array = (CardBar[])Traverse.Create((object)CardBarHandler.instance).Field("cardBars").GetValue();
for (int i = 0; i < array.Length; i++)
{
<>c__DisplayClass7_0 <>c__DisplayClass7_ = new <>c__DisplayClass7_0();
if (i >= PlayerManager.instance.players.Count || i >= array.Length)
{
continue;
}
CardBar val = array[i];
<>c__DisplayClass7_.player = PlayerManager.instance.players[i];
CardBarButton[] componentsInChildren = ((Component)val).GetComponentsInChildren<CardBarButton>();
CardBarButton[] array2 = componentsInChildren;
foreach (CardBarButton val2 in array2)
{
<>c__DisplayClass7_1 CS$<>8__locals0 = new <>c__DisplayClass7_1();
CS$<>8__locals0.CS$<>8__locals1 = <>c__DisplayClass7_;
CS$<>8__locals0.card = (CardInfo)Traverse.Create((object)val2).Field("card").GetValue();
SwapButton orAddComponent = ExtensionMethods.GetOrAddComponent<SwapButton>(((Component)val2).gameObject, false);
((UnityEvent)orAddComponent.onClick).AddListener((UnityAction)delegate
{
((MonoBehaviour)Unbound.Instance).StartCoroutine(instance.SwapCard(CS$<>8__locals0.CS$<>8__locals1.player, CS$<>8__locals0.card));
});
}
}
}
public void NewCardAdd(int teamId, CardInfo newCard)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
<>c__DisplayClass8_0 <>c__DisplayClass8_ = new <>c__DisplayClass8_0();
if (teamId >= PlayerManager.instance.players.Count)
{
Debug.LogError("teamId is out of bounds");
}
<>c__DisplayClass8_.player = PlayerManager.instance.players[teamId];
CardBar[] array = (CardBar[])Traverse.Create((object)CardBarHandler.instance).Field("cardBars").GetValue();
CardBar val = array[teamId];
CardBarButton[] componentsInChildren = ((Component)val).GetComponentsInChildren<CardBarButton>();
CardBarButton[] array2 = componentsInChildren;
foreach (CardBarButton val2 in array2)
{
<>c__DisplayClass8_1 CS$<>8__locals0 = new <>c__DisplayClass8_1();
CS$<>8__locals0.CS$<>8__locals1 = <>c__DisplayClass8_;
CS$<>8__locals0.card = (CardInfo)Traverse.Create((object)val2).Field("card").GetValue();
SwapButton orAddComponent = ExtensionMethods.GetOrAddComponent<SwapButton>(((Component)val2).gameObject, false);
((UnityEvent)orAddComponent.onClick).AddListener((UnityAction)delegate
{
((MonoBehaviour)Unbound.Instance).StartCoroutine(instance.SwapCard(CS$<>8__locals0.CS$<>8__locals1.player, CS$<>8__locals0.card));
});
}
}
}
public class SwapButton : Selectable, IPointerClickHandler, IEventSystemHandler
{
[Serializable]
public class ButtonClickedEvent : UnityEvent
{
}
[FormerlySerializedAs("onClick")]
[SerializeField]
private ButtonClickedEvent m_OnClick = new ButtonClickedEvent();
public ButtonClickedEvent onClick
{
get
{
return m_OnClick;
}
set
{
m_OnClick = value;
}
}
public void OnPointerClick(PointerEventData eventData)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
if (((UIBehaviour)this).IsActive() && ((Selectable)this).IsInteractable() && (int)eventData.button == 1)
{
((UnityEvent)m_OnClick).Invoke();
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class WatchNewCardsPatch : Object
{
public static void Postfix(int teamId, CardInfo card)
{
CardReplacer.instance.NewCardAdd(teamId, card);
}
}
}