Decompiled source of ActuallyUsableShuttleboxes v1.0.0

plugins/CustomInteractAPI.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
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 AK;
using Agents;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CustomInteractAPI.Components;
using GTFO.API;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CustomInteractAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomInteractAPI")]
[assembly: AssemblyTitle("CustomInteractAPI")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[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 CustomInteractAPI
{
	[BepInPlugin("JarheadHME.CustomInteractAPI", "CustomInteractAPI", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _Harmony = null;

		public override void Load()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			Il2CppAPI.InjectWithInterface<Interact_Base>();
			Il2CppAPI.InjectWithInterface<Interact_Timed>();
			Il2CppAPI.InjectWithInterface<Interact_ManualTimedWithCallback>();
			ClassInjector.RegisterTypeInIl2Cpp<CustomInteractionManager>();
			_Harmony = new Harmony("CustomInteractAPI.Harmony");
			_Harmony.PatchAll();
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
			}
			Logger.Info(val);
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_Logger = new ManualLogSource("CustomInteractAPI");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "CustomInteractAPI";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = null;

		public const string SemVer = "1.0.0";

		public const string GitRevShort = null;

		public const string GitRevLong = null;

		public const string GitBranch = null;

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = false;
	}
}
namespace CustomInteractAPI.Patches
{
	[HarmonyPatch]
	internal class LocalPlayerAgent_Setup
	{
		[HarmonyPatch(typeof(LocalPlayerAgent), "Setup")]
		[HarmonyPostfix]
		public static void AddInteractManager(LocalPlayerAgent __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<CustomInteractionManager>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<CustomInteractionManager>().Agent = __instance;
			}
		}
	}
	[HarmonyPatch]
	internal class PlayerInteraction_Patches
	{
		[HarmonyPatch(typeof(PlayerInteraction), "UpdateWorldInteractions")]
		[HarmonyPrefix]
		public static bool UpdateWorldInteractions_Prefix()
		{
			return !CustomInteractionManager.HasInteract;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		public static void HasWorldInteraction_Prefix(ref bool __result)
		{
			if (!__result)
			{
				__result = CustomInteractionManager.HasInteract;
			}
		}
	}
}
namespace CustomInteractAPI.Components
{
	internal class CustomInteractionManager : MonoBehaviour
	{
		public LocalPlayerAgent Agent;

		public float RayCastDist = 1.35f;

		public static readonly int InteractionLayer = LayerMask.NameToLayer("Interaction");

		public static readonly int InteractionMask = LayerMask.GetMask(new string[1] { "Interaction" });

		public static readonly int InteractionBlockMask = LayerMask.GetMask(new string[4] { "Default", "Default_NoGraph", "Default_BlockGraph", "Dynamic" });

		private Interact_Base m_target;

		private Ray AgentRay => new Ray(((PlayerAgent)Agent).FPSCamera.Position, ((PlayerAgent)Agent).FPSCamera.Forward);

		public static bool HasInteract { get; private set; }

		public void FixedUpdate()
		{
			//IL_0002: 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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(AgentRay, ref val, RayCastDist, InteractionMask) && !((Object)(object)((RaycastHit)(ref val)).collider == (Object)null))
			{
				Interact_Base component = ((Component)((RaycastHit)(ref val)).collider).GetComponent<Interact_Base>();
				if (!((Object)(object)component == (Object)null) && !Physics.Linecast(((Agent)Agent).EyePosition, ((RaycastHit)(ref val)).point, InteractionBlockMask) && component.PlayerCanInteract((PlayerAgent)(object)Agent))
				{
					SelectInteract(component);
					return;
				}
			}
			UnselectInteract();
		}

		public void UnselectInteract()
		{
			if ((Object)(object)m_target != (Object)null)
			{
				m_target?.PlayerSetSelected(selected: false, (PlayerAgent)(object)Agent);
				m_target = null;
			}
			HasInteract = false;
		}

		[HideFromIl2Cpp]
		public void SelectInteract(Interact_Base target)
		{
			target.PlayerSetSelected(selected: true, (PlayerAgent)(object)Agent);
			m_target = target;
			HasInteract = true;
		}
	}
	public interface iInteractTarget
	{
		Transform Root { get; }

		bool PlayerCanInteract(PlayerAgent source);

		bool PlayerDoInteract(PlayerAgent source);

		void PlayerSetSelected(bool selected, PlayerAgent agent);

		bool PlayerCheckInput(PlayerAgent agent);
	}
	public class Interact_Base : MonoBehaviourExtended, iInteractTarget
	{
		private bool m_isActive = true;

		private bool m_isBlocked;

		public Collider m_colliderToOwn;

		public Action OnPickedUp;

		public virtual InputAction InputAction => (InputAction)6;

		public virtual bool ManualTriggeringOnly => false;

		public virtual bool OnlyActiveWhenLookingStraightAt { get; set; }

		public bool IsActive => m_isActive;

		public bool IsBlocked => m_isBlocked;

		public bool IsSelected { get; private set; }

		public Transform Root => ((Component)this).transform;

		public virtual void SetupFromItem(Item item)
		{
		}

		public virtual void SetActive(bool active)
		{
			m_isActive = active;
			((Behaviour)this).enabled = active;
			if ((Object)(object)m_colliderToOwn != (Object)null)
			{
				m_colliderToOwn.enabled = active;
			}
		}

		public void SetBlocked(bool state)
		{
			m_isBlocked = state;
		}

		public virtual bool PlayerCanInteract(PlayerAgent source)
		{
			return IsActive;
		}

		public virtual bool PlayerDoInteract(PlayerAgent source)
		{
			return false;
		}

		public virtual void PlayerSetSelected(bool selected, PlayerAgent agent)
		{
			bool flag = selected && !GuiManager.InteractionLayer.InteractPromptVisible;
			if (IsSelected != selected || flag)
			{
				OnSelectedChange(selected, agent, flag);
			}
			IsSelected = selected;
		}

		public virtual void OnSelectedChange(bool selected, PlayerAgent agent, bool forceUpdate = false)
		{
		}

		public virtual bool PlayerCheckInput(PlayerAgent agent)
		{
			//IL_0007: 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)
			return InputMapper.GetButtonDown.Invoke(InputAction, agent.InputFilter);
		}

		public virtual void OnProximityEnter(PlayerAgent agent)
		{
		}

		public virtual void OnProximityExit(PlayerAgent agent)
		{
		}

		public virtual void LocalPickup(PlayerAgent agent)
		{
		}

		public virtual void SyncedPickup(PlayerAgent agent)
		{
		}

		protected virtual void Update()
		{
		}
	}
	internal class Interact_ManualTimedWithCallback : Interact_Timed
	{
		private string m_desc;

		private InputAction m_input;

		public override bool ManualTriggeringOnly => true;

		public override InputAction InputAction => m_input;

		public Action OnTrigger { get; set; }

		public override void Start()
		{
			base.Start();
			SFXInteractStart = EVENTS.INTERACT_TOOL_START;
			SFXInteractCancel = EVENTS.INTERACT_TOOL_CANCEL;
			SFXInteractEnd = EVENTS.INTERACT_TOOL_FINISHED;
		}

		public void SetAction(string desc, InputAction input)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			InteractionMessage = desc;
			m_input = input;
		}

		public void ManualUpdateWithCondition(bool condition, PlayerAgent source, bool selectedOnIdle = false)
		{
			if (condition)
			{
				if (PlayerCheckInput(source))
				{
					PlayerDoInteract(source);
					PlayerSetSelected(selected: false, source);
				}
				else if (base.InteractionTimerRel > 0f && !base.IsSelected)
				{
					PlayerSetSelected(selected: true, source);
				}
				else if (base.InteractionTimerRel <= 0f && base.IsSelected != selectedOnIdle)
				{
					PlayerSetSelected(selectedOnIdle, source);
				}
			}
			else if (base.IsSelected)
			{
				PlayerSetSelected(selected: false, source);
			}
		}

		public override void TriggerInteractionAction(PlayerAgent source)
		{
			base.TriggerInteractionAction(source);
			if (OnTrigger != null)
			{
				OnTrigger();
			}
		}
	}
	public class Interact_Timed : Interact_Base
	{
		public class InteractorInfo
		{
			public PlayerAgent Agent;
		}

		private float m_interactDuration = 0.6f;

		public PlayerAgent m_interactTargetAgent;

		public bool m_timerIsActive;

		public bool m_UIState;

		public InteractorInfo m_localPlayerInteractInfo;

		public CellSoundPlayer m_sound;

		public List<InteractorInfo> m_interactors = new List<InteractorInfo>();

		public bool m_hasShownInteractionPrompt;

		public Vector3 m_triggerStartAgentWorldPos;

		public Vector3 m_triggerStartAgentLookDir;

		public float m_minCamDotAllowed = 0.5f;

		public float m_maxMoveDisAllowed = 2f;

		public float m_timerProgressRel;

		public virtual float InteractDuration
		{
			get
			{
				return m_interactDuration;
			}
			set
			{
				m_interactDuration = value;
			}
		}

		public virtual uint SFXInteractStart { get; set; } = EVENTS.REVIVELOOP;


		public virtual uint SFXInteractCancel { get; set; } = EVENTS.REVIVECANCEL;


		public virtual uint SFXInteractEnd { get; set; } = EVENTS.REVIVEEND;


		public virtual uint SFXInteractTrigger { get; set; }

		public float InteractionTimerRel => m_timerProgressRel;

		public virtual bool InternalAllowInput => true;

		public bool TimerIsActive => m_timerIsActive;

		public virtual string InteractionMessage { get; set; } = "Surprise";


		public bool AbortOnDotOrDistanceDiff { get; set; } = true;


		[HideFromIl2Cpp]
		public event Action OnInteractionEvaluationAbort;

		[HideFromIl2Cpp]
		public event Action<PlayerAgent> OnInteractionTriggered;

		[HideFromIl2Cpp]
		public event Action<PlayerAgent, bool> OnInteractionSelected;

		[HideFromIl2Cpp]
		public event Func<PlayerAgent, bool> ExternalPlayerCanInteract;

		[HideFromIl2Cpp]
		public event Func<string> OnAdditionalInteractionText;

		public virtual void Start()
		{
		}

		protected override void Update()
		{
			base.Update();
			float num = 0f;
			for (int i = 0; i < m_interactors.Count; i++)
			{
				num = ApplySpeedModifier(m_interactors[i].Agent, 1f);
			}
			if (num > 0f && m_timerProgressRel != 1f)
			{
				m_timerProgressRel += Time.deltaTime * num / InteractDuration;
				m_timerProgressRel = Mathf.Min(1f, m_timerProgressRel);
				OnTimerUpdate(m_timerProgressRel);
			}
		}

		public virtual void Setup(PlayerAgent owner)
		{
			m_interactTargetAgent = owner;
		}

		public virtual float ApplySpeedModifier(PlayerAgent sourceAgent, float dt)
		{
			return dt;
		}

		public virtual string GetAdditionalInteractionInfo()
		{
			if (this.OnAdditionalInteractionText != null)
			{
				return this.OnAdditionalInteractionText();
			}
			return string.Empty;
		}

		public override bool PlayerCanInteract(PlayerAgent source)
		{
			if (base.PlayerCanInteract(source))
			{
				return this.ExternalPlayerCanInteract?.Invoke(source) ?? true;
			}
			return false;
		}

		public override void OnSelectedChange(bool selected, PlayerAgent agent, bool forceUpdate = false)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if ((selected && !m_hasShownInteractionPrompt) || (!selected && m_hasShownInteractionPrompt) || forceUpdate)
			{
				GuiManager.InteractionLayer.InteractPromptVisible = selected;
			}
			if (selected)
			{
				string text = Text.Format(827u, (Object[])(object)new Object[1] { Object.op_Implicit(InputMapper.GetBindingName(InputAction)) });
				GuiManager.InteractionLayer.SetInteractPrompt(InteractionMessage + GetAdditionalInteractionInfo(), text, (ePUIMessageStyle)0);
			}
			m_hasShownInteractionPrompt = selected;
			TriggerOnInteractionSelectedCallback(agent, selected);
			if (!selected)
			{
				OnInteractorStateChanged(agent, state: false);
			}
		}

		public void TriggerOnInteractionSelectedCallback(PlayerAgent agent, bool selected)
		{
			this.OnInteractionSelected?.Invoke(agent, selected);
		}

		public override void SetActive(bool active)
		{
			if (m_timerIsActive)
			{
				SetTimerActive(active: false);
				SetUIState(state: false, fadeOut: false);
			}
			base.SetActive(active);
		}

		public override bool PlayerCheckInput(PlayerAgent agent)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			if (!InternalAllowInput)
			{
				OnInteractorStateChanged(agent, state: false);
				return false;
			}
			if (m_localPlayerInteractInfo == null)
			{
				if (InputMapper.GetButtonDown.Invoke(InputAction, agent.InputFilter))
				{
					OnInteractorStateChanged(agent, state: true);
				}
			}
			else if (InputMapper.GetButton.Invoke(InputAction, agent.InputFilter) && EvaluateTimedInteraction())
			{
				if (InteractionTimerRel == 1f)
				{
					OnInteractorCompleted(agent);
					return true;
				}
			}
			else
			{
				OnInteractorStateChanged(agent, state: false);
			}
			return false;
		}

		public override bool PlayerDoInteract(PlayerAgent source)
		{
			TriggerInteractionAction(source);
			return true;
		}

		public virtual bool EvaluateTimedInteraction()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (AbortOnDotOrDistanceDiff)
			{
				PlayerAgent agent = m_localPlayerInteractInfo.Agent;
				float num = Vector3.Dot(agent.FPSCamera.Forward, m_triggerStartAgentLookDir);
				Vector3 val = m_triggerStartAgentWorldPos - ((Agent)agent).Position;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (num < m_minCamDotAllowed || magnitude > m_maxMoveDisAllowed)
				{
					return false;
				}
			}
			return true;
		}

		public virtual void OnTimerUpdate(float timeRel)
		{
			GuiManager.InteractionLayer.SetTimer(timeRel);
		}

		public virtual void TriggerInteractionAction(PlayerAgent source)
		{
			CheckSoundPlayer();
			m_sound.Post(SFXInteractEnd, true);
			if (SFXInteractTrigger != 0)
			{
				m_sound.Post(SFXInteractTrigger, true);
			}
			if ((Object)(object)source == (Object)null)
			{
				source = PlayerManager.GetLocalPlayerAgent();
			}
			this.OnInteractionTriggered?.Invoke(source);
		}

		public void CheckSoundPlayer()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (m_sound == null)
			{
				m_sound = new CellSoundPlayer(((Component)this).transform.position);
			}
		}

		public virtual void SetTimerActive(bool active)
		{
			CheckSoundPlayer();
			if (active)
			{
				if (!m_timerIsActive)
				{
					m_sound.Post(SFXInteractStart, true);
					m_timerProgressRel = 0f;
				}
			}
			else if (m_timerIsActive)
			{
				m_sound.Post(SFXInteractCancel, true);
				m_timerProgressRel = 0f;
			}
			m_timerIsActive = active;
		}

		public virtual void SetUIState(bool state, bool fadeOut)
		{
			if (state)
			{
				if (NeedsUI())
				{
					m_UIState = true;
					GuiManager.InteractionLayer.SetTimer(m_timerProgressRel);
					GuiManager.InteractionLayer.TimerVisible = true;
					GuiManager.InteractionLayer.SetTimerAlphaMul(1f);
				}
			}
			else if (m_UIState && NeedsUI())
			{
				m_UIState = false;
				if (fadeOut)
				{
					float num = 0.1f;
					GuiManager.InteractionLayer.TimerFlash(num);
					((MonoBehaviourExtended)this).Callback(Action.op_Implicit((Action)HideTimer), num * 2f);
				}
				else
				{
					HideTimer();
				}
			}
		}

		public bool NeedsUI()
		{
			return ((Object)(object)m_interactTargetAgent != (Object)null && ((Agent)m_interactTargetAgent).IsLocallyOwned) || m_localPlayerInteractInfo != null;
		}

		public void HideTimer()
		{
			GuiManager.InteractionLayer.TimerVisible = false;
		}

		public void OnInteractorCompleted(PlayerAgent sourceAgent)
		{
			OnTimerUpdate(1f);
			SetTimerActive(active: false);
			SetUIState(state: false, fadeOut: true);
			OnInteractorStateChanged(sourceAgent, state: false);
		}

		public virtual void OnInteractorStateChanged(PlayerAgent sourceAgent, bool state)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			if (state)
			{
				for (int i = 0; i < m_interactors.Count; i++)
				{
					if ((Object)(object)m_interactors[i].Agent == (Object)(object)sourceAgent)
					{
						Logger.Error("[Interact_Timed.OnInteractorStateChanged] Double-registration of interactor!");
						return;
					}
				}
				InteractorInfo interactorInfo = new InteractorInfo
				{
					Agent = sourceAgent
				};
				m_interactors.Add(interactorInfo);
				if (((Agent)sourceAgent).IsLocallyOwned)
				{
					m_localPlayerInteractInfo = interactorInfo;
					m_triggerStartAgentWorldPos = ((Agent)sourceAgent).Position;
					m_triggerStartAgentLookDir = sourceAgent.FPSCamera.Forward;
				}
				SetTimerActive(active: true);
				SetUIState(state: true, fadeOut: false);
				return;
			}
			for (int j = 0; j < m_interactors.Count; j++)
			{
				if ((Object)(object)m_interactors[j].Agent == (Object)(object)sourceAgent)
				{
					if (m_interactors.Count == 1)
					{
						SetTimerActive(active: false);
					}
					if (m_interactors.Count == 1 || ((Agent)sourceAgent).IsLocallyOwned)
					{
						SetUIState(state: false, fadeOut: false);
					}
					m_interactors.RemoveAt(j);
					if (((Agent)sourceAgent).IsLocallyOwned)
					{
						m_localPlayerInteractInfo = null;
					}
					break;
				}
			}
		}
	}
}

