Decompiled source of Root Nulled v1.0.0

Nulled Cards.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using Nullmanager;
using RarityLib.Utils;
using RootCore;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils;
using UnityEngine;

[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: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[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 RootNulledCards
{
	public class DeNuller : OnAddEffect
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass0_0 : Object
		{
			public CharacterData data;

			public DeNuller <>4__this;

			public Player player;

			internal void <OnAdd>b__0()
			{
				List<CardInfo> currentCards = data.currentCards;
				List<int> val = new List<int>();
				List<CardInfo> val2 = new List<CardInfo>();
				for (int i = 0; i < currentCards.Count; i++)
				{
					CardInfo obj = currentCards[i];
					NullCardInfo val3 = (NullCardInfo)(object)((obj is NullCardInfo) ? obj : null);
					if (val3 != null)
					{
						val.Add(i);
						val2.Add(val3.NulledSorce);
					}
				}
				((MonoBehaviour)Unbound.Instance).StartCoroutine(<>4__this.ReplaceCards(player, val.ToArray(), val2.ToArray()));
			}
		}

		public override void OnAdd(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			<>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0();
			CS$<>8__locals0.data = data;
			CS$<>8__locals0.<>4__this = this;
			CS$<>8__locals0.player = player;
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Core.instance, 2, (Action)delegate
			{
				List<CardInfo> currentCards = CS$<>8__locals0.data.currentCards;
				List<int> val = new List<int>();
				List<CardInfo> val2 = new List<CardInfo>();
				for (int i = 0; i < currentCards.Count; i++)
				{
					CardInfo obj = currentCards[i];
					NullCardInfo val3 = (NullCardInfo)(object)((obj is NullCardInfo) ? obj : null);
					if (val3 != null)
					{
						val.Add(i);
						val2.Add(val3.NulledSorce);
					}
				}
				((MonoBehaviour)Unbound.Instance).StartCoroutine(CS$<>8__locals0.<>4__this.ReplaceCards(CS$<>8__locals0.player, val.ToArray(), val2.ToArray()));
			});
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		public IEnumerator ReplaceCards(Player player, int[] indeces, CardInfo[] newCards, string[] twoLetterCodes = null, bool editCardBar = true)
		{
			if (twoLetterCodes == null)
			{
				twoLetterCodes = (string[])(object)new String[indeces.Length];
				for (int i = 0; i < twoLetterCodes.Length; i++)
				{
					twoLetterCodes[i] = "";
				}
			}
			List<bool> reassign = new List<bool>();
			List<CardInfo> val = new List<CardInfo>();
			Enumerator<CardInfo> enumerator = player.data.currentCards.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					CardInfo current = enumerator.Current;
					val.Add(current);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			List<CardInfo> newCardsToAssign = new List<CardInfo>();
			List<string> twoLetterCodesToAssign = new List<string>();
			int num = 0;
			for (int j = 0; j < val.Count; j++)
			{
				if (!Enumerable.Contains<int>((IEnumerable<int>)(object)indeces, j))
				{
					newCardsToAssign.Add(val[j]);
					twoLetterCodesToAssign.Add("");
					reassign.Add(true);
				}
				else if ((Object)(object)newCards[num] == (Object)null)
				{
					newCardsToAssign.Add(val[j]);
					twoLetterCodesToAssign.Add("");
					num++;
					reassign.Add(true);
				}
				else
				{
					newCardsToAssign.Add(newCards[num]);
					twoLetterCodesToAssign.Add(twoLetterCodes[num]);
					num++;
					reassign.Add(false);
				}
			}
			Cards.instance.RemoveAllCardsFromPlayer(player, editCardBar);
			yield return new WaitForSecondsRealtime(0.1f);
			if (editCardBar)
			{
				CardBarUtils.instance.ClearCardBar(player);
			}
			Cards.instance.AddCardsToPlayer(player, newCardsToAssign.ToArray(), reassign.ToArray(), twoLetterCodesToAssign.ToArray(), (float[])null, (float[])null, editCardBar);
		}
	}
	public class DistillAcquisition : MonoBehaviour
	{
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Systems.R00t.Nulls", "Nulled Cards", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class Main : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_0 : Object
		{
			public Player player;

			internal bool <ExtraPicks>b__0(int i)
			{
				return PlayerManager.instance.players[i].playerID == player.playerID;
			}
		}

		private const string ModId = "Systems.R00t.Nulls";

		private const string ModName = "Nulled Cards";

		public const string Version = "1.0.0";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("Systems.R00t.Nulls").PatchAll();
			Core.RegesterCards(AssetUtils.LoadAssetBundleFromResources("nullcardassets", typeof(Main).Assembly).LoadAsset<GameObject>("Nulled").GetComponent<CardList>(), false);
		}

		private void Start()
		{
			NullManager.instance.RegesterOnAddCallback((Action<NullCardInfo, Player>)OnNullAdd);
			GameModeManager.AddHook("PlayerPickEnd", (Func<IGameModeHandler, IEnumerator>)ExtraPicks);
			GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)PointEnd);
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		internal IEnumerator ExtraPicks(IGameModeHandler gm)
		{
			Player[] array = PlayerManager.instance.players.ToArray();
			for (int j = 0; j < array.Length; j++)
			{
				<>c__DisplayClass5_0 CS$<>8__locals0 = new <>c__DisplayClass5_0
				{
					player = array[j]
				};
				if (CharacterStatModifiersExtension.GetRootData(CS$<>8__locals0.player).knowledge > 0)
				{
					yield return GameModeManager.TriggerHook("PlayerPickStart");
					CardChoiceVisuals.instance.Show(Enumerable.First<int>(Enumerable.Where<int>(Enumerable.Range(0, PlayerManager.instance.players.Count), (Func<int, bool>)((int i) => PlayerManager.instance.players[i].playerID == CS$<>8__locals0.player.playerID))), true);
					yield return CardChoice.instance.DoPick(1, CS$<>8__locals0.player.playerID, (PickerType)1);
					yield return new WaitForSecondsRealtime(0.1f);
					yield return GameModeManager.TriggerHook("PlayerPickEnd");
				}
			}
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		internal IEnumerator PointEnd(IGameModeHandler gm)
		{
			Enumerable.ToList<Player>((IEnumerable<Player>)(object)PlayerManager.instance.players).ForEach((Action<Player>)delegate(Player player)
			{
				CharacterStatModifiersExtension.AjustNulls(player.data.stats, CharacterStatModifiersExtension.GetRootData(player).nullsPerPoint);
			});
			yield break;
		}

		internal void OnNullAdd(NullCardInfo card, Player player)
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			Gun component = ((Component)((Component)player).GetComponent<Holding>().holdable).GetComponent<Gun>();
			GunAmmo componentInChildren = ((Component)component).GetComponentInChildren<GunAmmo>();
			CharacterData component2 = ((Component)player).GetComponent<CharacterData>();
			((Component)player).GetComponent<HealthHandler>();
			((Component)player).GetComponent<Gravity>();
			Block component3 = ((Component)player).GetComponent<Block>();
			CharacterStatModifiers component4 = ((Component)player).GetComponent<CharacterStatModifiers>();
			component2.maxHealth *= CharacterStatModifiersExtension.GetRootData(component4).nullData.Health_multiplier;
			component4.movementSpeed *= CharacterStatModifiersExtension.GetRootData(component4).nullData.MovmentSpeed_multiplier;
			component4.lifeSteal += CharacterStatModifiersExtension.GetRootData(component4).nullData.Lifesteal;
			component3.cdMultiplier *= CharacterStatModifiersExtension.GetRootData(component4).nullData.block_cdMultiplier;
			component.damage *= CharacterStatModifiersExtension.GetRootData(component4).nullData.Damage_multiplier;
			component.reflects += CharacterStatModifiersExtension.GetRootData(component4).nullData.gun_Reflects;
			componentInChildren.maxAmmo += CharacterStatModifiersExtension.GetRootData(component4).nullData.gun_Ammo;
			if (RarityUtils.GetRarityData(((CardInfo)card).rarity).relativeRarity <= RarityUtils.GetRarityData((Rarity)2).relativeRarity)
			{
				component4.respawns += CharacterStatModifiersExtension.GetRootData(component4).nullData.Revives;
			}
		}
	}
	public class PowerDistillation : OnAddEffect
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass1_0 : Object
		{
			public Player player;
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass1_1 : Object
		{
			public float time;

			public int cardCount;

			public CardInfo randomCard;

			public <>c__DisplayClass1_0 CS$<>8__locals1;

			internal bool <addRandomCards>b__0()
			{
				time += Time.deltaTime;
				if (CS$<>8__locals1.player.data.currentCards.Count <= cardCount && !((Object)(object)CS$<>8__locals1.player.data.currentCards[CS$<>8__locals1.player.data.currentCards.Count - 1] == (Object)(object)randomCard))
				{
					return time > 5f;
				}
				return true;
			}
		}

		public override void OnAdd(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			((MonoBehaviour)Core.instance).StartCoroutine(addRandomCards(player, gun, gunAmmo, data, health, gravity, block, characterStats));
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		public IEnumerator addRandomCards(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			<>c__DisplayClass1_0 cS$<>8__locals = new <>c__DisplayClass1_0
			{
				player = player
			};
			yield return null;
			for (int i = 0; i < 2; i++)
			{
				<>c__DisplayClass1_1 CS$<>8__locals0 = new <>c__DisplayClass1_1();
				CS$<>8__locals0.CS$<>8__locals1 = cS$<>8__locals;
				CS$<>8__locals0.randomCard = Cards.instance.NORARITY_GetRandomCardWithCondition(CS$<>8__locals0.CS$<>8__locals1.player, gun, gunAmmo, data, health, gravity, block, characterStats, (Func<CardInfo, Player, Gun, GunAmmo, CharacterData, HealthHandler, Gravity, Block, CharacterStatModifiers, bool>)condition, 1000);
				if ((Object)(object)CS$<>8__locals0.randomCard == (Object)null)
				{
					CardInfo[] array = Enumerable.ToArray<CardInfo>(Enumerable.Concat<CardInfo>((IEnumerable<CardInfo>)(object)Enumerable.ToList<CardInfo>((IEnumerable<CardInfo>)(object)(ObservableCollection<CardInfo>)typeof(CardManager).GetField("activeCards", (BindingFlags)40).GetValue((object)null)), (IEnumerable<CardInfo>)(object)(List<CardInfo>)typeof(CardManager).GetField("inactiveCards", (BindingFlags)40).GetValue((object)null)));
					CS$<>8__locals0.randomCard = Cards.instance.DrawRandomCardWithCondition(array, CS$<>8__locals0.CS$<>8__locals1.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>)condition, 1000);
				}
				CS$<>8__locals0.cardCount = Enumerable.Count<CardInfo>((IEnumerable<CardInfo>)(object)CS$<>8__locals0.CS$<>8__locals1.player.data.currentCards);
				UtilityExtenions.GiveCard(CS$<>8__locals0.CS$<>8__locals1.player, CS$<>8__locals0.randomCard);
				CS$<>8__locals0.time = 0f;
				yield return new WaitUntil((Func<bool>)delegate
				{
					CS$<>8__locals0.time += Time.deltaTime;
					return CS$<>8__locals0.CS$<>8__locals1.player.data.currentCards.Count > CS$<>8__locals0.cardCount || (Object)(object)CS$<>8__locals0.CS$<>8__locals1.player.data.currentCards[CS$<>8__locals0.CS$<>8__locals1.player.data.currentCards.Count - 1] == (Object)(object)CS$<>8__locals0.randomCard || CS$<>8__locals0.time > 5f;
				});
			}
		}

		public bool condition(CardInfo card, Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)card.rarity == 2 && !Enumerable.Any<CardCategory>(Enumerable.Intersect<CardCategory>((IEnumerable<CardCategory>)(object)card.categories, (IEnumerable<CardCategory>)(object)Core.NoLotteryCategories)))
			{
				return (Object)(object)card != (Object)(object)CardList.GetCardInfo("Integraty");
			}
			return false;
		}
	}
}
namespace RootNulledCards.Patches
{
	[Serializable]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class CardChoicePatchIDoEndPick : Object
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass0_0 : Object
		{
			public CardChoice __instance;

			internal bool <Prefix>b__0(Player p)
			{
				return p.playerID == __instance.pickrID;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass1_0 : Object
		{
			public CardChoice __instance;

			internal bool <GrabCard>b__0(Player p)
			{
				return p.playerID == __instance.pickrID;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass2_0 : Object
		{
			public int playerID;

			internal bool <GiveNulls>b__0(Player p)
			{
				return p.playerID == playerID;
			}
		}

		public static void Prefix(CardChoice __instance, ref List<GameObject> ___spawnedCards, ref GameObject pickedCard, ref float ___speed)
		{
			<>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0();
			CS$<>8__locals0.__instance = __instance;
			if ((Object)(object)pickedCard == (Object)null || !((Object)(object)pickedCard.GetComponent<DistillAcquisition>() != (Object)null))
			{
				return;
			}
			for (int i = 0; i < ___spawnedCards.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)___spawnedCards[i]) && (Object)(object)___spawnedCards[i].gameObject != (Object)(object)pickedCard)
				{
					((MonoBehaviour)CS$<>8__locals0.__instance).StartCoroutine(GrabCard(___spawnedCards[i], ___speed, CS$<>8__locals0.__instance));
				}
			}
			if (PlayerManager.instance.players.Find((Predicate<Player>)((Player p) => p.playerID == CS$<>8__locals0.__instance.pickrID)).data.view.IsMine)
			{
				NetworkingManager.RPC(typeof(CardChoicePatchIDoEndPick), "GiveNulls", (object[])(object)new Object[2]
				{
					(object)CS$<>8__locals0.__instance.pickrID,
					(object)(___spawnedCards.Count - 1)
				});
			}
			___spawnedCards.Clear();
			___spawnedCards.Add(pickedCard);
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		private static IEnumerator GrabCard(GameObject card, float speed, CardChoice __instance)
		{
			<>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0
			{
				__instance = __instance
			};
			if (PlayerManager.instance.players.Find((Predicate<Player>)((Player p) => p.playerID == CS$<>8__locals0.__instance.pickrID)).data.view.IsMine)
			{
				card.GetComponentInChildren<ApplyCardStats>().Pick(CS$<>8__locals0.__instance.pickrID, false, CS$<>8__locals0.__instance.pickerType);
			}
			Vector3 startPos = card.transform.position;
			Vector3 endPos = ((Component)CardChoiceVisuals.instance).transform.position;
			float c2 = 0f;
			while (c2 < 1f)
			{
				CardChoiceVisuals.instance.framesToSnap = 1;
				Vector3 position = Vector3.LerpUnclamped(startPos, endPos, CS$<>8__locals0.__instance.curve.Evaluate(c2));
				card.transform.position = position;
				c2 += Time.deltaTime * speed;
				yield return null;
			}
			Vector3 val = startPos - endPos;
			GamefeelManager.GameFeel(Vector2.op_Implicit(((Vector3)(ref val)).normalized * 2f));
			card.GetComponentInChildren<CardVisuals>().Leave();
			card.GetComponentInChildren<CardVisuals>().Pick();
		}

		[UnboundRPC]
		public static void GiveNulls(int playerID, int amount)
		{
			<>c__DisplayClass2_0 CS$<>8__locals0 = new <>c__DisplayClass2_0();
			CS$<>8__locals0.playerID = playerID;
			CharacterStatModifiersExtension.AjustNulls(PlayerManager.instance.players.Find((Predicate<Player>)((Player p) => p.playerID == CS$<>8__locals0.playerID)).data.stats, (int)((float)amount * 3.5f));
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class ApplyCardStatsPatch : Object
	{
		private static void Postfix(ApplyCardStats __instance, Player ___playerToUpgrade)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (CharacterStatModifiersExtension.GetRootData(___playerToUpgrade).knowledge > 0)
			{
				if (((Component)__instance).GetComponent<CardInfo>().sourceCard is NullCardInfo || ((Component)__instance).GetComponent<CardInfo>() is NullCardInfo)
				{
					CharacterStatModifiersRootData rootData = CharacterStatModifiersExtension.GetRootData(___playerToUpgrade);
					rootData.knowledge--;
				}
				else
				{
					CharacterStatModifiersExtension.AjustNulls(___playerToUpgrade.data.stats, (int)Mathf.Ceil(0.5f + (float)NullManager.instance.GetNullValue(((Component)__instance).GetComponent<CardInfo>().rarity) * 1.5f));
				}
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class AllowedCardPatch : Object
	{
		private static void Postfix(Player player, CardInfo card, ref bool __result, Cards __instance)
		{
			if (card != null && player != null)
			{
				if (CharacterStatModifiersExtension.GetRootData(player).knowledge > 0 && (!CardInfoExtension.IsNullable(card) || CardInfoExtension.IsAntiCard(card)))
				{
					__result = false;
				}
				if ((Object)(object)card == (Object)(object)CardList.GetCardInfo("Integraty") && !Enumerable.Any<CardInfo>((IEnumerable<CardInfo>)(object)player.data.currentCards, (Func<CardInfo, bool>)((CardInfo c) => c is NullCardInfo)))
				{
					__result = false;
				}
			}
		}
	}
}