Decompiled source of FeralBright v1.1.2

BepInEx/plugins/FeralBright.dll

Decompiled 5 months 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 FeralBright.Behaviors;
using FeralCommon;
using FeralCommon.Config;
using FeralCommon.Input;
using FeralCommon.Utils;
using FeralCommon.Utils.Extensions;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Ferus LLC")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A simple plugin with various methods of lighting up the facility")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+223fae0c067b999e1466b9305abac8ee1e41ba11")]
[assembly: AssemblyProduct("FeralBright")]
[assembly: AssemblyTitle("FeralBright")]
[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.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;
		}
	}
	[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 FeralBright
{
	public static class Config
	{
		public static class Flashlight
		{
			public static readonly FloatConfig Intensity = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Intensity")).WithDescription("Determines the intensity of the light. The higher the value, the brighter the light will be.")).WithDefaultValue(800f)).WithMin(0f)).WithMax(25000f).WithStep(1f);

			public static readonly FloatConfig Range = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Range")).WithDescription("Determines the range of the light. The higher the value, the further the light will reach.")).WithDefaultValue(99999f)).WithMin(0f)).WithMax(99999f).WithStep(1f);

			public static readonly FloatConfig Spread = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Spread")).WithDescription("Determines the spread of the light. The higher the value, the wider the light will be.")).WithDefaultValue(130f)).WithMin(1f)).WithMax(179f).WithStep(1f);

			public static readonly ColorConfig Color = ((Config<ColorConfig, string>)(object)((Config<ColorConfig, string>)new ColorConfig("Flashlight", "Color")).WithDescription("Determines the color of the light. The color is represented as a hexadecimal string.\nAn example of a valid color is #FF0000, which represents red.\nYou can use a color picker by searching for 'color picker' on your favorite search engine:\nhttps://www.google.com/search?q=color+picker")).WithDefaultValue("#FFFFFF");

			public static readonly FloatConfig OffsetX = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "X Offset")).WithDescription("Determines the offset of the light on the X-axis. A value of 1 will place the light 1 unit to the right of the player.\nThe further the value is from 0, the further left or right the light will be.")).WithDefaultValue(0f)).WithMin(-10f)).WithMax(10f).WithStep(0.1f);

			public static readonly FloatConfig OffsetY = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Y Offset")).WithDescription("Determines the offset of the light on the Y-axis. A value of 0 will place the light at the player's eye level.\nThe further the value is from 0, the higher or lower the light will be.")).WithDefaultValue(1.5f)).WithMin(-10f)).WithMax(10f).WithStep(0.1f);

			public static readonly FloatConfig OffsetZ = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Z Offset")).WithDescription("Determines the offset of the light on the Z-axis. A value of 1 will place the light 1 unit in front of the player.\nThe further the value is from 0, the further in front or behind the light will be.")).WithDefaultValue(0f)).WithMin(-10f)).WithMax(10f).WithStep(0.1f);

			public static readonly FloatConfig Pitch = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Pitch")).WithDescription("Determines the pitch of the light. The pitch is the side-to-side rotation of the light.\nA negative value will aim the light to the left, while a positive value will aim the light to the right.")).WithDefaultValue(0f)).WithMin(-180f)).WithMax(180f).WithStep(1f);

			public static readonly FloatConfig Yaw = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Flashlight", "Yaw")).WithDescription("Determines the yaw of the light. The yaw is the up-and-down rotation of the light.\nA negative value will aim the light down, while a positive value will aim the light up.")).WithDefaultValue(0f)).WithMin(-180f)).WithMax(180f).WithStep(1f);
		}

		public static class Sun
		{
			public static readonly FloatConfig InsideIntensity = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Sun", "Inside Intensity")).WithDescription("Determines the intensity of the sun's light while inside the facility.\nThe higher the value, the brighter the light will be.")).WithDefaultValue(25f)).WithMin(0f)).WithMax(100f).WithStep(1f);

			public static readonly BoolConfig EnablePositionOverride = ((Config<BoolConfig, bool>)(object)((Config<BoolConfig, bool>)new BoolConfig("Sun", "Enable Position Override")).WithDescription("Determines whether the sun's position should be overridden.\nIf enabled, the sun's position will be determined by the 'Position Override' setting.")).WithDefaultValue(true);

			public static readonly FloatConfig PositionOverride = ((RangeConfig<FloatConfig, float>)(object)((RangeConfig<FloatConfig, float>)(object)((Config<FloatConfig, float>)(object)((Config<FloatConfig, float>)new FloatConfig("Sun", "Position Override")).WithDescription("Determines the lifecycle position of the sun. The higher the value, the closer the sun will be to the end of its lifecycle.\nThe lowest lifecycle position is 0, but the day actually starts at around 0.092, which represents 7:40AM.\nThe lifecycle position at 0.333 represents 12:00PM, which is the highest point of the sun.\nThe highest lifecycle position is 1, which represents 12:00AM.")).WithDefaultValue(0.333f)).WithMin(0f)).WithMax(1f).WithStep(0.001f);
		}
	}
	[BepInPlugin("FeralBright", "FeralBright", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class FeralBrightPlugin : FeralPlugin
	{
		private class BinderWorkAround : LcInputActions
		{
			[CompilerGenerated]
			private FeralPlugin <plugin>P;

			public BinderWorkAround(FeralPlugin plugin)
			{
				<plugin>P = plugin;
				((LcInputActions)this)..ctor();
			}

			public override void CreateInputActions(in InputActionMapBuilder builder)
			{
				<plugin>P.CompleteWorkAroundPartOne(ref builder);
			}
		}

		protected override void Load()
		{
			((FeralPlugin)this).RegisterConfigs(typeof(Config));
			((FeralPlugin)this).RegisterButtons(typeof(Toggles));
			BinderWorkAround binderWorkAround = new BinderWorkAround((FeralPlugin)(object)this);
			((FeralPlugin)this).CompleteWorkAroundPartTwo((LcInputActions)(object)binderWorkAround);
			HarmonyExtension.PatchNamespace(((FeralPlugin)this).Harmony, "FeralBright.Patches");
		}
	}
	public static class Toggles
	{
		public static ButtonToggle Flashlight { get; } = new ButtonToggle("ToggleFlashlight", "Toggle \"hands-free\" flashlight", "<keyboard>/f", false);


		public static ButtonToggle SunInside { get; } = new ButtonToggle("ToggleSunInside", "Toggle sun visibility within facility", "<keyboard>/t", false);

	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "FeralBright";

		public const string PLUGIN_NAME = "FeralBright";

		public const string PLUGIN_VERSION = "1.1.2";
	}
}
namespace FeralBright.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public static class PlayerControllerBPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("ConnectClientToPlayerObject")]
		private static void PostFix_ConnectClientToPlayerObject(PlayerControllerB __instance)
		{
			((Component)__instance).gameObject.AddComponent<Flashlight>();
			Camera gameplayCamera = __instance.gameplayCamera;
			gameplayCamera.cullingMask += Mask.op_Implicit(Mask.Unused2);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public static class StartOfRoundPatch
	{
		private static GameObject _facilitySun;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void Postfix_Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_facilitySun))
			{
				Object.Destroy((Object)(object)_facilitySun);
			}
			_facilitySun = new GameObject("FeralBright_FacilitySun");
			_facilitySun.AddComponent<FacilitySun>();
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	public class TimeOfDayPatches
	{
		private static readonly int SunAnimatorTimeOfDayHash = Animator.StringToHash("timeOfDay");

		[HarmonyPatch("MoveTimeOfDay")]
		[HarmonyPostfix]
		private static void PostFix_MoveTimeOfDay(ref Animator ___sunAnimator)
		{
			if (Config<BoolConfig, bool>.op_Implicit((Config<BoolConfig, bool>)(object)Config.Sun.EnablePositionOverride) && Object.op_Implicit((Object)(object)___sunAnimator))
			{
				___sunAnimator.SetFloat(SunAnimatorTimeOfDayHash, Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Sun.PositionOverride));
			}
		}
	}
}
namespace FeralBright.Behaviors
{
	public class FacilitySun : MonoBehaviour
	{
		private Light _sun;

