Decompiled source of TeleportGUI Mod v1.0.0

TeleportGUI.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MelonLoader;
using Microsoft.CodeAnalysis;
using ScheduleOne;
using ScheduleOne.DevUtilities;
using ScheduleOne.PlayerScripts;
using TeleportGUI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Mod), "Teleport GUI", "1.0.1", "Flaco", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("TeleportGUI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TeleportGUI")]
[assembly: AssemblyTitle("TeleportGUI")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TeleportGUI
{
	public class Mod : MelonMod
	{
		private bool showGUI;

		private Rect windowRect = new Rect(100f, 100f, 320f, 500f);

		private Vector2 scrollPos = Vector2.zero;

		private List<Transform> teleportPoints = new List<Transform>();

		private bool initialized;

		private GUIStyle windowStyle;

		private GUIStyle buttonStyle;

		private GUIStyle titleStyle;

		private Texture2D backgroundTexture;

		public override void OnUpdate()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			if (Input.GetKeyDown((KeyCode)283))
			{
				showGUI = !showGUI;
				if (showGUI)
				{
					InputSimulator.KeyPress((KeyCode)27);
				}
			}
			if (initialized || !((Object)(object)Singleton<Console>.Instance != (Object)null) || !((Object)(object)Singleton<Console>.Instance.TeleportPointsContainer != (Object)null))
			{
				return;
			}
			foreach (Transform item2 in Singleton<Console>.Instance.TeleportPointsContainer)
			{
				Transform item = item2;
				teleportPoints.Add(item);
			}
			initialized = true;
		}

		public override void OnGUI()
		{
			//IL_001d: 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_003e: Expected O, but got Unknown
			//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)
			if (windowStyle == null)
			{
				InitStyles();
			}
			if (showGUI)
			{
				windowRect = GUI.Window(12345, windowRect, new WindowFunction(DrawWindow), "Teleport Menu", windowStyle);
			}
		}

		private void InitStyles()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0029: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00e8: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0129: Expected O, but got Unknown
			backgroundTexture = new Texture2D(1, 1);
			backgroundTexture.SetPixel(0, 0, new Color(0.8f, 0.9f, 1f, 1f));
			backgroundTexture.Apply();
			GUIStyle val = new GUIStyle(GUI.skin.window)
			{
				fontSize = 18,
				fontStyle = (FontStyle)1,
				padding = new RectOffset(10, 10, 25, 10)
			};
			val.normal.background = backgroundTexture;
			windowStyle = val;
			GUIStyle val2 = new GUIStyle(GUI.skin.button)
			{
				fontSize = 16,
				fixedHeight = 40f,
				margin = new RectOffset(5, 5, 5, 5)
			};
			val2.normal.textColor = Color.white;
			val2.active.textColor = Color.white;
			buttonStyle = val2;
			GUIStyle val3 = new GUIStyle(GUI.skin.label)
			{
				fontSize = 20,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)1
			};
			val3.normal.textColor = Color.black;
			val3.margin = new RectOffset(5, 5, 10, 20);
			titleStyle = val3;
		}

		private void DrawWindow(int windowID)
		{
			//IL_0017: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Select a destination", titleStyle, Array.Empty<GUILayoutOption>());
			scrollPos = GUILayout.BeginScrollView(scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(300f),
				GUILayout.Height(400f)
			});
			foreach (Transform teleportPoint in teleportPoints)
			{
				if (GUILayout.Button(((Object)teleportPoint).name, buttonStyle, Array.Empty<GUILayoutOption>()))
				{
					TryTeleport(teleportPoint);
					showGUI = false;
				}
			}
			GUILayout.EndScrollView();
			GUI.DragWindow();
		}

		private void TryTeleport(Transform destination)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			if (PlayerSingleton<PlayerMovement>.InstanceExists)
			{
				PlayerSingleton<PlayerMovement>.Instance.Teleport(destination.position + Vector3.up);
				((Component)Player.Local).transform.forward = destination.forward;
				Console.Log((object)("Teleported to '" + ((Object)destination).name + "'"), (Object)null);
			}
			else
			{
				Console.LogWarning((object)"Player not available yet.", (Object)null);
			}
		}
	}
	public static class InputSimulator
	{
		public static void KeyPress(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Event.current = new Event
			{
				type = (EventType)4,
				keyCode = key
			};
		}
	}
}