Decompiled source of VeganKoalasFantasticCards v0.0.2

plugins/VeganKFC.dll

Decompiled 4 months 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 HarmonyLib;
using Jotunn.Utils;
using ModdingUtils.Utils;
using ModsPlus;
using Photon.Pun;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnityEngine;
using VKFC.Cards;
using VKFC.Monos;
using VKFC.UnessesaryAddons;

[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("VeganKFC")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VeganKFC")]
[assembly: AssemblyTitle("VeganKFC")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VKFC
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("ancientkoala.rounds.vegankoalasfantasticcards", "Vegan Koalas Fantastic Cards", "0.0.2")]
	[BepInProcess("Rounds.exe")]
	public class VKFC : BaseUnityPlugin
	{
		private const string ModId = "ancientkoala.rounds.vegankoalasfantasticcards";

		private const string ModName = "Vegan Koalas Fantastic Cards";

		public const string Version = "0.0.2";

		public const string ModInitials = "VKFC";

		public static VKFC instance;

		internal static AssetBundle ArtAssets;

		public ObjectsToSpawn wallBounce;

		internal static GameObject BoxProj;

		internal static int BoxCap = 5;

		private void Start()
		{
			//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("ancientkoala.rounds.vegankoalasfantasticcards");
			val.PatchAll();
			instance = this;
			ArtAssets = AssetUtils.LoadAssetBundleFromResources("vkfcassets", typeof(VKFC).Assembly);
			if ((Object)(object)ArtAssets == (Object)null)
			{
				Debug.Log((object)"Vegan Assets no worky");
			}
			BoxProj = ArtAssets.LoadAsset<GameObject>("VKFC_Box");
			BoxProj.AddComponent<OwnerScript>();
			PhotonNetwork.PrefabPool.RegisterPrefab("VKFC_Box", BoxProj);
			CustomCard.BuildCard<BoxedBullets>((Action<CardInfo>)delegate(CardInfo card)
			{
				BoxedBullets.card = card;
				ExtensionMethods.SetAbbreviation(card, "Bb");
			});
		}
	}
}
namespace VKFC.UnessesaryAddons
{
	public class OwnerScript : MonoBehaviour
	{
		public Player Owner = null;

		private Rigidbody2D rb;

		public void FixedUpdate()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Owner != (Object)null)
			{
				rb = ((Component)this).GetComponent<Rigidbody2D>();
				rb.mass = Owner.data.weaponHandler.gun.damage * 20000f;
				((Component)((Component)this).transform.GetChild(0)).GetComponent<SpriteRenderer>().color = PlayerManager.instance.GetColorFromPlayer(Owner.playerID).color;
				((Component)this).GetComponent<SFPolygon>().shadowLayers = LayerMask.op_Implicit(-1);
			}
		}
	}
}
namespace VKFC.Monos
{
	public class BoxThoseBullets : CardEffect
	{
		public List<GameObject> Boxes = new List<GameObject>();

		private int curBox = 0;

		public override void OnShoot(GameObject projectile)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			if (Boxes.Count == 0)
			{
				SpawnBoxes();
			}
			GameObject val = Boxes[curBox];
			curBox++;
			if (curBox == VKFC.BoxCap)
			{
				curBox = 0;
			}
			val.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
			val.transform.position = projectile.transform.position + ((Vector3)(ref ((CardEffect)this).player.data.aimDirection)).normalized * 3f;
			val.transform.rotation = Quaternion.identity;
			float num = Mathf.Sqrt(((CardEffect)this).gun.projectileSpeed);
			Vector3 val2 = ((Vector3)(ref ((CardEffect)this).player.data.aimDirection)).normalized;
			float num2 = Random.Range(0f - ((CardEffect)this).gun.spread, ((CardEffect)this).gun.spread);
			num2 /= (1f + ((CardEffect)this).gun.projectileSpeed * 0.5f) * 0.5f;
			val2 += Vector3.Cross(val2, Vector3.forward) * num2;
			val.GetComponent<Rigidbody2D>().AddForce(Vector2.op_Implicit(((Vector3)(ref val2)).normalized * 40000000f * ((CardEffect)this).gun.damage * num));
			PhotonNetwork.Destroy(projectile);
		}

		[UnboundRPC]
		public static void RPCDistributeOwners(int playerId)
		{
			OwnerScript[] array = Object.FindObjectsOfType<OwnerScript>();
			foreach (OwnerScript ownerScript in array)
			{
				if ((Object)(object)ownerScript.Owner == (Object)null)
				{
					ownerScript.Owner = ExtensionMethods.GetPlayerWithID(PlayerManager.instance, playerId);
					break;
				}
			}
		}

		public override void OnTakeDamage(Vector2 damage, bool selfDamage)
		{
			if (((CardEffect)this).player.data.health < 0f)
			{
				ResetBoxes();
			}
		}

		public override IEnumerator OnPointEnd(IGameModeHandler gameModeHandler)
		{
			KillBoxes();
			yield return null;
		}

