Decompiled source of ScanVision v0.0.1

ScanVision.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ScanVision.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
[assembly: AssemblyCompany("ScanVision")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScanVision")]
[assembly: AssemblyTitle("ScanVision")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class NullableAttribute : System.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(/*Could not decode attribute arguments.*/)]
	internal sealed class NullableContextAttribute : System.Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : System.Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ScanVision
{
	public class PLUGIN_INFO
	{
		public const string PLUGIN_GUID = "yunussahinio.lethalcompanyscanvision";

		public const string PLUGIN_NAME = "Scan Vision";

		public const string PLUGIN_VERSION = "0.0.1";
	}
	[BepInPlugin("yunussahinio.lethalcompanyscanvision", "Scan Vision", "0.0.1")]
	public class ScanVision : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("yunussahinio.lethalcompanyscanvision");

		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"__________________Awake");
			harmony.PatchAll(typeof(ScanVision));
			harmony.PatchAll(typeof(HudManagerPatch));
			harmony.PatchAll(typeof(AudioSourcePatch));
		}
	}
}
namespace ScanVision.Patches
{
	[HarmonyPatch(typeof(AudioSource))]
	internal class AudioSourcePatch
	{
		[HarmonyPatch("PlayOneShotHelper", new System.Type[]
		{
			typeof(AudioSource),
			typeof(AudioClip),
			typeof(float)
		})]
		[HarmonyPrefix]
		public static void PlayOneShotHelper(AudioSource source, ref AudioClip clip, float volumeScale)
		{
			if ((Object)(object)clip == (Object)(object)HUDManager.Instance?.scanSFX)
			{
				HudManagerPatch.EnableScanVision = true;
				HudManagerPatch.AnimateScanVision = true;
				ScanVision.Log.LogInfo((object)HudManagerPatch.EnableScanVision);
				ScanVision.Log.LogInfo((object)HudManagerPatch.AnimateScanVision);
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HudManagerPatch
	{
		public static bool EnableScanVision;

		public static bool AnimateScanVision;

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static void Update()
		{
			if (!AnimateScanVision)
			{
				return;
			}
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return;
			}
			if (EnableScanVision)
			{
				Light nightVision = localPlayerController.nightVision;
				nightVision.intensity += ((localPlayerController.nightVision.intensity >= 6500f) ? 50f : 300f);
				Light nightVision2 = localPlayerController.nightVision;
				nightVision2.range += 100f;
				if (localPlayerController.nightVision.intensity >= 7500f)
				{
					localPlayerController.nightVision.range = 100000f;
					localPlayerController.nightVision.shadowStrength = 0f;
					localPlayerController.nightVision.shadows = (LightShadows)0;
					localPlayerController.nightVision.shape = (LightShape)2;
					EnableScanVision = false;
				}
			}
			if (!EnableScanVision)
			{
				Light nightVision3 = localPlayerController.nightVision;
				nightVision3.intensity -= 200f;
				Light nightVision4 = localPlayerController.nightVision;
				nightVision4.range -= 100f;
				if (localPlayerController.nightVision.intensity <= 366.9317f)
				{
					localPlayerController.nightVision.intensity = 366.9317f;
					localPlayerController.nightVision.range = 12f;
					localPlayerController.nightVision.shadowStrength = 1f;
					localPlayerController.nightVision.shadows = (LightShadows)0;
					localPlayerController.nightVision.shape = (LightShape)0;
					AnimateScanVision = false;
					ScanVision.Log.LogInfo((object)"ScanVision Disabled");
				}
			}
		}
	}
}