Decompiled source of GlowstickAdjustment v1.0.0

GlowstickAdjustment.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GlowstickAdjustment")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GlowstickAdjustment")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8FE07F01-FE6F-4A2B-978A-566F3574BE38")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GlowstickAdjustment;

[BepInPlugin("Mhz.GlowstickAdjustment", "GlowstickAdjustment", "1.0.0")]
public class Justment : BaseUnityPlugin
{
	[HarmonyPatch(typeof(GlowstickItem), "Start")]
	public static class GlowstickAdjustmentPatch
	{
		[HarmonyPostfix]
		public static void AdjustGlowstickLight(GlowstickItem __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				Light component = ((Component)__instance).GetComponent<Light>();
				if ((Object)(object)component != (Object)null)
				{
					component.intensity = _intensityConfig.Value;
					Debug.LogWarning((object)$"调整为{component.intensity}");
				}
				else
				{
					Debug.LogError((object)"没有灯组件");
				}
			}
			else
			{
				Debug.LogError((object)"没有这对象");
			}
		}
	}

	private static Harmony _harmony;

	private static ConfigEntry<float> _intensityConfig;

	private void Awake()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		if (_harmony == null)
		{
			_harmony = new Harmony("Mhz.GlowstickAdjustment");
		}
		_intensityConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Intensity", 2f, "Glowstick light intensity");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"荧光棒亮度调整加载成功!");
	}
}