using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("JammedControls")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JammedControls")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("db9d32b6-5ff0-4d86-b3cc-54e53aab5620")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JammedControls
{
[BepInPlugin("Snowlance.JammedControls", "JammedControls", "1.0.0")]
public class JammedControlsBase : BaseUnityPlugin
{
private const string modGUID = "Snowlance.JammedControls";
private const string modName = "JammedControls";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Snowlance.JammedControls");
public static JammedControlsBase PluginInstance;
public static ConfigEntry<bool> configRestrictTeleporter;
public static ConfigEntry<bool> configRestrictInverseTeleporter;
public static ConfigEntry<bool> configRestrictLever;
public static ManualLogSource LoggerInstance { get; private set; }
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if ((Object)PluginInstance == (Object)null)
{
PluginInstance = this;
}
LoggerInstance = ((BaseUnityPlugin)this).Logger;
LoggerInstance.LogInfo((object)"Plugin JammedControls loaded successfully.");
configRestrictTeleporter = ((BaseUnityPlugin)PluginInstance).Config.Bind<bool>("Restrictions", "Teleporter", true, "Restrict the use of the teleporter");
configRestrictInverseTeleporter = ((BaseUnityPlugin)PluginInstance).Config.Bind<bool>("Restrictions", "InverseTeleporter", true, "Restrict the use of the inverse teleporter");
configRestrictLever = ((BaseUnityPlugin)PluginInstance).Config.Bind<bool>("Restrictions", "Lever", true, "Restrict the use of the lever");
harmony.PatchAll();
}
}
}
namespace JammedControls.Patches
{
[HarmonyPatch]
internal class ShipTeleporterPatch
{
[HarmonyPatch(typeof(ShipTeleporter), "PressTeleportButtonOnLocalClient")]
[HarmonyPrefix]
private static bool PressTeleportButtonOnLocalClientPatch(ShipTeleporter __instance)
{
if (__instance.isInverseTeleporter && JammedControlsBase.configRestrictInverseTeleporter.Value && !GameNetworkManager.Instance.isHostingGame)
{
HUDManager.Instance.DisplayTip("Its jammed!", "Only the host can use this...", false, false, "LC_Tip1");
return false;
}
if (JammedControlsBase.configRestrictTeleporter.Value && !GameNetworkManager.Instance.isHostingGame)
{
HUDManager.Instance.DisplayTip("Its jammed!", "Only the host can use this...", false, false, "LC_Tip1");
return false;
}
return true;
}
}
[HarmonyPatch]
internal class StartMatchLeverPatch
{
[HarmonyPatch(typeof(StartMatchLever), "PullLever")]
[HarmonyPrefix]
private static bool PullLeverPatch(StartMatchLever __instance)
{
if (!GameNetworkManager.Instance.isHostingGame && JammedControlsBase.configRestrictLever.Value)
{
HUDManager.Instance.DisplayTip("Its jammed!", "Only the host can use this...", false, false, "LC_Tip1");
return false;
}
return true;
}
}
}