Decompiled source of TerminalGaming v1.0.1

TerminalGaming.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 BepInEx.Configuration;
using LethalAPI.LibTerminal;
using LethalAPI.LibTerminal.Attributes;
using LethalAPI.LibTerminal.Models;
using Microsoft.CodeAnalysis;
using TMPro;
using TerminalGaming.Commands;
using TerminalGaming.Enums;
using TerminalGaming.Extensions;
using TerminalGaming.Games.Pong;
using TerminalGaming.Games.Pong.Elements;
using TerminalGaming.Games.Pong.EventArgs;
using TerminalGaming.Games.Pong.Widgets;
using TerminalGaming.Helpers;
using TerminalGaming.Managers;
using TerminalGaming.UI;
using TerminalGaming.UI.Elements;
using TerminalGaming.UI.Elements.Views;
using TerminalGaming.UI.Elements.Views.PlayerSelectionView;
using TerminalGaming.UI.Layouts;
using TerminalGaming.UI.Layouts.Vertical;
using TerminalGaming.UI.Renderables;
using TerminalGaming.UI.Widgets;
using UnityEngine;
using UnityEngine.UI;

[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("jivanf")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("The classic arcade games, now on The Company's terminal!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+85af6ddd73c0389cef32c60e93182c09f9216a52")]
[assembly: AssemblyProduct("TerminalGaming")]
[assembly: AssemblyTitle("TerminalGaming")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
	internal class CompilerFeatureRequiredAttribute : Attribute
	{
		public CompilerFeatureRequiredAttribute(string name)
		{
		}
	}
	internal static class IsExternalInit
	{
	}
	internal class RequiredMemberAttribute : Attribute
	{
	}
}
namespace TerminalGaming
{
	[BepInPlugin("me.jivanf.terminalgaming", "TerminalGaming", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private TerminalModRegistry commandRegistry = null;

		private void Awake()
		{
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			commandRegistry = TerminalRegistry.CreateTerminalRegistry();
			commandRegistry.RegisterFrom<PlayCommand>();
		}

		private void OnDestroy()
		{
			commandRegistry.Deregister();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "me.jivanf.terminalgaming";

		public const string PLUGIN_NAME = "TerminalGaming";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TerminalGaming.UI
{
	public static class Router
	{
		private static IView? activeView;

		public static void Navigate<TView>() where TView : IView, new()
		{
			activeView?.Dispose();
			activeView = new TView();
			activeView.Render();
		}
	}
}
namespace TerminalGaming.UI.Widgets
{
	public class SelectionListWidget : VerticalLayout<SelectionListWidgetInput, SelectionListWidgetInitiator>
	{
		public override Type Script { get; } = typeof(SelectionListWidgetScript);


		public SelectionListWidget(SelectionListWidgetInput input)
			: base(input)
		{
		}
	}
	public class SelectionListWidgetInitiator : IInitiator<SelectionListWidgetInput>
	{
		public InitData Init(SelectionListWidgetInput input)
		{
			InitData initData = new InitData();
			foreach (StringLabelElement item in input.Options.Select((string option) => new StringLabelElement(new StringLabelElementInput
			{
				Name = "SelectionListOptionElement",
				Value = option
			})))
			{
				initData.AddRenderable(item);
			}
			return initData;
		}
	}
	public class SelectionListWidgetInput : LayoutInput
	{
		public required List<string> Options { get; init; }
	}
	public class SelectionListWidgetScript : MonoBehaviour
	{
		private const float SelectionCooldown = 0.2f;

		private TextMeshProUGUI[] options = null;

		private int selectedOptionIndex;

		private float nextSelectionTime = 5f;

		private void Start()
		{
			options = ((Component)this).gameObject.GetComponentsInChildren<TextMeshProUGUI>();
			SelectOption(0);
		}

		public void Update()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time >= nextSelectionTime)
			{
				KeyboardShortcut val = new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>());
				if (((KeyboardShortcut)(ref val)).IsPressed())
				{
					SelectNextOption();
					nextSelectionTime = Time.time + 0.2f;
				}
				val = new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>());
				if (((KeyboardShortcut)(ref val)).IsPressed())
				{
					SelectPreviousOption();
					nextSelectionTime = Time.time + 0.2f;
				}
				if (UnityInput.Current.GetKeyDown((KeyCode)13))
				{
					Router.Navigate<PongGameView>();
					nextSelectionTime = Time.time + 0.2f;
				}
			}
		}

		private void SelectOption(int index)
		{
			selectedOptionIndex = index;
			UpdateSelectedOptionText();
		}

		private void SelectNextOption()
		{
			DeselectOption();
			SelectOption((selectedOptionIndex + 1) % options.Length);
		}

		private void SelectPreviousOption()
		{
			DeselectOption();
			SelectOption((selectedOptionIndex - 1 + options.Length) % options.Length);
		}

		private void UpdateSelectedOptionText()
		{
			((TMP_Text)options[selectedOptionIndex]).text = "> " + ((TMP_Text)options[selectedOptionIndex]).text;
		}

		private void DeselectOption()
		{
			((TMP_Text)options[selectedOptionIndex]).text = ((TMP_Text)options[selectedOptionIndex]).text.Replace("> ", "");
		}
	}
}
namespace TerminalGaming.UI.Renderables
{
	public interface IInstantiator<in TInput> where TInput : RenderableInput
	{
		GameObject Instantiate(TInput input, Type? script);
	}
	public interface IInstantiator : IInstantiator<RenderableInput>
	{
	}
	public class Instantiator<TInput> : IInstantiator<TInput> where TInput : RenderableInput
	{
		public virtual GameObject Instantiate(TInput input, Type? script)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(input.Name, new Type[1] { typeof(RectTransform) });
			if (script != null)
			{
				val.AddComponent(script);
			}
			if (input.Debug && !(input is LabelElementInput))
			{
				Image val2 = val.AddComponent<Image>();
				((Graphic)val2).color = Color.white;
			}
			return val;
		}
	}
	public class Instantiator : Instantiator<RenderableInput>
	{
	}
	public interface IRenderable<in TInput> : IRenderable, IDisposable where TInput : RenderableInput
	{
		GameObject Instantiate(TInput input, Type? script);
	}
	public interface IRenderable : IDisposable
	{
		GameObject GameObject { get; }

		RectTransform RectTransform { get; }

		void Render(RectTransform? parent = null);
	}
	public interface IMultiRenderable : IRenderable, IDisposable
	{
		InitData InitData { get; set; }

		InitData Init();
	}
	public interface IMultiRenderable<in TInput> : IRenderable<TInput>, IRenderable, IDisposable, IMultiRenderable where TInput : RenderableInput
	{
	}
	public class InitData : IDisposable
	{
		public ObservableCollection<IRenderable> Renderables { get; } = new ObservableCollection<IRenderable>();


		public virtual void AddRenderable(IRenderable renderable)
		{
			Renderables.Add(renderable);
		}

		public virtual void Dispose()
		{
			foreach (IRenderable renderable in Renderables)
			{
				renderable.Dispose();
			}
			Renderables.Clear();
		}
	}
	public interface IInitiator<in TInput> where TInput : RenderableInput
	{
		InitData Init(TInput input);
	}
	public interface IInitiator : IInitiator<RenderableInput>
	{
	}
	public static class Initiator<TInitiator, TInput> where TInitiator : IInitiator<TInput>, new() where TInput : RenderableInput
	{
		private static readonly TInitiator Instance = new TInitiator();

		public static InitData Init(TInput input)
		{
			return Instance.Init(input);
		}
	}
	public abstract class MultiRenderable<TInput, TInitiator, TInstantiator, TRenderer> : Renderable<TInput, TInstantiator>, IMultiRenderable<TInput>, IRenderable<TInput>, IRenderable, IDisposable, IMultiRenderable where TInput : RenderableInput where TInitiator : IInitiator<TInput>, new() where TInstantiator : IInstantiator<TInput>, new() where TRenderer : IRenderer<TInput>, new()
	{
		public InitData InitData { get; set; }

		public MultiRenderable(TInput input)
			: base(input)
		{
			InitData = Init();
		}

		public InitData Init()
		{
			return Initiator<TInitiator, TInput>.Init(base.Input);
		}

		public override void Render(RectTransform? parent = null)
		{
			if (parent == null)
			{
				parent = Manager<TerminalManager>.Instance.Terminal.GetGameContainer().GetComponent<RectTransform>();
			}
			new TRenderer().Render(base.Input, base.GameObject, parent);
			foreach (IRenderable renderable in InitData.Renderables)
			{
				renderable.Render(base.GameObject.GetComponent<RectTransform>());
			}
		}

		public override void Dispose()
		{
			InitData.Dispose();
			base.Dispose();
		}
	}
	public abstract class MultiRenderable<TInput, TInitiator, TInstantiator> : MultiRenderable<TInput, TInitiator, TInstantiator, Renderer<TInput>> where TInput : RenderableInput where TInitiator : IInitiator<TInput>, new() where TInstantiator : IInstantiator<TInput>, new()
	{
		protected MultiRenderable(TInput input)
			: base(input)
		{
		}
	}
	public abstract class MultiRenderable<TInput, TInitiator> : MultiRenderable<TInput, TInitiator, Instantiator<TInput>, Renderer<TInput>> where TInput : RenderableInput where TInitiator : IInitiator<TInput>, new()
	{
		protected MultiRenderable(TInput input)
			: base(input)
		{
		}
	}
	public abstract class MultiRenderable<TInitiator> : MultiRenderable<RenderableInput, TInitiator, Instantiator, Renderer<RenderableInput>> where TInitiator : IInitiator, new()
	{
		protected MultiRenderable(RenderableInput? input = null)
			: base(input ?? new RenderableInput())
		{
		}
	}
	public abstract class Renderable<TInput, TInstantiator> : IRenderable<TInput>, IRenderable, IDisposable where TInput : RenderableInput where TInstantiator : IInstantiator<TInput>, new()
	{
		public TInput Input { get; }

		public GameObject GameObject { get; }

		public RectTransform RectTransform { get; }

		public virtual Type? Script { get; }

		protected Renderable(TInput input)
		{
			Input = input;
			GameObject = Instantiate(input, Script);
			RectTransform = GameObject.GetComponent<RectTransform>();
			Manager<UIManager>.Instance.AddRenderable(this);
		}

		public GameObject Instantiate(TInput input, Type? script)
		{
			return new TInstantiator().Instantiate(input, script);
		}

		public abstract void Render(RectTransform? parent = null);

		public virtual void Dispose()
		{
			Manager<UIManager>.Instance.RemoveRenderable(this);
			Object.Destroy((Object)(object)GameObject);
		}
	}
	public interface IRenderableInput
	{
	}
	public class RenderableInput : IRenderableInput
	{
		private string? name;

		private string? derivedClassName;

		public string Name
		{
			get
			{
				if (name != null)
				{
					return name;
				}
				if (derivedClassName != null)
				{
					return derivedClassName;
				}
				IEnumerable<StackFrame> enumerable = new StackTrace().GetFrames().SkipWhile((StackFrame frame) => frame.GetMethod().DeclaringType.GetInterface("IRenderable") == null).Skip(1);
				foreach (StackFrame item in enumerable)
				{
					Type type = item?.GetMethod()?.DeclaringType;
					if ((object)type == null || type.IsAbstract)
					{
						continue;
					}
					derivedClassName = type.Name.Replace("Input", "");
					break;
				}
				if (derivedClassName == null)
				{
					derivedClassName = GetType().Name.Replace("Input", "");
				}
				return derivedClassName;
			}
			set
			{
				name = value;
			}
		}

		public float? Width { get; init; }

		public float? Height { get; init; }

		public AnchorPosition? AnchorPosition { get; init; }

		public CollapsedAnchorPosition? CollapsedAnchorPosition { get; init; }

		public bool? FullScreen { get; init; }

		public Vector2? Position { get; init; }

		public virtual bool Debug { get; init; } = false;

	}
	public class AnchorPosition
	{
		public Vector2 AnchorMin { get; init; }

		public Vector2 AnchorMax { get; init; }

		public Vector2? Offset { get; init; }
	}
	public class CollapsedAnchorPosition
	{
		public Vector2 Anchor { get; init; }

		public Vector2? AnchoredPosition { get; init; }

		public Vector2? SizeDelta { get; init; }

		public Vector2? Offset { get; init; }
	}
	public interface IRenderer<in TInput> where TInput : RenderableInput
	{
		void Render(TInput input, GameObject gameObject, RectTransform parent);
	}
	public interface IRenderer : IRenderer<RenderableInput>
	{
	}
	public class Renderer<TInput> : IRenderer<TInput> where TInput : RenderableInput
	{
		public virtual void Render(TInput input, GameObject gameObject, RectTransform parent)
		{
			//IL_0011: 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_0038: 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_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_00ea: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = gameObject.GetComponent<RectTransform>();
			((Transform)component).SetParent((Transform)(object)parent);
			((Transform)component).localScale = Vector3.one;
			((Transform)component).eulerAngles = new Vector3(350f, 143f, 0f);
			((Transform)component).localEulerAngles = Vector3.zero;
			((Transform)component).localPosition = Vector3.zero;
			if (input != null)
			{
				bool? fullScreen = input.FullScreen;
				if (fullScreen.HasValue)
				{
					if (fullScreen.GetValueOrDefault())
					{
						component.anchorMin = Vector2.zero;
						component.anchorMax = Vector2.one;
						Vector2 offsetMin = (component.offsetMax = Vector2.zero);
						component.offsetMin = offsetMin;
					}
				}
				else
				{
					AnchorPosition anchorPosition = input.AnchorPosition;
					if (anchorPosition == null)
					{
						CollapsedAnchorPosition collapsedAnchorPosition = input.CollapsedAnchorPosition;
						if (collapsedAnchorPosition == null)
						{
							Vector2? position = input.Position;
							if (position.HasValue)
							{
								Vector2 valueOrDefault = position.GetValueOrDefault();
								component.anchoredPosition3D = Vector2.op_Implicit(valueOrDefault);
							}
						}
						else
						{
							Vector2 offsetMin = (component.anchorMax = collapsedAnchorPosition.Anchor);
							component.anchorMin = offsetMin;
							if (input != null)
							{
								CollapsedAnchorPosition collapsedAnchorPosition2 = input.CollapsedAnchorPosition;
								if (collapsedAnchorPosition2 != null)
								{
									Vector2? offset = collapsedAnchorPosition2.Offset;
									if (offset.HasValue)
									{
										Vector2 valueOrDefault2 = offset.GetValueOrDefault();
										if (true)
										{
											offsetMin = (component.offsetMax = valueOrDefault2);
											component.offsetMin = offsetMin;
											goto IL_0251;
										}
									}
								}
							}
							offsetMin = (component.offsetMax = Vector2.zero);
							component.offsetMin = offsetMin;
						}
					}
					else
					{
						component.anchorMin = anchorPosition.AnchorMin;
						component.anchorMax = anchorPosition.AnchorMax;
						Vector2 offsetMin;
						if (input != null)
						{
							AnchorPosition anchorPosition2 = input.AnchorPosition;
							if (anchorPosition2 != null)
							{
								Vector2? offset = anchorPosition2.Offset;
								if (offset.HasValue)
								{
									Vector2 valueOrDefault3 = offset.GetValueOrDefault();
									if (true)
									{
										offsetMin = (component.offsetMax = valueOrDefault3);
										component.offsetMin = offsetMin;
										goto IL_0251;
									}
								}
							}
						}
						offsetMin = (component.offsetMax = Vector2.zero);
						component.offsetMin = offsetMin;
					}
				}
			}
			goto IL_0251;
			IL_0251:
			component.anchoredPosition3D = new Vector3(component.anchoredPosition.x, component.anchoredPosition.y, -1f);
			if (input == null)
			{
				return;
			}
			float? width = input.Width;
			if (!width.HasValue)
			{
				return;
			}
			float valueOrDefault4 = width.GetValueOrDefault();
			float? height = input.Height;
			if (height.HasValue)
			{
				float valueOrDefault5 = height.GetValueOrDefault();
				if (true)
				{
					component.SetSize(valueOrDefault4, valueOrDefault5);
				}
			}
		}
	}
	public class Renderer : Renderer<RenderableInput>
	{
	}
}
namespace TerminalGaming.UI.Layouts
{
	public abstract class Layout<TLayoutGroup, TInput, TInitiator, TInstantiator, TRenderer> : MultiRenderable<TInput, TInitiator, LayoutInstantiator<TLayoutGroup>> where TLayoutGroup : HorizontalOrVerticalLayoutGroup where TInput : LayoutInput where TInitiator : IInitiator<TInput>, new() where TInstantiator : IInstantiator<TInput>, new() where TRenderer : IRenderer<TInput>, new()
	{
		protected Layout(TInput input)
			: base(input)
		{
		}
	}
	public abstract class Layout<TLayoutGroup, TInput, TInitiator> : MultiRenderable<TInput, TInitiator, LayoutInstantiator<TLayoutGroup>> where TLayoutGroup : HorizontalOrVerticalLayoutGroup where TInput : LayoutInput where TInitiator : IInitiator<TInput>, new()
	{
		protected Layout(TInput input)
			: base(input)
		{
		}
	}
	public abstract class Layout<TLayoutGroup, TInitiator> : Layout<TLayoutGroup, LayoutInput, TInitiator> where TLayoutGroup : HorizontalOrVerticalLayoutGroup where TInitiator : IInitiator<LayoutInput>, new()
	{
		protected Layout()
			: base(new LayoutInput())
		{
		}
	}
	public class LayoutInput : RenderableInput
	{
		private const int DefaultSpacing = 0;

