Decompiled source of EndlessRounds v1.1.0

EndlessRounds.dll

Decompiled 3 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 Microsoft.CodeAnalysis;
using RWF;
using RWF.GameModes;
using RWF.UI;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;

[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.1.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 EndlessMode
{
	public class EndlessHandler : RWFGameModeHandler<Endless>
	{
		public const string NAME = "Endless Rounds";

		public const string ID = "endless";

		public EndlessHandler(bool teams)
			: base(teams ? "Team Endless Rounds" : "Endless Rounds", teams ? "teamendless" : "endless", teams, 3, -1, default(Nullable<int>), default(Nullable<int>), default(Nullable<int>), default(Nullable<int>), "Endless Rounds: everything is made up and the points dont mater.", default(Nullable<int>), (string)null)
		{
		}//IL_0024: 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_002d: 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)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)


		public override int[] GetGameWinners()
		{
			return (int[])(object)new Int32[0];
		}

		public override void ChangeSetting(string name, object value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			GameSettings val = new GameSettings();
			IEnumerator<KeyValuePair<string, object>> enumerator = ((GameModeHandler<Endless>)(object)this).Settings.GetEnumerator();
			try
			{
				while (((IEnumerator)enumerator).MoveNext())
				{
					KeyValuePair<string, object> current = enumerator.Current;
					val.Add(current.Key, (current.Key == name) ? value : current.Value);
				}
			}
			finally
			{
				if (enumerator != null)
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			((GameModeHandler<Endless>)(object)this).Settings = val;
		}
	}
	public class Endless : RWFGameMode
	{
		[CompilerGenerated]
		private sealed class <PointTransition>d__2 : Object, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Endless <>4__this;

			public int[] winningTeamIDs;

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

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

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

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

			private bool MoveNext()
			{
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Expected O, but got Unknown
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Expected O, but got Unknown
				int num = <>1__state;
				Endless endless = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = GameModeManager.TriggerHook("PointEnd");
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((MonoBehaviour)endless).StartCoroutine(PointVisualizerExtensions.DoSequence(PointVisualizer.instance, ((RWFGameMode)endless).teamPoints, endless.empty, winningTeamIDs));
					<>2__current = (object)new WaitForSecondsRealtime(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					MapManager.instance.LoadNextLevel(false, false);
					<>2__current = (object)new WaitForSecondsRealtime(0.5f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = ((RWFGameMode)endless).WaitForSyncUp();
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					PlayerSpotlight.FadeIn(0.5f, 0f);
					MapManager.instance.CallInNewMapAndMovePlayers(MapManager.instance.currentLevelID);
					PlayerManager.instance.RevivePlayers();
					<>2__current = (object)new WaitForSecondsRealtime(0.3f);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					TimeHandler.instance.DoSpeedUp();
					GameManager.instance.battleOngoing = true;
					((RWFGameMode)endless).isTransitioning = false;
					UIHandlerExtensions.ShowRoundCounterSmall(UIHandler.instance, ((RWFGameMode)endless).teamPoints, endless.empty);
					((MonoBehaviour)endless).StartCoroutine(((RWFGameMode)endless).DoPointStart());
					return false;
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <RoundTransition>d__1 : Object, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Endless <>4__this;

			public int[] winningTeamIDs;

			private Enumerator<Player> <>7__wrap1;

			private Player <player>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 6) <= 4u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<player>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Expected O, but got Unknown
				//IL_0223: Unknown result type (might be due to invalid IL or missing references)
				//IL_0228: Unknown result type (might be due to invalid IL or missing references)
				//IL_0324: Unknown result type (might be due to invalid IL or missing references)
				//IL_032e: Expected O, but got Unknown
				//IL_040c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0416: Expected O, but got Unknown
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Expected O, but got Unknown
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					int num = <>1__state;
					Endless endless = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = GameModeManager.TriggerHook("PointEnd");
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						<>2__current = GameModeManager.TriggerHook("RoundEnd");
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -1;
						if (Enumerable.Any<int>((IEnumerable<int>)(object)GameModeManager.CurrentHandler.GetGameWinners()))
						{
							((RWFGameMode)endless).GameOver(winningTeamIDs);
							return false;
						}
						((MonoBehaviour)endless).StartCoroutine(PointVisualizerExtensions.DoWinSequence(PointVisualizer.instance, ((RWFGameMode)endless).teamPoints, endless.empty, winningTeamIDs));
						<>2__current = (object)new WaitForSecondsRealtime(1f);
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -1;
						MapManager.instance.LoadNextLevel(false, false);
						<>2__current = (object)new WaitForSecondsRealtime(1.3f);
						<>1__state = 4;
						return true;
					case 4:
					{
						<>1__state = -1;
						PlayerManager.instance.SetPlayersSimulated(false);
						TimeHandler.instance.DoSpeedUp();
						Transform parent = UIHandler.instance.roundCounterSmall.p1Parent.parent;
						int[] array = winningTeamIDs;
						foreach (int num2 in array)
						{
							TextMeshProUGUI componentInChildren = ((Component)parent.GetChild(num2 + 1)).GetComponentInChildren<TextMeshProUGUI>();
							int rounds = GameModeManager.CurrentHandler.GetTeamScore(num2).rounds;
							((TMP_Text)componentInChildren).text = String.Concat("<b>", ((Int32)(ref rounds)).ToString(), "</b>");
						}
						<>2__current = GameModeManager.TriggerHook("PickStart");
						<>1__state = 5;
						return true;
					}
					case 5:
					{
						<>1__state = -1;
						ExtensionMethods.InvokeMethod((object)PlayerManager.instance, "SetPlayersVisible", (object[])(object)new Object[1] { (object)(Boolean)0 });
						List<Player> pickOrder = PlayerManagerExtensions.GetPickOrder(PlayerManager.instance, winningTeamIDs);
						<>7__wrap1 = pickOrder.GetEnumerator();
						<>1__state = -3;
						goto IL_034c;
					}
					case 6:
						<>1__state = -3;
						<>2__current = GameModeManager.TriggerHook("PlayerPickStart");
						<>1__state = 7;
						return true;
					case 7:
						<>1__state = -3;
						CardChoiceVisuals.instance.Show(<player>5__3.playerID, true);
						<>2__current = CardChoice.instance.DoPick(1, <player>5__3.playerID, (PickerType)1);
						<>1__state = 8;
						return true;
					case 8:
						<>1__state = -3;
						<>2__current = GameModeManager.TriggerHook("PlayerPickEnd");
						<>1__state = 9;
						return true;
					case 9:
						<>1__state = -3;
						<>2__current = (object)new WaitForSecondsRealtime(0.1f);
						<>1__state = 10;
						return true;
					case 10:
						<>1__state = -3;
						goto IL_0345;
					case 11:
						<>1__state = -1;
						<>2__current = ((MonoBehaviour)endless).StartCoroutine(((RWFGameMode)endless).WaitForSyncUp());
						<>1__state = 12;
						return true;
					case 12:
						<>1__state = -1;
						PlayerSpotlight.FadeIn(0.5f, 0f);
						TimeHandler.instance.DoSlowDown();
						MapManager.instance.CallInNewMapAndMovePlayers(MapManager.instance.currentLevelID);
						PlayerManager.instance.RevivePlayers();
						<>2__current = (object)new WaitForSecondsRealtime(0.3f);
						<>1__state = 13;
						return true;
					case 13:
						{
							<>1__state = -1;
							TimeHandler.instance.DoSpeedUp();
							GameManager.instance.battleOngoing = true;
							((RWFGameMode)endless).isTransitioning = false;
							UIHandlerExtensions.ShowRoundCounterSmall(UIHandler.instance, ((RWFGameMode)endless).teamPoints, endless.empty);
							((MonoBehaviour)endless).StartCoroutine(((RWFGameMode)endless).DoRoundStart());
							return false;
						}
						IL_034c:
						if (<>7__wrap1.MoveNext())
						{
							<player>5__3 = <>7__wrap1.Current;
							if (!Enumerable.Contains<int>((IEnumerable<int>)(object)winningTeamIDs, <player>5__3.teamID))
							{
								<>2__current = ((RWFGameMode)endless).WaitForSyncUp();
								<>1__state = 6;
								return true;
							}
							goto IL_0345;
						}
						<>m__Finally1();
						ExtensionMethods.InvokeMethod((object)PlayerManager.instance, "SetPlayersVisible", (object[])(object)new Object[1] { (object)(Boolean)1 });
						<>2__current = GameModeManager.TriggerHook("PickEnd");
						<>1__state = 11;
						return true;
						IL_0345:
						<player>5__3 = null;
						goto IL_034c;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap1).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}
		}

		private Dictionary<int, int> empty = new Dictionary<int, int>();

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		public override IEnumerator RoundTransition(int[] winningTeamIDs)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return (IEnumerator)(object)new <RoundTransition>d__1(0)
			{
				<>4__this = this,
				winningTeamIDs = winningTeamIDs
			};
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		public override IEnumerator PointTransition(int[] winningTeamIDs)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return (IEnumerator)(object)new <PointTransition>d__2(0)
			{
				<>4__this = this,
				winningTeamIDs = winningTeamIDs
			};
		}

		public override void StartGame()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			GameModeManager.CurrentHandler.ChangeSetting("roundsToWinGame", (object)2);
			((RWFGameMode)this).StartGame();
			int num = Enumerable.Count<int>(Enumerable.Distinct<int>(Enumerable.Select<Player, int>((IEnumerable<Player>)(object)PlayerManager.instance.players, (Func<Player, int>)((Player p) => p.teamID))));
			Transform parent = UIHandler.instance.roundCounterSmall.p1Parent.parent;
			for (int i = 1; i <= num; i++)
			{
				Transform child = parent.GetChild(i).GetChild(1);
				TextMeshProUGUI component = ((Component)Object.Instantiate<Transform>(((Component)UIHandler.instance.roundCounterSmall).transform.Find("Slash"), child)).GetComponent<TextMeshProUGUI>();
				((TMP_Text)component).transform.localPosition = Vector3.zero;
				((TMP_Text)component).transform.localScale = Vector3.one * 3f;
				((Component)component).gameObject.SetActive(true);
				((TMP_Text)component).text = "<b>0</b>";
				((Graphic)component).color = Enumerable.First<Player>((IEnumerable<Player>)(object)PlayerManager.instance.GetPlayersInTeam(i - 1)).GetTeamColors().color;
				empty.Add(i - 1, 0);
				((Behaviour)((Component)child).GetComponent<ProceduralImage>()).enabled = false;
			}
			GameModeManager.CurrentHandler.ChangeSetting("roundsToWinGame", (object)2147483647);
		}

		public override IEnumerator DoRoundStart()
		{
			UIHandler.instance.roundCounterSmall.UpdateRounds(0, 0);
			return ((RWFGameMode)this).DoRoundStart();
		}

		public override IEnumerator DoPointStart()
		{
			return ((RWFGameMode)this).DoPointStart();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Systems.R00t.Endless", "Endless Rounds", "1.1.0")]
	[BepInProcess("Rounds.exe")]
	public class Plugin : BaseUnityPlugin
	{
		private const string ModId = "Systems.R00t.Endless";

		private const string ModName = "Endless Rounds";

		public const string Version = "1.1.0";

		private void Start()
		{
			GameModeManager.AddHandler<Endless>("endless", (IGameModeHandler)(object)new EndlessHandler(teams: false));
			GameModeManager.AddHandler<Endless>("teamendless", (IGameModeHandler)(object)new EndlessHandler(teams: true));
		}
	}
}