Decompiled source of DevIslandUnlocked v1.1.0

DevIslandUnlocked.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DevIslandUnlocked")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DevIslandUnlocked")]
[assembly: AssemblyTitle("DevIslandUnlocked")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 DevIslandUnlocked
{
	[BepInPlugin("com.howtofish.devislandunlocked", "Dev Island Unlocked", "1.1.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.howtofish.devislandunlocked";

		public const string Name = "Dev Island Unlocked";

		public const string Version = "1.1.0";

		private static readonly Vector3 DevIslandWorldPosition = Vector3.zero;

		private static readonly Color DevIslandRadarColor = new Color(0f, 0.85f, 1f, 1f);

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<bool> _showRadarDot;

		private ConfigEntry<bool> _debugLogging;

		private bool _injected;

		private bool _injectAttemptStarted;

		private object _radarUi;

		private object _devMapDot;

		private MethodInfo _radarUpdateDotMethod;

		private float _nextRadarAcquireTime;

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Unlock DevIsland as a normal navigable island.");
			_showRadarDot = ((BaseUnityPlugin)this).Config.Bind<bool>("Radar", "ShowDevIslandDot", true, "Show DevIsland on the native island radar.");
			_debugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Enable extra diagnostic logging.");
			SceneManager.sceneLoaded += OnSceneLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Dev Island Unlocked v1.1.0 loaded.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"DevIsland is never moved. Navigation and radar use the proven logical position (0,0,0).");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Navigation uses the native cloned IslandSpawner plus a collider-trigger bridge; no global player-position fallback is used.");
		}

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

		private void Update()
		{
			if (_enabled.Value)
			{
				if (!_injected)
				{
					TryInjectDevIsland();
				}
				if (_injected && _showRadarDot.Value)
				{
					EnsureDevIslandRadarDot();
					UpdateDevIslandRadarDot();
				}
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled.Value)
			{
				if (_debugLogging.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"[SCENE] Loaded '{((Scene)(ref scene)).name}', buildIndex={((Scene)(ref scene)).buildIndex}, mode={mode}.");
				}
				if (string.Equals(((Scene)(ref scene)).name, "DevIsland", StringComparison.OrdinalIgnoreCase))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[DEV ISLAND] Loaded at its original baked world position. No scene objects were repositioned.");
				}
				_radarUi = null;
				_devMapDot = null;
				_radarUpdateDotMethod = null;
				_nextRadarAcquireTime = Time.unscaledTime + 0.75f;
			}
		}

		private void TryInjectDevIsland()
		{
			//IL_0225: 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_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			if (_injectAttemptStarted)
			{
				return;
			}
			object obj = FindLiveObjectByTypeName("IslandManager");
			if (obj == null)
			{
				return;
			}
			Type type = obj.GetType();
			FieldInfo fieldInfo = FindField(type, "_islandInfos");
			FieldInfo fieldInfo2 = FindField(type, "_scenes");
			if (fieldInfo == null || fieldInfo2 == null)
			{
				return;
			}
			Array array = fieldInfo.GetValue(obj) as Array;
			IList list = fieldInfo2.GetValue(obj) as IList;
			if (array == null || list == null || array.Length < 5 || list.Count < 7)
			{
				return;
			}
			_injectAttemptStarted = true;
			try
			{
				if (array.Length >= 6 && HasLogicalDevIsland(array))
				{
					_injected = true;
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[DEV ISLAND] An existing logical DevIsland entry was detected. Reusing it.");
					return;
				}
				if (!string.Equals(list[6]?.ToString(), "DevIsland", StringComparison.OrdinalIgnoreCase))
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] Expected _scenes[6] to be DevIsland, but it was not. Injection cancelled for safety.");
					return;
				}
				if (array.Length != 5)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)($"[DEV ISLAND] IslandInfo length is {array.Length}, not the expected native length 5. " + "Another island-expansion mod may already be active. Injection cancelled to avoid index conflicts."));
					return;
				}
				object value = array.GetValue(4);
				if (value == null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] IslandInfo[4] (Island5) is null.");
					return;
				}
				Type type2 = value.GetType();
				FieldInfo fieldInfo3 = FindField(type2, "_spawnPosition");
				FieldInfo fieldInfo4 = FindField(type2, "_warning");
				if (fieldInfo3 == null || fieldInfo4 == null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] IslandInfo no longer exposes _spawnPosition/_warning.");
					return;
				}
				object? value2 = fieldInfo3.GetValue(value);
				GameObject val = (GameObject)((value2 is GameObject) ? value2 : null);
				object? value3 = fieldInfo4.GetValue(value);
				GameObject val2 = (GameObject)((value3 is GameObject) ? value3 : null);
				if ((Object)(object)val == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] Could not get Island5 navigation trigger.");
					return;
				}
				GameObject val3 = CloneIslandTriggerHolder(val);
				if ((Object)(object)val3 == (Object)null)
				{
					return;
				}
				Transform val4 = FindChildRecursive(val3.transform, ((Object)val).name);
				if ((Object)(object)val4 == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] Could not find cloned Island5 spawn inside holder.");
					Object.Destroy((Object)(object)val3);
					return;
				}
				Vector3 val5 = DevIslandWorldPosition - val4.position;
				Transform transform = val3.transform;
				transform.position += val5;
				GameObject gameObject = ((Component)val4).gameObject;
				((Object)gameObject).name = "IslandPosition6_DevIslandUnlocked";
				GameObject val6 = null;
				if ((Object)(object)val2 != (Object)null)
				{
					Transform val7 = FindChildRecursive(val3.transform, ((Object)val2).name);
					if ((Object)(object)val7 != (Object)null)
					{
						val6 = ((Component)val7).gameObject;
						((Object)val6).name = "IslandWarning6_DevIslandUnlocked";
					}
				}
				Type type3 = AccessTools.TypeByName("IslandSpawner");
				if (type3 == null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] IslandSpawner type not found.");
					Object.Destroy((Object)(object)val3);
					return;
				}
				Component component = gameObject.GetComponent(type3);
				if ((Object)(object)component == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] Cloned trigger has no IslandSpawner.");
					Object.Destroy((Object)(object)val3);
					return;
				}
				FieldInfo fieldInfo5 = FindField(type3, "_islandIndex");
				if (fieldInfo5 == null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"[DEV ISLAND] IslandSpawner._islandIndex not found.");
					Object.Destroy((Object)(object)val3);
					return;
				}
				fieldInfo5.SetValue(component, Convert.ChangeType(5, fieldInfo5.FieldType));
				DevIslandTriggerBridge devIslandTriggerBridge = gameObject.GetComponent<DevIslandTriggerBridge>();
				if ((Object)(object)devIslandTriggerBridge == (Object)null)
				{
					devIslandTriggerBridge = gameObject.AddComponent<DevIslandTriggerBridge>();
				}
				devIslandTriggerBridge.IslandIndex = 5;
				object obj2 = Activator.CreateInstance(type2, nonPublic: true);
				fieldInfo3.SetValue(obj2, gameObject);
				fieldInfo4.SetValue(obj2, val6);
				Array array2 = Array.CreateInstance(type2, 6);
				Array.Copy(array, array2, 5);
				array2.SetValue(obj2, 5);
				fieldInfo.SetValue(obj, array2);
				((Object)val3).name = "IslandPositionHolder6_DevIslandUnlocked";
				val3.SetActive(true);
				gameObject.SetActive(true);
				_injected = true;
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[DEV ISLAND] Unlocked successfully: logical island index 5 -> _scenes[6] DevIsland.");
				((BaseUnityPlugin)this).Logger.LogInfo((object)($"[DEV ISLAND] Navigation trigger position={gameObject.transform.position}. " + "DevIsland scene position remains untouched."));
				Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>(true);
				ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
				string[] obj3 = new string[5]
				{
					$"[DEV ISLAND] Navigation holder active={val3.activeInHierarchy}, ",
					$"spawnActive={gameObject.activeInHierarchy}, colliders={componentsInChildren.Length}, ",
					"spawnerEnabled=",
					null,
					null
				};
				Behaviour val8 = (Behaviour)(object)((component is Behaviour) ? component : null);
				obj3[3] = ((val8 != null) ? val8.enabled.ToString() : "n/a");
				obj3[4] = ".";
				logger.LogInfo((object)string.Concat(obj3));
				_radarUi = null;
				_devMapDot = null;
				_radarUpdateDotMethod = null;
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"[DEV ISLAND] Injection failed: {arg}");
			}
		}

		private bool HasLogicalDevIsland(Array infos)
		{
			if (infos == null || infos.Length < 6)
			{
				return false;
			}
			object value = infos.GetValue(5);
			if (value == null)
			{
				return false;
			}
			object? obj = FindField(value.GetType(), "_spawnPosition")?.GetValue(value);
			GameObject val = (GameObject)((obj is GameObject) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Type type = AccessTools.TypeByName("IslandSpawner");
			Component val2 = ((type != null) ? val.GetComponent(type) : null);
			FieldInfo fieldInfo = (((Object)(object)val2 != (Object)null) ? FindField(((object)val2).GetType(), "_islandIndex") : null);
			if (fieldInfo == null)
			{
				return false;
			}
			try
			{
				return Convert.ToInt32(fieldInfo.GetValue(val2)) == 5;
			}
			catch
			{
				return false;
			}
		}

		private GameObject CloneIslandTriggerHolder(GameObject sourceSpawn)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Transform parent = sourceSpawn.transform.parent;
			GameObject val;
			if ((Object)(object)parent != (Object)null)
			{
				val = Object.Instantiate<GameObject>(((Component)parent).gameObject);
			}
			else
			{
				val = new GameObject("IslandPositionHolder6_DevIslandUnlocked");
				((Object)Object.Instantiate<GameObject>(sourceSpawn, val.transform)).name = ((Object)sourceSpawn).name;
			}
			((Object)val).name = "IslandPositionHolder6_DevIslandUnlocked";
			return val;
		}

		private void EnsureDevIslandRadarDot()
		{
			if ((_devMapDot != null && _radarUi != null) || Time.unscaledTime < _nextRadarAcquireTime)
			{
				return;
			}
			_nextRadarAcquireTime = Time.unscaledTime + 1f;
			try
			{
				object obj = FindLiveObjectByTypeName("RadarUI");
				if (obj == null)
				{
					return;
				}
				FieldInfo fieldInfo = FindField(obj.GetType(), "_islandDots");
				if (fieldInfo == null || !(fieldInfo.GetValue(obj) is Array { Length: >=5 } array))
				{
					return;
				}
				if (array.Length >= 6 && array.GetValue(5) != null)
				{
					_radarUi = obj;
					_devMapDot = array.GetValue(5);
					ResolveRadarUpdateMethod();
					return;
				}
				Type elementType = array.GetType().GetElementType();
				if (elementType == null)
				{
					return;
				}
				object obj2 = null;
				for (int i = 0; i < array.Length; i++)
				{
					object value = array.GetValue(i);
					if (value != null)
					{
						obj2 = value;
						break;
					}
				}
				if (obj2 != null)
				{
					object obj3 = CloneInitializedMapDot(obj2, "DevIslandUnlocked_RadarDot");
					if (obj3 != null)
					{
						Array array2 = Array.CreateInstance(elementType, Math.Max(6, array.Length + 1));
						Array.Copy(array, array2, array.Length);
						array2.SetValue(obj3, 5);
						fieldInfo.SetValue(obj, array2);
						_radarUi = obj;
						_devMapDot = obj3;
						ResolveRadarUpdateMethod();
						((BaseUnityPlugin)this).Logger.LogInfo((object)("[RADAR] Added native-style DevIsland MapDot at index 5. " + $"Array {array.Length} -> {array2.Length}."));
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[RADAR] Could not create DevIsland dot: " + ex.Message));
				_radarUi = null;
				_devMapDot = null;
				_radarUpdateDotMethod = null;
			}
		}

		private object CloneInitializedMapDot(object template, string dotName)
		{
			//IL_00b1: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			if (template == null)
			{
				return null;
			}
			try
			{
				Type type = template.GetType();
				object obj = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(template, null);
				FieldInfo fieldInfo = FindField(type, "_dot");
				if (fieldInfo == null)
				{
					return null;
				}
				object? value = fieldInfo.GetValue(template);
				Component val = (Component)((value is Component) ? value : null);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				Transform parent = val.transform.parent;
				if ((Object)(object)parent == (Object)null)
				{
					return null;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val.gameObject);
				((Object)val2).name = dotName;
				val2.transform.SetParent(parent, false);
				val2.transform.localPosition = val.transform.localPosition;
				val2.transform.localRotation = val.transform.localRotation;
				val2.transform.localScale = val.transform.localScale;
				Component component = val2.GetComponent(fieldInfo.FieldType);
				if ((Object)(object)component == (Object)null)
				{
					Object.Destroy((Object)(object)val2);
					return null;
				}
				fieldInfo.SetValue(obj, component);
				val2.SetActive(val.gameObject.activeInHierarchy);
				ApplyDevIslandRadarColor(obj);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[RADAR] DevIsland dot color set to cyan {DevIslandRadarColor}.");
				return obj;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[RADAR] MapDot clone failed: " + ex.Message));
				return null;
			}
		}

		private void ApplyDevIslandRadarColor(object mapDot)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (mapDot == null)
			{
				return;
			}
			try
			{
				FieldInfo fieldInfo = FindField(mapDot.GetType(), "_dot");
				Component val = (Component)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if (!((Object)(object)val == (Object)null))
				{
					PropertyInfo property = ((object)val).GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(property == null) && property.CanWrite && !(property.PropertyType != typeof(Color)))
					{
						property.SetValue(val, DevIslandRadarColor, null);
					}
				}
			}
			catch (Exception ex)
			{
				if (_debugLogging != null && _debugLogging.Value)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("[RADAR] Could not apply DevIsland cyan color: " + ex.Message));
				}
			}
		}

		private void ResolveRadarUpdateMethod()
		{
			if (_radarUi != null && _devMapDot != null)
			{
				Type type = _radarUi.GetType();
				Type type2 = _devMapDot.GetType();
				_radarUpdateDotMethod = type.GetMethod("UpdateDot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
				{
					type2,
					typeof(Vector3)
				}, null);
				if (_radarUpdateDotMethod == null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[RADAR] UpdateDot(MapDot, Vector3) not found.");
				}
			}
		}

		private bool IsNativeRadarCurrentlyVisible()
		{
			if (_radarUi == null)
			{
				return false;
			}
			try
			{
				FieldInfo fieldInfo = FindField(_radarUi.GetType(), "_islandDots");
				Array array = ((fieldInfo != null) ? (fieldInfo.GetValue(_radarUi) as Array) : null);
				if (array == null)
				{
					return false;
				}
				int num = Math.Min(5, array.Length);
				for (int i = 0; i < num; i++)
				{
					object value = array.GetValue(i);
					if (value != null)
					{
						FieldInfo fieldInfo2 = FindField(value.GetType(), "_dot");
						Component val = (Component)((fieldInfo2 != null) ? /*isinst with value type is only supported in some contexts*/: null);
						if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null && val.gameObject.activeInHierarchy)
						{
							return true;
						}
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private void SetMapDotVisualActive(object mapDot, bool active)
		{
			if (mapDot == null)
			{
				return;
			}
			try
			{
				FieldInfo fieldInfo = FindField(mapDot.GetType(), "_dot");
				Component val = (Component)((fieldInfo != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null && val.gameObject.activeSelf != active)
				{
					val.gameObject.SetActive(active);
				}
			}
			catch
			{
			}
		}

		private void UpdateDevIslandRadarDot()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (_radarUi == null || _devMapDot == null || _radarUpdateDotMethod == null)
			{
				return;
			}
			if (!IsNativeRadarCurrentlyVisible())
			{
				SetMapDotVisualActive(_devMapDot, active: false);
				return;
			}
			try
			{
				_radarUpdateDotMethod.Invoke(_radarUi, new object[2] { _devMapDot, DevIslandWorldPosition });
				SetMapDotVisualActive(_devMapDot, active: true);
				ApplyDevIslandRadarColor(_devMapDot);
			}
			catch (TargetInvocationException ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[RADAR] Native UpdateDot failed: " + (ex.InnerException?.Message ?? ex.Message)));
				_radarUi = null;
				_devMapDot = null;
				_radarUpdateDotMethod = null;
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[RADAR] Update failed: " + ex2.Message));
				_radarUi = null;
				_devMapDot = null;
				_radarUpdateDotMethod = null;
			}
		}

		internal void QueueDevIslandFromTrigger(Collider other, string callbackName)
		{
			if (!_enabled.Value || (Object)(object)other == (Object)null || IsSceneLoaded("DevIsland"))
			{
				return;
			}
			if (!IsBoatOrPlayerCollider(other))
			{
				if (_debugLogging.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[DEV TRIGGER] Ignored " + callbackName + " collider " + $"'{((Object)other).name}' layer={((Component)other).gameObject.layer}."));
				}
				return;
			}
			object obj = FindLiveObjectByTypeName("IslandManager");
			if (obj == null)
			{
				return;
			}
			try
			{
				FieldInfo fieldInfo = FindField(obj.GetType(), "_hasQueuedIsland");
				if (!(fieldInfo != null) || !(fieldInfo.FieldType == typeof(bool)) || !(bool)fieldInfo.GetValue(obj))
				{
					MethodInfo method = obj.GetType().GetMethod("QueueRequest", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(byte) }, null);
					if (method == null)
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)"[DEV TRIGGER] IslandManager.QueueRequest(byte) not found.");
						return;
					}
					((BaseUnityPlugin)this).Logger.LogWarning((object)("[DEV TRIGGER] " + callbackName + ": accepted collider '" + ((Object)other).name + "'. QueueRequest(5) -> DevIsland."));
					method.Invoke(obj, new object[1] { (byte)5 });
				}
			}
			catch (TargetInvocationException ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[DEV TRIGGER] QueueRequest failed: " + (ex.InnerException?.Message ?? ex.Message)));
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[DEV TRIGGER] Queue failed: " + ex2.Message));
			}
		}

		private static bool IsBoatOrPlayerCollider(Collider other)
		{
			if ((Object)(object)other == (Object)null)
			{
				return false;
			}
			Transform val = ((Component)other).transform;
			Type type = AccessTools.TypeByName("Boat");
			Type type2 = AccessTools.TypeByName("Player");
			while ((Object)(object)val != (Object)null)
			{
				GameObject gameObject = ((Component)val).gameObject;
				if (type != null && (Object)(object)gameObject.GetComponent(type) != (Object)null)
				{
					return true;
				}
				if (type2 != null && (Object)(object)gameObject.GetComponent(type2) != (Object)null)
				{
					return true;
				}
				string text = ((Object)gameObject).name ?? "";
				if (text.IndexOf("Boat", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Player", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static bool IsSceneLoaded(string sceneName)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (((Scene)(ref sceneAt)).IsValid() && ((Scene)(ref sceneAt)).isLoaded && string.Equals(((Scene)(ref sceneAt)).name, sceneName, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		private static object FindLiveObjectByTypeName(string typeName)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Type type = AccessTools.TypeByName(typeName);
			if (type == null)
			{
				return null;
			}
			try
			{
				Object[] array = Resources.FindObjectsOfTypeAll(type);
				Object[] array2 = array;
				foreach (Object obj in array2)
				{
					Component val = (Component)(object)((obj is Component) ? obj : null);
					if (!((Object)(object)val == (Object)null) && !((Object)(object)val.gameObject == (Object)null))
					{
						Scene scene = val.gameObject.scene;
						if (((Scene)(ref scene)).IsValid() && ((Scene)(ref scene)).isLoaded)
						{
							return val;
						}
					}
				}
				return ((IEnumerable<Object>)array).FirstOrDefault((Func<Object, bool>)((Object o) => o != (Object)null));
			}
			catch
			{
				return null;
			}
		}

		private static FieldInfo FindField(Type type, string name)
		{
			Type type2 = type;
			while (type2 != null)
			{
				FieldInfo field = type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field;
				}
				type2 = type2.BaseType;
			}
			return null;
		}

		private static Transform FindChildRecursive(Transform parent, string name)
		{
			if ((Object)(object)parent == (Object)null)
			{
				return null;
			}
			if (string.Equals(((Object)parent).name, name, StringComparison.Ordinal))
			{
				return parent;
			}
			for (int i = 0; i < parent.childCount; i++)
			{
				Transform val = FindChildRecursive(parent.GetChild(i), name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}
	}
	internal sealed class DevIslandTriggerBridge : MonoBehaviour
	{
		public byte IslandIndex = 5;

		private float _nextAllowedTime;

		private void OnTriggerEnter(Collider other)
		{
			TryForward(other, "OnTriggerEnter");
		}

		private void OnTriggerStay(Collider other)
		{
			if (!(Time.unscaledTime < _nextAllowedTime))
			{
				TryForward(other, "OnTriggerStay");
			}
		}

		private void TryForward(Collider other, string callbackName)
		{
			_nextAllowedTime = Time.unscaledTime + 0.75f;
			Plugin instance = Plugin.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				instance.QueueDevIslandFromTrigger(other, callbackName);
			}
		}
	}
}