		public int Spacing { get; init; } = 0;

	}
	public class LayoutInstantiator<TLayoutGroup> : IInstantiator<LayoutInput> where TLayoutGroup : HorizontalOrVerticalLayoutGroup
	{
		public GameObject Instantiate(LayoutInput input, Type? script)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			GameObject val = new GameObject(input.Name);
			TLayoutGroup val2 = val.AddComponent<TLayoutGroup>();
			if (script != null)
			{
				val.AddComponent(script);
			}
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val2).spacing = input.Spacing;
			return val;
		}
	}
	public class LayoutRenderer
	{
	}
}
namespace TerminalGaming.UI.Layouts.Vertical
{
	public abstract class VerticalLayout<TInput, TInitiator> : Layout<VerticalLayoutGroup, TInput, TInitiator> where TInput : LayoutInput where TInitiator : IInitiator<TInput>, new()
	{
		protected VerticalLayout(TInput input)
			: base(input)
		{
		}
	}
	public abstract class VerticalLayout<TInitiator> : VerticalLayout<LayoutInput, TInitiator> where TInitiator : IInitiator<LayoutInput>, new()
	{
		protected VerticalLayout(LayoutInput? input = null)
			: base(input ?? new LayoutInput())
		{
		}
	}
}
namespace TerminalGaming.UI.Elements
{
	public abstract class Element<TInput, TInstantiator, TRenderer> : Renderable<TInput, TInstantiator> where TInput : ElementInput where TInstantiator : IInstantiator<TInput>, new() where TRenderer : IRenderer<TInput>, new()
	{
		protected Element(TInput input)
			: base(input)
		{
		}

