using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NightVision")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NightVision")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f4d720c4-02e0-4ce6-a273-6020eaa38b00")]
[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 NightVision;
[BepInPlugin("nightvision.hex", "Night Vision Mod", "1.0.0.0")]
[BepInProcess("Lethal Company.exe")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "nightvision.hex";
private const string PLUGIN_NAME = "Night Vision Mod";
private const string PLUGIN_VERSION = "1.0.0.0";
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GameObject val = new GameObject("NV Controller");
val.AddComponent<NV_Script>();
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin nightvision.hex is loaded!");
}
}
public class NV_Script : MonoBehaviour
{
private IInputSystem input_manager;
private PlayerControllerB player_controller;
private GameObject player;
private GameObject camera_object;
private bool night_vision_enabled = false;
private GameObject normal_filter;
private Volume normal_volume;
private Volume NV_volume;
private GameObject nightvision_filter;
private Light NV_ambient;
private float NV_response_time = 0.1f;
private float NV_timer = 0f;
private void Awake()
{
input_manager = UnityInput.Current;
}
private void Update()
{
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)NV_ambient != (Object)null)
{
NV_ambient.intensity = 0.3f * (NV_timer / NV_response_time);
}
if ((Object)(object)player == (Object)null)
{
player = GameObject.Find("Player");
if ((Object)(object)player != (Object)null)
{
camera_object = ((Component)player.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera")).gameObject;
player_controller = player.GetComponent<PlayerControllerB>();
GameObject.Find("PlayerHUDHelmetModel").SetActive(false);
normal_filter = GameObject.Find("CustomPass");
normal_volume = GameObject.Find("VolumeMain").GetComponent<Volume>();
nightvision_filter = Object.Instantiate<GameObject>(GameObject.Find("VolumeMain"));
((Object)nightvision_filter).name = "NightVisionVolume";
NV_ambient = nightvision_filter.AddComponent<Light>();
NV_ambient.type = (LightType)1;
NV_ambient.intensity = 0.3f;
nightvision_filter.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
NV_volume = nightvision_filter.GetComponent<Volume>();
VolumeProfile profile = NV_volume.profile;
((Object)profile).name = "NightVisionProfile";
profile.components.Clear();
Bloom val = profile.Add<Bloom>(true);
((VolumeParameter<float>)(object)val.intensity).value = 12f;
((VolumeParameter<float>)(object)val.threshold).value = 0.7f;
((VolumeComponent)val).active = true;
Vignette val2 = profile.Add<Vignette>(true);
((VolumeParameter<float>)(object)val2.intensity).value = 0.5f;
((VolumeParameter<float>)(object)val2.smoothness).value = 1f;
((VolumeComponent)val2).active = true;
ColorAdjustments val3 = profile.Add<ColorAdjustments>(true);
((VolumeParameter<Color>)(object)val3.colorFilter).value = new Color(0f, 0.75f, 0.03f);
((VolumeParameter<float>)(object)val3.postExposure).value = 3.5f;
((VolumeComponent)val3).active = true;
FilmGrain val4 = profile.Add<FilmGrain>(true);
((VolumeParameter<FilmGrainLookup>)(object)val4.type).value = (FilmGrainLookup)9;
((VolumeParameter<float>)(object)val4.intensity).value = 1f;
((VolumeParameter<float>)(object)val4.response).value = 0.8f;
((VolumeComponent)val4).active = true;
nightvision_filter.SetActive(true);
NV_volume.weight = 0f;
}
}
if (input_manager.GetKeyDown((KeyCode)99) && !player_controller.inTerminalMenu && !player_controller.isTypingChat)
{
ToggleNightVision();
}
if (night_vision_enabled)
{
NV_timer += Time.deltaTime;
}
else
{
NV_timer -= Time.deltaTime;
}
if (NV_timer <= 0f)
{
NV_timer = 0f;
}
if (NV_timer >= NV_response_time)
{
NV_timer = NV_response_time;
}
if ((Object)(object)player != (Object)null)
{
normal_volume.weight = (NV_response_time - NV_timer) / NV_response_time;
NV_volume.weight = NV_timer / NV_response_time;
}
}
public void ToggleNightVision()
{
if (!((Object)(object)player == (Object)null) && !((Object)(object)camera_object == (Object)null))
{
night_vision_enabled = !night_vision_enabled;
if (night_vision_enabled)
{
normal_filter.SetActive(false);
}
else
{
normal_filter.SetActive(true);
}
}
}
}