using System;
using System.Diagnostics;
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.Client.Player.Interactions;
using CG.Game.Player;
using CG.Input;
using CG.Ship.Modules;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UI;
using UI.PilotHUD;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
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("PilotHUD")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Displays the pilot HUD when the helm is powered. Client side.")]
[assembly: AssemblyFileVersion("0.0.4.0")]
[assembly: AssemblyInformationalVersion("0.0.4+a06c9dcd44dea4eb96f26ca493f464c7ca2bec7e")]
[assembly: AssemblyProduct("PilotHUD")]
[assembly: AssemblyTitle("Displays the pilot HUD when the helm is powered.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.4.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 PilotHUD
{
[BepInPlugin("18107.PilotHUD", "Pilot HUD", "0.0.4")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BepinPlugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.PilotHUD");
Configs.Load(this);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.PilotHUD is loaded!");
}
}
internal class Configs
{
internal static ConfigEntry<bool> HUDVisible;
internal static ConfigEntry<KeyCode> ToggleHUDKeybindConfig;
internal static ConfigEntry<bool> DisableHUDOfflineEffects;
internal static void Load(BepinPlugin plugin)
{
HUDVisible = ((BaseUnityPlugin)plugin).Config.Bind<bool>("PilotHUD", "HUDVisible", true, (ConfigDescription)null);
ToggleHUDKeybindConfig = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("PilotHUD", "ToggleHUD", (KeyCode)0, (ConfigDescription)null);
DisableHUDOfflineEffects = ((BaseUnityPlugin)plugin).Config.Bind<bool>("PilotHUD", "HUDOfflineEffects", true, "Disables blinking 'Wayfinder Offline' text when helm is offline.");
}
}
internal class GUI : ModSettingsMenu
{
public override string Name()
{
return "Pilot HUD";
}
public override void Draw()
{
if (GUITools.DrawCheckbox("Pilot HUD", ref Configs.HUDVisible))
{
PilotHUDDisplayerPatch.UpdateHUD();
}
if (GUITools.DrawCheckbox("Disable blinking 'Wayfinder Offline' text", ref Configs.DisableHUDOfflineEffects))
{
PilotHUD pilotHUD = PilotHUDPowerDisplayerPatch.PilotHUD;
pilotHUD.PowerChanged(((ChangeResponsive<bool>)(object)((CellModule)pilotHUD.helm).PowerDrain.IsOn).Value);
}
GUITools.DrawChangeKeybindButton("Change Toggle HUD Keybind", ref Configs.ToggleHUDKeybindConfig);
}
}
public class MyPluginInfo
{
public const string PLUGIN_GUID = "18107.PilotHUD";
public const string PLUGIN_NAME = "PilotHUD";
public const string USERS_PLUGIN_NAME = "Pilot HUD";
public const string PLUGIN_VERSION = "0.0.4";
public const string PLUGIN_DESCRIPTION = "Displays the pilot HUD when the helm is powered.";
public const string PLUGIN_ORIGINAL_AUTHOR = "18107";
public const string PLUGIN_AUTHORS = "18107";
public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Pilot_HUD";
}
[HarmonyPatch(typeof(PilotHUD), "InteractionModeChanged")]
internal class PilotHUDDisplayerPatch
{
private static void Prefix(ref InteractionMode newMode)
{
if (Configs.HUDVisible.Value && !((Enum)newMode).HasFlag((Enum)(object)(InteractionMode)131072))
{
newMode = (InteractionMode)((uint)newMode | 0x401000u);
}
}
internal static void UpdateHUD()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
ViewEventBus.Instance?.OnInteractionModeChanged.Publish(LocalPlayer.Instance.InteractionState.ActiveModes);
}
}
[HarmonyPatch(typeof(PilotHUD), "PowerChanged")]
internal class PilotHUDPowerDisplayerPatch
{
internal static PilotHUD PilotHUD;
private static void Postfix(PilotHUD __instance, bool powerOn)
{
PilotHUD = __instance;
if (!powerOn && Configs.DisableHUDOfflineEffects.Value)
{
UItoolkitExtensionMethods.SetDisplay(__instance.poweredOffRootVE, false);
UItoolkitExtensionMethods.StopRepeatBlink(__instance.powerStatusVE, __instance.blinkingElements);
}
}
}
public class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)8;
public override string Author => "18107";
public override string Description => "Displays the pilot HUD when the helm is powered.";
public override string ThunderstoreID => "VoidCrewModdingTeam/Pilot_HUD";
public VoidManagerPlugin()
{
Events.Instance.LateUpdate += delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if ((int)Configs.ToggleHUDKeybindConfig.Value != 0 && UnityInput.Current.GetKeyDown(Configs.ToggleHUDKeybindConfig.Value) && !ServiceBase<InputService>.Instance.CursorVisibilityControl.IsCursorShown)
{
Configs.HUDVisible.Value = !Configs.HUDVisible.Value;
PilotHUDDisplayerPatch.UpdateHUD();
}
};
}
}
}