using System; using System.Collections.Generic; 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 GeneralImprovements.Items; using HarmonyLib; using LightsOut.Patches; 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: AssemblyCompany("LightsOut")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A template for Lethal Company")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1+f8e310059a99cc28744a17ef8ec074061c9d359a")] [assembly: AssemblyProduct("LightsOut")] [assembly: AssemblyTitle("LightsOut")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 LightsOut { public static class LightSourceToggle { public static void Disable(GrabbableObject item, bool stopAudio = false) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if (!ShouldReturn(item)) { Plugin.Logger.LogDebug((object)("Disabling light of " + item.itemProperties.itemName)); CollectionExtensions.Do((IEnumerable)((Component)item).GetComponentsInChildren(), (Action)delegate(Light l) { ((Behaviour)l).enabled = false; }); if ("LungProp" == item.__getTypeName() && stopAudio) { Plugin.Logger.LogDebug((object)"Disabling sound of LungProp"); LungProp val = (LungProp)item; val.isLungDocked = false; val.isLungDockedInElevator = false; val.isLungPowered = false; ((Component)val).GetComponent().Stop(); } if (item.__getTypeName() == "ToggleableFancyLamp") { GeneralImprovementsPatch.DisableGILamp(item); } } } public static void Enable(GrabbableObject item) { if (!ShouldReturn(item)) { Plugin.Logger.LogDebug((object)("Enabling light of " + item.itemProperties.itemName)); CollectionExtensions.Do((IEnumerable)((Component)item).GetComponentsInChildren(), (Action)delegate(Light l) { ((Behaviour)l).enabled = true; }); if (item.__getTypeName() == "ToggleableFancyLamp") { GeneralImprovementsPatch.EnableGILamp(item); } } } private static bool ShouldReturn(GrabbableObject item) { if (!item.isInShipRoom) { Plugin.Logger.LogDebug((object)(item.__getTypeName() + " is not in ship room")); return true; } if (item.__getTypeName() != "PhysicsProp" && item.__getTypeName() != "LungProp" && item.__getTypeName() != "ToggleableFancyLamp") { Plugin.Logger.LogDebug((object)(item.__getTypeName() + " is not a predefined type")); return true; } if ((Object)(object)((Component)item).GetComponentInChildren() == (Object)null) { Plugin.Logger.LogDebug((object)(item.__getTypeName() + " has no light")); return true; } return false; } } [BepInPlugin("mrov.LightsOut", "LightsOut", "0.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "mrov.LightsOut"); Logger.LogInfo((object)"Plugin mrov.LightsOut 0.2.1 is loaded!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "mrov.LightsOut"; public const string PLUGIN_NAME = "LightsOut"; public const string PLUGIN_VERSION = "0.2.1"; } } namespace LightsOut.Patches { internal class GeneralImprovementsPatch { public static void DisableGILamp(GrabbableObject lamp) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown try { ToggleableFancyLamp val = (ToggleableFancyLamp)lamp; ((GrabbableObject)val).ItemActivate(false, false); ((GrabbableObject)val).isBeingUsed = false; } catch { Plugin.Logger.LogWarning((object)"Failed to disable GI lamp"); } } public static void EnableGILamp(GrabbableObject lamp) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown try { ToggleableFancyLamp val = (ToggleableFancyLamp)lamp; ((GrabbableObject)val).ItemActivate(true, false); ((GrabbableObject)val).isBeingUsed = true; } catch { Plugin.Logger.LogWarning((object)"Failed to enable GI lamp"); } } } [HarmonyPatch(typeof(GrabbableObject))] public static class GrabbableObjectPatch { [HarmonyPatch("DiscardItem")] [HarmonyPostfix] public static void DiscardItemClientRpc(GrabbableObject __instance) { Plugin.Logger.LogDebug((object)("DiscardItem " + __instance.itemProperties.itemName)); if (__instance.isInShipRoom) { LightSourceToggle.Disable(__instance, stopAudio: true); } } [HarmonyPatch("GrabItem")] [HarmonyPostfix] public static void GrabClientRpc(GrabbableObject __instance) { Plugin.Logger.LogDebug((object)("GrabItem " + __instance.itemProperties.itemName)); LightSourceToggle.Enable(__instance); } } [HarmonyPatch(typeof(StartOfRound))] public static class LoadItemPatch { [HarmonyPatch("LoadShipGrabbableItems")] [HarmonyPostfix] public static void ServerTurnOffLights() { GameObject val = GameObject.Find("/Environment/HangarShip"); GrabbableObject[] componentsInChildren = val.GetComponentsInChildren(); GrabbableObject[] array = componentsInChildren; foreach (GrabbableObject item in array) { LightSourceToggle.Disable(item, stopAudio: true); } } [HarmonyPatch("SyncShipUnlockablesClientRpc")] [HarmonyPostfix] public static void ClientTurnOffLights() { GameObject val = GameObject.Find("/Environment/HangarShip"); GrabbableObject[] componentsInChildren = val.GetComponentsInChildren(); GrabbableObject[] array = componentsInChildren; foreach (GrabbableObject item in array) { LightSourceToggle.Disable(item, stopAudio: true); } } } [HarmonyPatch(typeof(StartOfRound))] public static class SetShipReadyToLandPatch { [HarmonyPatch("SetShipReadyToLand")] [HarmonyPostfix] public static void TurnOffLights() { GameObject val = GameObject.Find("/Environment/HangarShip"); GrabbableObject[] componentsInChildren = val.GetComponentsInChildren(); GrabbableObject[] array = componentsInChildren; foreach (GrabbableObject item in array) { LightSourceToggle.Disable(item, stopAudio: true); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }