Decompiled source of PitchBlack v1.1.0

PitchBlack.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using Zorro.Settings;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PitchBlack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PitchBlack")]
[assembly: AssemblyTitle("PitchBlack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace PitchBlack
{
	[BepInPlugin("arargd.bepinex.pitchblack", "pitchblack", "1.1.0")]
	public class Main : BaseUnityPlugin
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class SettingsSetup
		{
			public static void Postfix(SettingsHandler __instance)
			{
				Setting val = (Setting)(object)new LightGainSetting();
				__instance.settings.Add(val);
				val.Load(__instance._settingsSaveLoad);
				val.ApplyValue();
			}
		}

		[HarmonyPatch(typeof(LightToggler), "Check")]
		public class DarkPatch
		{
			public static void Postfix(LightToggler __instance)
			{
				try
				{
					if (!((Object)((Component)__instance.light).transform.parent).name.Contains("Mesh"))
					{
						((Behaviour)__instance.light).enabled = false;
						((Component)((Component)__instance.light).transform.parent).gameObject.SetActive(false);
					}
				}
				catch
				{
					((Behaviour)__instance.light).enabled = false;
				}
			}
		}

		[HarmonyPatch(typeof(Level), "SetupFinished")]
		public class LightsAndGamma
		{
			public static void Postfix()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				Scene activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name == "HarborScene"))
				{
					activeScene = SceneManager.GetActiveScene();
					if (!(((Scene)(ref activeScene)).name == "FactoryScene"))
					{
						PostVolumeHandler val = Object.FindObjectOfType<PostVolumeHandler>();
						((VolumeParameter<Vector4>)(object)val.m_lightGammaGain.gain).value = new Vector4(1f, 1f, 1f, 0f);
						((VolumeParameter<Vector4>)(object)val.m_lightGammaGain.gamma).value = new Vector4(1f, 1f, 1f, 0f);
						return;
					}
				}
				ApplyLightGain();
				(from obj in Object.FindObjectsOfType<Transform>()
					where ((Object)obj).name.Contains("Factory_Light")
					select obj).ToList().ForEach(delegate(Transform obj)
				{
					((Component)obj).gameObject.SetActive(false);
				});
			}
		}

		public class LightGainSetting : FloatSetting, IExposedSetting
		{
			public override void ApplyValue()
			{
				Debug.LogError((object)"Applying light gain value!");
				LightGain.Value = ((FloatSetting)this).Value;
				ApplyLightGain();
			}

			protected override float GetDefaultValue()
			{
				return -0.3f;
			}

			protected override float2 GetMinMaxValue()
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				return new float2(-1f, 1f);
			}

			public SettingCategory GetSettingCategory()
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return (SettingCategory)0;
			}

			public string GetDisplayName()
			{
				return "Light Gain";
			}
		}

		public static ConfigEntry<float> LightGain;

		public void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			LightGain = ((BaseUnityPlugin)this).Config.Bind<float>("SETTINGS", "lightgain", -0.3f, "Adjusts the light gain, negative for darker lighting and positive for brighter. Generally stay in the -1 to 1 range.");
			Harmony val = new Harmony("arargdPitchBlack");
			val.PatchAll();
			Debug.Log((object)"PitchBlack Loaded Successfully, I hope!");
		}

		public static void ApplyLightGain()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name == "HarborScene"))
			{
				activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name == "FactoryScene"))
				{
					return;
				}
			}
			PostVolumeHandler val = Object.FindObjectOfType<PostVolumeHandler>();
			((VolumeParameter<Vector4>)(object)val.m_lightGammaGain.gain).value = new Vector4(1f, 1f, 1f, LightGain.Value);
			((VolumeParameter<Vector4>)(object)val.m_lightGammaGain.gamma).value = new Vector4(1f, 1f, 1f, LightGain.Value);
		}
	}
}