Decompiled source of CyansFrost v1.0.0

Cyan's Frost.dll

Decompiled 2 weeks 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 HarmonyLib;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
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("1.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;
		}
	}
}
[Serializable]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public class FrozenPatches : Object
{
	[CompilerGenerated]
	private sealed class <>c__DisplayClass0_0 : Object
	{
		public int pickerID;

		public bool forcePick;

		public PickerType pickerType;

		internal void <Postfix>b__0()
		{
			//IL_0020: 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_002f: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			<>c__DisplayClass0_1 CS$<>8__locals0 = new <>c__DisplayClass0_1
			{
				cold = PhotonNetwork.Instantiate(((Object)CardManager.cards["Cold bullets"].cardInfo).name, Vector3.down * 9999f, Quaternion.identity, (byte)0, (object[])null)
			};
			CS$<>8__locals0.cold.GetComponent<ApplyCardStats>().Pick(pickerID, forcePick, pickerType);
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 10, (Action)delegate
			{
				PhotonNetwork.Destroy(CS$<>8__locals0.cold);
			});
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass0_1 : Object
	{
		public GameObject cold;

		internal void <Postfix>b__1()
		{
			PhotonNetwork.Destroy(cold);
		}
	}

	public static void Postfix(ApplyCardStats __instance, int pickerID, bool forcePick, PickerType pickerType)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		<>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0();
		CS$<>8__locals0.pickerID = pickerID;
		CS$<>8__locals0.forcePick = forcePick;
		CS$<>8__locals0.pickerType = pickerType;
		if (!(((Object)((Component)__instance).transform.GetChild(0).GetChild(0)).name == "IS_FROZEN"))
		{
			return;
		}
		ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 10, (Action)delegate
		{
			//IL_0020: 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_002f: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			<>c__DisplayClass0_1 CS$<>8__locals1 = new <>c__DisplayClass0_1
			{
				cold = PhotonNetwork.Instantiate(((Object)CardManager.cards["Cold bullets"].cardInfo).name, Vector3.down * 9999f, Quaternion.identity, (byte)0, (object[])null)
			};
			CS$<>8__locals1.cold.GetComponent<ApplyCardStats>().Pick(CS$<>8__locals0.pickerID, CS$<>8__locals0.forcePick, CS$<>8__locals0.pickerType);
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 10, (Action)delegate
			{
				PhotonNetwork.Destroy(CS$<>8__locals1.cold);
			});
		});
	}
}
[BepInPlugin("Systems.R00t.Coms.CyanFrost", "Cyan's Frost", "1.0.0")]
[BepInProcess("Rounds.exe")]
public class Main : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <SetUp>d__6 : Object, IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Main <>4__this;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			int num = <>1__state;
			Main main = <>4__this;
			if (num != 0)
			{
				return false;
			}
			<>1__state = -1;
			FreezeHandler.indx = 0;
			CardInfo[] cards = CardChoice.instance.cards;
			for (int i = 0; i < cards.Length; i++)
			{
				ExtensionMethods.GetOrAddComponent<FreezeHandler>(((Component)cards[i]).gameObject, false);
			}
			List<float> val = new List<float>();
			if (PhotonNetwork.OfflineMode)
			{
				for (int j = 0; j < 100; j++)
				{
					val.Add(Random.value);
				}
			}
			else
			{
				Random val2 = new Random(Int32.Parse(PhotonNetwork.CurrentRoom.Name.Substring(PhotonNetwork.CurrentRoom.Name.Length - 9)));
				for (int k = 0; k < 100; k++)
				{
					val.Add((float)val2.NextDouble());
				}
			}
			main.SetFrozenOdds(val.ToArray());
			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 = "Systems.R00t.Coms.CyanFrost";

	private const string ModName = "Cyan's Frost";

	public const string Version = "1.0.0";

	public static GameObject frostBase;

	public static CardInfo card;

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("Systems.R00t.Coms.CyanFrost").PatchAll();
		AssetBundle obj = AssetUtils.LoadAssetBundleFromResources("cyanfrost", typeof(Main).Assembly);
		frostBase = obj.LoadAsset<GameObject>("FrozenCardBase");
		card = obj.LoadAsset<GameObject>("CyanCard").GetComponent<CardInfo>();
		CustomCard.RegisterUnityCard(((Component)card).gameObject, "Cyan's Frost", card.cardName, true, (Action<CardInfo>)null);
		GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)SetUp);
	}

	[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
	public IEnumerator SetUp(IGameModeHandler _gm)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return (IEnumerator)(object)new <SetUp>d__6(0)
		{
			<>4__this = this
		};
	}

	public void SetFrozenOdds(float[] odds)
	{
		FreezeHandler.odds = odds;
	}
}
public class FreezeHandler : MonoBehaviour, IPunInstantiateMagicCallback
{
	[CompilerGenerated]
	private sealed class <>c__DisplayClass2_0 : Object
	{
		public PhotonMessageInfo info;

		public FreezeHandler <>4__this;

		internal void <OnPhotonInstantiate>b__0()
		{
			int num = Enumerable.Count<CardInfo>((IEnumerable<CardInfo>)(object)PlayerManager.instance.GetPlayerWithActorID(info.Sender.ActorNumber).data.currentCards, (Func<CardInfo, bool>)((CardInfo c) => c.cardName == Main.card.cardName));
			if (num > 0 && (float)num / 10f > odds[indx++ % odds.Length])
			{
				Object.DestroyImmediate((Object)(object)((Component)((Component)<>4__this).gameObject.transform.GetChild(0)).gameObject);
				((Component)<>4__this).gameObject.GetComponent<CardInfo>().cardBase = Main.frostBase;
				((Component)<>4__this).gameObject.GetComponent<CardInfo>().Awake();
			}
		}
	}

	public static float[] odds;

	public static int indx = -1;

	public void OnPhotonInstantiate(PhotonMessageInfo info)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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_0053: Expected O, but got Unknown
		<>c__DisplayClass2_0 CS$<>8__locals0 = new <>c__DisplayClass2_0();
		CS$<>8__locals0.info = info;
		CS$<>8__locals0.<>4__this = this;
		if (((Component)this).GetComponent<CardInfo>().cardName == CardManager.cards["Cold bullets"].cardInfo.cardName)
		{
			return;
		}
		ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)this, 2, (Action)delegate
		{
			int num = Enumerable.Count<CardInfo>((IEnumerable<CardInfo>)(object)PlayerManager.instance.GetPlayerWithActorID(CS$<>8__locals0.info.Sender.ActorNumber).data.currentCards, (Func<CardInfo, bool>)((CardInfo c) => c.cardName == Main.card.cardName));
			if (num > 0 && (float)num / 10f > odds[indx++ % odds.Length])
			{
				Object.DestroyImmediate((Object)(object)((Component)((Component)CS$<>8__locals0.<>4__this).gameObject.transform.GetChild(0)).gameObject);
				((Component)CS$<>8__locals0.<>4__this).gameObject.GetComponent<CardInfo>().cardBase = Main.frostBase;
				((Component)CS$<>8__locals0.<>4__this).gameObject.GetComponent<CardInfo>().Awake();
			}
		});
	}
}