		public override IEnumerator OnPointStart(IGameModeHandler gameModeHandler)
		{
			SpawnBoxes();
			yield return null;
		}

		public void SpawnBoxes()
		{
			//IL_0033: 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)
			if (Boxes.Count > 0)
			{
				KillBoxes();
			}
			for (int i = 0; i < ((CardEffect)this).gunAmmo.maxAmmo; i++)
			{
				GameObject item = PhotonNetwork.Instantiate("VKFC_Box", new Vector3(999f, 999f, 0f), Quaternion.identity, (byte)0, (object[])null);
				Boxes.Add(item);
				NetworkingManager.RPC(typeof(BoxThoseBullets), "RPCDistributeOwners", new object[1] { ((CardEffect)this).player.playerID });
			}
		}

		public void ResetBoxes()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject box in Boxes)
			{
				box.transform.position = new Vector3(999f, 999f, 0f);
			}
		}

		public void KillBoxes()
		{
			foreach (GameObject box in Boxes)
			{
				PhotonNetwork.Destroy(box.gameObject);
			}
			Boxes.Clear();
		}
	}
	public class WeStayWinning : CardEffect
	{
		public Dictionary<int, int> TeamScore = new Dictionary<int, int>();

		public override IEnumerator OnPickPhaseStart(IGameModeHandler gameModeHandler)
		{
			foreach (KeyValuePair<int, int> ts in TeamScore)
			{
				if (ts.Key != ((CardEffect)this).player.teamID && GameModeManager.CurrentHandler.GetTeamScore(ts.Key).rounds != ts.Value)
				{
					Cards.instance.RemoveAllCardsFromPlayer(((CardEffect)this).player, true);
				}
			}
			yield return null;
		}
	}
}
namespace VKFC.Cards
{
	public class BoxedBullets : CustomEffectCard<BoxThoseBullets>
	{
		internal static CardInfo card;

		public override CardDetails<BoxThoseBullets> Details => new CardDetails<BoxThoseBullets>
		{
			Title = "Boxed Bullets",
			Description = "Shoot boxes at people instead of bullets",
			ModName = "VKFC",
			Art = VKFC.ArtAssets.LoadAsset<GameObject>("C_BoxedBullets"),
			Rarity = (Rarity)2,
			Theme = (CardThemeColorType)8,
			OwnerOnly = true
		};

		public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers)
		{
			cardInfo.allowMultiple = false;
		}
	}
	public class StayWinning : CustomEffectCard<WeStayWinning>
	{
		internal static CardInfo card;

		public override CardDetails<WeStayWinning> Details
		{
			get
			{
				//IL_0059: 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_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Expected O, but got Unknown
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: 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_009c: 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)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Expected O, but got Unknown
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Expected O, but got Unknown
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: 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_00f4: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Expected O, but got Unknown
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Expected O, but got Unknown
				CardDetails<WeStayWinning> val = new CardDetails<WeStayWinning>();
				val.Title = "We Stay Winning";
				val.Description = "Insane stats, but don't lose";
				val.ModName = "VKFC";
				val.Art = VKFC.ArtAssets.LoadAsset<GameObject>("C_WeStayWinning");
				val.Rarity = (Rarity)2;
				val.Theme = (CardThemeColorType)1;
				val.Stats = (CardInfoStat[])(object)new CardInfoStat[5]
				{
					new CardInfoStat
					{
						amount = "+150%",
						positive = true,
						simepleAmount = (SimpleAmount)0,
						stat = "Damage"
					},
					new CardInfoStat
					{
						amount = "+150%",
						positive = true,
						simepleAmount = (SimpleAmount)0,
						stat = "Attack Speed"
					},
					new CardInfoStat
					{
						amount = "+150%",
						positive = true,
						simepleAmount = (SimpleAmount)0,
						stat = "Reload Time"
					},
					new CardInfoStat
					{
						amount = "+150%",
						positive = true,
						simepleAmount = (SimpleAmount)0,
						stat = "Bullet Speed"
					},
					new CardInfoStat
					{
						amount = "+15",
						positive = true,
						simepleAmount = (SimpleAmount)0,
						stat = "Ammo"
					}
				};
				val.OwnerOnly = true;
				return val;
			}
		}

		public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers)
		{
			cardInfo.allowMultiple = false;
			gun.damage = 2.5f;
			gun.attackSpeed = 0.4f;
			gun.reloadTime = 0.4f;
			gun.projectileSpeed = 2.5f;
			gun.ammo = 15;
		}

		protected override void Added(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)VKFC.instance, 20, (Action)delegate
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				foreach (Player player2 in PlayerManager.instance.players)
				{
					((Component)player).GetComponentInChildren<WeStayWinning>().TeamScore.Add(player2.teamID, GameModeManager.CurrentHandler.GetTeamScore(player2.teamID).rounds);
				}
			});
		}
	}
}