Decompiled source of PitchDark v0.1.0

PitchDark.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BelowTheStone;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Rendering.Universal;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PitchDark")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PitchDark")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0EE86567-433B-4E34-97E6-FCBBC2423913")]
[assembly: AssemblyFileVersion("0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace PitchDark;

[HarmonyPatch]
public static class Patches
{
	[HarmonyPatch(typeof(PlayerObject), "Awake")]
	[HarmonyPostfix]
	public static void PlayerLightChange(PlayerObject __instance)
	{
		GameObject val = GameObject.Find("Player Lamp");
		if (Object.op_Implicit((Object)(object)val))
		{
			Light2D[] componentsInChildren = val.GetComponentsInChildren<Light2D>();
			foreach (Light2D val2 in componentsInChildren)
			{
				val2.pointLightInnerRadius = Plugin.playerLightInnerRadius.Value;
				val2.pointLightOuterRadius = Mathf.Max(Plugin.playerLightInnerRadius.Value, Plugin.playerLightOuterRadius.Value);
			}
		}
	}

	[HarmonyPatch(typeof(PlacedEntity), "Awake")]
	[HarmonyPatch(typeof(EquippedItem), "Awake")]
	[HarmonyPostfix]
	public static void TorchLightChange(PlacedEntity __instance)
	{
		if (((Object)__instance).name == "torch_placed(Clone)" || ((Object)__instance).name == "placeable_item_prefab_torch(Clone)")
		{
			Light2D[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Light2D>();
			foreach (Light2D val in componentsInChildren)
			{
				val.pointLightInnerRadius = Plugin.torchLightInnerRadius.Value;
				val.pointLightOuterRadius = Mathf.Max(Plugin.torchLightInnerRadius.Value, Plugin.torchLightOuterRadius.Value);
			}
		}
	}
}
[BepInPlugin("com.maxsch.BelowTheStone.PitchDark", "Pitch Dark", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.maxsch.BelowTheStone.PitchDark";

	public const string PluginName = "Pitch Dark";

	public const string PluginVersion = "0.1.0";

	public static ConfigEntry<float> playerLightInnerRadius;

	public static ConfigEntry<float> playerLightOuterRadius;

	public static ConfigEntry<float> torchLightInnerRadius;

	public static ConfigEntry<float> torchLightOuterRadius;

	public static ManualLogSource Log { get; private set; }

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("com.maxsch.BelowTheStone.PitchDark");
		val.PatchAll();
		AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(0f, 25f);
		playerLightInnerRadius = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "Player Inner Light Radius", 0.5f, new ConfigDescription("The inner radius of the player's light", (AcceptableValueBase)null, new object[1] { val2 }));
		playerLightOuterRadius = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "Player Outer Light Radius", 2f, new ConfigDescription("The outer radius of the player's light", (AcceptableValueBase)null, new object[1] { val2 }));
		torchLightInnerRadius = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "Torch Inner Light Radius", 0.5f, new ConfigDescription("The inner radius of player placed torch lights", (AcceptableValueBase)null, new object[1] { val2 }));
		torchLightOuterRadius = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "Torch Outer Light Radius", 5f, new ConfigDescription("The outer radius of player placed torch lights", (AcceptableValueBase)null, new object[1] { val2 }));
	}
}