Decompiled source of BaphometsRedLight v1.0.0

BaphometsRedLight.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BaphometsRedLight.Patches;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
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("BaphometsRedLight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BaphometsRedLight")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("925a9914-a943-4be2-9e38-287140bc7261")]
[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 BaphometsRedLight
{
	[BepInPlugin("com.Truok.BRL", "BaphometsRedLight", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BRL : BaseUnityPlugin
	{
		public enum FailAction
		{
			Death,
			Damage,
			QuitApplication
		}

		public static PluginConfigurator PluginConfig = PluginConfigurator.Create("Baphomets Red Light", "com.Truok.BRL.Config");

		internal static ManualLogSource Log;

		internal readonly Harmony harmony = new Harmony("com.Truok.BRL");

		public static BoolField StopInfTiming = new BoolField(PluginConfig.rootPanel, "Limited Light Length Choice Reccomendation", "com.Truok.BRL.ULLCR", true);

		public static IntField GreenLightMinLength = new IntField(PluginConfig.rootPanel, "Green Light Min Length", "com.Truok.BRL.GLMinLenght", 10);

		public static IntField GreenLightMaxLength = new IntField(PluginConfig.rootPanel, "Green Light Max Length", "com.Truok.BRL.GLMaxLenght", 20);

		public static IntField RedLightMinLength = new IntField(PluginConfig.rootPanel, "Red Light Min Length", "com.Truok.BRL.RLMinLenght", 3);

		public static IntField RedLightMaxLength = new IntField(PluginConfig.rootPanel, "Red Light Max Length", "com.Truok.BRL.RLMaxLenght", 10);

		public static EnumField<FailAction> ACTIONONFAIL = new EnumField<FailAction>(PluginConfig.rootPanel, "Action On Fail", "com.Truok.BRL.ActionFailChoices", FailAction.Death);

		public static IntField FailActionDamageAmount = new IntField(PluginConfig.rootPanel, "Failed Damage Amount", "com.Truok.BRL.FailActionDamageAmount", 25);

		public static BRL Instance { get; private set; }

		private void Awake()
		{
			Log = Logger.CreateLogSource("BaphometsRedLight Debuger");
			Log.LogInfo((object)"Mod Is Loaded");
			harmony.PatchAll();
			((Component)this).gameObject.AddComponent<Patch>();
		}

		private void Update()
		{
			if (StopInfTiming.value)
			{
				if (GreenLightMinLength.value < 5)
				{
					GreenLightMinLength.value = 5;
				}
				if (GreenLightMaxLength.value > 25)
				{
					GreenLightMaxLength.value = 25;
				}
				if (RedLightMinLength.value < 2)
				{
					RedLightMinLength.value = 2;
				}
				if (RedLightMaxLength.value > 15)
				{
					RedLightMaxLength.value = 15;
				}
			}
			if (GreenLightMinLength.value > GreenLightMaxLength.value)
			{
				GreenLightMinLength.value = GreenLightMaxLength.value;
			}
			if (GreenLightMaxLength.value < GreenLightMinLength.value)
			{
				GreenLightMaxLength.value = GreenLightMinLength.value;
			}
			if (RedLightMinLength.value > RedLightMaxLength.value)
			{
				RedLightMinLength.value = RedLightMaxLength.value;
			}
			if (RedLightMaxLength.value < RedLightMinLength.value)
			{
				RedLightMaxLength.value = RedLightMinLength.value;
			}
			if (FailActionDamageAmount.value > 100)
			{
				FailActionDamageAmount.value = 100;
			}
			if (FailActionDamageAmount.value < 1)
			{
				FailActionDamageAmount.value = 1;
			}
		}
	}
}
namespace BaphometsRedLight.Patches
{
	[HarmonyPatch(typeof(PlayerInput))]
	internal class Patch : MonoBehaviour
	{
		private string lightstatus;

		private float TimeWaitG;

		private float TimeWaitR;

		private bool hassentlight;

		private NewMovement Movement;

		private float FailActionCooldown;

		private void Awake()
		{
			FailActionCooldown = 0f;
			hassentlight = false;
			lightstatus = "green";
			TimeWaitG = Random.Range(BRL.GreenLightMinLength.value, BRL.GreenLightMaxLength.value);
		}

		private void OnEnable()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnDisable()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			FailActionCooldown = 0.5f;
			hassentlight = false;
			lightstatus = "green";
			TimeWaitG = Random.Range(BRL.GreenLightMinLength.value, BRL.GreenLightMaxLength.value);
			TimeWaitR = 0f;
		}

		private void Update()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "b3e7f2f8052488a45b35549efb98d902"))
			{
				return;
			}
			Movement = MonoSingleton<NewMovement>.Instance;
			if (FailActionCooldown > 0f)
			{
				FailActionCooldown -= Time.deltaTime;
			}
			if (lightstatus == "green" && TimeWaitG > 0f)
			{
				if (!hassentlight)
				{
					MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("<color=#06DE02> " + lightstatus + " Light! </color>", "", "", 0, false, false, true);
					BRL.Log.LogInfo((object)(lightstatus + " Light!"));
					hassentlight = true;
				}
				TimeWaitG -= Time.deltaTime;
			}
			else if (lightstatus == "green" && TimeWaitG <= 0f)
			{
				FailActionCooldown = 1f;
				hassentlight = false;
				lightstatus = "red";
				TimeWaitR = Random.Range(BRL.RedLightMinLength.value, BRL.RedLightMaxLength.value);
			}
			if (lightstatus == "red" && TimeWaitR > 0f)
			{
				if (!hassentlight)
				{
					MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("<color=#DE2802> " + lightstatus + " Light! </color>", "", "", 0, false, false, true);
					BRL.Log.LogInfo((object)(lightstatus + " Light!"));
					hassentlight = true;
				}
				TimeWaitR -= Time.deltaTime;
				Vector3 velocity = Movement.rb.velocity;
				if (((Vector3)(ref velocity)).magnitude > 0.1f && FailActionCooldown <= 0f)
				{
					BRL.Log.LogInfo((object)"Player Moved on Red Light");
					if (BRL.ACTIONONFAIL.value == BRL.FailAction.Death)
					{
						Movement.GetHurt(100, false, 1f, false, false, 0.35f, false);
						FailActionCooldown = 2f;
					}
					if (BRL.ACTIONONFAIL.value == BRL.FailAction.Damage)
					{
						Movement.GetHurt(BRL.FailActionDamageAmount.value, false, 1f, false, false, 0.35f, false);
						FailActionCooldown = 1f;
					}
					if (BRL.ACTIONONFAIL.value == BRL.FailAction.QuitApplication)
					{
						Application.Quit();
					}
				}
			}
			else if (lightstatus == "red" && TimeWaitR <= 0f)
			{
				FailActionCooldown = 0.5f;
				hassentlight = false;
				lightstatus = "green";
				TimeWaitG = Random.Range(BRL.GreenLightMinLength.value, BRL.GreenLightMaxLength.value);
			}
		}
	}
}