Decompiled source of Guidelines v1.0.2

BepInEx/plugins/GuidelineMod/GuidelineMod.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 System.Threading;
using BepInEx;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.CompilerServices;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
using UnityEngine.LowLevel;

[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("GuidelineMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GuidelineMod")]
[assembly: AssemblyTitle("GuidelineMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GuidelineMod;

public class GuidelineInfo : MonoBehaviour, IPunObservable
{
	[CompilerGenerated]
	private sealed class <IntallingWaypointRoutine>d__8 : IAsyncStateMachine
	{
		public int <>1__state;

		public AsyncUniTaskMethodBuilder <>t__builder;

		public Transform targetTransform;

		public GuidelineInfo <>4__this;

		private Awaiter <>u__1;

		private Awaiter <>u__2;

		private void MoveNext()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00c3: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			int num = <>1__state;
			try
			{
				Awaiter awaiter;
				Awaiter awaiter2;
				if (num != 0)
				{
					if (num == 1)
					{
						awaiter = <>u__2;
						<>u__2 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_0232;
					}
					SwitchToMainThreadAwaitable val = UniTask.SwitchToMainThread(default(CancellationToken));
					awaiter2 = ((SwitchToMainThreadAwaitable)(ref val)).GetAwaiter();
					if (!((Awaiter)(ref awaiter2)).IsCompleted)
					{
						num = (<>1__state = 0);
						<>u__1 = awaiter2;
						<IntallingWaypointRoutine>d__8 <IntallingWaypointRoutine>d__ = this;
						((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <IntallingWaypointRoutine>d__8>(ref awaiter2, ref <IntallingWaypointRoutine>d__);
						return;
					}
				}
				else
				{
					awaiter2 = <>u__1;
					<>u__1 = default(Awaiter);
					num = (<>1__state = -1);
				}
				((Awaiter)(ref awaiter2)).GetResult();
				goto IL_023b;
				IL_023b:
				if (!<>4__this.InstallGuidelineCTS.IsCancellationRequested)
				{
					<>4__this.currentGuideline.SetPosition(<>4__this.currentGuideline.positionCount - 1, targetTransform.position + Vector3.up * 0.25f);
					if (<>4__this.avatar.isLocal)
					{
						if (!Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)102))
						{
							if (GameManager.Multiplayer())
							{
								PlayerAvatar.instance.photonView.RPC("PushWaypoint", (RpcTarget)3, Array.Empty<object>());
							}
							else
							{
								<>4__this.PushWaypoint();
							}
						}
						if (!Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)103))
						{
							if (GameManager.Multiplayer())
							{
								PlayerAvatar.instance.photonView.RPC("PopWaypoint", (RpcTarget)3, Array.Empty<object>());
							}
							else
							{
								<>4__this.PopWaypoint();
							}
						}
					}
					if (<>4__this.currentGuideline.positionCount > 1)
					{
						YieldAwaitable val2 = UniTask.Yield();
						awaiter = ((YieldAwaitable)(ref val2)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__2 = awaiter;
							<IntallingWaypointRoutine>d__8 <IntallingWaypointRoutine>d__ = this;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <IntallingWaypointRoutine>d__8>(ref awaiter, ref <IntallingWaypointRoutine>d__);
							return;
						}
						goto IL_0232;
					}
					Object.Destroy((Object)(object)((Component)<>4__this.guidelines.Pop()).gameObject);
					<>4__this.StopInstall();
				}
				goto end_IL_0007;
				IL_0232:
				((Awaiter)(ref awaiter)).GetResult();
				goto IL_023b;
				end_IL_0007:;
			}
			catch (Exception exception)
			{
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
				return;
			}
			<>1__state = -2;
			((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
		}

		void IAsyncStateMachine.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			this.MoveNext();
		}

		[DebuggerHidden]
		private void SetStateMachine(IAsyncStateMachine stateMachine)
		{
		}

		void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
		{
			//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
			this.SetStateMachine(stateMachine);
		}
	}

	public PlayerAvatar avatar;

	public PlayerAvatarVisuals visuals;

	public Stack<LineRenderer> guidelines = new Stack<LineRenderer>();

	public CancellationTokenSource InstallGuidelineCTS;

	public LineRenderer currentGuideline;

	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		throw new NotImplementedException();
	}

	public void Awake()
	{
		avatar = ((Component)this).gameObject.GetComponent<PlayerAvatar>();
		visuals = avatar.playerAvatarVisuals;
	}

	public void Update()
	{
		if (!avatar.isLocal || !Input.GetKey((KeyCode)306))
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)102))
		{
			if (InstallGuidelineCTS == null)
			{
				if (GameManager.Multiplayer())
				{
					PlayerAvatar.instance.photonView.RPC("PushGuideline", (RpcTarget)3, Array.Empty<object>());
				}
				else
				{
					PushGuideline();
				}
			}
			else if (GameManager.Multiplayer())
			{
				PlayerAvatar.instance.photonView.RPC("StopInstall", (RpcTarget)3, Array.Empty<object>());
			}
			else
			{
				StopInstall();
			}
		}
		if (Input.GetKeyDown((KeyCode)103))
		{
			if (GameManager.Multiplayer())
			{
				PlayerAvatar.instance.photonView.RPC("PopGuideline", (RpcTarget)3, Array.Empty<object>());
			}
			else
			{
				PopGuideline();
			}
		}
	}

	[AsyncStateMachine(typeof(<IntallingWaypointRoutine>d__8))]
	[DebuggerStepThrough]
	private UniTask IntallingWaypointRoutine(Transform targetTransform)
	{
		//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_0039: Unknown result type (might be due to invalid IL or missing references)
		<IntallingWaypointRoutine>d__8 <IntallingWaypointRoutine>d__ = new <IntallingWaypointRoutine>d__8();
		<IntallingWaypointRoutine>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
		<IntallingWaypointRoutine>d__.<>4__this = this;
		<IntallingWaypointRoutine>d__.targetTransform = targetTransform;
		<IntallingWaypointRoutine>d__.<>1__state = -1;
		((AsyncUniTaskMethodBuilder)(ref <IntallingWaypointRoutine>d__.<>t__builder)).Start<<IntallingWaypointRoutine>d__8>(ref <IntallingWaypointRoutine>d__);
		return ((AsyncUniTaskMethodBuilder)(ref <IntallingWaypointRoutine>d__.<>t__builder)).Task;
	}

	[PunRPC]
	public void PushGuideline()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: 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_0149: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Guideline");
		val.transform.position = ((Component)avatar).transform.position;
		guidelines.Push(val.AddComponent<LineRenderer>());
		currentGuideline = guidelines.Peek();
		((Renderer)currentGuideline).material = GuidelineMod.instance.lineMat;
		currentGuideline.startWidth = 0.3f;
		currentGuideline.endWidth = 0.3f;
		currentGuideline.numCornerVertices = 5;
		currentGuideline.numCapVertices = 1;
		Color color = visuals.color;
		((Renderer)currentGuideline).material.color = color;
		currentGuideline.startColor = color;
		currentGuideline.endColor = color;
		currentGuideline.positionCount = 2;
		currentGuideline.SetPosition(0, ((Component)avatar).transform.position + Vector3.up * 0.25f);
		InstallGuidelineCTS = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { ((MonoBehaviour)this).destroyCancellationToken });
		UniTask.RunOnThreadPool((Func<UniTask>)(() => IntallingWaypointRoutine(((Component)avatar).transform)), true, InstallGuidelineCTS.Token);
	}

	[PunRPC]
	public void PopGuideline()
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)currentGuideline != (Object)null)
		{
			if (GameManager.Multiplayer())
			{
				PlayerAvatar.instance.photonView.RPC("StopInstall", (RpcTarget)3, Array.Empty<object>());
			}
			else
			{
				StopInstall();
			}
			Object.Destroy((Object)(object)guidelines.Pop());
		}
		else if (guidelines.Count > 0)
		{
			currentGuideline = guidelines.Peek();
			InstallGuidelineCTS = CancellationTokenSource.CreateLinkedTokenSource(new CancellationToken[1] { ((MonoBehaviour)this).destroyCancellationToken });
			UniTask.RunOnThreadPool((Func<UniTask>)(() => IntallingWaypointRoutine(((Component)avatar).transform)), true, InstallGuidelineCTS.Token);
		}
	}

	[PunRPC]
	public void PushWaypoint()
	{
		LineRenderer obj = currentGuideline;
		int positionCount = obj.positionCount;
		obj.positionCount = positionCount + 1;
	}

	[PunRPC]
	public void PopWaypoint()
	{
		LineRenderer obj = currentGuideline;
		int positionCount = obj.positionCount;
		obj.positionCount = positionCount - 1;
	}

	[PunRPC]
	public void StopInstall()
	{
		currentGuideline = null;
		InstallGuidelineCTS?.Cancel();
		InstallGuidelineCTS?.Dispose();
		InstallGuidelineCTS = null;
	}
}
[BepInPlugin("com.vg.guidelines", "Vg's Guidelines", "1.0.0")]
public class GuidelineMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(PlayerAvatar), "Awake")]
	private class PlayerAvatar_Awake_Patch
	{
		[HarmonyPostfix]
		public static void PlayerAvatar_Awake_Postfix(PlayerAvatar __instance)
		{
			((Component)__instance).gameObject.AddComponent<GuidelineInfo>();
			GuidelineMod instance = GuidelineMod.instance;
			if (instance.lineMat == null)
			{
				instance.lineMat = ((Component)Object.FindObjectOfType<PhysGrabBeam>(true)).GetComponent<Renderer>().material;
			}
		}
	}

	public static GuidelineMod instance;

	public Material lineMat;

	private readonly Harmony harmony = new Harmony("com.vg.guidelines");

	public const string PluginGuid = "com.vg.guidelines";

	public const string PluginName = "Vg's Guidelines";

	public const string PluginVersion = "1.0.0";

	public void Awake()
	{
		//IL_0024: 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)
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
		}
		harmony.PatchAll();
		PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();
		PlayerLoopHelper.Initialize(ref currentPlayerLoop, (InjectPlayerLoopTimings)65535);
	}
}