Decompiled source of Walk On Boarding v1.0.0

Walk On Boarding.dll

Decompiled a week ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;
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: AssemblyTitle("Board Flight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Board Flight")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("088bdbe1-e2f4-43bb-9b89-3fa225dca6ff")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WalkOnBoarding;

[BepInPlugin("tony4twenty.Walk_On_Boarding", "Walk On Boarding", "1.0.0")]
public class WalkOnBoardPlugin : BaseUnityPlugin
{
	private GameObject boardingPanel;

	private bool triggeredBoarding = false;

	private bool gameStarted = false;

	private float checkInterval = 1f;

	private float checkTimer = 0f;

	private readonly Vector3 boxMin = new Vector3(30f, 0f, 90f);

	private readonly Vector3 boxMax = new Vector3(43f, 2f, 97f);

	private void OnEnable()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnDisable()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name == "Airport")
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Airport scene loaded. Attempting to remove sliding doors and kiosk visuals...");
			RemoveSlidingDoors();
			RemoveCheckInKiosk();
			triggeredBoarding = false;
			gameStarted = false;
			checkTimer = 0f;
		}
	}

	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_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		if (!PhotonNetwork.IsMasterClient)
		{
			return;
		}
		Scene activeScene = SceneManager.GetActiveScene();
		if (((Scene)(ref activeScene)).name != "Airport")
		{
			return;
		}
		checkTimer += Time.deltaTime;
		if (checkTimer < checkInterval)
		{
			return;
		}
		checkTimer = 0f;
		if (gameStarted)
		{
			return;
		}
		GameObject obj = GameObject.Find("StartGameButton");
		Button val = ((obj != null) ? obj.GetComponent<Button>() : null);
		if ((Object)(object)val != (Object)null && !((Selectable)val).interactable)
		{
			gameStarted = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Start game button is disabled, game likely started. Preventing kiosk reopen.");
			return;
		}
		Character[] array = Object.FindObjectsByType<Character>((FindObjectsSortMode)0);
		Character[] array2 = array;
		foreach (Character val2 in array2)
		{
			if (!((MonoBehaviourPun)val2).photonView.IsMine)
			{
				continue;
			}
			CharacterData component = ((Component)val2).GetComponent<CharacterData>();
			if ((Object)(object)component == (Object)null)
			{
				continue;
			}
			Vector3 groundPos = component.groundPos;
			if (IsInsideTriggerBox(groundPos))
			{
				if (!triggeredBoarding)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Host is inside trigger zone. Triggering Interact_CastFinished...");
					AirportCheckInKiosk val3 = Object.FindFirstObjectByType<AirportCheckInKiosk>();
					if ((Object)(object)val3 != (Object)null)
					{
						val3.Interact_CastFinished(val2);
						triggeredBoarding = true;
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find AirportCheckInKiosk to trigger interaction.");
					}
				}
			}
			else
			{
				triggeredBoarding = false;
			}
		}
	}

	private bool IsInsideTriggerBox(Vector3 pos)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_003a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		return pos.x >= boxMin.x && pos.x <= boxMax.x && pos.y >= boxMin.y && pos.y <= boxMax.y && pos.z >= boxMin.z && pos.z <= boxMax.z;
	}

	private void RemoveSlidingDoors()
	{
		//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)
		Scene activeScene = SceneManager.GetActiveScene();
		GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
		GameObject[] array = rootGameObjects;
		foreach (GameObject val in array)
		{
			Transform val2 = FindDeepChild(val.transform, "Sliding Doors");
			if ((Object)(object)val2 != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found 'Sliding Doors' GameObject. Removing MeshRenderer, MeshFilter, and Collider...");
				Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<MeshRenderer>());
				Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<MeshFilter>());
				Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<Collider>());
				return;
			}
		}
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find 'Sliding Doors' GameObject in Airport scene.");
	}

	private void RemoveCheckInKiosk()
	{
		//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)
		Scene activeScene = SceneManager.GetActiveScene();
		GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
		GameObject[] array = rootGameObjects;
		foreach (GameObject val in array)
		{
			Transform val2 = FindDeepChild(val.transform, "AirportGateKiosk");
			if ((Object)(object)val2 != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found 'AirportGateKiosk'. Removing MeshRenderer, MeshFilter, and Collider...");
				Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<MeshRenderer>());
				Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<MeshFilter>());
				Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<Collider>());
				return;
			}
		}
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find 'AirportGateKiosk' GameObject in Airport scene.");
	}

	private Transform FindDeepChild(Transform parent, string name)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		foreach (Transform item in parent)
		{
			Transform val = item;
			if (((Object)val).name == name)
			{
				return val;
			}
			Transform val2 = FindDeepChild(val, name);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
		}
		return null;
	}
}