Decompiled source of LetThereBeLight v1.1.0

Flashlight.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("Flashlight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Flashlight")]
[assembly: AssemblyTitle("Flashlight")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace PortalFlashlightMod;

public enum FlashlightColorId
{
	White,
	WarmWhite,
	Cyan,
	Blue,
	Purple,
	Magenta,
	Red,
	Orange,
	Yellow,
	Green,
	Custom
}
[BepInPlugin("com.gogogadgetjustice.flashlight", "Portal Flashlight", "2.2.0")]
public class PortalFlashlightPlugin : BasePlugin
{
	public const string GUID = "com.gogogadgetjustice.flashlight";

	public const string PluginName = "Portal Flashlight";

	public const string Version = "2.2.0";

	public static ManualLogSource Log;

	public static ConfigEntry<KeyCode> MenuToggleKey;

	public static ConfigEntry<bool> FreeCursorInMenu;

	public static ConfigEntry<KeyCode> ToggleFlashlightKey;

	public static ConfigEntry<KeyCode> CycleColorForwardKey;

	public static ConfigEntry<KeyCode> CycleColorBackwardKey;

	public static ConfigEntry<bool> UseScrollWheelToCycle;

	public static ConfigEntry<float> Range;

	public static ConfigEntry<float> Intensity;

	public static ConfigEntry<float> SpotAngle;

	public static ConfigEntry<float> OffsetForward;

	public static ConfigEntry<float> OffsetDown;

	public static ConfigEntry<float> CustomRed;

	public static ConfigEntry<float> CustomGreen;

	public static ConfigEntry<float> CustomBlue;

	public static ConfigEntry<float> P1_Intensity;

	public static ConfigEntry<float> P1_Range;

	public static ConfigEntry<float> P1_Angle;

	public static ConfigEntry<float> P2_Intensity;

	public static ConfigEntry<float> P2_Range;

	public static ConfigEntry<float> P2_Angle;

	public static ConfigEntry<float> P3_Intensity;

	public static ConfigEntry<float> P3_Range;

	public static ConfigEntry<float> P3_Angle;

	public override void Load()
	{
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Expected O, but got Unknown
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Expected O, but got Unknown
		Log = ((BasePlugin)this).Log;
		MenuToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("Menu", "ToggleKey", (KeyCode)284, "Key that opens/closes the config panel.");
		FreeCursorInMenu = ((BasePlugin)this).Config.Bind<bool>("Menu", "FreeCursor", true, "Unlock and show the mouse cursor while the config panel is open.");
		ToggleFlashlightKey = ((BasePlugin)this).Config.Bind<KeyCode>("Flashlight", "ToggleKey", (KeyCode)102, "Press to switch the flashlight on/off.");
		CycleColorForwardKey = ((BasePlugin)this).Config.Bind<KeyCode>("Flashlight", "ColorForwardKey", (KeyCode)99, "Cycle the flashlight color forward.");
		CycleColorBackwardKey = ((BasePlugin)this).Config.Bind<KeyCode>("Flashlight", "ColorBackwardKey", (KeyCode)118, "Cycle the flashlight color backward.");
		UseScrollWheelToCycle = ((BasePlugin)this).Config.Bind<bool>("Flashlight", "UseScrollWheel", true, "Also let the mouse scroll wheel cycle colors.");
		Range = ((BasePlugin)this).Config.Bind<float>("Flashlight", "Range", 25f, "How far the light reaches, in meters.");
		Intensity = ((BasePlugin)this).Config.Bind<float>("Flashlight", "Intensity", 4f, "Brightness of the light.");
		SpotAngle = ((BasePlugin)this).Config.Bind<float>("Flashlight", "SpotAngle", 55f, "Cone width of the spotlight, in degrees.");
		OffsetForward = ((BasePlugin)this).Config.Bind<float>("Flashlight", "OffsetForward", 0.35f, "How far in front of the camera the light sits, in meters.");
		OffsetDown = ((BasePlugin)this).Config.Bind<float>("Flashlight", "OffsetDown", 0.08f, "How far below the camera the light sits, in meters.");
		CustomRed = ((BasePlugin)this).Config.Bind<float>("CustomColor", "Red", 1f, "Custom color Red component (0.0 - 1.0).");
		CustomGreen = ((BasePlugin)this).Config.Bind<float>("CustomColor", "Green", 0.5f, "Custom color Green component (0.0 - 1.0).");
		CustomBlue = ((BasePlugin)this).Config.Bind<float>("CustomColor", "Blue", 0.8f, "Custom color Blue component (0.0 - 1.0).");
		P1_Intensity = ((BasePlugin)this).Config.Bind<float>("Presets", "P1_Intensity", 4f, "Preset 1 Intensity");
		P1_Range = ((BasePlugin)this).Config.Bind<float>("Presets", "P1_Range", 25f, "Preset 1 Range");
		P1_Angle = ((BasePlugin)this).Config.Bind<float>("Presets", "P1_Angle", 55f, "Preset 1 Angle");
		P2_Intensity = ((BasePlugin)this).Config.Bind<float>("Presets", "P2_Intensity", 10f, "Preset 2 Intensity");
		P2_Range = ((BasePlugin)this).Config.Bind<float>("Presets", "P2_Range", 50f, "Preset 2 Range");
		P2_Angle = ((BasePlugin)this).Config.Bind<float>("Presets", "P2_Angle", 30f, "Preset 2 Angle");
		P3_Intensity = ((BasePlugin)this).Config.Bind<float>("Presets", "P3_Intensity", 20f, "Preset 3 Intensity");
		P3_Range = ((BasePlugin)this).Config.Bind<float>("Presets", "P3_Range", 100f, "Preset 3 Range");
		P3_Angle = ((BasePlugin)this).Config.Bind<float>("Presets", "P3_Angle", 15f, "Preset 3 Angle");
		ClassInjector.RegisterTypeInIl2Cpp<FlashlightMenuRuntime>();
		ClassInjector.RegisterTypeInIl2Cpp<FlashlightController>();
		GameObject val = new GameObject("FlashlightModMenuHost")
		{
			hideFlags = (HideFlags)61
		};
		Object.DontDestroyOnLoad((Object)(object)val);
		val.AddComponent<FlashlightMenuRuntime>();
		((BasePlugin)this).AddComponent<FlashlightController>();
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(22, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Portal Flashlight");
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
			((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("2.2.0");
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded successfully.");
		}
		log.LogInfo(val2);
	}
}
public class FlashlightMenuRuntime : MonoBehaviour
{
	private bool _open = false;

	private CursorLockMode _lockWas;

	private bool _cursorWas;

	public FlashlightMenuRuntime(nint ptr)
		: base((global::System.IntPtr)ptr)
	{
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		if (Input.GetKeyDown(PortalFlashlightPlugin.MenuToggleKey.Value) || Input.GetKeyDown((KeyCode)291))
		{
			_open = !_open;
			ManualLogSource log = PortalFlashlightPlugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[FlashlightMenu] Toggle state changed. Menu is now: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_open ? "OPEN" : "CLOSED");
			}
			log.LogInfo(val);
			SetCursor(_open);
		}
	}

	private void SetCursor(bool free)
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		if (PortalFlashlightPlugin.FreeCursorInMenu.Value)
		{
			if (free)
			{
				_lockWas = Cursor.lockState;
				_cursorWas = Cursor.visible;
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			else
			{
				Cursor.lockState = _lockWas;
				Cursor.visible = _cursorWas;
			}
		}
	}

	private void OnGUI()
	{
		//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c1: Expected O, but got Unknown
		//IL_05ec: 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)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		if (!_open)
		{
			return;
		}
		if (PortalFlashlightPlugin.FreeCursorInMenu.Value)
		{
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}
		Matrix4x4 matrix = GUI.matrix;
		GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1.2f, 1.2f, 1f));
		try
		{
			GUILayout.BeginArea(new Rect(50f, 50f, 380f, 680f), "Enhanced Flashlight Config", GUI.skin.window);
			GUILayout.Space(10f);
			GUILayout.Label("<b>Flashlight Settings</b>", (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label($"Intensity: {PortalFlashlightPlugin.Intensity.Value:F1}", (Il2CppReferenceArray<GUILayoutOption>)null);
			float num = GUILayout.HorizontalSlider(PortalFlashlightPlugin.Intensity.Value, 0.5f, 30f, global::System.Array.Empty<GUILayoutOption>());
			if (num != PortalFlashlightPlugin.Intensity.Value)
			{
				PortalFlashlightPlugin.Intensity.Value = num;
				FlashlightController.Instance?.ApplySettings();
			}
			GUILayout.Label($"Range (meters): {PortalFlashlightPlugin.Range.Value:F1}", (Il2CppReferenceArray<GUILayoutOption>)null);
			float num2 = GUILayout.HorizontalSlider(PortalFlashlightPlugin.Range.Value, 5f, 5000f, global::System.Array.Empty<GUILayoutOption>());
			if (num2 != PortalFlashlightPlugin.Range.Value)
			{
				PortalFlashlightPlugin.Range.Value = num2;
				FlashlightController.Instance?.ApplySettings();
			}
			GUILayout.Label($"Spotlight Bloom: {PortalFlashlightPlugin.SpotAngle.Value:F0}", (Il2CppReferenceArray<GUILayoutOption>)null);
			float num3 = GUILayout.HorizontalSlider(PortalFlashlightPlugin.SpotAngle.Value, 10f, 360f, global::System.Array.Empty<GUILayoutOption>());
			if (num3 != PortalFlashlightPlugin.SpotAngle.Value)
			{
				PortalFlashlightPlugin.SpotAngle.Value = num3;
				FlashlightController.Instance?.ApplySettings();
			}
			GUILayout.Space(10f);
			GUILayout.Label("<b>Custom RGB Color Mixer</b>", (Il2CppReferenceArray<GUILayoutOption>)null);
			bool flag = false;
			GUILayout.Label($"Red: {PortalFlashlightPlugin.CustomRed.Value:F2}", (Il2CppReferenceArray<GUILayoutOption>)null);
			float num4 = GUILayout.HorizontalSlider(PortalFlashlightPlugin.CustomRed.Value, 0f, 1f, global::System.Array.Empty<GUILayoutOption>());
			if (num4 != PortalFlashlightPlugin.CustomRed.Value)
			{
				PortalFlashlightPlugin.CustomRed.Value = num4;
				flag = true;
			}
			GUILayout.Label($"Green: {PortalFlashlightPlugin.CustomGreen.Value:F2}", (Il2CppReferenceArray<GUILayoutOption>)null);
			float num5 = GUILayout.HorizontalSlider(PortalFlashlightPlugin.CustomGreen.Value, 0f, 1f, global::System.Array.Empty<GUILayoutOption>());
			if (num5 != PortalFlashlightPlugin.CustomGreen.Value)
			{
				PortalFlashlightPlugin.CustomGreen.Value = num5;
				flag = true;
			}
			GUILayout.Label($"Blue: {PortalFlashlightPlugin.CustomBlue.Value:F2}", (Il2CppReferenceArray<GUILayoutOption>)null);
			float num6 = GUILayout.HorizontalSlider(PortalFlashlightPlugin.CustomBlue.Value, 0f, 1f, global::System.Array.Empty<GUILayoutOption>());
			if (num6 != PortalFlashlightPlugin.CustomBlue.Value)
			{
				PortalFlashlightPlugin.CustomBlue.Value = num6;
				flag = true;
			}
			if (flag && (Object)(object)FlashlightController.Instance != (Object)null)
			{
				FlashlightController.Instance.SetCustomColor();
			}
			GUILayout.Space(10f);
			GUILayout.Label("<b>Flashlight Settings Save/Load Presets</b>", (Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Load 1", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				FlashlightController.Instance?.LoadPreset(1);
			}
			if (GUILayout.Button("Save 1", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				FlashlightController.Instance?.SavePreset(1);
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Load 2", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				FlashlightController.Instance?.LoadPreset(2);
			}
			if (GUILayout.Button("Save 2", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				FlashlightController.Instance?.SavePreset(2);
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			if (GUILayout.Button("Load 3", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				FlashlightController.Instance?.LoadPreset(3);
			}
			if (GUILayout.Button("Save 3", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				FlashlightController.Instance?.SavePreset(3);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			PortalFlashlightPlugin.UseScrollWheelToCycle.Value = GUILayout.Toggle(PortalFlashlightPlugin.UseScrollWheelToCycle.Value, "Use Mouse Scroll to Cycle Colors", global::System.Array.Empty<GUILayoutOption>());
			GUILayout.Space(15f);
			if (GUILayout.Button("Close Menu", (Il2CppReferenceArray<GUILayoutOption>)null))
			{
				_open = false;
				SetCursor(free: false);
			}
			GUILayout.EndArea();
		}
		catch (global::System.Exception ex)
		{
			_open = false;
			SetCursor(free: false);
			ManualLogSource log = PortalFlashlightPlugin.Log;
			bool flag2 = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[FlashlightMenu] UI exception: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<global::System.Exception>(ex);
			}
			log.LogError(val);
		}
		finally
		{
			GUI.matrix = matrix;
		}
	}
}
public class FlashlightController : MonoBehaviour
{
	private Light _noseLight;

	private Camera _attachedCamera;

	private bool _isOn = false;

	private float _cameraSearchTimer = 0f;

	private static readonly FlashlightColorId[] CycleOrder;

	private int _cycleIndex = 0;

	private static readonly Dictionary<FlashlightColorId, Color> PresetColors;

	[field: CompilerGenerated]
	[field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)]
	public static FlashlightController Instance
	{
		[CompilerGenerated]
		get;
		[CompilerGenerated]
		private set;
	}

	private FlashlightColorId CurrentColor => CycleOrder[_cycleIndex];

	public FlashlightController(nint ptr)
		: base((global::System.IntPtr)ptr)
	{
	}

	private void Awake()
	{
		Instance = this;
	}

	private void Update()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_attachedCamera == (Object)null)
		{
			_cameraSearchTimer -= Time.unscaledDeltaTime;
			if (_cameraSearchTimer <= 0f)
			{
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null)
				{
					AttachFlashlightTo(main);
				}
				_cameraSearchTimer = 1f;
			}
		}
		if (Input.GetKeyDown(PortalFlashlightPlugin.ToggleFlashlightKey.Value))
		{
			ToggleFlashlight();
		}
		if (!_isOn)
		{
			return;
		}
		if (Input.GetKeyDown(PortalFlashlightPlugin.CycleColorForwardKey.Value))
		{
			CycleColor(1);
		}
		if (Input.GetKeyDown(PortalFlashlightPlugin.CycleColorBackwardKey.Value))
		{
			CycleColor(-1);
		}
		if (PortalFlashlightPlugin.UseScrollWheelToCycle.Value)
		{
			float axis = Input.GetAxis("Mouse ScrollWheel");
			if (axis > 0.01f)
			{
				CycleColor(1);
			}
			else if (axis < -0.01f)
			{
				CycleColor(-1);
			}
		}
	}

	private void AttachFlashlightTo(Camera cam)
	{
		_attachedCamera = cam;
		if ((Object)(object)_noseLight == (Object)null)
		{
			CreateLight();
		}
		((Component)_noseLight).transform.SetParent(((Component)cam).transform, false);
		ApplyOffset();
	}

	private void CreateLight()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("EnhancedFlashlight");
		_noseLight = ((Il2CppObjectBase)val.AddComponent(Il2CppType.Of<Light>())).Cast<Light>();
		_noseLight.type = (LightType)0;
		_noseLight.shadows = (LightShadows)2;
		val.SetActive(_isOn);
		ApplySettings();
		UpdateLightColor();
	}

	private void ApplyOffset()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_noseLight == (Object)null))
		{
			((Component)_noseLight).transform.localPosition = new Vector3(0f, 0f - PortalFlashlightPlugin.OffsetDown.Value, PortalFlashlightPlugin.OffsetForward.Value);
			((Component)_noseLight).transform.localRotation = Quaternion.identity;
		}
	}

	public void ApplySettings()
	{
		if (!((Object)(object)_noseLight == (Object)null))
		{
			_noseLight.range = PortalFlashlightPlugin.Range.Value;
			_noseLight.intensity = PortalFlashlightPlugin.Intensity.Value;
			_noseLight.spotAngle = PortalFlashlightPlugin.SpotAngle.Value;
			ApplyOffset();
		}
	}

	private void ToggleFlashlight()
	{
		if ((Object)(object)_noseLight == (Object)null)
		{
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			AttachFlashlightTo(main);
		}
		ApplySettings();
		_isOn = !_isOn;
		((Component)_noseLight).gameObject.SetActive(_isOn);
	}

	private void CycleColor(int direction)
	{
		_cycleIndex = (_cycleIndex + direction + CycleOrder.Length) % CycleOrder.Length;
		UpdateLightColor();
	}

	public void SetCustomColor()
	{
		for (int i = 0; i < CycleOrder.Length; i++)
		{
			if (CycleOrder[i] == FlashlightColorId.Custom)
			{
				_cycleIndex = i;
				break;
			}
		}
		UpdateLightColor();
	}

	public void UpdateLightColor()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_noseLight == (Object)null))
		{
			Color color = default(Color);
			if (CurrentColor == FlashlightColorId.Custom)
			{
				_noseLight.color = new Color(PortalFlashlightPlugin.CustomRed.Value, PortalFlashlightPlugin.CustomGreen.Value, PortalFlashlightPlugin.CustomBlue.Value);
			}
			else if (PresetColors.TryGetValue(CurrentColor, ref color))
			{
				_noseLight.color = color;
			}
		}
	}

	public void SavePreset(int id)
	{
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Expected O, but got Unknown
		switch (id)
		{
		case 1:
			PortalFlashlightPlugin.P1_Intensity.Value = PortalFlashlightPlugin.Intensity.Value;
			PortalFlashlightPlugin.P1_Range.Value = PortalFlashlightPlugin.Range.Value;
			PortalFlashlightPlugin.P1_Angle.Value = PortalFlashlightPlugin.SpotAngle.Value;
			break;
		case 2:
			PortalFlashlightPlugin.P2_Intensity.Value = PortalFlashlightPlugin.Intensity.Value;
			PortalFlashlightPlugin.P2_Range.Value = PortalFlashlightPlugin.Range.Value;
			PortalFlashlightPlugin.P2_Angle.Value = PortalFlashlightPlugin.SpotAngle.Value;
			break;
		case 3:
			PortalFlashlightPlugin.P3_Intensity.Value = PortalFlashlightPlugin.Intensity.Value;
			PortalFlashlightPlugin.P3_Range.Value = PortalFlashlightPlugin.Range.Value;
			PortalFlashlightPlugin.P3_Angle.Value = PortalFlashlightPlugin.SpotAngle.Value;
			break;
		}
		ManualLogSource log = PortalFlashlightPlugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Saved current settings to Preset ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(id);
		}
		log.LogInfo(val);
	}

	public void LoadPreset(int id)
	{
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Expected O, but got Unknown
		switch (id)
		{
		case 1:
			PortalFlashlightPlugin.Intensity.Value = PortalFlashlightPlugin.P1_Intensity.Value;
			PortalFlashlightPlugin.Range.Value = PortalFlashlightPlugin.P1_Range.Value;
			PortalFlashlightPlugin.SpotAngle.Value = PortalFlashlightPlugin.P1_Angle.Value;
			break;
		case 2:
			PortalFlashlightPlugin.Intensity.Value = PortalFlashlightPlugin.P2_Intensity.Value;
			PortalFlashlightPlugin.Range.Value = PortalFlashlightPlugin.P2_Range.Value;
			PortalFlashlightPlugin.SpotAngle.Value = PortalFlashlightPlugin.P2_Angle.Value;
			break;
		case 3:
			PortalFlashlightPlugin.Intensity.Value = PortalFlashlightPlugin.P3_Intensity.Value;
			PortalFlashlightPlugin.Range.Value = PortalFlashlightPlugin.P3_Range.Value;
			PortalFlashlightPlugin.SpotAngle.Value = PortalFlashlightPlugin.P3_Angle.Value;
			break;
		}
		ApplySettings();
		ManualLogSource log = PortalFlashlightPlugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded Preset ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(id);
		}
		log.LogInfo(val);
	}

	static FlashlightController()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		FlashlightColorId[] array = new FlashlightColorId[11];
		RuntimeHelpers.InitializeArray((global::System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		CycleOrder = array;
		Dictionary<FlashlightColorId, Color> obj = new Dictionary<FlashlightColorId, Color>();
		obj.Add(FlashlightColorId.White, Color.white);
		obj.Add(FlashlightColorId.WarmWhite, new Color(1f, 0.9f, 0.7f));
		obj.Add(FlashlightColorId.Cyan, new Color(0f, 1f, 1f));
		obj.Add(FlashlightColorId.Blue, new Color(0.153f, 0.655f, 0.847f));
		obj.Add(FlashlightColorId.Purple, new Color(0.5f, 0f, 0.8f));
		obj.Add(FlashlightColorId.Magenta, new Color(1f, 0f, 0.5f));
		obj.Add(FlashlightColorId.Red, new Color(0.898f, 0.145f, 0.129f));
		obj.Add(FlashlightColorId.Orange, new Color(1f, 0.365f, 0f));
		obj.Add(FlashlightColorId.Yellow, new Color(1f, 0.92f, 0.192f));
		obj.Add(FlashlightColorId.Green, new Color(0.282f, 0.678f, 0.086f));
		PresetColors = obj;
	}
}