		public override void Render(RectTransform? parent = null)
		{
			if (parent == null)
			{
				parent = Manager<TerminalManager>.Instance.Terminal.GetGameContainer().GetComponent<RectTransform>();
			}
			new TRenderer().Render(base.Input, base.GameObject, parent);
		}
	}
	public abstract class Element<TInput, TInstantiator> : Element<TInput, TInstantiator, Renderer> where TInput : ElementInput where TInstantiator : IInstantiator<TInput>, new()
	{
		protected Element(TInput input)
			: base(input)
		{
		}
	}
	public class ElementInput : RenderableInput
	{
	}
	public class ElementRenderer : Renderer<ElementInput>
	{
		public override void Render(ElementInput input, GameObject gameObject, RectTransform parent)
		{
			base.Render(input, gameObject, parent);
		}
	}
	public class IntLabelElement : LabelElement<IntLabelElementInput, IntLabelElementInstantiator>
	{
		public int Value
		{
			get
			{
				return int.Parse(((TMP_Text)base.TextMesh).text ?? "0");
			}
			set
			{
				((TMP_Text)base.TextMesh).text = value.ToString();
			}
		}

		public IntLabelElement(IntLabelElementInput input)
			: base(input)
		{
		}

		public void Increment(int increment = 1)
		{
			Value += increment;
		}

