using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using Microsoft.CodeAnalysis;
using NAudio.Wave;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Lethal_Company_WFJS")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lethal_Company_WFJS")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("EF7E9066-B55A-460D-9DCA-BF6E76D44CAB")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Lethal_Company_WFJS
{
public class JumpscareHandler
{
private const int Frames = 14;
private const int Framerate = 60;
private const float Offset = 6f;
private readonly GameObject _canvasContainer;
private readonly RectTransform _imageTransform;
private readonly float _baseWidth;
private readonly float _baseHeight;
private float _stopwatch;
public JumpscareHandler(AudioSource audioSource)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
_canvasContainer = new GameObject
{
name = "JumpscareCanvasContainer"
};
_canvasContainer.AddComponent<Canvas>().renderMode = (RenderMode)0;
GameObject val = new GameObject
{
name = "JumpscareImageContainer"
};
val.transform.parent = _canvasContainer.transform;
RawImage val2 = val.AddComponent<RawImage>();
val2.texture = (Texture)(object)WFJS_Main.JumpscareTexture;
_imageTransform = ((Graphic)val2).rectTransform;
_imageTransform.sizeDelta = new Vector2((float)Screen.width, (float)(Screen.height * 14));
_baseWidth = (float)Screen.width / 2f;
_baseHeight = (float)(-Screen.height) * 6f;
((Transform)_imageTransform).position = new Vector3(_baseWidth, _baseHeight);
audioSource.PlayOneShot(WFJS_Main.JumpscareAudio);
}
public bool Tick(float deltaTime)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
_stopwatch += deltaTime;
int num = (int)(_stopwatch / (1f / 60f));
((Transform)_imageTransform).position = new Vector3(_baseWidth, _baseHeight + (float)(Screen.height * Mathf.Min(num, 13)));
return num < 74;
}
public void Destroy()
{
Object.Destroy((Object)(object)_canvasContainer);
}
}
public class JumpscareTriggerManager : MonoBehaviour
{
private const float Chance = 0.0002f;
private static JumpscareHandler _jumpscare;
private void Awake()
{
((MonoBehaviour)this).StartCoroutine(RollCoroutine());
}
private void Update()
{
JumpscareHandler jumpscare = _jumpscare;
if (jumpscare != null && !jumpscare.Tick(Time.deltaTime))
{
_jumpscare.Destroy();
_jumpscare = null;
}
}
private static IEnumerator RollCoroutine()
{
yield return (object)new WaitForSeconds(60f);
while (true)
{
if (CanRollForJumpscare() && Random.value <= 0.0002f)
{
_jumpscare = new JumpscareHandler(HUDManager.Instance.UIAudio);
}
yield return (object)new WaitForSeconds(1f);
}
}
private static bool CanRollForJumpscare()
{
if (WFJS_Main.Enabled && _jumpscare == null && !GameNetworkManager.Instance.localPlayerController.isPlayerDead && StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.shipIsLeaving)
{
return StartOfRound.Instance.currentLevel.PlanetName != "71 Gordion";
}
return false;
}
}
public class WFJS_Inputs : LcInputActions
{
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction Toggle { get; set; }
}
[BepInPlugin("esegn.wfjs", "WFJS", "1.0.2")]
public class WFJS_Main : BaseUnityPlugin
{
public const string PluginGuid = "esegn.wfjs";
public const string PluginName = "WFJS";
public const string PluginVersion = "1.0.2";
internal static WFJS_Inputs Inputs;
internal static string AssetsPath = "";
public static WFJS_Main Instance;
public static bool Enabled = true;
public static AudioClip JumpscareAudio;
public static Texture2D JumpscareTexture = new Texture2D(1, 1);
public ManualLogSource Log;
public WFJS_Main()
{
Instance = this;
}
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
new Harmony("esegn.wfjs").PatchAll(executingAssembly);
Inputs = new WFJS_Inputs();
AssetsPath = Path.Combine(executingAssembly.Location, "..");
WaveFileReader val = new WaveFileReader(Path.Combine(AssetsPath, "jumpscare.wav"));
try
{
JumpscareAudio = AudioClip.Create("WFJS_Jumpscare", (int)val.SampleCount, 2, 44100, false);
float[] array = new float[val.SampleCount * 2];
int num = 0;
while (true)
{
float[] array2 = val.ReadNextSampleFrame();
if (array2 == null)
{
break;
}
array[num] = array2[0];
array[num + 1] = array2[1];
num += 2;
}
JumpscareAudio.SetData(array, 0);
ImageConversion.LoadImage(JumpscareTexture, File.ReadAllBytes(Path.Combine(AssetsPath, "jumpscare.png")));
}
finally
{
((IDisposable)val)?.Dispose();
}
}
}
}
namespace Lethal_Company_WFJS.Patches
{
[HarmonyPatch(typeof(HUDManager))]
public static class Patch_HUDManager
{
private static GameObject _jumpscareTriggerContainer;
[HarmonyPatch("OnEnable")]
[HarmonyPostfix]
public static void Postfix_OnEnable()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
_jumpscareTriggerContainer = new GameObject
{
name = "JumpscareTriggerContainer"
};
_jumpscareTriggerContainer.AddComponent<JumpscareTriggerManager>();
}
[HarmonyPatch("OnDisable")]
[HarmonyPostfix]
public static void Postfix_OnDisable()
{
Object.Destroy((Object)(object)_jumpscareTriggerContainer);
}
}
[HarmonyPatch(typeof(MenuManager))]
public static class Patch_MenuManager
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void Postfix_Update(MenuManager __instance)
{
if (WFJS_Main.Inputs.Toggle.WasReleasedThisFrame())
{
WFJS_Main.Enabled = !WFJS_Main.Enabled;
WFJS_Main.Instance.Log.LogInfo((object)(WFJS_Main.Enabled ? "Functionality enabled." : "Functionality disabled."));
}
}
}
}