Decompiled source of Demonic Cards v1.0.0

Demonic Cards.dll

Decompiled a day ago
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 System.Security;
using System.Security.Permissions;
using BepInEx;
using ClassesManagerReborn;
using HarmonyLib;
using InControl;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using RarityLib.Utils;
using RootCore;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
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 RootDemonicCards
{
	public class ContractPath : ClassHandler
	{
		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		public override IEnumerator Init()
		{
			ClassesRegistry.Register((CardInfo)(object)CardList.GetCardInfo("Lilith_Deal"), (CardType)33, 0);
			ClassesRegistry.Register((CardInfo)(object)CardList.GetCardInfo("Contract"), (CardType)40, (CardInfo)(object)CardList.GetCardInfo("Lilith_Deal"), 0);
			ClassesRegistry.Register((CardInfo)(object)CardList.GetCardInfo("Dark_Queen"), (CardType)48, (CardInfo)(object)CardList.GetCardInfo("Contract"), 0);
			yield break;
		}
	}
	public class Dark_Queen : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass6_0 : Object
		{
			public Player player;

			public Vector3 vector;

			internal void <Telleport>b__0()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				((Damagable)player.data.healthHandler).CallTakeDamage(Vector2.up * player.data.maxHealth * 0.34f, Vector2.op_Implicit(vector), (GameObject)null, player, true);
			}
		}

		public GameObject SoulStone;

		private GameObject _SoulStone;

		private float timer;

		private void Awake()
		{
			((Behaviour)((Component)this).GetComponentInParent<Gravity>()).enabled = false;
			((Behaviour)((Component)this).GetComponentInParent<PlayerVelocity>()).enabled = false;
			Transform transform = ((Component)((Component)this).GetComponentInParent<WeaponHandler>().gun).transform;
			((Component)transform.Find("Spring/Handle")).gameObject.SetActive(false);
			((Component)transform.Find("Spring/Barrel")).gameObject.SetActive(false);
			((Component)transform.Find("Spring/Ammo/Canvas")).gameObject.SetActive(false);
			_SoulStone = Object.Instantiate<GameObject>(SoulStone, transform);
		}

		private void OnDestroy()
		{
			((Behaviour)((Component)this).GetComponentInParent<Gravity>()).enabled = true;
			((Behaviour)((Component)this).GetComponentInParent<PlayerVelocity>()).enabled = true;
			Transform transform = ((Component)((Component)this).GetComponentInParent<WeaponHandler>().gun).transform;
			((Component)transform.Find("Spring/Handle")).gameObject.SetActive(true);
			((Component)transform.Find("Spring/Barrel")).gameObject.SetActive(true);
			((Component)transform.Find("Spring/Ammo/Canvas")).gameObject.SetActive(true);
			Object.Destroy((Object)(object)_SoulStone);
		}

		private void Update()
		{
			if (timer > 0f)
			{
				timer -= TimeHandler.deltaTime;
				if (timer <= 0f)
				{
					_SoulStone.SetActive(true);
				}
			}
		}

		public void Telleport()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			if (!(timer <= 0f))
			{
				return;
			}
			<>c__DisplayClass6_0 CS$<>8__locals0 = new <>c__DisplayClass6_0();
			CS$<>8__locals0.vector = MainCam.instance.cam.ScreenToWorldPoint(Input.mousePosition);
			CS$<>8__locals0.player = ((Component)this).GetComponentInParent<Player>();
			CS$<>8__locals0.vector.z = ((Component)CS$<>8__locals0.player).transform.position.z;
			if (!Object.op_Implicit((Object)(object)Physics2D.OverlapCircle(Vector2.op_Implicit(CS$<>8__locals0.vector), 0.5f)) && CS$<>8__locals0.player.data.view.IsMine)
			{
				((Component)CS$<>8__locals0.player).GetComponentInParent<PlayerCollision>().IgnoreWallForFrames(2);
				((Component)CS$<>8__locals0.player).transform.position = CS$<>8__locals0.vector;
				ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Core.instance, 2, (Action)delegate
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					((Damagable)CS$<>8__locals0.player.data.healthHandler).CallTakeDamage(Vector2.up * CS$<>8__locals0.player.data.maxHealth * 0.34f, Vector2.op_Implicit(CS$<>8__locals0.vector), (GameObject)null, CS$<>8__locals0.player, true);
				});
				_SoulStone.SetActive(false);
				timer = 2.5f;
			}
		}
	}
	public class HealthCurse : MonoBehaviour
	{
		private float _Health;

		private Player _player;

		public void Awake()
		{
			if ((Object)(object)_player == (Object)null)
			{
				_player = ((Component)this).gameObject.GetComponent<Player>();
			}
			GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)([CompilerGenerated] (IGameModeHandler gm) => reset()));
		}

		public void Cull(float HP)
		{
			if ((Object)(object)_player == (Object)null)
			{
				_player = ((Component)this).gameObject.GetComponent<Player>();
			}
			if (PlayerStatus.PlayerAliveAndSimulated(_player))
			{
				CharacterData data = _player.data;
				data.maxHealth += _Health;
				_Health = Mathf.Min(_Health + HP, _player.data.maxHealth - 1f);
				CharacterData data2 = _player.data;
				data2.maxHealth -= _Health;
			}
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		public IEnumerator reset()
		{
			CharacterData data = _player.data;
			data.maxHealth += _Health;
			_Health = 0f;
			yield break;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Systems.R00t.DemonicCards", "Demonic Cards", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class Main : BaseUnityPlugin
	{
		private const string ModId = "Systems.R00t.DemonicCards";

		private const string ModName = "Demonic Cards";

		public const string Version = "1.0.0";

		public static AssetBundle Assets;

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

		private void Start()
		{
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)GameStart);
		}

		internal void SetUpContract()
		{
			RarityUtils.SetCardRarityModifier((CardInfo)(object)CardList.GetCardInfo("Contract"), 20f);
			RarityUtils.SetCardRarityModifier((CardInfo)(object)CardList.GetCardInfo("Dark_Queen"), 200f);
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		internal IEnumerator GameStart(IGameModeHandler gm)
		{
			SetUpContract();
			yield break;
		}
	}
	internal class PainfullAttacks : DealtDamageEffect
	{
		public override void DealtDamage(Vector2 damage, bool selfDamage, Player damagedPlayer)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (!selfDamage && !((Object)(object)damagedPlayer == (Object)null))
			{
				((Component)this).gameObject.GetComponentInParent<Player>().data.healthHandler.DoDamage(damage, damagedPlayer.data.playerVel.position, Color.magenta, (GameObject)null, ((Component)this).gameObject.GetComponentInParent<Player>(), false, true, true);
			}
		}
	}
	public class PhyrexianText : MonoBehaviour
	{
		public static char[] Codes;

		public int count;

		public int min;

		public int max;

		public float changetime;

		private float time;

		private string target;

		private void Start()
		{
			((TMP_Text)((Component)this).GetComponent<TextMeshPro>()).text = GenerateStrings(count, min, max);
			((Component)this).GetComponent<Renderer>().sortingLayerName = "MostFront";
			target = GenerateStrings(count, min, max);
			time = 0f;
		}

		private void Update()
		{
			time += Time.deltaTime;
			((TMP_Text)((Component)this).GetComponent<TextMeshPro>()).text = LarpTexts(count, ((TMP_Text)((Component)this).GetComponent<TextMeshPro>()).text, target, time / changetime);
			if (time >= changetime)
			{
				time = 0f;
				target = GenerateStrings(count, min, max);
			}
		}

		public static string LarpTexts(int count, string start, string end, float part)
		{
			part = Mathf.Clamp01(part);
			count++;
			int num = Mathf.RoundToInt((float)start.Length * part);
			char[] array = start.ToCharArray();
			for (int i = 0; i < count; i++)
			{
				for (int j = 0; j < start.Length / count; j++)
				{
					if (i * count + j < num)
					{
						array[j * count + count - 2 - i] = end[j * count + count - 2 - i];
					}
				}
			}
			return TMPro_ExtensionMethods.ArrayToString(array);
		}

		public static string GenerateStrings(int count, int minLangth, int maxLangth)
		{
			List<string> val = new List<string>();
			for (int i = 0; i < count; i++)
			{
				int num = Random.Range(minLangth, maxLangth + 1);
				string text = "|";
				for (int j = 0; j < num; j++)
				{
					text = String.Concat(text, ((Char)(ref Codes[Random.Range(0, Codes.Length)])).ToString());
				}
				text = String.Concat(text, ".");
				for (int k = num; k < maxLangth; k++)
				{
					text = String.Concat(text, " ");
				}
				val.Add(text);
			}
			string text2 = "";
			for (int l = 0; l < maxLangth + 2; l++)
			{
				char c;
				for (int m = 0; m < val.Count; m++)
				{
					string text3 = text2;
					c = val[m][l];
					text2 = String.Concat(text3, ((Char)(ref c)).ToString());
				}
				string text4 = text2;
				c = Convert.ToChar(10);
				text2 = String.Concat(text4, ((Char)(ref c)).ToString());
			}
			return text2;
		}

		static PhyrexianText()
		{
			Char[] array = new Char[49];
			RuntimeHelpers.InitializeArray((Array)(object)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Codes = (char[])(object)array;
		}
	}
	internal class SoulContract : DealtDamageEffect
	{
		internal class SoulReturn : MonoBehaviour
		{
			private float health;

			private Player player;

			private float timer;

			private float duration;

			internal void SetPlayerAndHealth(Player player, float health)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: 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)
				this.player = player;
				this.health = health;
				((Component)this).transform.localScale = Vector3.one * Mathf.Clamp(health / 100f, 0.25f, 5f);
				duration = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) / 7f;
			}

			public void Update()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				timer += TimeHandler.deltaTime;
				((Component)this).gameObject.transform.position = Vector3.Lerp(((Component)this).gameObject.transform.position, ((Component)player).transform.position, TimeHandler.deltaTime / (duration - timer));
				if (timer > duration + 0.1f)
				{
					player.data.healthHandler.Heal(health);
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass4_0 : Object
		{
			public Player damagedPlayer;

			public Func<Player, bool> <>9__0;

			internal bool <SoulDrain>b__0(Player p)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				if (p.teamID != damagedPlayer.playerID)
				{
					return Vector3.Distance(((Component)damagedPlayer).transform.position, ((Component)p).transform.position) < 14f * ((Component)damagedPlayer).transform.localScale.z;
				}
				return false;
			}
		}

		private float Cooldown;

		private float storedDamage;

		public override void DealtDamage(Vector2 damage, bool selfDamage, Player damagedPlayer = null)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (selfDamage)
			{
				if (Cooldown > 0f)
				{
					storedDamage += ((Vector2)(ref damage)).magnitude;
					return;
				}
				SoulDrain(damage, damagedPlayer);
				Cooldown = 0.3f;
			}
		}

		private void Update()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (!(Cooldown > 0f))
			{
				return;
			}
			Cooldown -= Time.deltaTime;
			if (Cooldown <= 0f)
			{
				if (storedDamage > 0f)
				{
					SoulDrain(Vector2.up * storedDamage, ((Component)this).GetComponentInParent<Player>());
				}
				storedDamage = 0f;
			}
		}

		private void SoulDrain(Vector2 damage, Player damagedPlayer)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			<>c__DisplayClass4_0 CS$<>8__locals0 = new <>c__DisplayClass4_0();
			CS$<>8__locals0.damagedPlayer = damagedPlayer;
			IEnumerator<Player> enumerator = Enumerable.Where<Player>((IEnumerable<Player>)(object)PlayerManager.instance.players, (Func<Player, bool>)((Player p) => p.teamID != CS$<>8__locals0.damagedPlayer.playerID && Vector3.Distance(((Component)CS$<>8__locals0.damagedPlayer).transform.position, ((Component)p).transform.position) < 14f * ((Component)CS$<>8__locals0.damagedPlayer).transform.localScale.z)).GetEnumerator();
			try
			{
				while (((IEnumerator)enumerator).MoveNext())
				{
					Player current = enumerator.Current;
					Vector2 val = damage * (1f - Vector3.Distance(((Component)CS$<>8__locals0.damagedPlayer).transform.position, ((Component)current).transform.position) / (14f * ((Component)CS$<>8__locals0.damagedPlayer).transform.localScale.z));
					if (CS$<>8__locals0.damagedPlayer.data.view.IsMine)
					{
						((Damagable)current.data.healthHandler).CallTakeDamage(val, Vector2.op_Implicit(((Component)CS$<>8__locals0.damagedPlayer).transform.position), (GameObject)null, (Player)null, true);
					}
					Object.Instantiate<GameObject>(Main.Assets.LoadAsset<GameObject>("Soul"), ((Component)current).transform.position, Quaternion.Euler(0f, 0f, 0f)).AddComponent<SoulReturn>().SetPlayerAndHealth(CS$<>8__locals0.damagedPlayer, ((Vector2)(ref val)).magnitude);
				}
			}
			finally
			{
				if (enumerator != null)
				{
					((IDisposable)enumerator).Dispose();
				}
			}
		}
	}
}
namespace RootDemonicCards.Patches
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class DoDamagePatch : Object
	{
		private static void Postfix(HealthHandler __instance, Vector2 damage, Player damagingPlayer)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)damagingPlayer == (Object)null) && !(CharacterStatModifiersExtension.GetRootData(damagingPlayer).hpCulling <= 0f))
			{
				ExtensionMethods.GetOrAddComponent<HealthCurse>(((Component)(Player)Traverse.Create((object)__instance).Field("player").GetValue()).gameObject, false).Cull(((Vector2)(ref damage)).magnitude * CharacterStatModifiersExtension.GetRootData(damagingPlayer).hpCulling);
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class GeneralInputPatchUpdate : Object
	{
		public static float vel = 10f;

		private static void Postfix(GeneralInput __instance)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CharacterData component = ((Component)__instance).GetComponent<CharacterData>();
				Dark_Queen componentInChildren = ((Component)__instance).GetComponentInChildren<Dark_Queen>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					if (((OneAxisInputControl)component.playerActions.Up).IsPressed)
					{
						Transform transform = ((Component)__instance).transform;
						transform.position += Vector3.up * vel * component.stats.movementSpeed * TimeHandler.deltaTime;
					}
					if (((OneAxisInputControl)component.playerActions.Down).IsPressed)
					{
						Transform transform2 = ((Component)__instance).transform;
						transform2.position += Vector3.down * vel * component.stats.movementSpeed * TimeHandler.deltaTime;
					}
					if (((OneAxisInputControl)component.playerActions.Left).IsPressed)
					{
						Transform transform3 = ((Component)__instance).transform;
						transform3.position += Vector3.left * vel * component.stats.movementSpeed * TimeHandler.deltaTime;
					}
					if (((OneAxisInputControl)component.playerActions.Right).IsPressed)
					{
						Transform transform4 = ((Component)__instance).transform;
						transform4.position += Vector3.right * vel * component.stats.movementSpeed * TimeHandler.deltaTime;
					}
					if (((OneAxisInputControl)component.playerActions.Fire).WasPressed)
					{
						componentInChildren.Telleport();
					}
					__instance.shootIsPressed = false;
					__instance.shootWasPressed = false;
					__instance.shootWasReleased = false;
				}
			}
			catch (Object)
			{
			}
		}
	}
}