		public void Decrement(int decrement = 1)
		{
			Value -= decrement;
		}
	}
	public class IntLabelElementInput : LabelElementInput
	{
		public int Value { get; init; }

		public override bool Debug { get; init; } = false;

	}
	public class IntLabelElementInstantiator : LabelElementInstantiator, IInstantiator<IntLabelElementInput>
	{
		public GameObject Instantiate(IntLabelElementInput input, Type? script)
		{
			GameObject val = Instantiate((LabelElementInput)input, script);
			((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = input.Value.ToString();
			return val;
		}
	}
	public abstract class LabelElement<TInput, TInstantiator> : Element<TInput, TInstantiator> where TInput : LabelElementInput where TInstantiator : IInstantiator<TInput>, new()
	{
		protected TextMeshProUGUI TextMesh { get; private set; }

		protected LabelElement(TInput input)
			: base(input)
		{
			TextMesh = base.GameObject.GetComponent<TextMeshProUGUI>();
		}
	}
	public abstract class LabelElement<TInput> : LabelElement<TInput, LabelElementInstantiator> where TInput : LabelElementInput
	{
		protected LabelElement(TInput input)
			: base(input)
		{
		}
	}
	public class LabelElementInput : ElementInput
	{
		private const int DefaultFontSize = 32;

		public int FontSize { get; init; } = 32;

	}
	public class LabelElementInstantiator : Instantiator<LabelElementInput>
	{
		private const string FontAssetName = "3270-Regular SDF";

		public override GameObject Instantiate(LabelElementInput input, Type? script)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = base.Instantiate(input, script);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			TMP_FontAsset font = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().First((TMP_FontAsset asset) => ((Object)asset).name == "3270-Regular SDF");
			((Graphic)val2).color = Color.green;
			((TMP_Text)val2).font = font;
			((TMP_Text)val2).fontSize = input.FontSize;
			return val;
		}
	}
	public class LabelElementRenderer
	{
	}
	public class StringLabelElement : LabelElement<StringLabelElementInput, StringLabelElementInstantiator>
	{
		public string Value
		{
			get
			{
				return ((TMP_Text)base.TextMesh).text;
			}
			set
			{
				((TMP_Text)base.TextMesh).text = value;
			}
		}

