Decompiled source of NoobFlashlight v1.1.0

NoobFlashlight.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoobFoots")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoobFoots")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("640e8c95-dc1a-4e64-864f-78190efa6d9a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NoobFlashlight;

[BepInPlugin("com.noobfly.Flashlight", "FlashLight", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Logger;

	internal static Scene currentScene;

	internal static MainCamera mainCamera;

	private static GameObject flashlightObject;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		SceneManager.sceneLoaded += OnSceneLoaded;
		Logger.LogInfo((object)"Loaded FlashLight");
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode _)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		currentScene = scene;
		if ((Object)(object)flashlightObject != (Object)null)
		{
			Object.Destroy((Object)(object)flashlightObject);
			flashlightObject = null;
		}
		mainCamera = null;
	}

	private void Update()
	{
		if (((Scene)(ref currentScene)).name == null || !((Scene)(ref currentScene)).name.StartsWith("Level_"))
		{
			return;
		}
		if ((Object)(object)mainCamera == (Object)null)
		{
			mainCamera = Object.FindFirstObjectByType<MainCamera>();
			if ((Object)(object)mainCamera == (Object)null)
			{
				return;
			}
		}
		if ((Object)(object)flashlightObject == (Object)null)
		{
			InitializeFlashlight();
		}
		CheckHotkeys();
	}

	private void InitializeFlashlight()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		flashlightObject = new GameObject("NoobFlashlightObject");
		flashlightObject.transform.SetParent(((Component)mainCamera).transform, false);
		flashlightObject.transform.localPosition = Vector3.zero;
		flashlightObject.transform.localRotation = Quaternion.identity;
		Light val = flashlightObject.AddComponent<Light>();
		val.type = (LightType)0;
		val.range = 50f;
		val.spotAngle = 60f;
		val.intensity = 2f;
		val.color = Color.yellow;
		val.shadows = (LightShadows)2;
		flashlightObject.SetActive(false);
		Logger.LogInfo((object)"Flashlight created and attached to camera.");
	}

	private void CheckHotkeys()
	{
		if (Input.GetKeyDown((KeyCode)108) && (Object)(object)flashlightObject != (Object)null)
		{
			bool activeSelf = flashlightObject.activeSelf;
			flashlightObject.SetActive(!activeSelf);
			Logger.LogInfo((object)("Flashlight " + (activeSelf ? "DISABLED" : "ENABLED")));
		}
	}
}