Decompiled source of SwayFlashlight v0.1.0

com.sagtag.SwayFlashlight.dll

Decompiled 2 hours 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.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
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("SagTag")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright (c) 2026 SagTag")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.sagtag.SwayFlashlight")]
[assembly: AssemblyTitle("SwayFlashlight")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 SwayFlashlight
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerStartStuff
	{
		public static GameObject helmetLightP;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void SpawnGO(PlayerControllerB __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			if ((Object)(object)helmetLightP == (Object)null)
			{
				helmetLightP = new GameObject("HelmetLightParent");
				helmetLightP.tag = "SagTagSway";
			}
		}
	}
	[HarmonyPatch(typeof(FlashlightItem))]
	public class FlashlightSway
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void RotationSway(FlashlightItem __instance)
		{
			//IL_003b: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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)
			if ((Object)(object)PlayerStartStuff.helmetLightP != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null)
			{
				float x = ((Component)StartOfRound.Instance.activeCamera).transform.position.x;
				float y = ((Component)StartOfRound.Instance.activeCamera).transform.position.y;
				float z = ((Component)StartOfRound.Instance.activeCamera).transform.position.z;
				Quaternion rotation = ((Component)StartOfRound.Instance.activeCamera).transform.rotation;
				Quaternion rotation2 = PlayerStartStuff.helmetLightP.transform.rotation;
				PlayerStartStuff.helmetLightP.transform.position = ((Component)StartOfRound.Instance.activeCamera).transform.position;
				PlayerStartStuff.helmetLightP.transform.localPosition = new Vector3(x, y + 0.04f, z + 0.04f);
				if (__instance.usingPlayerHelmetLight && (Object)(object)__instance.previousPlayerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					((Component)__instance.previousPlayerHeldBy.helmetLight).transform.SetParent(PlayerStartStuff.helmetLightP.transform);
					((Component)__instance.previousPlayerHeldBy.helmetLight).transform.localRotation = default(Quaternion);
					PlayerStartStuff.helmetLightP.transform.localRotation = Quaternion.Slerp(rotation2, rotation, Time.deltaTime * Plugin.SwaySpeed.Value);
				}
			}
		}
	}
	[BepInPlugin("com.sagtag.SwayFlashlight", "SwayFlashlight", "0.1.0")]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log { get; private set; }

		internal static ConfigEntry<float> SwaySpeed { get; private set; }

		private void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			SwaySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("SagTags Better Flashlights", "Sway Speed", 2f, "the higher the value, the faster the sway is");
			Harmony val = new Harmony("com.sagtag.FlashlightTweaks");
			val.PatchAll();
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"SwayFlashlight 0.1.0 loaded");
		}
	}
	internal static class MyPluginInfo
	{
		public const string Id = "com.sagtag.SwayFlashlight";

		public const string Name = "SwayFlashlight";

		public const string Version = "0.1.0";
	}
}