		private void Awake()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			_sun = ((Component)this).gameObject.AddComponent<Light>();
			_sun.type = (LightType)1;
			_sun.shape = (LightShape)0;
			_sun.color = Color.white;
			((Component)_sun).transform.position = new Vector3(0f, 1000f, 0f);
			((Component)_sun).transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			_sun.cullingMask = Mask.op_Implicit(Mask.Unused2);
		}

		private void Update()
		{
			PlayerControllerB val = Player.LocalPlayerNullable();
			if (!Object.op_Implicit((Object)(object)val) || !val.isInsideFactory)
			{
				((Behaviour)_sun).enabled = false;
				return;
			}
			((Behaviour)_sun).enabled = ButtonToggle.op_Implicit(Toggles.SunInside);
			_sun.intensity = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Sun.InsideIntensity);
		}
	}
	public class Flashlight : MonoBehaviour
	{
		private static Light _light;

		public void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_light))
			{
				Object.Destroy((Object)(object)_light);
			}
			_light = new GameObject("FeralBright_Flashlight").AddComponent<Light>();
			((Component)_light).transform.SetParent(((Component)Player.LocalPlayer().playerEye).transform);
			((Component)_light).transform.rotation = Quaternion.LookRotation(((Component)Player.LocalPlayer().playerEye).transform.forward);
			_light.cullingMask = Mask.op_Implicit(Mask.Unused2);
			_light.type = (LightType)0;
		}

		public void Update()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)_light).enabled = ButtonToggle.op_Implicit(Toggles.Flashlight);
			_light.intensity = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.Intensity);
			_light.range = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.Range);
			_light.spotAngle = Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.Spread);
			_light.color = ColorConfig.op_Implicit(Config.Flashlight.Color);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.OffsetX), Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.OffsetY), Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.OffsetZ));
			Quaternion val2 = Quaternion.Euler(Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.Yaw) * -1f, Config<FloatConfig, float>.op_Implicit((Config<FloatConfig, float>)(object)Config.Flashlight.Pitch), 0f);
			((Component)_light).transform.SetLocalPositionAndRotation(val, val2);
		}
	}
}