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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("RED")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OnlyHostShopkeeperSwitch")] [assembly: AssemblyTitle("OnlyHostShopkeeperSwitch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 OnlyHostShopkeeperSwitch { [BepInPlugin("com.red.OnlyHostShopkeeperSwitch", "OnlyHostShopkeeperSwitch", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "com.red.OnlyHostShopkeeperSwitch"; public const string Name = "OnlyHostShopkeeperSwitch"; public const string Version = "1.0.0"; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.red.OnlyHostShopkeeperSwitch").PatchAll(); Log.LogInfo((object)"OnlyHostShopkeeperSwitch v1.0.0 loaded."); } } } namespace OnlyHostShopkeeperSwitch.Patches { [HarmonyPatch(typeof(ShopKeeper))] internal static class ShopKeeperPatches { private static bool _hostPressInFlight; private static PhysGrabObjectGrabArea _switchGrabArea; [HarmonyPrefix] [HarmonyPatch("WakeUpOrSleepLogic")] private static bool OnlyLocalPress(ShopKeeper __instance) { if (!SemiFunc.IsMultiplayer()) { _hostPressInFlight = true; return true; } if ((Object)(object)_switchGrabArea == (Object)null && (Object)(object)__instance.OnOffSwitch != (Object)null) { _switchGrabArea = __instance.OnOffSwitch.GetComponentInChildren(); } if ((Object)(object)_switchGrabArea == (Object)null) { Plugin.Log.LogWarning((object)"[OHSS] switch grab area not resolvable; blocking press"); return false; } PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null) { return false; } if (!_switchGrabArea.listOfAllGrabbers.Contains(instance)) { Plugin.Log.LogInfo((object)"[OHSS] non-host press blocked"); return false; } _hostPressInFlight = true; return true; } [HarmonyPostfix] [HarmonyPatch("WakeUpOrSleepLogic")] private static void CloseWindow() { _hostPressInFlight = false; } [HarmonyPrefix] [HarmonyPatch("WakeUpRPC")] private static bool GateWakeUp() { if (SemiFunc.IsMultiplayer()) { return _hostPressInFlight; } return true; } [HarmonyPrefix] [HarmonyPatch("SleepRPC")] private static bool GateSleep() { if (SemiFunc.IsMultiplayer()) { return _hostPressInFlight; } return true; } } }