plugins/ShuttleboxPlugin.dll

Decompiled 2 months ago
#define DEBUG
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.Json.Serialization;
using AIGraph;
using AK;
using Agents;
using AmorLib.Networking.StateReplicators;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CustomInteractAPI.Components;
using FluffyUnderware.DevTools.Extensions;
using GTFO.API;
using GTFO.API.Extensions;
using GTFO.API.JSON;
using GTFO.API.Utilities;
using GameData;
using Gear;
using Globals;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using ShuttleboxPlugin.Modules;
using ShuttleboxPlugin.Patches;
using ShuttleboxPlugin.Utils;
using TMPro;
using TerminalQueryAPI;
using TexturePainterAPI.PaintableTextures;
using UnityEngine;
using UnityEngine.UI;
using XXHashing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ShuttleboxPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+gitb597ab7-dirty-master.b597ab706ccc87785d1453de4a45d9912303a3ce")]
[assembly: AssemblyProduct("ShuttleboxPlugin")]
[assembly: AssemblyTitle("ShuttleboxPlugin")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[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;
		}
	}
}
namespace ShuttleboxPlugin
{
	public static class Assets
	{
		public static readonly string ShuttleboxPrefabPath;

		public static readonly GameObject ShuttleboxPrefab;

		public static readonly string ShuttleboxPaintableMainTexPath;

		public static readonly Texture2D ShuttleboxPaintableMainTex;

		public static readonly Material ShuttleboxSharedMaterial;

		public static readonly string ShuttleboxPaintableMaskPath;

		public static readonly Texture2D ShuttleboxPaintableMask;

		public static readonly string TerminalFloorPath;

		public static readonly TMP_FontAsset OxaniumFont;

		public static readonly Material OxaniumFontMaterial;

		static Assets()
		{
			ShuttleboxPrefabPath = "Assets/GameObject/ShuttleboxPlugin.prefab";
			ShuttleboxPrefab = null;
			ShuttleboxPaintableMainTexPath = "Assets/Texture2D/Shuttlebox_Base.png";
			ShuttleboxPaintableMainTex = null;
			ShuttleboxSharedMaterial = null;
			ShuttleboxPaintableMaskPath = "Assets/Texture2D/Shuttlebox_Mask.png";
			ShuttleboxPaintableMask = null;
			TerminalFloorPath = "ASSETS/ASSETPREFABS/COMPLEX/GENERIC/FUNCTIONMARKERS/TERMINAL_FLOOR.PREFAB";
			OxaniumFont = null;
			OxaniumFontMaterial = null;
			ShuttleboxPrefab = AssetAPI.GetLoadedAsset<GameObject>(ShuttleboxPrefabPath);
			ShuttleboxSharedMaterial = ((Component)ShuttleboxPrefab.transform.Find(Shuttlebox_Core.MainMeshPath).Find(Shuttlebox_Core.MainVisualMeshSubpath)).GetComponent<Renderer>().sharedMaterial;
			ShuttleboxPaintableMainTex = AssetAPI.GetLoadedAsset<Texture2D>(ShuttleboxPaintableMainTexPath);
			ShuttleboxPaintableMask = AssetAPI.GetLoadedAsset<Texture2D>(ShuttleboxPaintableMaskPath);
			GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>(TerminalFloorPath);
			TextMeshPro component = ((Component)loadedAsset.transform.Find("Serial")).GetComponent<TextMeshPro>();
			OxaniumFont = ((TMP_Text)component).font;
			OxaniumFontMaterial = ((TMP_Text)component).fontSharedMaterial;
		}
	}
	[BepInPlugin("JarheadHME.ShuttleboxPlugin", "ShuttleboxPlugin", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _Harmony = null;

		internal const string PartialData_GUID = "MTFO.Extension.PartialBlocks";

		internal const string TexturePainterAPI_GUID = "TexturePainterAPI";

		internal const string AmorLib_GUID = "Amor.AmorLib";

		public override void Load()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			_Harmony = new Harmony("ShuttleboxPlugin.Harmony");
			_Harmony.PatchAll();
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
			}
			Logger.Info(val);
			ClassInjector.RegisterTypeInIl2Cpp<Shuttlebox_Core>();
			ClassInjector.RegisterTypeInIl2Cpp<Shuttlebox_LightFader>();
			Il2CppAPI.InjectWithInterface<Shuttlebox_AnyItemInteract>();
			InsertTypeEnum.Init();
			NetworkAPI.RegisterEvent<pItemData>(NetworkEvents.DeregisterTerminalItemEvent, (Action<ulong, pItemData>)NetworkEvents.AttemptDeregisterTerminalItem);
			NetworkAPI.RegisterEvent<pItemData>(NetworkEvents.OverrideQueryEvent, (Action<ulong, pItemData>)NetworkEvents.OverrideItemQueryInformation);
			NetworkAPI.RegisterEvent<pItemData>(NetworkEvents.ResetOverriddenQueryEvent, (Action<ulong, pItemData>)NetworkEvents.ResetItemQueryOverride);
			GameDataAPI.OnGameDataInitialized += ShuttleboxPlacements.Init;
			LevelAPI.OnLevelCleanup += OnLevelCleanup;
			ElevatorPatch.OnStopElevator += OnStopElevator;
		}

		public static void OnLevelCleanup()
		{
			SpawnShuttleboxesPatch.ClearDistributedZones();
			Shuttlebox_Core.OnLevelCleanup();
			KeyItemTracker.ClearTrackedKeyIds();
		}

		public static void OnStopElevator()
		{
			KeyItemTracker.TrackAllKeysInLevel();
			Shuttlebox_Core.ActivateLights();
			Shuttlebox_Core.FinishSetupSummonItems();
			Shuttlebox_Core.CloseShuttleboxesAtStart();
			Shuttlebox_Core.FinishSetupAllItemDicts();
		}

		public override bool Unload()
		{
			_Harmony.UnpatchSelf();
			return ((BasePlugin)this).Unload();
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_Logger = new ManualLogSource("ShuttleboxPlugin");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "ShuttleboxPlugin";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = "gitb597ab7-dirty-master";

		public const string SemVer = "1.0.0+gitb597ab7-dirty-master";

		public const string GitRevShort = "b597ab7-dirty";

		public const string GitRevLong = "b597ab706ccc87785d1453de4a45d9912303a3ce-dirty";

		public const string GitBranch = "master";

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = true;
	}
}
namespace ShuttleboxPlugin.Utils
{
	internal static class Extensions
	{
		public static bool TryCastAtHome<T, O>(this T inclass, out O outclass) where T : Il2CppObjectBase where O : Il2CppObjectBase
		{
			outclass = ((Il2CppObjectBase)inclass).TryCast<O>();
			return outclass != null;
		}