		public StringLabelElement(StringLabelElementInput input)
			: base(input)
		{
		}
	}
	public class StringLabelElementInput : LabelElementInput
	{
		public required string Value { get; init; }
	}
	public class StringLabelElementInstantiator : LabelElementInstantiator, IInstantiator<StringLabelElementInput>
	{
		public GameObject Instantiate(StringLabelElementInput input, Type? script)
		{
			GameObject val = Instantiate((LabelElementInput)input, script);
			((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = input.Value;
			return val;
		}
	}
	public class RectElement : Element<RectElementInput, RectInstantiator>
	{
		public RectElement(RectElementInput input)
			: base(input)
		{
		}
	}
	public class RectElementInput : ElementInput
	{
	}
	public class RectInstantiator : Instantiator
	{
		public override GameObject Instantiate(RenderableInput input, Type? script)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = base.Instantiate(input, script);
			val.AddComponent<Image>();
			Image component = val.GetComponent<Image>();
			((Graphic)component).color = Color.green;
			return val;
		}
	}
}
namespace TerminalGaming.UI.Elements.Views
{
	public interface IView : IMultiRenderable, IRenderable, IDisposable
	{
	}
	public abstract class View<TInitiator> : MultiRenderable<TInitiator>, IView, IMultiRenderable, IRenderable, IDisposable where TInitiator : IInitiator, new()
	{
		protected View()
			: base(new RenderableInput
			{
				FullScreen = true
			})
		{
		}
	}
}
namespace TerminalGaming.UI.Elements.Views.PlayerSelectionView
{
	public class TitleElement : StringLabelElement
	{
		public TitleElement()
			: base(new StringLabelElementInput
			{
				Name = "TitleElement",
				Value = "PONG",
				FontSize = 128,
				CollapsedAnchorPosition = new CollapsedAnchorPosition
				{
					Anchor = new Vector2(0.5f, 0.9f)
				}
			})
		{
		}//IL_003b: Unknown result type (might be due to invalid IL or missing references)

	}
	public class PlayerSelectionContainer : VerticalLayout<PlayerSelectionContainerInitiator>
	{
		public PlayerSelectionContainer()
			: base(new LayoutInput
			{
				FullScreen = true
			})
		{
		}
	}
	public class PlayerSelectionContainerInitiator : IInitiator, IInitiator<RenderableInput>
	{
		public InitData Init(RenderableInput input)
		{
			InitData initData = new InitData();
			initData.AddRenderable(new TitleElement());
			initData.AddRenderable(new SelectionListWidget(new SelectionListWidgetInput
			{
				Options = new List<string>(1) { "1 PLAYER" },
				Width = 500f,
				Height = 300f,
				Spacing = 16
			}));
			return initData;
		}
	}
	public class PlayerSelectionView : View<PlayerSelectionViewInitiator>
	{
	}
	public class PlayerSelectionViewInitiator : IInitiator, IInitiator<RenderableInput>
	{
		public InitData Init(RenderableInput input)
		{
			InitData initData = new InitData();
			initData.AddRenderable(new PlayerSelectionContainer());
			return initData;
		}
	}
}
namespace TerminalGaming.Stubs.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Constructor)]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
}
namespace TerminalGaming.Managers
{
	public class GameManager : Manager<GameManager>
	{
		public delegate void QuitEventHandler();

		public event QuitEventHandler Quit = null;

		public void Awake()
		{
			Quit += GameScript_Quit;
		}

		public TGame AddGame<TGame>() where TGame : GameScript
		{
			return ((Component)this).gameObject.AddComponent<TGame>();
		}

		private void OnQuit()
		{
			this.Quit();
		}

		private void GameScript_Quit()
		{
			Terminal terminal = Manager<TerminalManager>.Instance.Terminal;
			GameObject mainContainer = terminal.GetMainContainer();
			PlayCommand.SetMainContainerActive(value: true);
			TMP_InputField component = ((Component)mainContainer.transform.Find("Scroll View/Viewport/InputField (TMP)")).GetComponent<TMP_InputField>();
			component.ActivateInputField();
		}

		protected void Update()
		{
			//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)
			KeyboardShortcut val = new KeyboardShortcut((KeyCode)127, Array.Empty<KeyCode>());
			if (((KeyboardShortcut)(ref val)).IsDown())
			{
				OnQuit();
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public abstract class Manager<TManager> : MonoBehaviour where TManager : Manager<TManager>
	{
		private static string Name { get; } = "TerminalGaming_" + typeof(TManager).Name;


		public static TManager Instance => Instantiate<TManager>(Name);

		private static TInstantiatedManager Instantiate<TInstantiatedManager>(string name) where TInstantiatedManager : MonoBehaviour
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find(name);
			if (val == null)
			{
				return new GameObject(name, new Type[1] { typeof(TManager) }).GetComponent<TInstantiatedManager>();
			}
			if (val.GetComponent<TInstantiatedManager>() == null)
			{
				val.AddComponent<TInstantiatedManager>();
			}
			return val.GetComponent<TInstantiatedManager>();
		}
	}
	public class TerminalManager : Manager<TerminalManager>
	{
		public Terminal Terminal { get; set; } = null;

	}
	public class UIManager : Manager<UIManager>
	{
		public Dictionary<IRenderable, GameObject> Renderables { get; set; } = new Dictionary<IRenderable, GameObject>();


		public void AddRenderable(IRenderable renderable)
		{
			Renderables.Add(renderable, renderable.GameObject);
		}

		public TRenderable GetRenderable<TRenderable>(string? renderableName = null) where TRenderable : class, IRenderable
		{
			string renderableName2 = renderableName;
			return Renderables.First<KeyValuePair<IRenderable, GameObject>>((KeyValuePair<IRenderable, GameObject> r) => (renderableName2 == null) ? (r.Key is TRenderable) : (r.Key is TRenderable && ((Object)r.Value).name == renderableName2)).Key as TRenderable;
		}

		public void RemoveRenderable(IRenderable renderable)
		{
			Renderables.Remove(renderable);
		}
	}
}
namespace TerminalGaming.Helpers
{
	public static class ObjectHelpers
	{
		public static GameObject InstantiateWithoutChildren(GameObject? original, Transform parent)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(original, parent);
			if (val == null)
			{
				throw new Exception("Object couldn't be instantiated.");
			}
			foreach (Transform item in val.transform)
			{
				Transform val2 = item;
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			return val;
		}
	}
}
namespace TerminalGaming.Games.Pong
{
	public class Game
	{
		public void Render()
		{
			Router.Navigate<PlayerSelectionView>();
		}
	}
	public abstract class GameScript : MonoBehaviour
	{
		protected GameObject Container = null;

		protected RectTransform ContainerRectTransform = null;

		protected virtual void Start()
		{
			Container = Manager<TerminalManager>.Instance.Terminal.GetGameContainer();
			ContainerRectTransform = Container.GetComponent<RectTransform>();
		}
	}
	public static class PongGameEvents
	{
		public delegate void RallyStartEventHandler(RallyStartEventArgs args);

		public delegate void BallHitEventHandler(BallHitEventArgs args);

		public static event RallyStartEventHandler RallyStart;

		public static event BallHitEventHandler BallHit;

		public static void OnRallyStart(RallyStartEventArgs args)
		{
			PongGameEvents.RallyStart(args);
		}

		public static void OnBallHit(BallHitEventArgs args)
		{
			PongGameEvents.BallHit(args);
		}
	}
	internal enum PaddleDirection
	{
		Up,
		Down
	}
	public sealed class PongGameScript : GameScript
	{
		private const float InitialPaddleSpeed = 320f;

		private const float InitialBallSpeed = 340f;

		private const float MaxPaddleSpeed = 650f;

		private const int SpeedIncrement = 5;

		private float paddleSpeed = 320f;

