Decompiled source of Delayed Shards v0.1.1

DelayedShards.dll

Decompiled 19 hours ago
using System;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CG;
using CG.Client;
using CG.Game;
using CG.Game.Player;
using CG.Input;
using CG.Network;
using CG.Objects;
using CG.Ship.Hull;
using DelayedShards.Controls;
using DelayedShards.Functionality;
using Gameplay.Carryables;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using ResourceAssets;
using UnityEngine;
using VoidManager;
using VoidManager.Chat.Router;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.ModMessages;
using VoidManager.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("18107")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Stores functional shards when inserted into the astral map, which may be activated on demand. Session Mod.")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+9169e99a43fa162901ba73e46b535f8c1bd18be5")]
[assembly: AssemblyProduct("DelayedShards")]
[assembly: AssemblyTitle("Stores functional shards when inserted into the astral map, which may be activated on demand.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.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 DelayedShards
{
	internal class Configs
	{
		internal static ConfigEntry<KeyCode> SummonEscortConfig;

		internal static ConfigEntry<KeyCode> SummonMinefieldConfig;

		internal static ConfigEntry<bool> DisplayGUIAsPilot;

		internal static ConfigEntry<bool> AlwaysDisplayGUI;

		internal static ConfigEntry<bool> VoidManagerUIStyle;

		internal static ConfigEntry<float> GUIPosX;

		internal static ConfigEntry<float> GUIPosY;

		internal static ConfigEntry<bool> enableQueue;

		internal static bool hostHasMod;

		internal static void Load(BepinPlugin plugin)
		{
			SummonEscortConfig = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("DelayedShards", "SummonEscort", (KeyCode)50, (ConfigDescription)null);
			SummonMinefieldConfig = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("DelayedShards", "SummonMinefield", (KeyCode)51, (ConfigDescription)null);
			DisplayGUIAsPilot = ((BaseUnityPlugin)plugin).Config.Bind<bool>("DelayedShards", "RecieveNotificationsAsPilot", true, (ConfigDescription)null);
			AlwaysDisplayGUI = ((BaseUnityPlugin)plugin).Config.Bind<bool>("DelayedShards", "AlwaysRecieveNotifications", false, (ConfigDescription)null);
			VoidManagerUIStyle = ((BaseUnityPlugin)plugin).Config.Bind<bool>("DelayedShards", "VoidManagerUIStyle", false, (ConfigDescription)null);
			GUIPosX = ((BaseUnityPlugin)plugin).Config.Bind<float>("DelayedShards", "GUIPosX", 0.17f, (ConfigDescription)null);
			GUIPosY = ((BaseUnityPlugin)plugin).Config.Bind<float>("DelayedShards", "GUIPosY", 0.789f, (ConfigDescription)null);
			enableQueue = ((BaseUnityPlugin)plugin).Config.Bind<bool>("DelayedShards", "EnableQueue", true, (ConfigDescription)null);
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.DelayedShards";

		public const string PLUGIN_NAME = "DelayedShards";

		public const string USERS_PLUGIN_NAME = "Delayed Shards";

		public const string PLUGIN_VERSION = "0.1.1";

		public const string PLUGIN_DESCRIPTION = "Stores functional shards when inserted into the astral map, which may be activated on demand.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107, Dragon";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Delayed_Shards";
	}
	[BepInPlugin("18107.DelayedShards", "Delayed Shards", "0.1.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.DelayedShards");
			Configs.Load(this);
			((Object)new GameObject("DataShardGUI", new Type[1] { typeof(DataShardGUI) })).hideFlags = (HideFlags)61;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.DelayedShards is loaded!");
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)20;

		public override string Author => "18107, Dragon";

		public override string Description => "Stores functional shards when inserted into the astral map, which may be activated on demand.";

		public override string ThunderstoreID => "VoidCrewModdingTeam/Delayed_Shards";

		public VoidManagerPlugin()
		{
			Events.Instance.JoinedRoom += delegate
			{
				ShardMessageHandler.SubscribeToCountUpdates();
			};
			Events.Instance.LeftRoom += delegate
			{
				Helper.Reset();
			};
			Events.Instance.HostStartSession += delegate
			{
				Helper.Reset();
			};
			Events.Instance.MasterClientSwitched += delegate
			{
				ShardMessageHandler.SubscribeToCountUpdates();
			};
			Events.Instance.PlayerLeftRoom += delegate(object sender, PlayerEventArgs e)
			{
				ShardMessageHandler.subscribedPlayers.Remove(e.player);
			};
			Events.Instance.LateUpdate += delegate
			{
				Inputs.HandleInputs();
			};
		}
	}
	internal class SettingsGUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Delayed Shards";
		}

		public override void Draw()
		{
			GUILayout.Label("", Array.Empty<GUILayoutOption>());
			if (GUITools.DrawCheckbox("Add inserted shards to queue (host)", ref Configs.enableQueue))
			{
				CarryablesSocketPatch.ToggleQueue();
			}
			GUITools.DrawCheckbox("Display GUI when in the pilots seat (client)", ref Configs.DisplayGUIAsPilot);
			GUITools.DrawCheckbox("Always display GUI (client)", ref Configs.AlwaysDisplayGUI);
			GUITools.DrawCheckbox("Use Void Manager GUI style", ref Configs.VoidManagerUIStyle);
			GUILayout.Label("", Array.Empty<GUILayoutOption>());
			GUITools.DrawChangeKeybindButton("Change Summon Escort Keybind", ref Configs.SummonEscortConfig);
			GUITools.DrawChangeKeybindButton("Change Summon Minefield Keybind", ref Configs.SummonMinefieldConfig);
			GUILayout.Label("", Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label("GUI Position", Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Label("X: " + Configs.GUIPosX.Value.ToString("P"), Array.Empty<GUILayoutOption>());
			if (GUITools.DrawSlider(ref Configs.GUIPosX, 0f, 1f))
			{
				DataShardGUI.Instance.UpdateWindowPos();
			}
			GUILayout.Label("Y: " + Configs.GUIPosY.Value.ToString("P"), Array.Empty<GUILayoutOption>());
			if (GUITools.DrawSlider(ref Configs.GUIPosY, 0f, 1f))
			{
				DataShardGUI.Instance.UpdateWindowPos();
			}
			if (GUILayout.Button("Reset", Array.Empty<GUILayoutOption>()))
			{
				Configs.GUIPosX.Value = (float)((ConfigEntryBase)Configs.GUIPosX).DefaultValue;
				Configs.GUIPosY.Value = (float)((ConfigEntryBase)Configs.GUIPosY).DefaultValue;
				DataShardGUI.Instance.UpdateWindowPos();
			}
		}
	}
}
namespace DelayedShards.Functionality
{
	[HarmonyPatch(typeof(CarryablesSocket))]
	internal class CarryablesSocketPatch
	{
		internal static CarryablesSocket GalaxyMapSocket;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatch(CarryablesSocket __instance)
		{
			if (((Object)__instance).name == "Socket_AstralMap")
			{
				GalaxyMapSocket = __instance;
				__instance.ClosedWhileInVoid = false;
				GameSessionSectorManager.OnSectorExited += PlayerShipEnteredVoid;
				GameSessionSectorManager.OnSectorEntered += OnPlayerShipSectorEnter;
				BepinPlugin.Log.LogInfo((object)"patched astral map socket");
			}
		}

		[HarmonyPatch("OnDestroy")]
		[HarmonyPostfix]
		private static void DestroyPatch()
		{
			GameSessionSectorManager.OnSectorExited -= PlayerShipEnteredVoid;
			GameSessionSectorManager.OnSectorEntered -= OnPlayerShipSectorEnter;
		}

		internal static void ToggleQueue()
		{
			if (Helper.IsInVoidJump())
			{
				if (Configs.enableQueue.Value)
				{
					GalaxyMapSocket.closedBecauseInVoid = false;
					GalaxyMapSocket.SetState((SocketState)1);
				}
				else
				{
					GalaxyMapSocket.SetState((SocketState)0);
					GalaxyMapSocket.closedBecauseInVoid = true;
				}
			}
		}

		private static void OnPlayerShipSectorEnter(GameSessionSector sector)
		{
			if (!Configs.enableQueue.Value)
			{
				GalaxyMapSocket.closedBecauseInVoid = false;
				GalaxyMapSocket.SetState((SocketState)1);
			}
		}

		private static void PlayerShipEnteredVoid(GameSessionSector sector)
		{
			if (!Configs.enableQueue.Value)
			{
				GalaxyMapSocket.SetState((SocketState)0);
				GalaxyMapSocket.closedBecauseInVoid = true;
			}
		}
	}
	internal class DataShardGUI : MonoBehaviour
	{
		private bool mainUiEnabled = true;

		private bool guiActive = false;

		internal Rect WindowPos;

		internal const float width = 100f;

		internal const float height = 74f;

		private static GUISkin _cachedSkin;

		private static readonly Color32 _classicMenuBackground = new Color32((byte)32, (byte)32, (byte)32, byte.MaxValue);

		internal static DataShardGUI Instance { get; private set; }

		private DataShardGUI()
		{
			Instance = this;
			Tools.DelayDo((Action)delegate
			{
				ViewEventBus.Instance.OnUIToggle.Subscribe((Action<bool>)delegate(bool enable)
				{
					mainUiEnabled = enable;
				}, (AutoUnsubscribeCollection)null);
			}, 12000.0);
		}

		internal void UpdateWindowPos()
		{
			//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)
			WindowPos = new Rect((float)Screen.width * Configs.GUIPosX.Value, (float)Screen.height * Configs.GUIPosY.Value, 100f, 74f);
		}

		private void Update()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			int num;
			if (Configs.hostHasMod && mainUiEnabled && (Configs.AlwaysDisplayGUI.Value || (Configs.DisplayGUIAsPilot.Value && Helper.IsInPilotsSeat(PhotonNetwork.LocalPlayer))))
			{
				ClientGame current = ClientGame.Current;
				num = (((Object)(object)((current == null) ? null : current.PlayerShip?.InteriorAtmosphere) != (Object)null) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag = (byte)num != 0;
			if (flag != guiActive)
			{
				guiActive = !guiActive;
				WindowPos = new Rect((float)Screen.width * Configs.GUIPosX.Value, (float)Screen.height * Configs.GUIPosY.Value, 100f, 74f);
			}
		}

		private void OnGUI()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (guiActive)
			{
				if (Configs.VoidManagerUIStyle.Value)
				{
					GUI.skin = ChangeSkin();
				}
				GUI.Window(818107, WindowPos, new WindowFunction(WindowFunction), "Data Shards");
			}
		}

		private void WindowFunction(int windowID)
		{
			GUILayout.Label($"Escort:    {Helper.EscortsAvailable}", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Minefield: {Helper.MinefieldsAvailable}", Array.Empty<GUILayoutOption>());
		}

		private GUISkin ChangeSkin()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (_cachedSkin == null || _cachedSkin.window.active.background == null)
			{
				_cachedSkin = Object.Instantiate<GUISkin>(GUI.skin);
				Texture2D background = BuildTexFrom1Color(Color32.op_Implicit(_classicMenuBackground));
				_cachedSkin.window.active.background = background;
				_cachedSkin.window.onActive.background = background;
				_cachedSkin.window.focused.background = background;
				_cachedSkin.window.onFocused.background = background;
				_cachedSkin.window.hover.background = background;
				_cachedSkin.window.onHover.background = background;
				_cachedSkin.window.normal.background = background;
				_cachedSkin.window.onNormal.background = background;
			}
			return _cachedSkin;
		}

		private Texture2D BuildTexFrom1Color(Color color)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}
	}
	internal class Helper
	{
		internal enum RejectReason
		{
			None,
			CooldownTimer,
			VoidJump,
			EscortShardCount,
			MinefieldShardCount
		}

		public const long messageTimeout = 8000L;

		internal static GUIDUnion EscortGUID = new GUIDUnion("db0a40ea1d616fa4eb80b044dc3efa3e");

		internal static int EscortsAvailable = 0;

		internal static GUIDUnion MinefieldGUID = new GUIDUnion("d2427729f742ec04d98aa89b0575e9e0");

		internal static int MinefieldsAvailable = 0;

		private static float lastShardActivated = 0f;

		internal static RejectReason SummonEscort()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (EscortsAvailable <= 0)
			{
				return RejectReason.EscortShardCount;
			}
			if (Time.time - lastShardActivated < 8f)
			{
				return RejectReason.CooldownTimer;
			}
			if (IsInVoidJump())
			{
				return RejectReason.VoidJump;
			}
			CarryableObject asset = ((ResourceAssetDef<CarryableObject>)(object)((ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>)(object)ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>.Instance).GetAssetDefById(EscortGUID, true)).Asset;
			IConsumptionEffect component = ((Component)asset).GetComponent<IConsumptionEffect>();
			if (component != null)
			{
				ClientGame.Current.ModelEventBus.OnCarryableConsumed.Publish(asset, GameSessionManager.ActiveSector);
				component.OnConsume();
			}
			EscortsAvailable--;
			lastShardActivated = Time.time;
			ShardMessageHandler.SendShardCount();
			return RejectReason.None;
		}

		internal static RejectReason SummonMinefield()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (MinefieldsAvailable <= 0)
			{
				return RejectReason.MinefieldShardCount;
			}
			if (Time.time - lastShardActivated < 8f)
			{
				return RejectReason.CooldownTimer;
			}
			if (IsInVoidJump())
			{
				return RejectReason.VoidJump;
			}
			((Component)((ResourceAssetDef<CarryableObject>)(object)((ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>)(object)ResourceAssetContainer<CarryableContainer, CarryableObject, CarryableDef>.Instance).GetAssetDefById(MinefieldGUID, true)).Asset).GetComponent<CarryableSummonConsumptionEffect>().SummonUnits();
			MinefieldsAvailable--;
			lastShardActivated = Time.time;
			ShardMessageHandler.SendShardCount();
			return RejectReason.None;
		}

		internal static void Reset()
		{
			EscortsAvailable = 0;
			MinefieldsAvailable = 0;
			ShardMessageHandler.subscribedPlayers = ShardMessageHandler.subscribedPlayers.Intersect(PhotonNetwork.PlayerListOthers).ToList();
			ShardMessageHandler.SendShardCount();
		}

		internal static bool IsInPilotsSeat(Player player)
		{
			if (player == null)
			{
				return false;
			}
			Player currentPilot = Game.CurrentPilot;
			return ((currentPilot != null) ? currentPilot.PhotonPlayer : null) == player;
		}

		internal static bool IsInVoidJump()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			return (int)GameSessionSectorManager.Instance.Status > 0;
		}

		internal static void SendPublicMessage(RejectReason reason = RejectReason.None)
		{
			Messaging.Echo(GetDisplayMessage(reason), false);
		}

		internal static void DisplayLocalMessage(RejectReason reason = RejectReason.None)
		{
			if (reason != 0)
			{
				Messaging.Notification(GetDisplayMessage(reason), 8000L, false);
			}
		}

		private static string GetDisplayMessage(RejectReason reason)
		{
			if (1 == 0)
			{
			}
			string result = reason switch
			{
				RejectReason.None => $"{EscortsAvailable} escort shards available\n{MinefieldsAvailable} minefield shards available", 
				RejectReason.CooldownTimer => "Data shards on cooldown", 
				RejectReason.VoidJump => "Data shards not available during void jump", 
				RejectReason.EscortShardCount => "No escort shards available", 
				RejectReason.MinefieldShardCount => "No minefield shards available", 
				_ => throw new ArgumentException(), 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		public static bool ButtonPressed(KeyCode key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((int)key == 0)
			{
				return false;
			}
			return UnityInput.Current.GetKeyDown(key);
		}
	}
	internal class ShardMessageHandler : ModMessage
	{
		private enum Requests
		{
			Subscribe,
			Sent,
			Activate,
			Reject
		}

		internal static List<Player> subscribedPlayers = new List<Player>();

		public override void Handle(object[] arguments, Player sender)
		{
			if (arguments.Length == 0)
			{
				return;
			}
			if ((string)arguments[0] != "0.1.1")
			{
				BepinPlugin.Log.LogInfo((object)("Got version " + (string)arguments[0] + " from " + sender.NickName + ", expected version 0.1.1"));
				return;
			}
			switch ((Requests)arguments[1])
			{
			case Requests.Subscribe:
				if (PhotonNetwork.IsMasterClient)
				{
					if (!subscribedPlayers.Contains(sender))
					{
						subscribedPlayers.Add(sender);
					}
					SendShardCount(sender);
				}
				break;
			case Requests.Sent:
				if (!PhotonNetwork.IsMasterClient && sender == PhotonNetwork.MasterClient)
				{
					Configs.hostHasMod = true;
					int[] array = (int[])arguments[2];
					Helper.EscortsAvailable = array[0];
					Helper.MinefieldsAvailable = array[1];
				}
				break;
			case Requests.Activate:
			{
				if (!PhotonNetwork.IsMasterClient)
				{
					break;
				}
				Helper.RejectReason rejectReason = Helper.RejectReason.None;
				string text = ((string)arguments[2]).ToLower();
				string text2 = text;
				if (!(text2 == "escort"))
				{
					if (text2 == "minefield")
					{
						rejectReason = Helper.SummonMinefield();
					}
				}
				else
				{
					rejectReason = Helper.SummonEscort();
				}
				if (rejectReason != 0)
				{
					SendRejectMessage(sender, rejectReason);
				}
				break;
			}
			case Requests.Reject:
				if (!PhotonNetwork.IsMasterClient && sender == PhotonNetwork.MasterClient)
				{
					Helper.DisplayLocalMessage((Helper.RejectReason)arguments[2]);
				}
				break;
			}
		}

		internal static void SubscribeToCountUpdates()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Configs.hostHasMod = true;
				return;
			}
			Configs.hostHasMod = false;
			ModMessage.Send("18107.DelayedShards", ModMessage.GetIdentifier(typeof(ShardMessageHandler)), PhotonNetwork.MasterClient, new object[2]
			{
				"0.1.1",
				Requests.Subscribe
			}, false);
		}

		internal static void ActivateShard(string shardName)
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				ModMessage.Send("18107.DelayedShards", ModMessage.GetIdentifier(typeof(ShardMessageHandler)), PhotonNetwork.MasterClient, new object[3]
				{
					"0.1.1",
					Requests.Activate,
					shardName
				}, false);
			}
		}

		internal static void SendShardCount(params Player[] player)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				if (player == null || player.Length == 0)
				{
					player = subscribedPlayers.ToArray();
				}
				ModMessage.Send("18107.DelayedShards", ModMessage.GetIdentifier(typeof(ShardMessageHandler)), player, new object[3]
				{
					"0.1.1",
					Requests.Sent,
					new int[2]
					{
						Helper.EscortsAvailable,
						Helper.MinefieldsAvailable
					}
				}, false);
			}
		}

		internal static void SendRejectMessage(Player player, Helper.RejectReason reason)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				ModMessage.Send("18107.DelayedShards", ModMessage.GetIdentifier(typeof(ShardMessageHandler)), player, new object[3]
				{
					"0.1.1",
					Requests.Reject,
					reason
				}, false);
			}
		}
	}
	[HarmonyPatch(typeof(SocketPayloadConsumer), "OnAcquireCarryable")]
	internal class SummonInterceptPatch
	{
		private static bool Prefix(SocketPayloadConsumer __instance, CarryableObject carryable)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			if (!Configs.enableQueue.Value || !PhotonNetwork.IsMasterClient)
			{
				return true;
			}
			if (((AbstractCloneStarObject)carryable).assetGuid == Helper.MinefieldGUID)
			{
				Helper.MinefieldsAvailable++;
				ShardMessageHandler.SendShardCount();
				__instance.ConsumePayload();
				return false;
			}
			if (((AbstractCloneStarObject)carryable).assetGuid == Helper.EscortGUID)
			{
				Helper.EscortsAvailable++;
				ShardMessageHandler.SendShardCount();
				__instance.ConsumePayload();
				return false;
			}
			return true;
		}
	}
}
namespace DelayedShards.Controls
{
	internal class ActivateShardCommand : PublicCommand
	{
		public override string[] CommandAliases()
		{
			return new string[1] { "ActivateShard" };
		}

