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.Game.Scenarios;
using CG.Game.Scenarios.Actions;
using CG.Game.Scenarios.Conditions;
using CG.Game.SpaceObjects;
using CG.Game.SpaceObjects.Controllers;
using CG.Input;
using CG.Network;
using CG.Ship.Hull;
using CG.Ship.Modules;
using CG.Space;
using Gameplay.Carryables;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
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.0.7.0")]
[assembly: AssemblyInformationalVersion("0.0.7+ffb28dea70ba5d2ed8eadf908d629ea3924db7ac")]
[assembly: AssemblyProduct("DelayedShards")]
[assembly: AssemblyTitle("Stores functional shards when inserted into the astral map, which may be activated on demand. Session Mod.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.7.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 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(new char[1] { ' ' })[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(new char[1] { ' ' })[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);
}
}
}
[BepInPlugin("18107.DelayedShards", "Delayed Shards", "0.0.7")]
[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!");
}
}
[HarmonyPatch(typeof(CarryablesSocket), "Start")]
internal class CarryablesSocketPatch
{
private static readonly FieldInfo closedBecauseInVoidField = AccessTools.Field(typeof(CarryablesSocket), "closedBecauseInVoid");
internal static CarryablesSocket GalaxyMapSocket;
internal static bool InVoid { get; private set; } = false;
private static void Prefix(CarryablesSocket __instance)
{
if (((Object)__instance).name == "GalaxyMapTerminal_SingleSocket")
{
GalaxyMapSocket = __instance;
__instance.ClosedWhileInVoid = false;
VoidJumpSystem component = ((Component)ClientGame.Current.PlayerShip).GetComponent<VoidJumpSystem>();
component.OnVoidEntered += PlayerShipEnteredVoid;
component.OnSectorEnter += OnPlayerShipSectorEnter;
}
}
internal static void ToggleQueue()
{
if (InVoid)
{
if (Configs.enableQueue.Value)
{
closedBecauseInVoidField.SetValue(GalaxyMapSocket, false);
GalaxyMapSocket.SetState((SocketState)1);
}
else
{
GalaxyMapSocket.SetState((SocketState)0);
closedBecauseInVoidField.SetValue(GalaxyMapSocket, true);
}
}
}
private static void OnPlayerShipSectorEnter(GameSessionSector sector)
{
InVoid = false;
if (!Configs.enableQueue.Value)
{
closedBecauseInVoidField.SetValue(GalaxyMapSocket, false);
GalaxyMapSocket.SetState((SocketState)1);
}
}
private static void PlayerShipEnteredVoid()
{
InVoid = true;
if (!Configs.enableQueue.Value)
{
GalaxyMapSocket.SetState((SocketState)0);
closedBecauseInVoidField.SetValue(GalaxyMapSocket, true);
}
}
}
[HarmonyPatch(typeof(Classifier), "OnTriggerConditionChanged")]
internal class ClassifierPatch
{
private static bool Prefix(Classifier __instance, AbstractScenarioClassifierCondition abstractScenarioClassifierCondition, bool value, ClassifierContext context)
{
if (!Configs.enableQueue.Value)
{
if (__instance.Id == "Generic_DataShard_OnInsert_SummonEscort" || __instance.Id == "Generic_DataShard_OnInsert_DataShard_SummonMinefield")
{
Helper.ShardInsertedActivated();
}
return true;
}
if (!value)
{
return true;
}
if (__instance.Id == "Generic_DataShard_OnInsert_SummonEscort")
{
__instance.HasBeenInvoked = true;
Helper.EscortsAvailable++;
ShardMessageHandler.SendShardCount();
return false;
}
if (__instance.Id == "Generic_DataShard_OnInsert_DataShard_SummonMinefield")
{
__instance.HasBeenInvoked = true;
Helper.MinefieldsAvailable++;
ShardMessageHandler.SendShardCount();
return false;
}
return true;
}
}
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);
}
}
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 const string EscortID = "Generic_DataShard_OnInsert_SummonEscort";
internal static AbstractScenarioClassifierAction[] EscortActions;
internal static int EscortsAvailable;
internal const string MinefieldID = "Generic_DataShard_OnInsert_DataShard_SummonMinefield";
internal static AbstractScenarioClassifierAction[] MinefieldActions;
internal static int MinefieldsAvailable;
private static float lastShardActivated;
internal static RejectReason SummonEscort()
{
if (EscortsAvailable <= 0)
{
return RejectReason.EscortShardCount;
}
if (Time.time - lastShardActivated < 8f)
{
return RejectReason.CooldownTimer;
}
if (IsInVoidJump())
{
return RejectReason.VoidJump;
}
ClassifierContext val = AbstractScenarioClassifierCondition.BuildContext((AbstractScenarioClassifierCondition)null, (Player)null, (IOrbitObject)(object)ClientGame.Current.PlayerShip, GameSessionManager.ActiveSector);
AbstractScenarioClassifierAction[] escortActions = EscortActions;
foreach (AbstractScenarioClassifierAction val2 in escortActions)
{
val2.Invoke(val);
}
EscortsAvailable--;
lastShardActivated = Time.time;
ShardMessageHandler.SendShardCount();
CheckPreventShardInsert();
return RejectReason.None;
}
internal static RejectReason SummonMinefield()
{
if (MinefieldsAvailable <= 0)
{
return RejectReason.MinefieldShardCount;
}
if (Time.time - lastShardActivated < 8f)
{
return RejectReason.CooldownTimer;
}
if (IsInVoidJump())
{
return RejectReason.VoidJump;
}
ClassifierContext val = AbstractScenarioClassifierCondition.BuildContext((AbstractScenarioClassifierCondition)null, (Player)null, (IOrbitObject)(object)ClientGame.Current.PlayerShip, GameSessionManager.ActiveSector);
AbstractScenarioClassifierAction[] minefieldActions = MinefieldActions;
foreach (AbstractScenarioClassifierAction val2 in minefieldActions)
{
val2.Invoke(val);
}
MinefieldsAvailable--;
lastShardActivated = Time.time;
ShardMessageHandler.SendShardCount();
CheckPreventShardInsert();
return RejectReason.None;
}
internal static void ShardInsertedActivated()
{
lastShardActivated = Time.time;
}
private static void CheckPreventShardInsert()
{
if (!Configs.enableQueue.Value)
{
CarryablesSocketPatch.GalaxyMapSocket.SetState((SocketState)0);
Tools.DelayDoUnique((object)CarryablesSocketPatch.GalaxyMapSocket, (Action)delegate
{
CarryablesSocketPatch.GalaxyMapSocket.SetState((SocketState)1);
}, 8000.0);
}
}
internal static void Reset()
{
EscortActions = null;
EscortsAvailable = 0;
MinefieldActions = null;
MinefieldsAvailable = 0;
ShardMessageHandler.subscribedPlayers = ShardMessageHandler.subscribedPlayers.Intersect(PhotonNetwork.PlayerListOthers).ToList();
ShardMessageHandler.SendShardCount();
}
internal static bool IsInPilotsSeat(Player player)
{
if (player == null)
{
return false;
}
ClientGame current = ClientGame.Current;
object obj;
if (current == null)
{
obj = null;
}
else
{
AbstractPlayerControlledShip playerShip = current.PlayerShip;
if (playerShip == null)
{
obj = null;
}
else
{
Helm module = playerShip.GetModule<Helm>();
obj = ((module != null) ? module.Chair : null);
}
}
TakeoverChair val = (TakeoverChair)((obj is TakeoverChair) ? obj : null);
return (Object)(object)val != (Object)null && !val.IsAvailable && player == ((MonoBehaviourPun)val).photonView.Owner;
}
internal static bool IsInVoidJump()
{
VoidJumpState activeState = ((Component)ClientGame.Current.PlayerShip).GetComponent<VoidJumpSystem>().ActiveState;
return activeState is VoidJumpInterdiction || activeState is VoidJumpTravellingStable || activeState is VoidJumpTravellingUnstable || activeState is VoidJumpApproachingDestination;
}
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 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");
}
}
}
[HarmonyPatch(typeof(AnalyticsManager), "SendGameSessionStart")]
internal class LoadShardDataPatch
{
private static readonly FieldInfo delayMsField = AccessTools.Field(typeof(Timer), "delayMs");
[HarmonyPostfix]
private static void LoadClassifiersPatch(string missionName)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
if (!(missionName == "HUB"))
{
BepinPlugin.Log.LogInfo((object)"Caching data after quest load");
Helper.EscortActions = GameSessionManager.ActiveSession.ActiveQuest.Classifiers.First((Classifier classi) => classi.Id == "Generic_DataShard_OnInsert_SummonEscort").Actions;
delayMsField.SetValue((object?)(Timer)Helper.EscortActions[0], 0);
delayMsField.SetValue((object?)(Timer)Helper.EscortActions[2], 2000);
Helper.MinefieldActions = GameSessionManager.ActiveSession.ActiveQuest.Classifiers.First((Classifier classi) => classi.Id == "Generic_DataShard_OnInsert_DataShard_SummonMinefield").Actions;
delayMsField.SetValue((object?)(Timer)Helper.MinefieldActions[0], 0);
delayMsField.SetValue((object?)(Timer)Helper.MinefieldActions[1], 8000);
}
}
}
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.0.7";
public const string PLUGIN_DESCRIPTION = "Stores functional shards when inserted into the astral map, which may be activated on demand. Session Mod.";
public const string PLUGIN_ORIGINAL_AUTHOR = "18107";
public const string PLUGIN_AUTHORS = "18107, Dragon";
public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Delayed_Shards";
}
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();
}
}
}
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.0.7")
{
BepinPlugin.Log.LogInfo((object)("Got version " + (string)arguments[0] + " from " + sender.NickName + ", expected version 0.0.7"));
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.0.7",
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.0.7",
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.0.7",
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.0.7",
Requests.Reject,
reason
}, false);
}
}
}
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. Session Mod.";
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();
};
}
}
}