Decompiled source of ProFlashlightPlus v1.0.3

vegemike.ProFlashlightPlus.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
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 UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("vegemike")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ProFlashlightPlus")]
[assembly: AssemblyTitle("vegemike.ProFlashlightPlus")]
[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 ProFlashlightPlus
{
	[BepInPlugin("vegemike.ProFlashlightPlus", "ProFlashlightPlus", "1.0.0")]
	public class ProFlashlightPlus : BaseUnityPlugin
	{
		internal static bool UIOpen = false;

		internal const float DefaultIntensityValue = 100f;

		internal const float DefaultAngleValue = 60f;

		internal const float DefaultR = 1f;

		internal const float DefaultG = 1f;

		internal const float DefaultB = 1f;

		internal const bool DefaultStrobe = false;

		internal const float DefaultSpeed = 1f;

		internal static float IntensityValue = 100f;

		internal static float AngleValue = 60f;

		internal static float RValue = 1f;

		internal static float GValue = 1f;

		internal static float BValue = 1f;

		internal static bool StrobeEnabled = false;

		internal static float SpeedValue = 1f;

		internal static ManualLogSource Logger { get; private set; } = null;


		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"ProFlashlightPlus Awake – subscribing to sceneLoaded.");
			Harmony val = new Harmony("vegemike.ProFlashlightPlus");
			val.PatchAll();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			Logger.LogInfo((object)("Scene '" + ((Scene)(ref scene)).name + "' loaded – spawning UI now"));
			GameObject val = new GameObject("ProFlashlightUI");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<FlashlightUI>();
			Logger.LogInfo((object)"FlashlightUI component attached.");
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}
	}
	public class FlashlightUI : MonoBehaviour
	{
		private Rect _windowRect;

		private const int WindowId = 123456;

		private void Start()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			float num = 500f;
			float num2 = 350f;
			_windowRect = new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2);
		}

		private void Update()
		{
			Keyboard current = Keyboard.current;
			if (current != null && ((ButtonControl)current.f8Key).wasPressedThisFrame)
			{
				ProFlashlightPlus.UIOpen = !ProFlashlightPlus.UIOpen;
				Cursor.visible = ProFlashlightPlus.UIOpen;
				Cursor.lockState = (CursorLockMode)((!ProFlashlightPlus.UIOpen) ? 1 : 0);
				Debug.Log((object)$"[FlashlightUI] F8 pressed — UIOpen = {ProFlashlightPlus.UIOpen}");
			}
		}

		private void OnGUI()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (ProFlashlightPlus.UIOpen)
			{
				_windowRect = GUI.ModalWindow(123456, _windowRect, new WindowFunction(DrawWindow), "Flashlight Control");
			}
		}

		private void DrawWindow(int id)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			float width = ((Rect)(ref _windowRect)).width;
			float height = ((Rect)(ref _windowRect)).height;
			if (GUI.Button(new Rect(width - 28f, 4f, 24f, 24f), "X"))
			{
				ProFlashlightPlus.UIOpen = false;
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
			}
			GUI.Label(new Rect(10f, 40f, 140f, 20f), "Intensity (0–2500):");
			float num = GUI.HorizontalSlider(new Rect(160f, 45f, width - 180f, 20f), ProFlashlightPlus.IntensityValue, 0f, 2500f);
			if (!Mathf.Approximately(num, ProFlashlightPlus.IntensityValue))
			{
				ProFlashlightPlus.IntensityValue = num;
			}
			GUI.Label(new Rect(10f, 80f, 140f, 20f), "Spread (°):");
			float num2 = GUI.HorizontalSlider(new Rect(160f, 85f, width - 180f, 20f), ProFlashlightPlus.AngleValue, 5f, 160f);
			if (!Mathf.Approximately(num2, ProFlashlightPlus.AngleValue))
			{
				ProFlashlightPlus.AngleValue = num2;
			}
			GUI.Label(new Rect(10f, 120f, 140f, 20f), "Color - R:");
			float num3 = GUI.HorizontalSlider(new Rect(160f, 125f, width - 180f, 20f), ProFlashlightPlus.RValue, 0f, 1f);
			if (!Mathf.Approximately(num3, ProFlashlightPlus.RValue))
			{
				ProFlashlightPlus.RValue = num3;
			}
			GUI.Label(new Rect(10f, 160f, 140f, 20f), "Color - G:");
			float num4 = GUI.HorizontalSlider(new Rect(160f, 165f, width - 180f, 20f), ProFlashlightPlus.GValue, 0f, 1f);
			if (!Mathf.Approximately(num4, ProFlashlightPlus.GValue))
			{
				ProFlashlightPlus.GValue = num4;
			}
			GUI.Label(new Rect(10f, 200f, 140f, 20f), "Color - B:");
			float num5 = GUI.HorizontalSlider(new Rect(160f, 205f, width - 180f, 20f), ProFlashlightPlus.BValue, 0f, 1f);
			if (!Mathf.Approximately(num5, ProFlashlightPlus.BValue))
			{
				ProFlashlightPlus.BValue = num5;
			}
			GUI.Label(new Rect(10f, 240f, 140f, 20f), "Strobe:");
			bool flag = GUI.Toggle(new Rect(160f, 240f, 20f, 20f), ProFlashlightPlus.StrobeEnabled, "");
			if (flag != ProFlashlightPlus.StrobeEnabled)
			{
				ProFlashlightPlus.StrobeEnabled = flag;
			}
			GUI.Label(new Rect(10f, 280f, 140f, 20f), "Strobe Speed:");
			float num6 = GUI.HorizontalSlider(new Rect(160f, 285f, width - 180f, 20f), ProFlashlightPlus.SpeedValue, 0.1f, 10f);
			if (!Mathf.Approximately(num6, ProFlashlightPlus.SpeedValue))
			{
				ProFlashlightPlus.SpeedValue = num6;
			}
			if (GUI.Button(new Rect((width - 100f) / 2f, height - 40f, 100f, 30f), "Reset"))
			{
				ProFlashlightPlus.IntensityValue = 100f;
				ProFlashlightPlus.AngleValue = 60f;
				ProFlashlightPlus.RValue = 1f;
				ProFlashlightPlus.GValue = 1f;
				ProFlashlightPlus.BValue = 1f;
				ProFlashlightPlus.StrobeEnabled = false;
				ProFlashlightPlus.SpeedValue = 1f;
			}
			GUI.Label(new Rect(width - 100f, 40f, 90f, 20f), ProFlashlightPlus.IntensityValue.ToString("0"));
			GUI.Label(new Rect(width - 100f, 80f, 90f, 20f), ProFlashlightPlus.AngleValue.ToString("0"));
			GUI.Label(new Rect(width - 100f, 120f, 90f, 20f), ProFlashlightPlus.RValue.ToString("0.00"));
			GUI.Label(new Rect(width - 100f, 160f, 90f, 20f), ProFlashlightPlus.GValue.ToString("0.00"));
			GUI.Label(new Rect(width - 100f, 200f, 90f, 20f), ProFlashlightPlus.BValue.ToString("0.00"));
			GUI.Label(new Rect(width - 100f, 240f, 90f, 20f), ProFlashlightPlus.StrobeEnabled ? "On" : "Off");
			GUI.Label(new Rect(width - 100f, 280f, 90f, 20f), ProFlashlightPlus.SpeedValue.ToString("0.0"));
			GUI.DragWindow(new Rect(0f, 0f, width, 24f));
		}
	}
	[HarmonyPatch(typeof(FlashlightItem), "Update")]
	public static class FlashlightItem_Update_Patch
	{
		private static void Postfix(FlashlightItem __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Light flashlightBulb = __instance.flashlightBulb;
			if ((Object)(object)flashlightBulb != (Object)null)
			{
				flashlightBulb.intensity = ProFlashlightPlus.IntensityValue;
				if ((int)flashlightBulb.type == 0)
				{
					flashlightBulb.spotAngle = ProFlashlightPlus.AngleValue;
				}
				if (ProFlashlightPlus.StrobeEnabled)
				{
					float num = Time.time * (ProFlashlightPlus.SpeedValue / 2f) % 1f;
					Color color = Color.HSVToRGB(num, 1f, 1f);
					flashlightBulb.color = color;
				}
				else
				{
					flashlightBulb.color = new Color(ProFlashlightPlus.RValue, ProFlashlightPlus.GValue, ProFlashlightPlus.BValue);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "vegemike.ProFlashlightPlus";

		public const string PLUGIN_NAME = "ProFlashlightPlus";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ProFlashlightPlus.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}