		private float ballSpeed = 340f;

		private PaddleElement leftPaddle = null;

		private RectTransform leftPaddleTransform = null;

		private PaddleElement rightPaddle = null;

		private RectTransform rightPaddleTransform = null;

		private BallElement ball = null;

		private RectTransform ballTransform = null;

		private ScoreElement leftScore = null;

		private ScoreElement rightScore = null;

		private Vector2 ballDirection;

		private Vector2 ballDestination;

		protected override void Start()
		{
			base.Start();
			leftPaddle = Manager<UIManager>.Instance.GetRenderable<PaddleElement>("LeftPaddleElement");
			leftPaddleTransform = leftPaddle.RectTransform;
			rightPaddle = Manager<UIManager>.Instance.GetRenderable<PaddleElement>("RightPaddleElement");
			rightPaddleTransform = rightPaddle.RectTransform;
			ball = Manager<UIManager>.Instance.GetRenderable<BallElement>();
			ballTransform = ball.RectTransform;
			leftScore = Manager<UIManager>.Instance.GetRenderable<ScoreElement>("LeftScoreElement");
			rightScore = Manager<UIManager>.Instance.GetRenderable<ScoreElement>("RightScoreElement");
			PongGameEvents.RallyStart += PongGame_RallyStart;
			PongGameEvents.BallHit += PongGame_BallHit;
			PongGameEvents.OnRallyStart(new RallyStartEventArgs
			{
				WinnerScore = null
			});
		}

		private void Update()
		{
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_003a: 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_008b: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut val = new KeyboardShortcut((KeyCode)119, Array.Empty<KeyCode>());
			if (!((KeyboardShortcut)(ref val)).IsPressed())
			{
				val = new KeyboardShortcut((KeyCode)115, Array.Empty<KeyCode>());
				if (!((KeyboardShortcut)(ref val)).IsPressed())
				{
					goto IL_0068;
				}
			}
			val = new KeyboardShortcut((KeyCode)119, Array.Empty<KeyCode>());
			PaddleDirection direction = ((!((KeyboardShortcut)(ref val)).IsPressed()) ? PaddleDirection.Down : PaddleDirection.Up);
			leftPaddleTransform.anchoredPosition = MovePaddle(leftPaddleTransform, direction);
			goto IL_0068;
			IL_00dc:
			PaddleElement paddleElement = (ballTransform.CollidesWith(leftPaddleTransform) ? leftPaddle : (ballTransform.CollidesWith(rightPaddleTransform) ? rightPaddle : null));
			if (paddleElement != null)
			{
				if (!paddleElement.IsHittingBall)
				{
					paddleElement.IsHittingBall = true;
					PongGameEvents.OnBallHit(new BallHitEventArgs
					{
						HittingPaddle = paddleElement
					});
					float num = (object.Equals(paddleElement, leftPaddle) ? 1 : (-1));
					float num2 = Mathf.InverseLerp(paddleElement.RectTransform.GetLocalBorderPosition(BorderPosition.Bottom).y, paddleElement.RectTransform.GetLocalBorderPosition(BorderPosition.Top).y, ((Transform)ballTransform).localPosition.y);
					Vector2 val2 = new Vector2(num, -1f);
					Vector2 normalized = ((Vector2)(ref val2)).normalized;
					val2 = new Vector2(num, 1f);
					ballDirection = Vector2.Lerp(normalized, ((Vector2)(ref val2)).normalized, num2);
					SetBallDestination();
				}
			}
			else
			{
				leftPaddle.IsHittingBall = false;
				rightPaddle.IsHittingBall = false;
			}
			if (ballDestination != Vector2.zero && (double)Vector2.Distance(ballTransform.anchoredPosition, ballDestination) < 0.0001)
			{
				Vector2? val3 = null;
				float num3 = ContainerRectTransform.GetWidth() / 2f * Mathf.Sign(ballTransform.anchoredPosition.x);
				float num4 = ContainerRectTransform.GetHeight() / 2f * Mathf.Sign(ballTransform.anchoredPosition.y);
				if (Mathf.Approximately(ballTransform.anchoredPosition.x, num3))
				{
					PongGameEvents.OnRallyStart(new RallyStartEventArgs
					{
						WinnerScore = ((num3 > 0f) ? leftScore : rightScore)
					});
					return;
				}
				if (Mathf.Approximately(ballTransform.anchoredPosition.y, num4))
				{
					val3 = ((num4 > 0f) ? Vector2.down : Vector2.up);
				}
				ballDirection = Vector2.Reflect(ballDirection, val3.Value);
				SetBallDestination();
			}
			MoveBall();
			return;
			IL_0068:
			val = new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>());
			if (!((KeyboardShortcut)(ref val)).IsPressed())
			{
				val = new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>());
				if (!((KeyboardShortcut)(ref val)).IsPressed())
				{
					goto IL_00dc;
				}
			}
			val = new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>());
			PaddleDirection direction2 = ((!((KeyboardShortcut)(ref val)).IsPressed()) ? PaddleDirection.Down : PaddleDirection.Up);
			rightPaddleTransform.anchoredPosition = MovePaddle(rightPaddleTransform, direction2);
			goto IL_00dc;
		}

		private void OnDestroy()
		{
			PongGameEvents.RallyStart -= PongGame_RallyStart;
			PongGameEvents.BallHit -= PongGame_BallHit;
		}

		private void PongGame_RallyStart(RallyStartEventArgs args)
		{
			args.WinnerScore?.Increment();
			((MonoBehaviour)this).StartCoroutine(ResetRound());
		}

		private void PongGame_BallHit(BallHitEventArgs args)
		{
			if (!(paddleSpeed >= 650f))
			{
				paddleSpeed += 5f;
				ballSpeed += 5f;
			}
		}

		private IEnumerator ResetRound()
		{
			ballTransform.anchoredPosition = Vector2.zero;
			ballDirection = Vector2.zero;
			ballDestination = Vector2.zero;
			paddleSpeed = 320f;
			ballSpeed = 340f;
			yield return (object)new WaitForSeconds(1f);
			SetInitialBallDirection();
			SetBallDestination();
		}

