Decompiled source of ServerCards v3.0.0

ServerCards.dll

Decompiled 2 weeks ago
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 BepInEx.Bootstrap;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ServerCards.Cards;
using UnboundLib.Cards;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ServerCards")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3e96e4cd89e173fd8bf8c31cb669a8fb61259795")]
[assembly: AssemblyProduct("ServerCards")]
[assembly: AssemblyTitle("ServerCards")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ServerCards
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.rounds.servercards.Id", "Server Cards", "2.0.0")]
	[BepInProcess("Rounds.exe")]
	public class ServerCards : BaseUnityPlugin
	{
		private const string ModId = "com.rounds.servercards.Id";

		private const string ModName = "Server Cards";

		public const string Version = "2.0.0";

		public const string ModInitials = "SERC";

		public static ServerCards instance { get; private set; }

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("com.rounds.servercards.Id");
			val.PatchAll();
			instance = this;
		}

		private void Start()
		{
			CustomCard.BuildCard<teleporting>();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.reckzro.servercards", "ServerCards", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class ServerCardsPlugin : BaseUnityPlugin
	{
		internal static Harmony harmony;

		private const string ModId = "com.reckzro.servercards";

		private const string ModName = "Server Cards";

		public const string Version = "2.0.0";

		public const string ModInitials = "SERC";

		public static ServerCardsPlugin instance { get; private set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			instance = this;
			harmony = new Harmony("com.reckzro.servercards");
			harmony.PatchAll();
			try
			{
				Type type = Type.GetType("ClassesManagerReborn.API+ClassData, ClassesManagerReborn") ?? Type.GetType("ClassData, ClassesManagerReborn") ?? null;
				if (type != null)
				{
					object obj = Activator.CreateInstance(type);
					type.GetField("className").SetValue(obj, "Teleporter");
					type.GetField("description").SetValue(obj, "Teleport to your cursor on block");
					FieldInfo field = type.GetField("themeColor");
					if (field != null)
					{
						Type fieldType = field.FieldType;
						try
						{
							object value = Enum.Parse(fieldType, "DefensiveBlue");
							field.SetValue(obj, value);
						}
						catch
						{
						}
					}
					FieldInfo field2 = type.GetField("startingCards");
					if (field2 != null)
					{
						field2.SetValue(obj, new string[1] { "Teleporting" });
					}
					Type type2 = Type.GetType("ClassesManagerReborn.API, ClassesManagerReborn") ?? Type.GetType("ClassesManagerReborn.APIClass, ClassesManagerReborn");
					if (type2 != null)
					{
						MethodInfo method = type2.GetMethod("RegisterClass", BindingFlags.Static | BindingFlags.Public);
						if (method != null)
						{
							method.Invoke(null, new object[1] { obj });
							((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Teleporter class with Class Manager Reborn.");
						}
						else
						{
							((BaseUnityPlugin)this).Logger.LogWarning((object)"RegisterClass method not found on ClassesManagerReborn API; class not registered automatically.");
						}
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)"ClassesManagerReborn API type not found; class not registered automatically.");
					}
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"ClassData type for ClassesManagerReborn not found; class not registered automatically.");
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to register class with Class Manager Reborn: " + ex));
			}
		}

		private void Start()
		{
			try
			{
				CustomCard.BuildCard<teleporting>();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Built TeleportCard.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to build TeleportCard: " + ex));
			}
			try
			{
				List<BaseUnityPlugin> list = (List<BaseUnityPlugin>)typeof(Chainloader).GetField("_plugins", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
				if (!list.Exists((BaseUnityPlugin p) => p.Info.Metadata.GUID == "com.willuwontu.rounds.tabinfo"))
				{
				}
			}
			catch
			{
			}
		}

		private void OnDestroy()
		{
			try
			{
				Harmony obj = harmony;
				if (obj != null)
				{
					obj.UnpatchSelf();
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to unpatch self: " + ex));
			}
		}
	}
}
namespace ServerCards.Cards
{
	public class TeleportEffect : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <TeleportCoroutine>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Vector3 target;

			public TeleportEffect <>4__this;

			private PlayerCollision <collision>5__1;

			private FieldInfo <velField>5__2;

			private string[] <posFields>5__3;

			private string[] <>s__4;

			private int <>s__5;

			private string <fName>5__6;

			private FieldInfo <f>5__7;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TeleportCoroutine>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<collision>5__1 = null;
				<velField>5__2 = null;
				<posFields>5__3 = null;
				<>s__4 = null;
				<fName>5__6 = null;
				<f>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_006c: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<collision>5__1 = ((Component)<>4__this.player).GetComponent<PlayerCollision>();
					if ((Object)(object)<collision>5__1 != (Object)null)
					{
						<collision>5__1.IgnoreWallForFrames(2);
					}
					((Component)<>4__this.player.data).transform.position = target;
					((Component)<>4__this).transform.position = target;
					<velField>5__2 = ((object)<>4__this.player.data.playerVel).GetType().GetField("velocity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (<velField>5__2 != null)
					{
						<velField>5__2.SetValue(<>4__this.player.data.playerVel, Vector3.zero);
					}
					<>4__this.player.data.sinceGrounded = 0f;
					<posFields>5__3 = new string[4] { "prevPos", "lastPos", "previousPosition", "serverPos" };
					<>s__4 = <posFields>5__3;
					for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
					{
						<fName>5__6 = <>s__4[<>s__5];
						<f>5__7 = typeof(CharacterData).GetField(<fName>5__6, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (<f>5__7 != null && <f>5__7.FieldType == typeof(Vector3))
						{
							<f>5__7.SetValue(<>4__this.player.data, target);
						}
						<f>5__7 = null;
						<fName>5__6 = null;
					}
					<>s__4 = null;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					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 Player player;

		public Block block;

		private Camera cam;

		private void Start()
		{
			cam = Camera.main;
			if ((Object)(object)block != (Object)null)
			{
				Block obj = block;
				obj.BlockAction = (Action<BlockTriggerType>)Delegate.Combine(obj.BlockAction, new Action<BlockTriggerType>(OnBlock));
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)block != (Object)null)
			{
				Block obj = block;
				obj.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(obj.BlockAction, new Action<BlockTriggerType>(OnBlock));
			}
		}

		private void OnBlock(BlockTriggerType trigger)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)trigger <= 0 && !((Object)(object)player == (Object)null) && !((Object)(object)player.data == (Object)null))
			{
				Vector3 mousePosition = Input.mousePosition;
				mousePosition.z = Mathf.Abs(((Component)cam).transform.position.z - ((Component)player).transform.position.z);
				Vector3 target = cam.ScreenToWorldPoint(mousePosition);
				target.z = ((Component)player).transform.position.z;
				((MonoBehaviour)this).StartCoroutine(TeleportCoroutine(target));
			}
		}

		[IteratorStateMachine(typeof(<TeleportCoroutine>d__6))]
		private IEnumerator TeleportCoroutine(Vector3 target)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TeleportCoroutine>d__6(0)
			{
				<>4__this = this,
				target = target
			};
		}
	}
	public class teleporting : CustomCard
	{
		public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
		{
			statModifiers.health = 1.2f;
			block.cdAdd = 0.25f;
		}

		public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			if (!Object.op_Implicit((Object)(object)((Component)player).gameObject.GetComponent<TeleportEffect>()))
			{
				TeleportEffect teleportEffect = ((Component)player).gameObject.AddComponent<TeleportEffect>();
				teleportEffect.player = player;
				teleportEffect.block = block;
			}
		}

		public override void OnRemoveCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			TeleportEffect component = ((Component)player).gameObject.GetComponent<TeleportEffect>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
		}

		protected override string GetTitle()
		{
			return "Teleporting";
		}

		protected override string GetDescription()
		{
			return "Teleport instantly to your cursor when you block";
		}

		protected override GameObject GetCardArt()
		{
			return null;
		}

		protected override Rarity GetRarity()
		{
			return (Rarity)2;
		}

		protected override CardInfoStat[] GetStats()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			//IL_0056: 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_005e: Expected O, but got Unknown
			return (CardInfoStat[])(object)new CardInfoStat[2]
			{
				new CardInfoStat
				{
					positive = true,
					stat = "Health",
					amount = "+20%",
					simepleAmount = (SimpleAmount)0
				},
				new CardInfoStat
				{
					positive = false,
					stat = "Block Cooldown",
					amount = "+0.25s",
					simepleAmount = (SimpleAmount)0
				}
			};
		}

		protected override CardThemeColorType GetTheme()
		{
			return (CardThemeColorType)2;
		}

		public override string GetModName()
		{
			return "SERC";
		}
	}
}