using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HostPermissions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HostPermissions")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d5de1d1a-86a6-483e-afee-ff3ddf8168d6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HostPermissions;
public static class Constants
{
public const string GUID = "SomethingGemstone.HostPermissions";
public const string NAME = "Host Permissions";
public const string VERSION = "1.0.2.0";
}
[BepInPlugin("SomethingGemstone.HostPermissions", "Host Permissions", "1.0.2.0")]
public class Base : BaseUnityPlugin
{
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
Harmony val = new Harmony("SomethingGemstone.HostPermissions");
Logger.CreateLogSource("SomethingGemstone.HostPermissions").LogInfo((object)"Commencing Operation Obstruction of Chaos...");
val.PatchAll(typeof(BuildPatch));
val.PatchAll(typeof(LightSwitchPatch));
}
}
[HarmonyPatch(typeof(ShipLights))]
internal class LightSwitchPatch
{
[HarmonyPatch("ToggleShipLights")]
[HarmonyPrefix]
private static bool patchLightSwitchPermissions(ShipLights __instance)
{
if (!((NetworkBehaviour)__instance).NetworkManager.IsHost)
{
return !__instance.areLightsOn;
}
return true;
}
}
[HarmonyPatch(typeof(ShipBuildModeManager))]
internal class BuildPatch
{
[HarmonyPatch("PlayerMeetsConditionsToBuild")]
[HarmonyPostfix]
private static bool patchBuildPermissions(bool __result, ref PlayerControllerB ___player)
{
return ___player.isHostPlayerObject && __result;
}
}