		public static List<Transform> GetChildren(this Transform parent)
		{
			int childCount = parent.GetChildCount();
			List<Transform> list = new List<Transform>(childCount);
			for (int i = 0; i < childCount; i++)
			{
				list.Add(parent.GetChild(i));
			}
			return list;
		}
	}
	public static class NetworkEvents
	{
		public static readonly string DeregisterTerminalItemEvent = "JarheadHME.Shuttlebox.DeregisterHiddenTermItems";

		public static readonly string OverrideQueryEvent = "JarheadHME.Shuttlebox.SummonItemOverrideQuery";

		public static readonly string ResetOverriddenQueryEvent = "JarheadHME.Shuttlebox.SummonItemResetQuery";

		public static void RegisterAllEvents()
		{
			NetworkAPI.RegisterEvent<pItemData>(DeregisterTerminalItemEvent, (Action<ulong, pItemData>)AttemptDeregisterTerminalItem);
			NetworkAPI.RegisterEvent<pItemData>(OverrideQueryEvent, (Action<ulong, pItemData>)OverrideItemQueryInformation);
			NetworkAPI.RegisterEvent<pItemData>(ResetOverriddenQueryEvent, (Action<ulong, pItemData>)ResetItemQueryOverride);
		}

		public static void AttemptDeregisterTerminalItem(ulong sender, pItemData itemData)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Item val = default(Item);
			if (!GameStateManager.IsInExpedition)
			{
				Logger.Error("Trying to deregister an item when not in a level");
			}
			else if (PlayerBackpackManager.TryGetItemInLevelFromItemData(itemData, ref val))
			{
				iTerminalItem componentInChildren = ((Component)val).GetComponentInChildren<iTerminalItem>();
				if (componentInChildren != null)
				{
					LG_LevelInteractionManager.DeregisterTerminalItem(componentInChildren);
				}
			}
			else
			{
				Logger.Error("Tried to deregister terminal item, but didn't get item from pItemData");
			}
		}

		public static void OverrideItemQueryInformation(ulong sender, pItemData itemData)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_006b: 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_009a: Expected O, but got Unknown
			if (!GameStateManager.IsInExpedition)
			{
				Logger.Error("Trying to override item query when not in a level");
			}
			else
			{
				Item val = default(Item);
				if (PlayerBackpackManager.TryGetItemInLevelFromItemData(itemData, ref val))
				{
					iTerminalItem componentInChildren = ((Component)val).GetComponentInChildren<iTerminalItem>();
					if (componentInChildren == null)
					{
						return;
					}
					{
						foreach (Shuttlebox_Core s_setupShuttlebox in Shuttlebox_Core.s_setupShuttleboxes)
						{
							pItemData pItemData = ((Item)s_setupShuttlebox.ItemToSummon).Get_pItemData();
							if (((object)(pItemData)(ref pItemData)).Equals((object?)val.Get_pItemData()))
							{
								QueryableAPI.ModifyTempQueryableItem(componentInChildren, new QueryDelegate(s_setupShuttlebox.GetHiddenItemQueryInfo));
								if (!Shuttlebox_Core.PingOverrideItemKeys.Contains(componentInChildren.TerminalItemKey))
								{
									Shuttlebox_Core.PingOverrideItemKeys.Add(componentInChildren.TerminalItemKey);
								}
								break;
							}
						}
						return;
					}
				}
				Logger.Error("Tried to override item query, but didn't get item from pItemData");
			}
		}

		public static void ResetItemQueryOverride(ulong sender, pItemData itemData)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Item val = default(Item);
			if (!GameStateManager.IsInExpedition)
			{
				Logger.Error("Trying to reset overriden item query when not in a level");
			}
			else if (PlayerBackpackManager.TryGetItemInLevelFromItemData(itemData, ref val))
			{
				iTerminalItem componentInChildren = ((Component)val).GetComponentInChildren<iTerminalItem>();
				if (componentInChildren != null)
				{
					QueryableAPI.DeregisterTempQueryableItem(componentInChildren);
					Shuttlebox_Core.PingOverrideItemKeys.Remove(componentInChildren.TerminalItemKey);
				}
			}
			else
			{
				Logger.Error("Tried to reset overridden item query, but didn't get item from pItemData");
			}
		}
	}
	internal static class PDAPIWrapper
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		public static readonly bool HasPData;

		public static JsonConverter? PersistentIDConverter { get; private set; }

		static PDAPIWrapper()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			HasPData = false;
			PersistentIDConverter = null;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value))
			{
				return;
			}
			try
			{
				Assembly assembly = ((value == null) ? null : value.Instance?.GetType()?.Assembly);
				if ((object)assembly == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type[] types = assembly.GetTypes();
				Type type = types.First((Type t) => t.Name == "PersistentIDConverter");
				if ((object)type == null)
				{
					throw new Exception("Unable to Find PersistentIDConverter Class");
				}
				PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type);
				HasPData = true;
			}
			catch (Exception ex)
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(69, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Exception thrown while reading data from MTFO_Extension_PartialData:\n");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				Logger.Error(val);
			}
		}
	}
	internal class UnityColorHexConverter : JsonConverter<Color>
	{
		public override Color Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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)
			string @string = reader.GetString();
			return ColorExt.Hex(@string);
		}

		public override void Write(Utf8JsonWriter writer, Color value, JsonSerializerOptions options)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.WriteStringValue(ColorExt.ToHex(value));
		}
	}
}
namespace ShuttleboxPlugin.Patches
{
	[HarmonyPatch]
	internal class CarryItemPatch
	{
		private static eCarryItemInsertTargetType m_prevType;

		[HarmonyPatch(typeof(CarryItemEquippableFirstPerson), "OnWield")]
		[HarmonyPostfix]
		public static void OnWield(CarryItemEquippableFirstPerson __instance)
		{
			//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)
			m_prevType = __instance.m_insertCheckType;
		}

		[HarmonyPatch(typeof(CarryItemEquippableFirstPerson), "Update")]
		[HarmonyPostfix]
		public static void AllowInteractWithShuttlebox(CarryItemEquippableFirstPerson __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_007c: 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)
			if ((int)__instance.m_insertCheckType == 0)
			{
				PerformRaycast(__instance);
			}
			RaycastHit rayHit = __instance.m_rayHit;
			if ((Object)(object)((RaycastHit)(ref rayHit)).collider == (Object)null)
			{
				__instance.m_insertCheckType = m_prevType;
				return;
			}
			rayHit = __instance.m_rayHit;
			iCarryItemInteractionTarget componentInParent = ((Component)((RaycastHit)(ref rayHit)).collider).GetComponentInParent<iCarryItemInteractionTarget>();
			if (componentInParent == null || componentInParent.InsertType != InsertTypeEnum.value)
			{
				__instance.m_insertCheckType = m_prevType;
			}
			else
			{
				__instance.m_insertCheckType = InsertTypeEnum.value;
			}
		}