		private Vector2 MovePaddle(RectTransform paddle, PaddleDirection direction)
		{
			//IL_0052: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			float num = paddleSpeed * Time.deltaTime;
			float num2 = ((direction == PaddleDirection.Up) ? (ContainerRectTransform.GetHeight() / 2f - paddle.GetHeight() / 2f) : ((0f - ContainerRectTransform.GetHeight()) / 2f + paddle.GetHeight() / 2f));
			return Vector2.MoveTowards(paddle.anchoredPosition, new Vector2(leftPaddleTransform.GetWidth() / 2f, num2), num);
		}

		private void MoveBall()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			Vector2 anchoredPosition = ballTransform.anchoredPosition;
			ballTransform.anchoredPosition = Vector2.MoveTowards(anchoredPosition, ballDestination, ballSpeed * Time.deltaTime);
		}

		private void SetInitialBallDirection()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			ballDirection = new Vector2((float)(Random.Range(-1, 1) * 2 + 1), Random.Range(-0.5f, 0.5f));
		}

		private void SetBallDestination()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			Vector2 anchoredPosition = ballTransform.anchoredPosition;
			float num = ContainerRectTransform.GetWidth() / 2f;
			float num2 = ContainerRectTransform.GetHeight() / 2f;
			num = ((ballDirection.x > 0f) ? num : (0f - num));
			num2 = ((ballDirection.y > 0f) ? num2 : (0f - num2));
			float num3 = ballDirection.y / ballDirection.x;
			float num4 = anchoredPosition.y - num3 * anchoredPosition.x;
			float num5 = num3 * num + num4;
			float num6 = (num2 - num4) / num3;
			float num7 = (((ballDirection.x > 0f) ? (num >= num6) : (num <= num6)) ? num6 : num5);
			ballDestination = new Vector2(object.Equals(num7, num6) ? num6 : num, object.Equals(num7, num5) ? num5 : num2);
		}
	}
	public class PongGameInitiator : IInitiator, IInitiator<RenderableInput>
	{
		public InitData Init(RenderableInput input)
		{
			InitData initData = new InitData();
			initData.AddRenderable(new PaddleElement(PaddlePosition.Left));
			initData.AddRenderable(new PaddleElement(PaddlePosition.Right));
			initData.AddRenderable(new BallElement());
			initData.AddRenderable(new ScoreElement(ScorePosition.Left));
			initData.AddRenderable(new ScoreElement(ScorePosition.Right));
			initData.AddRenderable(new NetWidget());
			return initData;
		}
	}
	public class PongGameView : View<PongGameInitiator>
	{
		public override Type Script { get; } = typeof(PongGameScript);

	}
}
namespace TerminalGaming.Games.Pong.Widgets
{
	public class NetElement : RectElement
	{
		private const float NetGap = 20f;

		public NetElement(int index)
			: base(new RectElementInput
			{
				Name = "NetElement",
				Width = 2.5f,
				Height = 10f,
				CollapsedAnchorPosition = new CollapsedAnchorPosition
				{
					Anchor = new Vector2(0.5f, 1f),
					Offset = new Vector2(0f, 0f - (float)index * 30f)
				}
			})
		{
		}//IL_0043: 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)

	}
	public class NetWidget : MultiRenderable<NetWidgetInitiator>
	{
		public NetWidget()
			: base(new RenderableInput
			{
				CollapsedAnchorPosition = new CollapsedAnchorPosition
				{
					Anchor = new Vector2(0.5f, 0.95f)
				}
			})
		{
		}//IL_0017: Unknown result type (might be due to invalid IL or missing references)

	}
	public class NetWidgetInitiator : IInitiator, IInitiator<RenderableInput>
	{
		public InitData Init(RenderableInput input)
		{
			InitData initData = new InitData();
			for (int i = 0; i <= 12; i++)
			{
				initData.AddRenderable(new NetElement(i));
			}
			return initData;
		}
	}
}
namespace TerminalGaming.Games.Pong.EventArgs
{
	public sealed class BallHitEventArgs : System.EventArgs
	{
		public PaddleElement? HittingPaddle { get; set; }
	}
	public sealed class RallyStartEventArgs : System.EventArgs
	{
		public ScoreElement? WinnerScore { get; set; }
	}
}
namespace TerminalGaming.Games.Pong.Elements
{
	public class BallElement : RectElement
	{
		public BallElement()
			: base(new RectElementInput
			{
				Name = "BallElement",
				Width = 10f,
				Height = 10f,
				CollapsedAnchorPosition = new CollapsedAnchorPosition
				{
					Anchor = new Vector2(0.5f, 0.5f)
				}
			})
		{
		}//IL_0041: Unknown result type (might be due to invalid IL or missing references)

	}
	public enum PaddlePosition
	{
		Left,
		Right
	}
	public class PaddleElement : RectElement
	{
		private const float PaddleWidth = 10f;

		private const float PaddleHeight = 50f;

		public bool IsHittingBall = false;

		public PaddleElement(PaddlePosition position)
			: base(new RectElementInput
			{
				Name = ((position == PaddlePosition.Left) ? "LeftPaddleElement" : "RightPaddleElement"),
				Width = 10f,
				Height = 50f,
				CollapsedAnchorPosition = new CollapsedAnchorPosition
				{
					Anchor = new Vector2((float)((position != 0) ? 1 : 0), 0.5f),
					AnchoredPosition = new Vector2((position == PaddlePosition.Left) ? (-5f) : 25f, 0f)
				}
			})
		{
		}//IL_0059: 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)

	}
	public enum ScorePosition
	{
		Left,
		Right
	}
	public class ScoreElement : IntLabelElement
	{
		public ScoreElement(ScorePosition position)
			: base(new IntLabelElementInput
			{
				Name = ((position == ScorePosition.Left) ? "LeftScoreElement" : "RightScoreElement"),
				CollapsedAnchorPosition = new CollapsedAnchorPosition
				{
					Anchor = new Vector2((position == ScorePosition.Left) ? 0.25f : 0.75f, 0.9f)
				}
			})
		{
		}//IL_0037: Unknown result type (might be due to invalid IL or missing references)

	}
}
namespace TerminalGaming.Extensions
{
	public static class GameObjectExtensions
	{
		public static bool HasComponent<TComponent>(this GameObject gameObject)
		{
			return gameObject.GetComponent<TComponent>() != null;
		}
	}
	public enum BorderPosition
	{
		Top,
		Bottom,
		Left,
		Right
	}
	public static class RectTransformExtensions
	{
		public static Vector2 GetSize(this RectTransform source)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = source.rect;
			return ((Rect)(ref rect)).size;
		}

