using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TogglePersonalScanner.Patches;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
[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("TogglePersonalScanner")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Toggle personal scanner for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TogglePersonalScanner")]
[assembly: AssemblyTitle("TogglePersonalScanner")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TogglePersonalScanner
{
[BepInPlugin("TogglePersonalScanner", "TogglePersonalScanner", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private readonly Harmony _harmony = new Harmony("TogglePersonalScanner");
private void Awake()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"Plugin TogglePersonalScanner is loaded!");
byte[] array = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)), "scanner.png"));
Texture2D val = new Texture2D(64, 64, (TextureFormat)5, false);
ImageConversion.LoadImage(val, array);
((Texture)val).filterMode = (FilterMode)0;
HUDManagerPatches.scannerIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f));
_harmony.PatchAll();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TogglePersonalScanner";
public const string PLUGIN_NAME = "TogglePersonalScanner";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace TogglePersonalScanner.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal class HUDManagerPatches
{
private static CallbackContext pingContext;
private static InputAction pingScanAction;
private static bool toggleScan;
public static Sprite scannerIcon;
public static Image scannerImage;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(HUDManager __instance)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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)
//IL_0070: 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)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
pingScanAction = IngamePlayerSettings.Instance.playerInput.actions.FindAction("PingScan", false);
GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/TopLeftCorner/Self");
GameObject val2 = new GameObject("CrouchIcon");
val2.transform.SetParent(val.transform, false);
val2.transform.SetAsLastSibling();
val2.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
RectTransform val3 = val2.AddComponent<RectTransform>();
scannerImage = val2.AddComponent<Image>();
scannerImage.sprite = scannerIcon;
val3.sizeDelta = new Vector2(20f, 20f);
val2.transform.position = val.transform.position + new Vector3(0.18f, 0.1f, 0f);
((Behaviour)scannerImage).enabled = false;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch(HUDManager __instance)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom)
{
return;
}
if (pingScanAction.WasPressedThisFrame())
{
toggleScan = !toggleScan;
}
if (!pingScanAction.IsPressed())
{
if (toggleScan && __instance.playerPingingScan <= 0f)
{
if (__instance.playersManager.shipIsLeaving)
{
toggleScan = false;
}
else
{
__instance.playerPingingScan = 0.3f;
}
}
}
else if (__instance.playerPingingScan <= -1f)
{
toggleScan = false;
__instance.PingScan_performed(pingContext);
}
if (toggleScan)
{
((Behaviour)scannerImage).enabled = true;
}
else
{
((Behaviour)scannerImage).enabled = false;
}
}
[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
[HarmonyPrefix]
private static void OnScan(HUDManager __instance, CallbackContext context)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
pingContext = context;
}
[HarmonyPatch(typeof(HUDManager), "HideHUD")]
[HarmonyPostfix]
private static void HideHUDPatch()
{
toggleScan = false;
}
}
}