		public static void PerformRaycast(CarryItemEquippableFirstPerson __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			if (!((Object)(object)((Item)__instance).Owner == (Object)null))
			{
				RaycastHit rayHit = default(RaycastHit);
				Physics.Raycast(((Item)__instance).Owner.FPSCamera.Position, ((Item)__instance).Owner.FPSCamera.Forward, ref rayHit, 2.4f, LayerManager.MASK_APPLY_CARRY_ITEM);
				__instance.m_rayHit = rayHit;
			}
		}
	}
	[HarmonyPatch]
	internal class ElevatorPatch
	{
		public static event Action OnStopElevator;

		[HarmonyPatch(typeof(GS_StopElevatorRide), "Enter")]
		[HarmonyPostfix]
		public static void OnStopElevatorAPI()
		{
			ElevatorPatch.OnStopElevator?.Invoke();
		}
	}
	[HarmonyPatch]
	public class ItemPickupPatches
	{
		[HarmonyPatch(typeof(ConsumablePickup_Core), "OnSyncStateChange")]
		internal class ConsumablePatches
		{
			public static void Prefix(out (ItemInLevel, Shuttlebox_Core) __state, ConsumablePickup_Core __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				ItemInLevel _instance = ((Il2CppObjectBase)__instance).TryCast<ItemInLevel>();
				TryGetItemAndShuttlebox(out __state, _instance, status, player);
			}

			public static void Postfix((ItemInLevel, Shuttlebox_Core) __state, ConsumablePickup_Core __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
			{
				AttemptSwapIntoShuttlebox(__state);
			}
		}

		[HarmonyPatch(typeof(ResourcePackPickup), "OnSyncStateChange")]
		internal class ResourcePackPatches
		{
			public static void Prefix(out (ItemInLevel, Shuttlebox_Core) __state, ResourcePackPickup __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				ItemInLevel _instance = ((Il2CppObjectBase)__instance).TryCast<ItemInLevel>();
				TryGetItemAndShuttlebox(out __state, _instance, status, player);
			}

			public static void Postfix((ItemInLevel, Shuttlebox_Core) __state, ResourcePackPickup __instance, ePickupItemStatus status, pPickupPlacement placement, PlayerAgent player, bool isRecall)
			{
				AttemptSwapIntoShuttlebox(__state);
			}
		}

		public static void TryGetItemAndShuttlebox(out (ItemInLevel, Shuttlebox_Core) __state, ItemInLevel __instance, ePickupItemStatus status, PlayerAgent player)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//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)
			//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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			__state = (null, null);
			if (!SNet.IsMaster || (Object)(object)__instance == (Object)null || (int)status != 1)
			{
				return;
			}
			pItemData pItemData = ((Item)__instance).Get_pItemData();
			bool flag = default(bool);
			BackpackItem val2 = default(BackpackItem);
			foreach (Shuttlebox_Core s_setupShuttlebox in Shuttlebox_Core.s_setupShuttleboxes)
			{
				if (!s_setupShuttlebox.HasItem)
				{
					continue;
				}
				pItemData pItemData2 = ((Item)s_setupShuttlebox.ItemInside).Get_pItemData();
				if (!((object)(pItemData)(ref pItemData2)).Equals((object?)pItemData))
				{
					continue;
				}
				if ((Object)(object)player == (Object)null)
				{
					Logger.Error("Item from shuttlebox getting picked up but no playeragent?");
					break;
				}
				PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(player.Owner);
				if (backpack == null)
				{
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Player ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(player.Owner.NickName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" doesn't have a backpack??????");
					}
					Logger.Error(val);
					break;
				}
				if (!backpack.TryGetBackpackItem(pItemData.slot, ref val2))
				{
					continue;
				}
				ItemInLevel iteminlevel = null;
				if (!Shuttlebox_Core.TryGetItemInLevelFromData(val2.Instance.Get_pItemData(), out iteminlevel))
				{
					Logger.Error("No ItemInLevel from backpack item ._.");
					break;
				}
				__state = (iteminlevel, s_setupShuttlebox);
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(14, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Dropping ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Item)iteminlevel).PublicName);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" for ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Item)__instance).PublicName);
				}
				Logger.Info(val3);
				break;
			}
		}

		public static void AttemptSwapIntoShuttlebox((ItemInLevel, Shuttlebox_Core) __state)
		{
			if (SNet.IsMaster)
			{
				var (val, shuttlebox_Core) = __state;
				if (!((Object)(object)val == (Object)null) && !((Object)(object)shuttlebox_Core == (Object)null))
				{
					shuttlebox_Core.AttemptInteract(eShuttleboxInteractionType.SwapIn, null, ((Item)val).GetItem());
				}
			}
		}
	}
	[HarmonyPatch]
	internal class SpawnShuttleboxesPatch
	{
		private static ExpeditionFunction TargetFunction = (ExpeditionFunction)3;

		public static List<int> DistributedZones = new List<int>();

		public static Dictionary<string, string> DecorationLookup = new Dictionary<string, string>
		{
			{ "StraightShort", "Shuttlebox_Variant_01_Straight_Short" },
			{ "TurnShort", "Shuttlebox_Variant_02_Turn_Short" },
			{ "StraightLong", "Shuttlebox_Variant_03_Straight_Long" },
			{ "TurnLong", "Shuttlebox_Variant_04_Turn_Long" },
			{ "DoubleTurnRight", "Shuttlebox_Variant_05_DoubleTurn_Right" },
			{ "DoubleTurnLeft", "Shuttlebox_Variant_06_DoubleTurn_Left" },
			{ "Backward", "Shuttlebox_Variant_07_Backward" },
			{ "Angled", "Shuttlebox_Variant_08_Angled" },
			{ "Base", "Shuttlebox_Variant_09_Base" }
		};

		public static string DecorationRootPath = "Decorations/Shuttlebox_Decor_Variants";

		public static void ClearDistributedZones()
		{
			DistributedZones.Clear();
		}

		[HarmonyPatch(typeof(LG_PopulateFunctionMarkersInZoneJob), "Build")]
		[HarmonyPostfix]
		public static void PlaceShuttleboxes(LG_PopulateFunctionMarkersInZoneJob __instance, bool __result)
		{
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Expected O, but got Unknown
			//IL_04a4: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0079: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			if (!__result)
			{
				return;
			}
			LG_Zone zone = __instance.m_zone;
			if (DistributedZones.Contains(((Object)zone).GetInstanceID()))
			{
				return;
			}
			uint levelLayoutData = Builder.LevelGenExpedition.LevelLayoutData;
			if (!ShuttleboxPlacements.ShuttleboxesToPlace.TryGetValue(levelLayoutData, out var value))
			{
				return;
			}
			eDimensionIndex dimensionIndex = zone.DimensionIndex;
			LG_LayerType type = zone.m_layer.m_type;
			eLocalZoneIndex localIndex = zone.LocalIndex;
			GlobalZoneIndex val = default(GlobalZoneIndex);
			((GlobalZoneIndex)(ref val))..ctor(dimensionIndex, type, localIndex);
			List<ShuttleboxPlacementData> list = new List<ShuttleboxPlacementData>();
			foreach (ShuttleboxPlacementData item in value)
			{
				GlobalZoneIndex globalZoneIndex = item.GlobalZoneIndex;
				if (((object)(GlobalZoneIndex)(ref globalZoneIndex)).Equals((object?)val))
				{
					list.Add(item);
				}
			}
			bool flag = default(bool);
			try
			{
				XXHashSeed val4 = default(XXHashSeed);
				AIG_CourseNode val5 = default(AIG_CourseNode);
				LG_MarkerSpawner val10 = default(LG_MarkerSpawner);
				string text = default(string);
				for (int i = 0; i < list.Count; i++)
				{
					ShuttleboxPlacementData shuttleboxPlacementData = list[i];
					DumbwaiterPlacementData zonePlacement = shuttleboxPlacementData.ZonePlacement;
					GameObject val2 = null;
					LG_Area val3 = null;
					if (!shuttleboxPlacementData.AbsolutePosition)
					{
						XXHashSeed seed = __instance.m_rnd.Seed;
						((XXHashSeed)(ref val4))..ctor(((XXHashSeed)(ref seed)).SubSeed((uint)i, (uint)zonePlacement.AreaSeedOffset), true);
						if (!LG_DistributionJobUtils.TryGetWeightedNodeFromZone(zone, ((XXHashSeed)(ref val4)).Float(1u), zonePlacement.PlacementWeights, ref val5, false, ""))
						{
							BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Didn't get any course node for shuttlebox ");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(shuttleboxPlacementData.DebugName);
							}
							Logger.Error(val6);
							continue;
						}
						if (val5 == null)
						{
							BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(51, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Didn't find m_sourceNode for Shuttlebox '");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(shuttleboxPlacementData.DebugName);
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("' in zone ");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<GlobalZoneIndex>(val);
							}
							Logger.Error(val6);
							continue;
						}
						((XXHashSeed)(ref val4))..ctor(((XXHashSeed)(ref val4)).SubSeed((uint)zonePlacement.MarkerSeedOffset), true);
						val3 = val5.m_area;
						bool flag2 = false;
						List<MarkerComposition> val7 = new List<MarkerComposition>();
						val7.Add(new MarkerComposition
						{
							prefab = Assets.ShuttleboxPrefabPath
						});
						LG_FunctionMarkerBuilder val8 = new LG_FunctionMarkerBuilder(val5, TargetFunction, false, 0, (LG_Gate)null, (List<TerminalLogFileData>)null, (TerminalStartStateData)null, (TerminalPlacementData)null);
						LG_DistributeItem val9 = new LG_DistributeItem(TargetFunction, 1f, val5, (LG_Gate)null);
						val9.m_markerSeedOffset = zonePlacement.MarkerSeedOffset;
						__instance.TriggerFunctionBuilder(val8, val9, ref val10, false);
						ObjectExt.Destroy((Object)(object)val10.m_spawnedGO);
						val2 = val10.PickAndSpawnRandomPrefab(val7, 1f, 0f, ((Component)val10.m_producerSource).transform, TargetFunction, ref flag2, ref text);
					}
					else
					{
						int areaSeedOffset = shuttleboxPlacementData.ZonePlacement.AreaSeedOffset;
						if (areaSeedOffset >= zone.m_areas.Count)
						{
							BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(78, 4, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Chosen area for shuttlebox ");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(shuttleboxPlacementData.DebugName);
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" (Area ");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(((Il2CppArrayBase<string>)(object)LG_Area.m_areaChars)[areaSeedOffset % ((Il2CppArrayBase<string>)(object)LG_Area.m_areaChars).Length].ToUpper());
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" (AreaSeedOffset is value ");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<int>(areaSeedOffset);
								((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(")) is not in zone ");
								((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<GlobalZoneIndex>(val);
							}
							Logger.Error(val6);
							continue;
						}
						val3 = zone.m_areas[shuttleboxPlacementData.ZonePlacement.AreaSeedOffset];
						val2 = Object.Instantiate<GameObject>(Assets.ShuttleboxPrefab, ((Component)val3).transform);
					}
					if ((Object)(object)val2 != (Object)null)
					{
						Logger.DebugOnly("Successfully spawned shuttlebox '" + shuttleboxPlacementData.DebugName + "'");
						if (shuttleboxPlacementData.AbsolutePosition)
						{
							val2.transform.SetPositionAndRotation(shuttleboxPlacementData.Position, Quaternion.Euler(shuttleboxPlacementData.Rotation));
						}
						else
						{
							val2.transform.localPosition = shuttleboxPlacementData.Position;
							val2.transform.localRotation = Quaternion.Euler(shuttleboxPlacementData.Rotation);
						}
						SetupShuttlebox(val2, val3, shuttleboxPlacementData);
					}
					else
					{
						Logger.Error("Spawned shuttlebox was null???");
					}
				}
			}
			catch (Exception ex)
			{
				BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(54, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Exception occured while adding shuttleboxes to zone ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<GlobalZoneIndex>(val);
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(":\n");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
				}
				Logger.Error(val6);
			}
			DistributedZones.Add(((Object)zone).GetInstanceID());
		}

		public static void SetupShuttlebox(GameObject shuttlebox, LG_Area area, ShuttleboxPlacementData shuttleboxData)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			Transform transform = shuttlebox.transform;
			Transform val = transform.Find(DecorationRootPath);
			bool flag = default(bool);
			foreach (KeyValuePair<string, bool> decoration in shuttleboxData.Decorations)
			{
				if (!decoration.Value)
				{
					continue;
				}
				if (DecorationLookup.TryGetValue(decoration.Key, out var value))
				{
					((Component)val.Find(value)).gameObject.SetActive(true);
					continue;
				}
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Undefined decoration type: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(decoration.Key);
				}
				Logger.Error(val2);
			}
			Shuttlebox_Core shuttlebox_Core = shuttlebox.AddComponent<Shuttlebox_Core>();
			shuttlebox_Core.Setup(area, shuttleboxData);
		}
	}
	[HarmonyPatch]
	internal class TerminalPing_Patch
	{
		[HarmonyPatch(typeof(LG_TERM_Ping), "Setup")]
		[HarmonyPrefix]
		public static void CancelIsInSameZone(iTerminalItem target, string itemKey, string currentZoneName, bool repeatedPing, ref bool inSameZone)
		{
			if (Shuttlebox_Core.PingOverrideItemKeys.Contains(itemKey))
			{
				inSameZone = false;
			}
		}
	}
}
namespace ShuttleboxPlugin.Modules
{
	public static class InsertTypeEnum
	{
		public static readonly eCarryItemInsertTargetType value;

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void Init()
		{
		}

