Decompiled source of REPOFlashLightColor v1.0.0

BepInEx/plugins/REPOFlashLightColor/REPOFlashLightColor.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("REPOFlashLightColor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("REPOFlashLightColor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPOFlashLightColor
{
	[BepInPlugin("com.johnwhippits.REPOFlashLightColor", "REPOFlashLightColor", "1.0.0")]
	[HarmonyPatch]
	public class FlashlightColorPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FlashlightController), "Update")]
		public static class FlashlightController_Update_Patch
		{
			private static bool Prefix(FlashlightController __instance)
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				if (!isLocalRef.Invoke(__instance.PlayerAvatar))
				{
					return true;
				}
				if (Input.GetKeyDown((KeyCode)99))
				{
					currentColorIndex = (currentColorIndex + 1) % colors.Count;
					__instance.spotlight.color = colors[currentColorIndex];
				}
				return true;
			}
		}

		private static readonly List<Color> colors = new List<Color>
		{
			Color.white,
			Color.red,
			Color.green,
			Color.blue,
			Color.yellow,
			Color.cyan,
			Color.magenta,
			new Color(1f, 0.5f, 0f),
			new Color(0.5f, 0f, 0.5f),
			new Color(1f, 1f, 0f)
		};

		private static int currentColorIndex = 0;

		private static readonly FieldRef<PlayerAvatar, bool> isLocalRef = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isLocal");

		public void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"REPOFlashLightColor mod loaded successfully!");
			Harmony.CreateAndPatchAll(typeof(FlashlightController_Update_Patch), (string)null);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "REPOFlashLightColor";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}