		public override string Description()
		{
			return "Activates a previously inserted data shard";
		}

		public override List<Argument> Arguments()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			List<Argument> list = new List<Argument>();
			list.Add(new Argument(new string[2] { "Escort", "Minefield" }));
			return list;
		}

		public override string[] UsageExamples()
		{
			return ((PublicCommand)this).Arguments()[0].names.Select((string name) => "!" + ((PublicCommand)this).CommandAliases()[0] + " " + name).ToArray();
		}

		public override void Execute(string arguments, int SenderID)
		{
			if (!Helper.IsInPilotsSeat(Game.GetPlayerFromID(SenderID).PhotonPlayer))
			{
				Messaging.Echo("You must be in the pilot's seat to activate data shards", false);
				return;
			}
			string text = arguments.Split(' ')[0].ToLower();
			string text2 = text;
			string text3 = text2;
			if (!(text3 == "escort"))
			{
				if (text3 == "minefield")
				{
					Helper.SendPublicMessage(Helper.SummonMinefield());
				}
				else
				{
					Messaging.Echo("Options are \"Escort\" and \"Minefield\"", false);
				}
			}
			else
			{
				Helper.SendPublicMessage(Helper.SummonEscort());
			}
		}
	}
	internal class CountShardCommand : ActivateShardCommand
	{
		public override string[] CommandAliases()
		{
			return new string[1] { "CountShards" };
		}

		public override string Description()
		{
			return "Lists the number of shards available";
		}

		public override void Execute(string arguments, int SenderID)
		{
			if (Utility.IsNullOrWhiteSpace(arguments))
			{
				Helper.SendPublicMessage();
				return;
			}
			string text = arguments.Split(' ')[0].ToLower();
			string text2 = text;
			string text3 = text2;
			if (!(text3 == "escort"))
			{
				if (text3 == "minefield")
				{
					Messaging.Echo($"{Helper.MinefieldsAvailable} Minefield shards available", false);
				}
			}
			else
			{
				Messaging.Echo($"{Helper.EscortsAvailable} Escort shards available", false);
			}
		}
	}
	internal class Inputs
	{
		internal static void HandleInputs()
		{
			//IL_0087: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			if (Game.PlayerShipExists && !Helper.IsInPilotsSeat(PhotonNetwork.LocalPlayer))
			{
				if (!ServiceBase<InputService>.Instance.CursorVisibilityControl.IsCursorShown && (Helper.ButtonPressed(Configs.SummonEscortConfig.Value) || Helper.ButtonPressed(Configs.SummonMinefieldConfig.Value)))
				{
					Messaging.Notification("You must be in the pilot's seat to activate data shards", 8000L, false);
				}
				return;
			}
			if (!ServiceBase<InputService>.Instance.CursorVisibilityControl.IsCursorShown && Helper.ButtonPressed(Configs.SummonEscortConfig.Value))
			{
				if (PhotonNetwork.IsMasterClient)
				{
					Helper.RejectReason rejectReason = Helper.SummonEscort();
					if (rejectReason != 0)
					{
						Helper.DisplayLocalMessage(rejectReason);
					}
				}
				else
				{
					ShardMessageHandler.ActivateShard("escort");
				}
			}
			if (ServiceBase<InputService>.Instance.CursorVisibilityControl.IsCursorShown || !Helper.ButtonPressed(Configs.SummonMinefieldConfig.Value))
			{
				return;
			}
			if (PhotonNetwork.IsMasterClient)
			{
				Helper.RejectReason rejectReason2 = Helper.SummonMinefield();
				if (rejectReason2 != 0)
				{
					Helper.DisplayLocalMessage(rejectReason2);
				}
			}
			else
			{
				ShardMessageHandler.ActivateShard("minefield");
			}
		}
	}
}