		static InsertTypeEnum()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			int valueLength = EnumUtil.GetValueLength<eCarryItemInsertTargetType>();
			EnumInjector.InjectEnumValues<eCarryItemInsertTargetType>(new Dictionary<string, object> { { "ShuttleboxTransfer", valueLength } });
			value = (eCarryItemInsertTargetType)valueLength;
		}
	}
	public class KeyItemTracker
	{
		public static List<uint> KeyIdsInLevel = new List<uint>();

		public static void TrackAllKeysInLevel()
		{
			Enumerator<IProgressionObjective> enumerator = ProgressionObjectivesManager.Current.m_allProgressionObjectives.GetEnumerator();
			while (enumerator.MoveNext())
			{
				IProgressionObjective current = enumerator.Current;
				ProgressionObjective_KeyCard val = ((Il2CppObjectBase)current).TryCast<ProgressionObjective_KeyCard>();
				if (val != null)
				{
					KeyIdsInLevel.Add(val.KeyItem.DataBlockID);
				}
			}
		}

		public static void ClearTrackedKeyIds()
		{
			KeyIdsInLevel.Clear();
		}
	}
	public class ShuttleboxDTO
	{
		public uint MainLevelLayoutID { get; set; }

		public List<ShuttleboxPlacementData> Shuttleboxes { get; set; }
	}
	public class ShuttleboxPlacementData
	{
		public string DebugName { get; set; } = "Unnamed";


		public DumbwaiterPlacementData ZonePlacement { get; set; } = new DumbwaiterPlacementData();


		public eDimensionIndex DimensionIndex { get; set; } = (eDimensionIndex)0;


		public LG_LayerType Layer { get; set; } = (LG_LayerType)0;


		public eLocalZoneIndex LocalIndex { get; set; } = (eLocalZoneIndex)0;


		public bool AbsolutePosition { get; set; } = false;


		public Vector3 Position { get; set; } = Vector3.zero;


		public Vector3 Rotation { get; set; } = Vector3.zero;


		public Dictionary<string, bool> Decorations { get; set; } = new Dictionary<string, bool>();


		public ShuttleboxColorData Colors { get; set; } = new ShuttleboxColorData
		{
			MainColor = default(Color),
			AccentColor = default(Color),
			SerialColor = Color.white
		};


		public int LinkID { get; set; } = -1;


		public bool IsClosedAtStart { get; set; } = false;


		public List<ShuttleboxItemsData> ValidInsertItems { get; set; } = new List<ShuttleboxItemsData>();


		public ShuttleboxSpawnedItemData SpawnedItem { get; set; } = new ShuttleboxSpawnedItemData();


		public GlobalZoneIndex GlobalZoneIndex => new GlobalZoneIndex(DimensionIndex, Layer, LocalIndex);
	}
	public class ShuttleboxItemsData
	{
		public uint ItemID { get; set; } = 0u;


		public eShuttleboxAction ActionOnInsert { get; set; } = eShuttleboxAction.None;


		public List<WardenObjectiveEventData> Events { get; set; } = new List<WardenObjectiveEventData>();

	}
	public class ShuttleboxSpawnedItemData
	{
		public uint ItemID { get; set; } = 0u;


		public bool IsAvailableAtStart { get; set; } = false;


		public bool IsWardenObjective { get; set; } = false;


		public int ChainedObjectiveIndex { get; set; } = 0;


		public bool ShowOnTerminalList { get; set; } = false;


		public uint Uses { get; set; } = 0u;

	}
	public class ShuttleboxColorData
	{
		public Color MainColor { get; set; } = default(Color);


		public Color AccentColor { get; set; } = default(Color);


		public Color SerialColor { get; set; } = Color.white;

	}
	public static class ShuttleboxPlacements
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static LiveEditEventHandler <0>__OnLiveEditUpdate;

			public static Action<string> <1>__LoadShuttleboxes;
		}

		public static Dictionary<uint, List<ShuttleboxPlacementData>> ShuttleboxesToPlace;

		public const string CustomFolderName = "ShuttleboxData";

		public static string PlacementsPath;

		public static bool HasSetUpLiveEdit;

		public static readonly JsonSerializerOptions JsonSettings;

		public static string TemplateText;

		static ShuttleboxPlacements()
		{
			ShuttleboxesToPlace = new Dictionary<uint, List<ShuttleboxPlacementData>>();
			PlacementsPath = string.Empty;
			HasSetUpLiveEdit = false;
			JsonSettings = new JsonSerializerOptions
			{
				ReadCommentHandling = JsonCommentHandling.Skip,
				PropertyNameCaseInsensitive = true,
				AllowTrailingCommas = true
			};
			TemplateText = "[\n  {\n    \"MainLevelLayoutID\": 0, // LevelLayoutDatablock ID\n    \"Shuttleboxes\": [\n      {\n        \"DebugName\": \"NameOfShuttlebox\",\n\n        \"ZonePlacement\": { // DumbwaiterPlacementData\n          \"PlacementWeights\": { // ZonePlacementWeights\n            \"Start\": 0.0,\n            \"Middle\": 0.0,\n            \"End\": 0.0\n          },\n          \"AreaSeedOffset\": 0,\n          \"MarkerSeedOffset\": 0\n        },\n\n        \"DimensionIndex\": \"Reality\", // eDimensionIndex\n        \"Layer\": \"MainLayer\", // LG_LayerType\n        \"LocalIndex\": 0, // eLocalZoneIndex\n\n        \"AbsolutePosition\": false,\n        \"Position\": { // Vector3\n          \"x\": 0.0,\n          \"y\": 0.0,\n          \"z\": 0.0\n        },\n        \"Rotation\": { // Vector3\n          \"x\": 0.0,\n          \"y\": 0.0,\n          \"z\": 0.0\n        },\n\n        \"Decorations\": { // Dictionary\n          \"StraightShort\": false,\n          \"TurnShort\": false,\n          \"StraightLong\": false,\n          \"TurnLong\": false,\n          \"DoubleTurnRight\": false,\n          \"DoubleTurnLeft\": false,\n          \"Backward\": false,\n          \"Angled\": false,\n          \"Base\": false\n        },\n        \"Colors\": {\n          \"MainColor\": { // Color\n            \"r\": 0.5,\n            \"g\": 1.0,\n            \"b\": 0.0,\n            \"a\": 0.8\n          },\n          \"AccentColor\": \"#FFFF\", // Color\n          \"SerialColor\": \"#FFFFFF\" // Color\n        },\n\n        \"LinkID\": -1,\n        \"IsClosedAtStart\": false,\n\n        \"ValidInsertItems\": [\n          {\n            \"ItemID\": 0, // ItemDataBlock ID\n            \"ActionOnInsert\": \"None\", // enum - `0 = \"None\", 1 = \"Transfer\", 2 = \"Consume\", 3 = \"ConsumeAndRemainClosed\"`\n            \"Events\": [ // \n              {\n                \"Type\": 0,\n                \"Trigger\": \"OnStart\" // What fill this with is important, see \"Event Triggers\" section\n              }\n            ]\n          }\n        ],\n\n        \"SpawnedItem\": {\n          \"ItemID\": 0, // ItemDataBlock ID\n          \"IsAvailableAtStart\": false,\n          \"IsWardenObject\": false,\n          \"ChainedObjectiveIndex\": 0,\n          \"ShowOnTerminalList\": false,\n          \"Uses\": 0\n        }\n      }\n    ]\n  }\n]";
			JsonSettings.Converters.Clear();
			foreach (JsonConverter converter in JsonSerializer.DefaultSerializerSettingsWithLocalizedText.Converters)
			{
				JsonSettings.Converters.Add(converter);
			}
			JsonSettings.Converters.Add(new UnityColorHexConverter());
			if (PDAPIWrapper.HasPData)
			{
				JsonSettings.Converters.Add(PDAPIWrapper.PersistentIDConverter);
			}
		}

		public static void Init()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			if (!MTFOPathAPI.HasCustomPath)
			{
				Logger.Warn("No custom path, not trying to load shuttlebox data");
				return;
			}
			PlacementsPath = Path.Join(MTFOPathAPI.CustomPath, "ShuttleboxData");
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Initializing path '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(PlacementsPath);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
			}
			Logger.Info(val);
			if (!Directory.Exists(PlacementsPath))
			{
				Directory.CreateDirectory(PlacementsPath);
				CreateTemplate(PlacementsPath);
			}
			ClearDict();
			string[] files = Directory.GetFiles(PlacementsPath, "*.json");
			string[] array = files;
			foreach (string path in array)
			{
				string json = File.ReadAllText(path);
				LoadShuttleboxes(json);
			}
			if (!HasSetUpLiveEdit)
			{
				LiveEditListener val2 = LiveEdit.CreateListener(PlacementsPath, "*.json", true);
				val2.FileChangedEventCooldown = 1.5f;
				object obj = <>O.<0>__OnLiveEditUpdate;
				if (obj == null)
				{
					LiveEditEventHandler val3 = OnLiveEditUpdate;
					<>O.<0>__OnLiveEditUpdate = val3;
					obj = (object)val3;
				}
				val2.FileChanged += (LiveEditEventHandler)obj;
				HasSetUpLiveEdit = true;
			}
		}

		public static void CreateTemplate(string path)
		{
			string path2 = Path.Combine(path, "template.json");
			if (!File.Exists(path2))
			{
				File.WriteAllText(path2, TemplateText);
			}
		}

		public static void ClearDict()
		{
			foreach (List<ShuttleboxPlacementData> value in ShuttleboxesToPlace.Values)
			{
				value.Clear();
			}
			ShuttleboxesToPlace.Clear();
		}

		public static void OnLiveEditUpdate(LiveEditEventArgs e)
		{
			Logger.Info("LiveEdit File Changed");
			LiveEditInit();
		}

		public static void LiveEditInit()
		{
			ClearDict();
			string[] files = Directory.GetFiles(PlacementsPath, "*.json");
			string[] array = files;
			foreach (string text in array)
			{
				LiveEdit.TryReadFileContent(text, (Action<string>)LoadShuttleboxes);
			}
		}

		public static void LoadShuttleboxes(string json)
		{
			List<ShuttleboxDTO> list = JsonSerializer.Deserialize<List<ShuttleboxDTO>>(json, JsonSettings);
			foreach (ShuttleboxDTO item in list)
			{
				if (!ShuttleboxesToPlace.TryGetValue(item.MainLevelLayoutID, out var value))
				{
					value = new List<ShuttleboxPlacementData>();
					ShuttleboxesToPlace.Add(item.MainLevelLayoutID, value);
				}
				value.AddRange(item.Shuttleboxes);
				if (GameStateManager.IsInExpedition && RundownManager.Current.m_activeExpedition.LevelLayoutData == item.MainLevelLayoutID)
				{
					DoInLevelLiveEdit(item.Shuttleboxes);
				}
			}
		}

		public static void DoInLevelLiveEdit(List<ShuttleboxPlacementData> shuttleboxes)
		{
			//IL_0052: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			foreach (ShuttleboxPlacementData shuttlebox in shuttleboxes)
			{
				foreach (Shuttlebox_Core s_setupShuttlebox in Shuttlebox_Core.s_setupShuttleboxes)
				{
					if (s_setupShuttlebox.DebugName.Equals(shuttlebox.DebugName))
					{
						s_setupShuttlebox.TryChangeShuttleboxColor(shuttlebox.Colors.MainColor, shuttlebox.Colors.AccentColor);
						if (shuttlebox.AbsolutePosition)
						{
							((Component)s_setupShuttlebox).transform.position = shuttlebox.Position;
							((Component)s_setupShuttlebox).transform.rotation = Quaternion.Euler(shuttlebox.Rotation);
						}
						else
						{
							((Component)s_setupShuttlebox).transform.localPosition = shuttlebox.Position;
							((Component)s_setupShuttlebox).transform.localRotation = Quaternion.Euler(shuttlebox.Rotation);
						}
						break;
					}
				}
			}
		}
	}
	internal class Shuttlebox_AnyItemInteract : Interact_Timed
	{
		public uint InsertTextID = 865u;

		private static InputAction m_upAction = (InputAction)15;

		private static InputAction m_downAction = (InputAction)16;

		private Item m_lastItem = null;

		private bool m_pocketItemMode;

		private uint m_pocketSlotIndex = 0u;

		private bool m_pocketHasMoreThanOne = false;

		public Action<PlayerAgent> OnInteractionTriggered_action;

		public override string InteractionMessage { get; set; }

		[HideFromIl2Cpp]
		public event Action<SNet_Player, Item> AttemptInsertIntoShuttlebox;

		public void Awake()
		{
			OnInteractionTriggered_action = OnInteractTriggered;
			((Interact_Timed)this).OnInteractionTriggered += OnInteractionTriggered_action;
		}

		protected override void Update()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			((Interact_Timed)this).Update();
			if (!((Interact_Base)this).IsSelected)
			{
				return;
			}
			if ((Object)(object)base.m_interactTargetAgent != (Object)null && ((Interact_Timed)this).PlayerCheckInput(base.m_interactTargetAgent))
			{
				((Interact_Base)this).PlayerDoInteract(base.m_interactTargetAgent);
			}
			if (m_pocketItemMode)
			{
				if (InputMapper.GetButtonDown.Invoke(m_downAction, (eFocusState)0))
				{
					m_pocketSlotIndex++;
				}
				if (InputMapper.GetButtonDown.Invoke(m_upAction, (eFocusState)0))
				{
					m_pocketSlotIndex--;
				}
			}
		}

		public static string GetPocketUseMessage(bool multipleItems = true)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			text += Text.Format(827u, (Object[])(object)new Object[1] { Object.op_Implicit(InputMapper.GetBindingName((InputAction)6)) });
			if (multipleItems)
			{
				text += $"\nPress {InputMapper.GetBindingName(m_upAction)} or {InputMapper.GetBindingName(m_downAction)}\nto change selected item.";
			}
			return text;
		}

		public override void PlayerSetSelected(bool selected, PlayerAgent agent)
		{
			((Interact_Base)this).PlayerSetSelected(selected, agent);
			base.m_interactTargetAgent = (selected ? agent : null);
			((Interact_Timed)this).OnTimerUpdate(0f);
			if (m_pocketItemMode)
			{
				GuiManager.InteractionLayer.SetInteractPrompt(((Interact_Timed)this).InteractionMessage, GetPocketUseMessage(m_pocketHasMoreThanOne), (ePUIMessageStyle)0);
			}
		}

		public override bool PlayerCanInteract(PlayerAgent source)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			if (!((Interact_Timed)this).PlayerCanInteract(source))
			{
				return false;
			}
			InventorySlot wieldedSlot = source.Inventory.WieldedSlot;
			if ((int)wieldedSlot == 6 || (int)wieldedSlot == 8)
			{
				return false;
			}
			if (PlayerHasItemToSend(source, out var item))
			{
				((Interact_Timed)this).InteractionMessage = Text.Format(InsertTextID, (Object[])(object)new Object[1] { Object.op_Implicit(item.PublicName) });
				Item lastItem = m_lastItem;
				m_lastItem = item;
				if ((Object)(object)lastItem != (Object)null && !lastItem.PublicName.Equals(m_lastItem.PublicName))
				{
					((Interact_Base)this).OnSelectedChange(false, source, true);
				}
				return true;
			}
			return false;
		}

		public bool PlayerHasItemToSend(PlayerAgent player, out Item item)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_00f7: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			item = null;
			if ((int)player.Inventory.WieldedSlot == 5 || (int)player.Inventory.WieldedSlot == 4)
			{
				item = (Item)(object)player.Inventory.WieldedItem;
				m_pocketItemMode = false;
				return true;
			}
			PlayerBackpack backpack = PlayerBackpackManager.GetBackpack(player.Owner);
			List<uint> list = new List<uint>();
			Enumerator<uint, List<PocketItem>> enumerator = backpack.ItemIDToPocketItemGroup.GetEnumerator();
			while (enumerator.MoveNext())
			{
				KeyValuePair<uint, List<PocketItem>> current = enumerator.Current;
				if (current.Value.Count > 0)
				{
					list.Add(current.Key);
				}
			}
			if (list.Count == 0)
			{
				return false;
			}
			int num = (int)m_pocketSlotIndex % list.Count;
			num = ((num < 0) ? (num + list.Count) : num);
			uint num2 = list[num];
			PocketItem val = backpack.ItemIDToPocketItemGroup[num2][0];
			pItemData val2 = default(pItemData);
			val2.itemID_gearCRC = num2;
			val2.slot = (InventorySlot)7;
			val2.replicatorRef = val.replicatorRef;
			if (PlayerBackpackManager.TryGetItemInLevelFromItemData(val2, ref item))
			{
				m_pocketItemMode = true;
				m_pocketHasMoreThanOne = list.Count > 1;
				return true;
			}
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to get pocket item from pocket: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(num2);
			}
			Logger.Error(val3);
			return false;
		}

		public void OnInteractTriggered(PlayerAgent agent)
		{
			this.AttemptInsertIntoShuttlebox?.Invoke(agent.Owner, m_lastItem);
		}
	}
	public class Shuttlebox_Core : MonoBehaviour
	{
		public delegate bool IsInValidStateForInteractDelegate(Shuttlebox_Core shuttlebox, eShuttleboxInteractionType type);

		public Dictionary<eShuttleboxLightState, Color> LightStateToColor = new Dictionary<eShuttleboxLightState, Color>
		{
			{
				eShuttleboxLightState.ShutOff,
				Color.black
			},
			{
				eShuttleboxLightState.Ready,
				new Color(0f, 0.32f, 0.32f)
			},
			{
				eShuttleboxLightState.Working,
				new Color(0.08f, 0.3f, 0.08f)
			},
			{
				eShuttleboxLightState.Queued,
				new Color(0.36f, 0.32f, 0.12f)
			},
			{
				eShuttleboxLightState.InvalidItem,
				new Color(0.36f, 0.09f, 0.09f)
			}
		};

		public Dictionary<eShuttleboxInteractionType, bool> QueueStates = new Dictionary<eShuttleboxInteractionType, bool>
		{
			{
				eShuttleboxInteractionType.SwapIn,
				false
			},
			{
				eShuttleboxInteractionType.Transfer,
				false
			},
			{
				eShuttleboxInteractionType.Summon,
				false
			}
		};

		public static Dictionary<eShuttleboxInteractionType, IsInValidStateForInteractDelegate> ValidStateForInteract = new Dictionary<eShuttleboxInteractionType, IsInValidStateForInteractDelegate>
		{
			{
				eShuttleboxInteractionType.SwapIn,
				IsValidForSwap
			},
			{
				eShuttleboxInteractionType.Transfer,
				IsValidForTransfer
			},
			{
				eShuttleboxInteractionType.Summon,
				IsValidForSummon
			}
		};

		public Item QueuedItem = null;

		public static List<Shuttlebox_Core> s_setupShuttleboxes = new List<Shuttlebox_Core>();

		internal iCarryItemInteractionTarget m_interact;

		private LG_WorldEventAnimationTrigger m_animTrigger;

		private Transform m_itemAlign;

		private Transform m_serialAlign;

		internal Shuttlebox_Core m_linkedShuttlebox;

		private LG_WorldEventAnimationTrigger m_summonTrigger;

		private LG_WorldEventAnimationTrigger m_forceOpenTrigger;

		private LG_WorldEventAnimationTrigger m_forceCloseTrigger;

		private ItemInLevel m_itemInside;

		private AIG_CourseNode m_sourceNode;

		public int ShuttleboxLinkID = -1;

		public Dictionary<uint, ShuttleboxItemsData> ItemToEventsOnEnterDict;

		public static pShuttleboxState StartingState = default(pShuttleboxState);

		private iTerminalItem m_terminalItem;

		public bool ShouldDeregisterSummonItem = true;

		public static List<string> PingOverrideItemKeys = new List<string>();

		public LG_LightEmitterMesh LightMesh = null;

		public Shuttlebox_LightFader LightFader = null;

		private bool m_shouldCloseAtStart = false;

		private bool m_shouldHideItemToSummon = true;

		public static string MainMeshPath = "Decorations/Shuttlebox_Mesh";

		public static string MainVisualMeshSubpath = "g_prop_machine_dumbwaitershute_01";

		public static string HatchVisualMeshSubpath = "prop_machine_dumbwaitershute_hatch/g_prop_machine_dumbwaitershute_hatch";

		private PaintableChannelMaskedTexture PaintedTexture = null;

		public Color DecalColor = default(Color);

		private const string BigPickupAlignName = "Shuttlebox_ItemAlign";

		private const string TMPAlignName = "TMP Align";

		private const string TerminalPingAlignName = "Shuttlebox_TerminalPingAlign";

		private const string InteractObjName = "Shuttlebox_LG_GenericCarry";

		private const string OpenCloseName = "WorldEvents/EVT_ShuttleboxPlugin_OpenClose";

		public const string SummonEventTargetName = "WorldEvents/EVT_ShuttleboxPlugin_SetPickupAlign";

		public const string ForceCloseEventTargetName = "WorldEvents/EVT_ShuttleboxPlugin_ForceClose";

		public const string ForceOpenEventTargetName = "WorldEvents/EVT_ShuttleboxPlugin_ForceOpen";

		private Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool> OnSyncStatusChanged_action;

		public static bool IsMaster => SNet.IsMaster;

		[HideFromIl2Cpp]
		public StateReplicator<pShuttleboxState> Replicator { get; set; }

		public ItemInLevel ItemInside
		{
			get
			{
				return m_itemInside;
			}
			set
			{
				if ((Object)(object)m_itemInside != (Object)null && IsMaster)
				{
					m_itemInside.internalSync.OnSyncStateChange -= OnSyncStatusChanged_action;
				}
				m_itemInside = value;
				if ((Object)(object)m_itemInside != (Object)null)
				{
					m_interact.SetActive(false);
					if (IsMaster)
					{
						m_itemInside.internalSync.OnSyncStateChange += OnSyncStatusChanged_action;
						MoveItemToShuttlebox(m_itemInside);
					}
					if (IsOpen())
					{
						SetItemVisibleInteractable(m_itemInside);
					}
					else
					{
						SetItemVisibleNotInteractable(m_itemInside);
					}
				}
			}
		}

		public bool HasItem => (Object)(object)ItemInside != (Object)null;

		public string DebugName { get; set; } = string.Empty;


		public ItemInLevel ItemToSummon
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				pItemData summonItem = State.summonItem;
				if (((object)(pItemData)(ref summonItem)).Equals((object)default(pItemData)))
				{
					return null;
				}
				if (!TryGetItemInLevelFromData(summonItem, out var iteminlevel))
				{
					return null;
				}
				return iteminlevel;
			}
		}

		public pShuttleboxState State => Replicator.State;

		public eShuttleboxState CurrState => State.state;

		public eShuttleboxInteractionType InteractionType => State.type;

		public void SetOnlyLightState(eShuttleboxLightState lightState, pShuttleboxState state)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			SetOnlyLightState(LightStateToColor[lightState], state);
		}

		public void SetOnlyLightState(eShuttleboxLightState lightState)
		{
			SetOnlyLightState(lightState, Replicator.State);
		}

		public void SetOnlyLightState(Color color, pShuttleboxState state)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (IsMaster)
			{
				state.lightColor = color;
				Replicator.SetState(state);
			}
		}

		public void SetOnlyLightState(Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SetOnlyLightState(color, State);
		}

		public void Awake()
		{
			((Behaviour)this).enabled = false;
		}

		public void Start()
		{
			if (!IsMaster)
			{
				((Behaviour)this).enabled = false;
			}
		}

		public void Update()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			bool flag = default(bool);
			foreach (eShuttleboxInteractionType key in QueueStates.Keys)
			{
				if (!QueueStates[key])
				{
					continue;
				}
				if (ValidStateForInteract.TryGetValue(key, out var value))
				{
					if (value(this, key))
					{
						AttemptInteract(key, null, QueuedItem);
					}
					return;
				}
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(78, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] Has action ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eShuttleboxInteractionType>(key);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" queued but no delegate to check if in valid state!");
				}
				Logger.Error(val);
				DeQueueAction(key);
			}
			((Behaviour)this).enabled = false;
		}

		public void QueueAction(eShuttleboxInteractionType type)
		{
			if (QueueStates.ContainsKey(type))
			{
				QueueStates[type] = true;
			}
			else
			{
				QueueStates.Add(type, value: true);
			}
			((Behaviour)this).enabled = true;
		}

		public void DeQueueAction(eShuttleboxInteractionType type)
		{
			if (QueueStates.ContainsKey(type))
			{
				QueueStates[type] = false;
			}
		}

		public bool IsQueued(eShuttleboxInteractionType type)
		{
			bool value;
			return QueueStates.TryGetValue(type, out value) && value;
		}

		public bool AnyQueued()
		{
			return QueueStates.Values.Any((bool k) => k);
		}

		public bool IsOnlyQueued(eShuttleboxInteractionType type)
		{
			foreach (KeyValuePair<eShuttleboxInteractionType, bool> queueState in QueueStates)
			{
				eShuttleboxInteractionType key = queueState.Key;
				bool value = queueState.Value;
				if (key == type && !value)
				{
					return false;
				}
				if (key != type && value)
				{
					return false;
				}
			}
			return true;
		}

		public static bool IsValidForSwap(Shuttlebox_Core shuttlebox, eShuttleboxInteractionType type)
		{
			return shuttlebox.IsOpen() && !shuttlebox.HasItem;
		}

		public static bool IsValidForTransfer(Shuttlebox_Core shuttlebox, eShuttleboxInteractionType type)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Shuttlebox_Core linkedShuttlebox = shuttlebox.m_linkedShuttlebox;
			if ((Object)(object)linkedShuttlebox == (Object)null)
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(72, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(shuttlebox.DebugName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] Somehow had transfer queued when no linked shuttlebox???");
				}
				Logger.Error(val);
				shuttlebox.DeQueueAction(eShuttleboxInteractionType.Transfer);
				return false;
			}
			return shuttlebox.HasItem && shuttlebox.IsOpen() && !linkedShuttlebox.HasItem && linkedShuttlebox.IsOpen() && !linkedShuttlebox.IsQueued(eShuttleboxInteractionType.SwapIn);
		}

		public static bool IsValidForSummon(Shuttlebox_Core shuttlebox, eShuttleboxInteractionType type)
		{
			bool flag = shuttlebox.m_linkedShuttlebox?.IsQueued(eShuttleboxInteractionType.Transfer) ?? false;
			return !shuttlebox.HasItem && shuttlebox.IsOpen() && !flag;
		}

		[HideFromIl2Cpp]
		public void Setup(LG_Area chosen_area, ShuttleboxPlacementData data)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: 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)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_0197: Expected I4, but got Unknown
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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_01fc: Invalid comparison between Unknown and I4
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			DebugName = data.DebugName;
			m_itemAlign = ((Component)this).transform.FindChild("Shuttlebox_ItemAlign");
			m_serialAlign = ((Component)this).transform.FindChild("TMP Align");
			m_sourceNode = chosen_area.m_courseNode;
			SetupOnAnimationEnds();
			LG_GenericCarryItemInteractionTarget component = ((Component)((Component)this).transform.FindChild("Shuttlebox_LG_GenericCarry")).GetComponent<LG_GenericCarryItemInteractionTarget>();
			component.m_powerCellAlign = m_itemAlign;
			component.m_insertType = InsertTypeEnum.value;
			component.AttemptCarryItemInsert = Action<SNet_Player, Item>.op_Implicit((Action<SNet_Player, Item>)AttemptInsert);
			component.Setup();
			Shuttlebox_AnyItemInteract shuttlebox_AnyItemInteract = ((Component)component).gameObject.AddComponent<Shuttlebox_AnyItemInteract>();
			shuttlebox_AnyItemInteract.AttemptInsertIntoShuttlebox += AttemptInsert;
			m_interact = ((Il2CppObjectBase)component).TryCast<iCarryItemInteractionTarget>();
			OnSyncStatusChanged_action = Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>.op_Implicit((Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>)OnSyncStatusChanged);
			ShuttleboxLinkID = data.LinkID;
			TryLinkToShuttlebox();
			SetupItemDict(data.ValidInsertItems);
			((Object)((Component)this).gameObject).name = "Shuttlebox '" + DebugName + "'";
			ShuttleboxSpawnedItemData spawnedItem = data.SpawnedItem;
			uint itemID = spawnedItem.ItemID;
			ItemInLevel val = null;
			if (GameDataBlockBase<ItemDataBlock>.HasBlock(itemID))
			{
				ItemDataBlock block = GameDataBlockBase<ItemDataBlock>.GetBlock(itemID);
				InventorySlot inventorySlot = block.inventorySlot;
				LG_PickupItem val2 = LG_PickupItem.SpawnGenericPickupItem(GlobalManager.s_root);
				val2.SpawnNode = m_sourceNode;
				val2.SetupCommon();
				InventorySlot val3 = inventorySlot;
				InventorySlot val4 = val3;
				switch (val4 - 4)
				{
				case 0:
				case 1:
				{
					if (spawnedItem.Uses == 0)
					{
						Logger.Info("Tried to spawn Resource or Consumable with `Uses` set to 0");
						break;
					}
					val2.SetupAsConsumable(Builder.SessionSeedRandom.Range(0, int.MaxValue, "NO_TAG"), itemID);
					Item componentInChildren = ((Component)val2.m_root).GetComponentInChildren<Item>();
					pItemData pItemData = componentInChildren.Get_pItemData();
					uint num = spawnedItem.Uses;
					if ((int)inventorySlot == 4)
					{
						num *= 20;
					}
					pItemData.custom.ammo = num;
					componentInChildren.Set_pItemData(pItemData);
					break;
				}
				case 2:
				case 4:
					val2.SetupBigPickupItemWithItemId(itemID, spawnedItem.IsWardenObjective, spawnedItem.ChainedObjectiveIndex);
					break;
				case 3:
					val2.SetupAsSmallGenericPickup(Builder.SessionSeedRandom.Range(0, int.MaxValue, "NO_TAG"), itemID, spawnedItem.IsWardenObjective);
					break;
				default:
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(94, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'] Spawned Item isn't a slot I know what to do with, so can't run setup function.");
					}
					Logger.Warn(val5);
					break;
				}
				}
				val = ((Component)val2).GetComponentInChildren<ItemInLevel>(true);
				m_shouldHideItemToSummon = !spawnedItem.IsAvailableAtStart;
				ShouldDeregisterSummonItem = !spawnedItem.ShowOnTerminalList;
			}
			DecalColor = data.Colors.SerialColor;
			SetupTerminalItem();
			TryChangeShuttleboxColor(data.Colors.MainColor, data.Colors.AccentColor);
			LightMesh = ((Component)this).GetComponentInChildren<LG_LightEmitterMesh>(true);
			LightFader = ((Component)this).gameObject.AddComponent<Shuttlebox_LightFader>();
			LightFader.LightMesh = LightMesh;
			m_shouldCloseAtStart = data.IsClosedAtStart;
			s_setupShuttleboxes.Add(this);
			pShuttleboxState pShuttleboxState2 = default(pShuttleboxState);
			if ((Object)(object)val != (Object)null)
			{
				pShuttleboxState2.summonItem = ((Item)val).Get_pItemData();
			}
			Replicator = StateReplicator<pShuttleboxState>.Create((uint)s_setupShuttleboxes.Count, pShuttleboxState2, (LifeTimeType)1);
			Replicator.OnStateChanged += OnStateChange;
			Logger.DebugOnly("Successfully set up shuttlebox '" + DebugName + "'");
		}

		public void TryChangeShuttleboxColor(Color color1, Color color2)
		{
			//IL_003b: 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_0044: 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_0050: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			Transform val = ((Component)this).transform.Find(MainMeshPath);
			Renderer component = ((Component)val.Find(MainVisualMeshSubpath)).GetComponent<Renderer>();
			Renderer component2 = ((Component)val.Find(HatchVisualMeshSubpath)).GetComponent<Renderer>();
			Material material = component.material;
			if (color1 == default(Color) && color2 == default(Color))
			{
				component.sharedMaterial = Assets.ShuttleboxSharedMaterial;
				component2.sharedMaterial = Assets.ShuttleboxSharedMaterial;
				return;
			}
			if (PaintedTexture == null)
			{
				PaintedTexture = new PaintableChannelMaskedTexture(((Il2CppObjectBase)material.mainTexture).TryCast<Texture2D>());
				PaintedTexture.SetMainTexture(Assets.ShuttleboxPaintableMainTex);
				PaintedTexture.SetMaskTexture(Assets.ShuttleboxPaintableMask);
			}
			PaintedTexture.SetTintColor(color1, color2);
			material.mainTexture = ((PaintableTexture)PaintedTexture).CurrentTexture;
			material = component2.material;
			material.mainTexture = ((PaintableTexture)PaintedTexture).CurrentTexture;
		}

		private void TryLinkToShuttlebox()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			if (ShuttleboxLinkID < 0)
			{
				return;
			}
			bool flag = default(bool);
			if ((Object)(object)m_linkedShuttlebox != (Object)null)
			{
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(66, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Shuttlebox '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' already has a linked shuttlebox when trying to link?");
				}
				Logger.Warn(val);
				return;
			}
			foreach (Shuttlebox_Core s_setupShuttlebox in s_setupShuttleboxes)
			{
				if (s_setupShuttlebox.ShuttleboxLinkID != ShuttleboxLinkID)
				{
					continue;
				}
				if ((Object)(object)s_setupShuttlebox.m_linkedShuttlebox != (Object)null)
				{
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(91, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' tried to link to shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(s_setupShuttlebox.DebugName);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("', but that shuttlebox is already linked to one.");
					}
					Logger.Error(val2);
				}
				else
				{
					LinkToShuttlebox(s_setupShuttlebox);
					s_setupShuttlebox.LinkToShuttlebox(this);
				}
				break;
			}
		}

		private void SetupTerminalItem()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			m_terminalItem = ((Il2CppObjectBase)((Component)((Component)this).transform.FindChild("Shuttlebox_TerminalPingAlign")).GetComponent<LG_GenericTerminalItem>()).Cast<iTerminalItem>();
			m_terminalItem.SpawnNode = m_sourceNode;
			string text = $"SHUTTLEBOX_{SerialGenerator.GetUniqueSerialNo()}";
			m_terminalItem.Setup(text, (AIG_CourseNode)null);
			QueryableAPI.RegisterQueryableItem(text, new QueryDelegate(GetQueryInfo));
			SetupTerminalIDDecal(text);
		}

		[HideFromIl2Cpp]
		private List<string> GetQueryInfo(List<string> defaultDetails)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Invalid comparison between Unknown and I4
			List<string> list = new List<string>(2) { "----------------------------------------------------------------", "SHUTTLEBOX" };
			pItemData summonItem = State.summonItem;
			if (!((object)(pItemData)(ref summonItem)).Equals((object)default(pItemData)))
			{
				list.Add("STORED ITEM: " + TryGetTerminalNameFromItemInLevel(ItemToSummon));
			}
			if ((Object)(object)m_linkedShuttlebox != (Object)null)
			{
				list.Add("LINKED SHUTTLEBOX: " + m_linkedShuttlebox.m_terminalItem.TerminalItemKey);
			}
			list.AddRange(new <>z__ReadOnlyArray<string>(new string[5]
			{
				"----------------------------------------------------------------",
				defaultDetails[1],
				"STATUS: " + (((int)State.terminalItemStatus != 2) ? "ACTIVE" : "INACTIVE"),
				defaultDetails[3],
				defaultDetails[4]
			}));
			return list;
		}

		private void SetupTerminalIDDecal(string termKey)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)m_serialAlign).gameObject;
			TextMeshPro val = gameObject.GetComponent<TextMeshPro>();
			if ((Object)(object)val == (Object)null)
			{
				val = gameObject.AddComponent<TextMeshPro>();
			}
			((TMP_Text)val).horizontalAlignment = (HorizontalAlignmentOptions)2;
			((TMP_Text)val).autoSizeTextContainer = true;
			((TMP_Text)val).font = Assets.OxaniumFont;
			((TMP_Text)val).fontSharedMaterial = Assets.OxaniumFontMaterial;
			((Graphic)val).color = DecalColor;
			((TMP_Text)val).SetText(termKey, true);
		}

		private static string TryGetTerminalNameFromItemInLevel(ItemInLevel item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return "NONE";
			}
			iTerminalItem componentInChildren = ((Component)item).GetComponentInChildren<iTerminalItem>();
			if (componentInChildren == null)
			{
				return ((Item)item).ItemDataBlock.publicName;
			}
			return componentInChildren.TerminalItemKey;
		}

		[HideFromIl2Cpp]
		private void LinkToShuttlebox(Shuttlebox_Core shuttlebox)
		{
			m_linkedShuttlebox = shuttlebox;
		}

		[HideFromIl2Cpp]
		private void SetupItemDict(List<ShuttleboxItemsData> data)
		{
			if (ItemToEventsOnEnterDict == null)
			{
				ItemToEventsOnEnterDict = new Dictionary<uint, ShuttleboxItemsData>();
			}
			foreach (ShuttleboxItemsData datum in data)
			{
				ItemToEventsOnEnterDict.Add(datum.ItemID, datum);
			}
		}

		private void FinishSetupItemDict()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			if (ItemToEventsOnEnterDict.TryGetValue(0u, out var value))
			{
				bool flag = default(bool);
				foreach (uint item in KeyItemTracker.KeyIdsInLevel)
				{
					ShuttleboxItemsData value2 = new ShuttleboxItemsData
					{
						ItemID = item,
						ActionOnInsert = value.ActionOnInsert,
						Events = value.Events
					};
					if (!ItemToEventsOnEnterDict.TryAdd(item, value2))
					{
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(174, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] Tried to register a key item (id ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(item);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") for shuttlebox actions, but the item id was already registered. Why manually register what's supposed to be a keycard item?");
						}
						Logger.Error(val);
					}
				}
			}
			ItemToEventsOnEnterDict.Remove(0u);
		}

		public void SetupOnAnimationEnds()
		{
			m_animTrigger = ((Component)((Component)this).transform.FindChild("WorldEvents/EVT_ShuttleboxPlugin_OpenClose")).GetComponent<LG_WorldEventAnimationTrigger>();
			LG_AnimationSequencer val = ((Il2CppArrayBase<LG_AnimationSequencer>)(object)m_animTrigger.m_animationsOnTrigger)[0];
			val.OnSequenceDone += Action.op_Implicit((Action)OnCloseSequenceEnded);
			LG_AnimationSequencer val2 = ((Il2CppArrayBase<LG_AnimationSequencer>)(object)m_animTrigger.m_animationsOnReset)[0];
			val2.OnSequenceDone += Action.op_Implicit((Action)OnOpenSequenceEnded);
			m_summonTrigger = ((Component)((Component)this).transform.FindChild("WorldEvents/EVT_ShuttleboxPlugin_SetPickupAlign")).GetComponent<LG_WorldEventAnimationTrigger>();
			LG_AnimationSequencer obj = ((Il2CppArrayBase<LG_AnimationSequencer>)(object)m_summonTrigger.m_animationsOnTrigger)[0];
			obj.OnSequenceDone += Action.op_Implicit((Action)OnSummonSequenceTriggered);
			((Object)((Component)m_summonTrigger).gameObject).name = ((Object)((Component)m_summonTrigger).gameObject).name + "_" + DebugName;
			m_forceOpenTrigger = ((Component)((Component)this).transform.FindChild("WorldEvents/EVT_ShuttleboxPlugin_ForceOpen")).GetComponent<LG_WorldEventAnimationTrigger>();
			LG_AnimationSequencer obj2 = ((Il2CppArrayBase<LG_AnimationSequencer>)(object)m_forceOpenTrigger.m_animationsOnTrigger)[0];
			obj2.OnSequenceDone += Action.op_Implicit((Action)OnOpenSequenceTriggered);
			((Object)((Component)m_forceOpenTrigger).gameObject).name = ((Object)((Component)m_forceOpenTrigger).gameObject).name + "_" + DebugName;
			m_forceCloseTrigger = ((Component)((Component)this).transform.FindChild("WorldEvents/EVT_ShuttleboxPlugin_ForceClose")).GetComponent<LG_WorldEventAnimationTrigger>();
			LG_AnimationSequencer obj3 = ((Il2CppArrayBase<LG_AnimationSequencer>)(object)m_forceCloseTrigger.m_animationsOnTrigger)[0];
			obj3.OnSequenceDone += Action.op_Implicit((Action)OnCloseSequenceTriggered);
			((Object)((Component)m_forceCloseTrigger).gameObject).name = ((Object)((Component)m_forceCloseTrigger).gameObject).name + "_" + DebugName;
		}

		public static void OnLevelCleanup()
		{
			if (s_setupShuttleboxes == null)
			{
				s_setupShuttleboxes = new List<Shuttlebox_Core>();
			}
			s_setupShuttleboxes.Clear();
			PingOverrideItemKeys.Clear();
		}

		public static void FinishSetupSummonItems()
		{
			//IL_0072: 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)
			if (!IsMaster)
			{
				return;
			}
			foreach (Shuttlebox_Core s_setupShuttlebox in s_setupShuttleboxes)
			{
				ItemInLevel itemToSummon = s_setupShuttlebox.ItemToSummon;
				if ((Object)(object)itemToSummon != (Object)null)
				{
					if (s_setupShuttlebox.m_shouldHideItemToSummon)
					{
						s_setupShuttlebox.HideItemAtBottomOfElevator(itemToSummon, s_setupShuttlebox.ShouldDeregisterSummonItem);
						continue;
					}
					s_setupShuttlebox.AttemptInteract(eShuttleboxInteractionType.Place, null, (Item)(object)itemToSummon);
					pShuttleboxState state = s_setupShuttlebox.State;
					state.summonItem = default(pItemData);
					s_setupShuttlebox.Replicator.SetStateUnsynced(state);
				}
			}
		}

		public static void ActivateLights()
		{
			foreach (Shuttlebox_Core s_setupShuttlebox in s_setupShuttleboxes)
			{
				s_setupShuttlebox.SetOnlyLightState(eShuttleboxLightState.Ready);
			}
		}

		public static void CloseShuttleboxesAtStart()
		{
			if (!IsMaster)
			{
				return;
			}
			foreach (Shuttlebox_Core s_setupShuttlebox in s_setupShuttleboxes)
			{
				if (s_setupShuttlebox.m_shouldCloseAtStart)
				{
					s_setupShuttlebox.AttemptInteract(eShuttleboxInteractionType.Close);
				}
			}
		}

		public static void FinishSetupAllItemDicts()
		{
			foreach (Shuttlebox_Core s_setupShuttlebox in s_setupShuttleboxes)
			{
				s_setupShuttlebox.FinishSetupItemDict();
			}
		}

		public static void UpdateSoundPlayerPositions(ItemInLevel item)
		{
			//IL_002c: 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_0068: 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)
			Il2CppArrayBase<SimpleSoundPlayer> componentsInChildren = ((Component)item).GetComponentsInChildren<SimpleSoundPlayer>();
			Il2CppArrayBase<CellSoundPlayer> componentsInChildren2 = ((Component)item).GetComponentsInChildren<CellSoundPlayer>();
			foreach (SimpleSoundPlayer item2 in componentsInChildren)
			{
				item2.m_sound.UpdatePosition(((Component)item).transform.position);
			}
			foreach (CellSoundPlayer item3 in componentsInChildren2)
			{
				item3.UpdatePosition(((Component)item).transform.position);
			}
		}

		public void OnCloseSequenceEnded()
		{
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_011d: Expected O, but got Unknown
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			pShuttleboxState state = State;
			state.state = eShuttleboxState.Closed;
			Replicator.SetStateUnsynced(state);
			if (InteractionType == eShuttleboxInteractionType.None)
			{
				return;
			}
			if (HasItem && InteractionType != eShuttleboxInteractionType.ReceiveTransferClose && InteractionType != eShuttleboxInteractionType.Close)
			{
				TryExecuteItemEvents(((Item)ItemInside).GetItem(), (eWardenObjectiveEventTrigger)2);
			}
			else if (InteractionType == eShuttleboxInteractionType.Summon && (Object)(object)ItemToSummon != (Object)null)
			{
				TryExecuteItemEvents(((Item)ItemToSummon).GetItem(), (eWardenObjectiveEventTrigger)2);
			}
			if (!IsMaster)
			{
				return;
			}
			bool flag = true;
			bool flag2 = default(bool);
			switch (InteractionType)
			{
			case eShuttleboxInteractionType.Close:
				flag = false;
				break;
			case eShuttleboxInteractionType.CloseConsumeRemainShut:
				flag = false;
				goto case eShuttleboxInteractionType.CloseConsume;
			case eShuttleboxInteractionType.CloseConsume:
				if (!HasItem)
				{
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(66, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("'] Tried to consume item, but had no item to consume.");
					}
					Logger.Error(val3);
				}
				else
				{
					HideItemAtBottomOfElevator(ItemInside);
					ItemInside = null;
					state.interactedItem = default(pItemData);
				}
				break;
			case eShuttleboxInteractionType.Transfer:
			{
				m_linkedShuttlebox.ItemInside = ItemInside;
				pShuttleboxState state2 = m_linkedShuttlebox.State;
				state2.interactedItem = ((Item)ItemInside).Get_pItemData();
				m_linkedShuttlebox.Replicator.SetStateUnsynced(state2);
				m_linkedShuttlebox.MoveItemToShuttlebox(ItemInside);
				ItemInside = null;
				state.interactedItem = default(pItemData);
				state.type = eShuttleboxInteractionType.None;
				break;
			}
			case eShuttleboxInteractionType.ReceiveTransferClose:
				AttemptInteract(eShuttleboxInteractionType.ReceiveTransferOpen);
				return;
			case eShuttleboxInteractionType.Summon:
				if ((Object)(object)ItemToSummon == (Object)null)
				{
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(87, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Shuttlebox ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] Got to end of close sequence trying to summon, but had no item to summon.");
					}
					Logger.Info(val2);
					break;
				}
				ItemInside = ItemToSummon;
				state.interactedItem = state.summonItem;
				state.summonItem = default(pItemData);
				goto case eShuttleboxInteractionType.ReceiveTransferClose;
			default:
			{
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(71, 2, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] Got to end of close sequence with weird interact type: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eShuttleboxInteractionType>(InteractionType);
				}
				Logger.Warn(val);
				break;
			}
			}
			Replicator.SetStateUnsynced(state);
			if (flag)
			{
				AttemptInteract(eShuttleboxInteractionType.Open);
				return;
			}
			state.terminalItemStatus = (eFloorInventoryObjectStatus)2;
			SetOnlyLightState(eShuttleboxLightState.ShutOff, state);
		}

		public void OnOpenSequenceEnded()
		{
			//IL_0024: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			pShuttleboxState state = State;
			state.state = eShuttleboxState.Open;
			state.type = eShuttleboxInteractionType.None;
			if (!HasItem && state.interactedItem.itemID_gearCRC != 0 && !TryGetItemInsideFromState(state.interactedItem))
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(108, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] CurrState had item but no ItemInside, failed to get item from state. Unsetting state's item.");
				}
				Logger.Error(val);
				state.interactedItem = default(pItemData);
			}
			Replicator.SetStateUnsynced(state);
			m_interact.SetActive(!HasItem);
			if (HasItem)
			{
				SetItemVisibleInteractable(ItemInside);
			}
			if (IsMaster)
			{
				if (AnyQueued())
				{
					SetOnlyLightState(eShuttleboxLightState.Queued);
				}
				else
				{
					SetOnlyLightState(eShuttleboxLightState.Ready);
				}
			}
		}

		public void OnSummonSequenceTriggered()
		{
			Logger.DebugOnly("[Shuttlebox '" + DebugName + "'] Summon sequence triggered");
			if (IsMaster && (Object)(object)ItemToSummon != (Object)null)
			{
				AttemptInteract(eShuttleboxInteractionType.Summon);
			}
		}

		public void OnOpenSequenceTriggered()
		{
			Logger.DebugOnly("[Shuttlebox '" + DebugName + "'] ForceOpen sequence triggered");
			m_forceOpenTrigger.ResetTrigger();
			if (IsMaster)
			{
				AttemptInteract(eShuttleboxInteractionType.Open);
			}
		}

		public void OnCloseSequenceTriggered()
		{
			Logger.DebugOnly("[Shuttlebox '" + DebugName + "'] ForceClose sequence triggered");
			m_forceCloseTrigger.ResetTrigger();
			if (IsMaster)
			{
				AttemptInteract(eShuttleboxInteractionType.Close);
			}
		}

		public void OnStateChange(pShuttleboxState oldState, pShuttleboxState state, bool isRecall)
		{
			//IL_0071: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Expected O, but got Unknown
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			if (IsOpen(oldState) && IsClosing(state))
			{
				m_animTrigger.Trigger();
				m_interact.SetActive(false);
				if (HasItem)
				{
					SetItemVisibleNotInteractable(ItemInside);
				}
			}
			if (IsClosed(oldState) && IsOpening(state))
			{
				m_animTrigger.ResetTrigger();
			}
			LightFader.TargetColor = state.lightColor;
			if (state.EqualsNoLight(oldState))
			{
				return;
			}
			m_terminalItem.FloorItemStatus = state.terminalItemStatus;
			if (isRecall)
			{
				TryGetItemInsideFromState(state.interactedItem);
				m_interact.SetActive(!HasItem);
				if (IsMaster && (Object)(object)ItemToSummon != (Object)null)
				{
					HideItemAtBottomOfElevator(ItemToSummon, ShouldDeregisterSummonItem);
				}
			}
			bool flag = default(bool);
			switch (state.type)
			{
			case eShuttleboxInteractionType.Insert:
			{
				if (!HasItem && ValidatePlayerHasItem(state.interactingPlayer, state.interactedItem, out var player, out var item))
				{
					if (!AttemptRemoveItemFromInventory(player, item))
					{
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(45, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] (");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eShuttleboxInteractionType>(state.type);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") Validated insert failed???");
						}
						Logger.Error(val);
					}
					else
					{
						ItemInside = ((Il2CppObjectBase)item).Cast<ItemInLevel>();
						TryExecuteItemEvents(((Item)ItemInside).GetItem(), (eWardenObjectiveEventTrigger)1);
						state.type = eShuttleboxInteractionType.None;
						Replicator.SetStateUnsynced(state);
						if (IsMaster)
						{
							TryExecuteItemActions(item);
						}
					}
				}
				else
				{
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(96, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] (");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<eShuttleboxInteractionType>(state.type);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") Tried to insert item, but it either already had an item or validation failed.");
					}
					Logger.Error(val);
				}
				break;
			}
			case eShuttleboxInteractionType.Remove:
				if (HasItem || TryGetItemInsideFromState(oldState.interactedItem))
				{
					TryExecuteItemEvents(((Item)ItemInside).GetItem(), (eWardenObjectiveEventTrigger)3);
				}
				else
				{
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(132, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] Tried to remove item, but no item found. If this turns out to be a major issue, report this to the relevant persons.");
					}
					Logger.Error(val);
				}
				ItemInside = null;
				m_interact.SetActive(true);
				state.type = eShuttleboxInteractionType.None;
				Replicator.SetStateUnsynced(state);
				break;
			case eShuttleboxInteractionType.SwapIn:
			{
				ItemInLevel iteminlevel = null;
				if (!TryGetItemInLevelFromData(state.interactedItem, out iteminlevel))
				{
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(59, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Shuttlebox '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DebugName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'] Swapping in item but can't find iteminlevel");
					}
					Logger.Error(val);
				}
				ItemInside = iteminlevel;
				m_interact.SetActive(false);
				TryExecuteItemEvents(((Item)ItemInside).GetItem(), (eWardenObjectiveEventTrigger)1);
				if (IsMaster)
				{
					TryExecuteItemActions(((Item)ItemInside).GetItem());
				}
				break;
			}
			case eShuttleboxInteractionType.Place:
			{
				ItemInLevel iteminlevel2 = null;
				if (!TryGetItemInLevelFromData(state.