		public static float GetWidth(this RectTransform source)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = source.rect;
			return ((Rect)(ref rect)).size.x;
		}

		public static float GetHeight(this RectTransform source)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = source.rect;
			return ((Rect)(ref rect)).size.y;
		}

		public static void SetSize(this RectTransform source, RectTransform toCopy)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			source.SetSize(toCopy.GetSize());
		}

		public static void SetSize(this RectTransform source, Vector2 newSize)
		{
			//IL_0002: 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)
			source.SetSize(newSize.x, newSize.y);
		}

		public static void SetSize(this RectTransform source, float width, float height)
		{
			source.SetSizeWithCurrentAnchors((Axis)0, width);
			source.SetSizeWithCurrentAnchors((Axis)1, height);
		}

		public static void SetWidth(this RectTransform source, float width)
		{
			source.SetSizeWithCurrentAnchors((Axis)0, width);
		}

		public static void SetHeight(this RectTransform source, float height)
		{
			source.SetSizeWithCurrentAnchors((Axis)1, height);
		}

		public static Vector2 GetLocalBorderPosition(this RectTransform source, BorderPosition borderPosition)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0046: 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_0050: 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)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Vector2.op_Implicit(((Transform)source).localPosition);
			float num = source.GetWidth() / 2f;
			float num2 = source.GetHeight() / 2f;
			return (Vector2)(borderPosition switch
			{
				BorderPosition.Top => val + new Vector2(0f, num2), 
				BorderPosition.Bottom => val - new Vector2(0f, num2), 
				BorderPosition.Right => val + new Vector2(num, 0f), 
				BorderPosition.Left => val - new Vector2(num, 0f), 
				_ => throw new ArgumentOutOfRangeException("borderPosition", borderPosition, null), 
			});
		}

		public static bool CollidesWith(this RectTransform source, RectTransform collider)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Vector2.op_Implicit(((Transform)collider).localPosition);
			(float, float) tuple = (collider.GetLocalBorderPosition(BorderPosition.Right).x, collider.GetLocalBorderPosition(BorderPosition.Left).x);
			(float, float) tuple2 = (collider.GetLocalBorderPosition(BorderPosition.Top).y, collider.GetLocalBorderPosition(BorderPosition.Bottom).y);
			Vector3 localPosition = ((Transform)source).localPosition;
			return localPosition.x + source.GetWidth() / 2f > tuple.Item2 && localPosition.x - source.GetWidth() / 2f < tuple.Item1 && localPosition.y + source.GetHeight() / 2f > tuple2.Item2 && localPosition.y - source.GetHeight() / 2f < tuple2.Item1;
		}
	}
	public static class TerminalExtensions
	{
		public static GameObject GetMainContainer(this Terminal terminal)
		{
			GameObject container = terminal.GetContainer("MainContainer");
			if (container == null)
			{
				throw new Exception("MainContainer couldn't be found. An update or another plugin may have changed the UI.");
			}
			return container;
		}

		public static GameObject GetGameContainer(this Terminal terminal)
		{
			return terminal.GetContainer("GameContainer") ?? terminal.InstantiateGameContainer();
		}

		public static GameObject? GetContainer(this Terminal terminal, string containerName)
		{
			Transform obj = ((Component)terminal.terminalUIScreen).gameObject.transform.Find(containerName);
			return (obj != null) ? ((Component)obj).gameObject : null;
		}

		private static GameObject InstantiateGameContainer(this Terminal terminal)
		{
			//IL_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ObjectHelpers.InstantiateWithoutChildren(terminal.GetContainer("MainContainer"), ((Component)terminal.terminalUIScreen).transform);
			((Object)val).name = "GameContainer";
			RectTransform component = val.GetComponent<RectTransform>();
			Vector3 anchoredPosition3D = component.anchoredPosition3D;
			Rect rect = component.rect;
			component.SetWidth(((Rect)(ref rect)).width - 70f);
			rect = component.rect;
			component.SetHeight(((Rect)(ref rect)).height - 90f);
			anchoredPosition3D += new Vector3(anchoredPosition3D.x + 35f, anchoredPosition3D.y + 20f, 0f);
			component.anchoredPosition3D = anchoredPosition3D;
			return val;
		}
	}
	public static class Vector2Extensions
	{
		public static Vector2 Rotated(this Vector2 vector, float degrees)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			float num = degrees * (MathF.PI / 180f);
			float num2 = Mathf.Sin(num);
			float num3 = Mathf.Cos(num);
			return new Vector2(num3 * vector.x - num2 * vector.y, num2 * vector.x + num3 * vector.y);
		}
	}
}
namespace TerminalGaming.Enums
{
	public enum GameName
	{
		Pong
	}
}
namespace TerminalGaming.Commands
{
	public class PlayCommand
	{
		[TerminalCommand("Play", false)]
		public string? Play(ArgumentStream input, Terminal commandTerminal)
		{
			string value = default(string);
			input.TryReadNext(ref value);
			if (!Enum.TryParse<GameName>(value, ignoreCase: true, out var _))
			{
				return null;
			}
			Manager<TerminalManager>.Instance.Terminal = commandTerminal;
			GameManager instance = Manager<GameManager>.Instance;
			SetMainContainerActive(value: false);
			Router.Navigate<PlayerSelectionView>();
			return commandTerminal.currentText;
		}

		public static void SetMainContainerActive(bool value)
		{
			Terminal terminal = Manager<TerminalManager>.Instance.Terminal;
			GameObject mainContainer = terminal.GetMainContainer();
			GameObject gameContainer = terminal.GetGameContainer();
			if (value)
			{
				mainContainer.SetActive(true);
				Object.Destroy((Object)(object)gameContainer);
			}
			else
			{
				gameContainer.SetActive(true);
				mainContainer.SetActive(false);
			}
		}
	}
}