using System;
using System.Diagnostics;
using System.IO;
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 PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LightsOut")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1c0020d9fe4b6e1bd2935e1da909bdc9963c6318")]
[assembly: AssemblyProduct("LightsOut")]
[assembly: AssemblyTitle("LightsOut")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 Lights_Out
{
public class Configs
{
public static PluginConfigurator config;
public static BoolField enabler;
public static BoolField flashlightenabler;
public static IntField flashlightsize;
public static IntField flashlightstrength;
public static IntField flashlightrange;
public static Light flashlight;
public static bool inwater;
public static bool waterseen;
public static IntField flashlightbreaker;
public static BoolField laserpointer;
public static void createConfig()
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
config = PluginConfigurator.Create("Lights Out", "Lights_Out_GUID");
config.SetIconWithURL(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "icon.png"));
enabler = new BoolField(config.rootPanel, "Enabled", "enabler", true);
flashlightsize = new IntField(config.rootPanel, "Flashlight Size", "flashlightsize", 50, 20, 200);
flashlightrange = new IntField(config.rootPanel, "Flashlight Range", "flashlightrange", 100, 10, 500);
flashlightstrength = new IntField(config.rootPanel, "Flashlight Strength", "flashlightstrength", 2, 0, 10);
flashlightbreaker = new IntField(config.rootPanel, "Flashlight Breaking Chance", "flashlightbreaker", 0, 0, 100);
laserpointer = new BoolField(config.rootPanel, "Laser Pointer", "laserpointer", false);
flashlightenabler = new BoolField(config.rootPanel, "Nightmare mode", "flashlightenabler", false);
}
}
[HarmonyPatch]
public static class Patches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(LimboSkybox), "OnEnable")]
public static void MakeLimboSkyGoByeByte(LimboSkybox __instance)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
if (Configs.enabler.value)
{
Transform parent = ((Component)__instance).transform.parent;
Transform val = ((parent != null) ? parent.Find("SkySphere") : null);
if ((Object)(object)val != (Object)null)
{
Material material = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).material;
material.SetColor("_Tint", new Color(0f, 0f, 0f));
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(RenderSettings), "set_fogColor")]
public static void MakeFogDarker(ref Color value)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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)
if (Configs.enabler.value)
{
value /= 64f;
}
}
}
[BepInPlugin("lotus.ultrakill.Lights_Out", "Lights_Out", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static Plugin Instance;
public ManualLogSource log => ((BaseUnityPlugin)this).Logger;
public void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Killed the Lights");
SceneManager.sceneLoaded += delegate
{
OnSceneLoaded();
};
new Harmony("lights_out").PatchAll();
Configs.createConfig();
}
public void OnSceneLoaded()
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
if (!Configs.enabler.value || SceneHelper.CurrentScene == "Level 0-S" || SceneHelper.CurrentScene == "Level 4-3")
{
return;
}
Light[] array = Object.FindObjectsOfType<Light>(true);
Light[] array2 = array;
foreach (Light val in array2)
{
if (!Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<Enemy>(true)) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<Torch>(true)) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<Skull>(true)))
{
val.intensity = 0f;
val.range = 0f;
val.renderingLayerMask = 0;
val.cullingMask = 0;
}
}
if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null)
{
return;
}
MonoSingleton<CameraController>.Instance.cam.clearFlags = (CameraClearFlags)2;
MonoSingleton<CameraController>.Instance.cam.backgroundColor = Color.black;
RenderSettings.fogColor /= 1.001f;
if (Configs.flashlightenabler.value || SceneHelper.CurrentScene == "Level 4-3")
{
return;
}
Light val2 = (Configs.flashlight = ((Component)MonoSingleton<CameraController>.Instance).gameObject.AddComponent<Light>());
((Component)val2).gameObject.AddComponent<PortalAwareLight>();
val2.type = (LightType)0;
val2.spotAngle = Configs.flashlightsize.value;
val2.intensity = Configs.flashlightstrength.value;
val2.range = Configs.flashlightrange.value;
if (Configs.laserpointer.value)
{
Configs.flashlight.intensity = 4f;
Configs.flashlight.spotAngle = 25f;
Configs.flashlight.range = 50f;
if (Configs.flashlight.intensity > 2f)
{
Configs.flashlight.intensity = 2f;
}
if (Configs.flashlight.spotAngle > 25f)
{
Configs.flashlight.spotAngle = 25f;
}
if (Configs.flashlight.range > 50f)
{
Configs.flashlight.range = 50f;
}
}
if (Random.Range(0, 100) < Configs.flashlightbreaker.value)
{
Configs.flashlight.intensity = 0f;
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Flashlight broken", "", "", 0, false, false, true);
}
if (SceneHelper.CurrentScene == "Level 4-2")
{
HurtZone val3 = Object.FindObjectOfType<HurtZone>(true);
Object.Destroy((Object)(object)val3);
}
if (SceneHelper.CurrentScene == "Level 5-1")
{
CausticVolume[] array3 = Object.FindObjectsOfType<CausticVolume>(true);
CausticVolume[] array4 = array3;
foreach (CausticVolume val4 in array4)
{
val4.intensity = 0f;
}
}
}
public void Update()
{
if (!Configs.enabler.value || !Object.op_Implicit((Object)(object)Configs.flashlight) || !Object.op_Implicit((Object)(object)MonoSingleton<NewMovement>.Instance))
{
return;
}
Light flashlight = Configs.flashlight;
NewMovement instance = MonoSingleton<NewMovement>.Instance;
((Behaviour)flashlight).enabled = instance != null && instance.touchingWaters.Count == 0;
if (((Behaviour)Configs.flashlight).enabled != Configs.inwater)
{
Configs.inwater = ((Behaviour)Configs.flashlight).enabled;
if (!Configs.inwater && !Configs.waterseen)
{
MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Flashlight disables itself while in liquid.", "", "", 0, false, false, true);
Configs.waterseen = true;
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}