using System;
using System.Collections.Generic;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using GeneralImprovements;
using LCVR.Player;
using LethalCompanyInputUtils.Api;
using LethalExpansion;
using LethalExpansionCore;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using com.github.zehsteam.ToilHead.MonoBehaviours;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TouchScreen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A plugin to make the ship monitor interactable")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3")]
[assembly: AssemblyProduct("TouchScreen")]
[assembly: AssemblyTitle("TouchScreen")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.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 touchscreen
{
public static class LCVRUtil
{
internal static bool Setup(PluginInfo info)
{
if (VRSession.InVR)
{
InputUtil.LOOK_RAY = delegate(PlayerControllerB ply)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
VRPlayer localPlayer = VRSession.Instance.LocalPlayer;
Transform val = ((localPlayer != null) ? localPlayer.PrimaryController.InteractOrigin : null);
if (Object.op_Implicit((Object)(object)val))
{
return new Ray(val.position, val.forward);
}
Plugin.LOGGER.LogWarning((object)" > Failed to get primary VRController.");
return new Ray(((Component)ply.gameplayCamera).transform.position, ((Component)ply.gameplayCamera).transform.forward);
};
Plugin.LOGGER.LogInfo((object)$" > Hooked into LethalCompanyVR {info.Metadata.Version}");
return true;
}
return false;
}
public static LineRenderer getVRControllerRay()
{
VRPlayer localPlayer = VRSession.Instance.LocalPlayer;
if (localPlayer == null)
{
return null;
}
return ((Component)localPlayer.PrimaryController).GetComponent<LineRenderer>();
}
public static void UpdateInteractCanvas(Vector3 position)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
VRSession.Instance.HUD.UpdateInteractCanvasPosition(position);
}
}
public static class ToilHeadUtil
{
public static bool IsEnabled { get; private set; }
public static void Setup()
{
IsEnabled = true;
}
public static bool CallFollowTerminalAccessibleObject(Collider collider)
{
ScanNodeProperties component = ((Component)collider).GetComponent<ScanNodeProperties>();
FollowTerminalAccessibleObjectBehaviour val = ((component != null) ? ((Component)component).GetComponentInParent<FollowTerminalAccessibleObjectBehaviour>(false) : null);
if (Object.op_Implicit((Object)(object)val))
{
val.CallFunctionFromTerminal();
return true;
}
return false;
}
}
public class TouchScreenInputClass : LcInputActions
{
public static readonly TouchScreenInputClass Instance = new TouchScreenInputClass();
[InputAction("<Keyboard>/e", ActionId = "Touchscreen:Primary", Name = "Primary")]
public InputAction PRIMARY
{
get
{
return InputUtil.INPUT_PRIMARY;
}
set
{
InputUtil.INPUT_PRIMARY = value;
}
}
[InputAction("<Mouse>/leftButton", ActionId = "Touchscreen:Secondary", Name = "Secondary")]
public InputAction SECONDARY
{
get
{
return InputUtil.INPUT_SECONDARY;
}
set
{
InputUtil.INPUT_SECONDARY = value;
}
}
[InputAction("", ActionId = "Touchscreen:QuickSwitch", Name = "QuickSwitch")]
public InputAction QUICK_SWITCH
{
get
{
return InputUtil.INPUT_QUICKSWITCH;
}
set
{
InputUtil.INPUT_QUICKSWITCH = value;
}
}
[InputAction("", ActionId = "Touchscreen:AltQuickSwitch", Name = "Alt QuickSwitch")]
public InputAction ALT_QUICK_SWITCH
{
get
{
return InputUtil.INPUT_ALT_QUICKSWITCH;
}
set
{
InputUtil.INPUT_ALT_QUICKSWITCH = value;
}
}
}
internal static class MapCameraExtension
{
public static int GetPreviousValidRadarTarget(this ManualCameraRenderer renderer)
{
TransformAndName val = null;
for (int num = ((renderer.targetTransformIndex > 0) ? (renderer.targetTransformIndex - 1) : (renderer.radarTargets.Count - 1)); num != renderer.targetTransformIndex; num--)
{
if (num < 0)
{
num = renderer.radarTargets.Count - 1;
}
val = renderer.radarTargets[num];
if (val == null || !((Component)val.transform).gameObject.activeSelf)
{
continue;
}
if (!val.isNonPlayer)
{
PlayerControllerB component = ((Component)val.transform).gameObject.GetComponent<PlayerControllerB>();
if (component == null || !component.isPlayerControlled)
{
continue;
}
}
return num;
}
return renderer.targetTransformIndex;
}
public static void SwitchRadarTargetBackwards(this ManualCameraRenderer renderer, bool callRPC)
{
if (renderer.updateMapCameraCoroutine != null)
{
((MonoBehaviour)renderer).StopCoroutine(renderer.updateMapCameraCoroutine);
}
renderer.updateMapCameraCoroutine = ((MonoBehaviour)renderer).StartCoroutine(renderer.updateMapTarget(renderer.GetPreviousValidRadarTarget(), !callRPC));
}
}
[BepInPlugin("me.pm.TheDeadSnake", "TouchScreen", "1.1.3")]
[BepInProcess("Lethal Company.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal delegate R Func<R, T>(T value);
internal delegate R Supplier<R>();
internal static ManualLogSource LOGGER;
internal static Func<Bounds, GameObject> CREATE_BOUNDS;
private static bool _override = true;
private static bool _onPlanet = false;
public static bool IsActive
{
get
{
if (_onPlanet)
{
if (!_override)
{
return ConfigUtil.IGNORE_OVERRIDE;
}
return true;
}
return false;
}
set
{
if (_override != value)
{
_override = value;
MethodBase method = new StackTrace().GetFrame(1).GetMethod();
LOGGER.LogInfo((object)string.Format("Touchscreen was {0} by {1}.{2}.{3}", value ? "enabled" : "disabled", method.ReflectedType.Namespace, method.ReflectedType.Name, method.Name));
}
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
if (PlanetUtil.IsPlanet(scene))
{
StartOfRound instance = StartOfRound.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
ManualCameraRenderer mapScreen = instance.mapScreen;
obj = ((mapScreen != null) ? ((Component)mapScreen.mesh).gameObject : null);
}
GameObject val = (GameObject)obj;
if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<ScreenScript>() == (Object)null)
{
val.AddComponent<ScreenScript>();
}
_onPlanet = true;
}
}
private void OnSceneUnloaded(Scene scene)
{
if (_onPlanet)
{
_onPlanet = false;
}
}
private void Awake()
{
LOGGER = ((BaseUnityPlugin)this).Logger;
string pluginFolder = Path.Combine(Paths.PluginPath, "TheDeadSnake-Touchscreen");
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
ConfigUtil.Setup(((BaseUnityPlugin)this).Config, pluginFolder);
InputUtil.Setup();
PlanetUtil.checkPlugins();
Supplier<bool> supplier = () => Plugin.UseBetterMonitors.Value;
if (Chainloader.PluginInfos.TryGetValue("ShaosilGaming.GeneralImprovements", out var value) && supplier())
{
CREATE_BOUNDS = (GameObject x) => new Bounds(new Vector3(x.transform.position.x + -0.2f, x.transform.position.y + -0.05f, x.transform.position.z + 0.03f), new Vector3(0f, 1.05f, 1.36f));
LOGGER.LogInfo((object)$" > Hooked into GeneralImprovements {value.Metadata.Version}");
}
else
{
CREATE_BOUNDS = (GameObject x) => new Bounds(new Vector3(x.transform.position.x + 0.06f, x.transform.position.y + -0.05f, x.transform.position.z + 0.84f), new Vector3(0f, 1.05f, 1.36f));
}
if (Chainloader.PluginInfos.TryGetValue("com.github.zehsteam.ToilHead", out var value2))
{
ToilHeadUtil.Setup();
LOGGER.LogInfo((object)$" > Hooked into ToilHead {value2.Metadata.Version}");
}
LOGGER.LogInfo((object)"Enabled TouchScreen");
}
}
[DefaultExecutionOrder(100)]
public class ScreenScript : MonoBehaviour
{
private const float _isCloseMax = 1.25f;
private LineRenderer _vrRay;
private bool _vlookingAtMonitor;
private static PlayerControllerB LOCAL_PLAYER => GameNetworkManager.Instance?.localPlayerController;
private static ManualCameraRenderer MAP_RENDERER => StartOfRound.Instance?.mapScreen;
private bool _lookingAtMonitor
{
get
{
return _vlookingAtMonitor;
}
set
{
if (_vrRay != null)
{
((Renderer)_vrRay).enabled = value;
}
_vlookingAtMonitor = value;
}
}
private Bounds GetBounds()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return Plugin.CREATE_BOUNDS(((Component)this).gameObject);
}
private bool IsLookingAtMonitor(out Bounds bound, out Ray viewRay, out Ray camRay)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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)
PlayerControllerB lOCAL_PLAYER = LOCAL_PLAYER;
if (lOCAL_PLAYER != null && lOCAL_PLAYER.isInHangarShipRoom)
{
Ray val = InputUtil.LOOK_RAY(lOCAL_PLAYER);
Bounds bounds = GetBounds();
float num = default(float);
if (((Bounds)(ref bounds)).IntersectRay(val, ref num) && num <= lOCAL_PLAYER.grabDistance)
{
bound = bounds;
viewRay = val;
camRay = MAP_RENDERER.cam.ViewportPointToRay(GetMonitorCoordinates(bounds, ((Ray)(ref val)).GetPoint(num)));
return true;
}
}
bound = default(Bounds);
viewRay = default(Ray);
camRay = default(Ray);
return false;
}
private Vector3 GetMonitorCoordinates(Bounds bounds, Vector3 point)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(1f - 1f / Math.Abs(((Bounds)(ref bounds)).max.z - ((Bounds)(ref bounds)).min.z) * (point.z - ((Bounds)(ref bounds)).min.z), 1f / Math.Abs(((Bounds)(ref bounds)).max.y - ((Bounds)(ref bounds)).min.y) * (point.y - ((Bounds)(ref bounds)).min.y), 0f);
}
private bool TriggerRadar(RadarBoosterItem rItem, bool isAlt)
{
if ((Object)(object)rItem != (Object)null)
{
if (isAlt)
{
rItem.FlashAndSync();
}
else
{
rItem.PlayPingAudioAndSync();
}
return true;
}
return false;
}
internal void OnPlayerInteraction(bool isAlt)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)LOCAL_PLAYER != (Object)null) || !Plugin.IsActive || !IsLookingAtMonitor(out var _, out var _, out var camRay))
{
return;
}
Collider[] array = Physics.OverlapCapsule(((Ray)(ref camRay)).GetPoint(0f), ((Ray)(ref camRay)).GetPoint(10f), 1.25f);
foreach (Collider val in array)
{
if (!isAlt)
{
TerminalAccessibleObject component = ((Component)val).GetComponent<TerminalAccessibleObject>();
if (component != null)
{
component.CallFunctionFromTerminal();
break;
}
}
if (!isAlt)
{
NetworkObject componentInParent = ((Component)val).gameObject.GetComponentInParent<NetworkObject>();
if (componentInParent != null && ((Object)componentInParent).name.StartsWith("SpikeRoofTrapHazard"))
{
TerminalAccessibleObject componentInChildren = ((Component)componentInParent).GetComponentInChildren<TerminalAccessibleObject>();
if (componentInChildren != null)
{
componentInChildren.CallFunctionFromTerminal();
}
break;
}
}
RadarBoosterItem component2 = ((Component)val).GetComponent<RadarBoosterItem>();
if (component2 != null)
{
TriggerRadar(component2, isAlt);
break;
}
PlayerControllerB component3 = ((Component)val).GetComponent<PlayerControllerB>();
if (component3 != null)
{
GrabbableObject currentlyHeldObjectServer = component3.currentlyHeldObjectServer;
if (TriggerRadar((currentlyHeldObjectServer != null) ? ((Component)currentlyHeldObjectServer).GetComponent<RadarBoosterItem>() : null, isAlt) || isAlt)
{
continue;
}
List<TransformAndName> radarTargets = MAP_RENDERER.radarTargets;
for (int j = 0; j < radarTargets.Count; j++)
{
if (((object)((Component)component3).transform).Equals((object?)radarTargets[j].transform))
{
MAP_RENDERER.SwitchRadarTargetAndSync(j);
return;
}
}
}
else if (!isAlt && ToilHeadUtil.IsEnabled && ToilHeadUtil.CallFollowTerminalAccessibleObject(val))
{
break;
}
}
}
internal void OnPlayerQuickSwitch(bool isAlt)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB lOCAL_PLAYER = LOCAL_PLAYER;
if (lOCAL_PLAYER == null || !lOCAL_PLAYER.isInHangarShipRoom)
{
return;
}
Vector3 val = ((Component)this).gameObject.transform.position - ((Component)lOCAL_PLAYER).transform.position;
if (!(Math.Abs(val.x) + Math.Abs(val.y) + Math.Abs(val.z) < 6.85f))
{
return;
}
if (!isAlt)
{
if (ConfigUtil.CONFIG_ALT_REVERSE.Value && InputUtil.INPUT_ALT_QUICKSWITCH.IsPressed())
{
MAP_RENDERER.SwitchRadarTargetBackwards(callRPC: true);
}
else
{
MAP_RENDERER.SwitchRadarTargetForward(true);
}
}
else if (!ConfigUtil.CONFIG_ALT_REVERSE.Value)
{
MAP_RENDERER.SwitchRadarTargetBackwards(callRPC: true);
}
}
private void OnEnable()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
InputUtil.SCREEN_SCRIPT = this;
if ((Object)(object)LOCAL_PLAYER == (Object)null)
{
Plugin.LOGGER.LogWarning((object)"Unable to activate monitor touchscreen. Reason: Failed to get local player.");
}
else if (InputUtil.inVR && ConfigUtil.CONFIG_VR_SHOW_RAY.Value)
{
_vrRay = ((Component)this).gameObject.AddComponent<LineRenderer>();
((Renderer)_vrRay).enabled = false;
_vrRay.positionCount = 2;
_vrRay.SetPositions((Vector3[])(object)new Vector3[2]
{
Vector3.zero,
Vector3.zero
});
_vrRay.widthMultiplier = 0.0075f;
_vrRay.alignment = (LineAlignment)0;
LineRenderer vRControllerRay = LCVRUtil.getVRControllerRay();
if (vRControllerRay != null)
{
((Renderer)_vrRay).material = ((Renderer)vRControllerRay).material;
}
}
}
private void OnDisable()
{
InputUtil.SCREEN_SCRIPT = null;
}
private void LateUpdate()
{
//IL_0041: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB lOCAL_PLAYER = LOCAL_PLAYER;
if (Plugin.IsActive && IsLookingAtMonitor(out var _, out var viewRay, out var _))
{
if (InputUtil.inVR)
{
LineRenderer vrRay = _vrRay;
if (vrRay != null)
{
vrRay.SetPositions((Vector3[])(object)new Vector3[2]
{
((Ray)(ref viewRay)).origin,
((Ray)(ref viewRay)).GetPoint(lOCAL_PLAYER.grabDistance)
});
}
LCVRUtil.UpdateInteractCanvas(((Ray)(ref viewRay)).GetPoint(lOCAL_PLAYER.grabDistance / 2f));
if (ConfigUtil.CONFIG_SHOW_TOOLTIP.Value)
{
((TMP_Text)lOCAL_PLAYER.cursorTip).text = string.Format("[{0}] Interact\r\n[{1}] Flash (Radar)\r\n{2}", InputUtil.GetButtonDescription(InputUtil.INPUT_PRIMARY), InputUtil.GetButtonDescription(InputUtil.INPUT_SECONDARY), string.IsNullOrWhiteSpace(ConfigUtil.CONFIG_QUICK_SWITCH.Value) ? "" : ("[" + InputUtil.GetButtonDescription(InputUtil.INPUT_QUICKSWITCH) + "] Switch target"));
}
}
if (!_lookingAtMonitor)
{
_lookingAtMonitor = true;
lOCAL_PLAYER.isGrabbingObjectAnimation = true;
if (ConfigUtil.CONFIG_SHOW_POINTER.Value && !InputUtil.inVR)
{
((Behaviour)lOCAL_PLAYER.cursorIcon).enabled = true;
lOCAL_PLAYER.cursorIcon.sprite = ConfigUtil.HOVER_ICON;
}
if (ConfigUtil.CONFIG_SHOW_TOOLTIP.Value)
{
((TMP_Text)lOCAL_PLAYER.cursorTip).text = string.Format("[{0}] Interact\r\n[{1}] Flash (Radar)\r\n{2}", InputUtil.GetButtonDescription(InputUtil.INPUT_PRIMARY), InputUtil.GetButtonDescription(InputUtil.INPUT_SECONDARY), string.IsNullOrWhiteSpace(ConfigUtil.CONFIG_QUICK_SWITCH.Value) ? "" : ("[" + InputUtil.GetButtonDescription(InputUtil.INPUT_QUICKSWITCH) + "] Switch target"));
}
}
}
else if ((Object)(object)lOCAL_PLAYER != (Object)null && _lookingAtMonitor)
{
lOCAL_PLAYER.isGrabbingObjectAnimation = false;
_lookingAtMonitor = false;
}
}
}
public static class ConfigUtil
{
private static bool _config_ignore_override;
public static Sprite HOVER_ICON { get; private set; }
public static ConfigEntry<bool> CONFIG_ALT_REVERSE { get; private set; }
public static ConfigEntry<bool> CONFIG_SHOW_POINTER { get; private set; }
public static ConfigEntry<bool> CONFIG_SHOW_TOOLTIP { get; private set; }
public static ConfigEntry<bool> CONFIG_VR_SHOW_RAY { get; private set; }
public static bool IGNORE_OVERRIDE => _config_ignore_override;
public static ConfigEntry<string> CONFIG_PRIMARY { get; private set; }
public static ConfigEntry<string> CONFIG_SECONDARY { get; private set; }
public static ConfigEntry<string> CONFIG_QUICK_SWITCH { get; private set; }
public static ConfigEntry<string> CONFIG_ALT_QUICK_SWITCH { get; private set; }
public static ConfigEntry<string> CONFIG_VR_PRIMARY { get; private set; }
public static ConfigEntry<string> CONFIG_VR_SECONDARY { get; private set; }
public static ConfigEntry<string> CONFIG_VR_QUICK_SWITCH { get; private set; }
public static ConfigEntry<string> CONFIG_VR_ALT_QUICK_SWITCH { get; private set; }
internal static void Setup(ConfigFile config, string pluginFolder)
{
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Expected O, but got Unknown
//IL_0374: Unknown result type (might be due to invalid IL or missing references)
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
CONFIG_ALT_REVERSE = config.Bind<bool>("Layout", "ReverseSwitch", true, "Decides what the \"SwitchAlternative\" does when pressed\ntrue: When the alternative key is pressed, the quick switch will go through the reverse order\nfalse: When the alternative key is pressed the previous radar target will be selected");
CONFIG_PRIMARY = config.Bind<string>("Layout", "Primary", "<Keyboard>/e", "Name of the key mapping for the primary (switch, ping, trigger) actions\nAllowed value format: \"<Keyboard>/KEY\", \"<Mouse>/BUTTON\", \"<Gamepad>/BUTTON\"\nExamples: \"<Keyboard>/f\" \"<Mouse>/leftButton\" \"<Gamepad>/buttonNorth\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_SECONDARY = config.Bind<string>("Layout", "Secondary", "<Mouse>/leftButton", "Name of the key mapping for the secondary (Flash) action\nAllowed value format: \"<Keyboard>/KEY\", \"<Mouse>/BUTTON\", \"<Gamepad>/BUTTON\"\nExamples: \"<Keyboard>/g\" \"<Mouse>/rightButton\" \"<Gamepad>/buttonWest\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_QUICK_SWITCH = config.Bind<string>("Layout", "Switch", "", "Name of the key mapping for the quick switch action\nAllowed value format: \"<Keyboard>/KEY\", \"<Mouse>/BUTTON\", \"<Gamepad>/BUTTON\"\nExamples: \"<Keyboard>/g\" \"<Mouse>/rightButton\" \"<Gamepad>/buttonWest\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_ALT_QUICK_SWITCH = config.Bind<string>("Layout", "SwitchAlternative", "", "Name of the key mapping for the alternative quick switch action\nThe behaviour of the key is dependent on the \"ReverseSwitch\" option\nAllowed value format: \"<Keyboard>/KEY\", \"<Mouse>/BUTTON\", \"<Gamepad>/BUTTON\"\nExamples: \"<Keyboard>/g\" \"<Mouse>/rightButton\" \"<Gamepad>/buttonWest\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_VR_PRIMARY = config.Bind<string>("VR Layout", "Primary", "<XRController>{RightHand}/triggerButton", "Name of the key mapping for the primary (switch, ping, trigger) actions\nAllowed value format: \"<XRController>{HAND}/BUTTON\"\nExamples: \"<XRController>{RightHand}/triggerButton\" \"<XRController>{RightHand}/gripButton\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_VR_SECONDARY = config.Bind<string>("VR Layout", "Secondary", "<XRController>{RightHand}/gripButton", "Name of the key mapping for the secondary (Flash) action\nAllowed value format: \"<XRController>{HAND}/BUTTON\"\nExamples: \"<XRController>{RightHand}/triggerButton\" \"<XRController>{RightHand}/gripButton\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_VR_QUICK_SWITCH = config.Bind<string>("VR Layout", "Switch", "", "Name of the key mapping for the quick switch action\nAllowed value format: \"<XRController>{HAND}/BUTTON\"\nExamples: \"<XRController>{RightHand}/triggerButton\" \"<XRController>{RightHand}/gripButton\" \"<XRController>{LeftHand}/primaryButton\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
CONFIG_VR_ALT_QUICK_SWITCH = config.Bind<string>("VR Layout", "SwitchAlternative", "", "Name of the key mapping for the alternative quick switch action\nThe behaviour of the key is dependent on the \"ReverseSwitch\" option\nAllowed value format: \"<XRController>{HAND}/BUTTON\"\nExamples: \"<XRController>{RightHand}/triggerButton\" \"<XRController>{RightHand}/gripButton\" \"<XRController>{LeftHand}/primaryButton\"\nFor in depth instructions see: https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.InputControlPath.html");
_config_ignore_override = config.Bind<bool>("Features", "IgnoreOverride", false, "Set if other plugins can disable / enable the Touchscreen feature.\n > \"true\": Other plugins can no longer toggle it\n > \"false\": Other plugins may disable / enable it").Value;
ConfigEntry<string> val = config.Bind<string>("UI", "PointerIcon", "HoverIcon.png", $"Accepts a file name relative to the plugin name, a full system path or you can\nchoose one of the three default icons \"HoverIcon.png\", \"CrossIcon.png\", \"DotIcon.png\".\nIf you create your own icon make sure it's either a .png or .jpg file.\nExamples: \"HoverIcon.png\" or \"X:\\Images\\SomeImage.png\"");
CONFIG_SHOW_POINTER = config.Bind<bool>("UI", "ShowPointer", true, string.Format("Enable / Disable the pointer when hovering over the monitor", pluginFolder));
CONFIG_SHOW_TOOLTIP = config.Bind<bool>("UI", "ShowTooltip", true, string.Format("Enable / Disable the keybind tooltip when hovering over the monitor", pluginFolder));
CONFIG_VR_SHOW_RAY = config.Bind<bool>("UI", "VRShowRay", true, string.Format("Enable / Disable the VR Ray when hovering over the Monitor", pluginFolder));
string iconPath = "";
if (val.Value.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || val.Value.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase))
{
iconPath = ((Path.GetFileName(val.Value) == val.Value) ? Path.Combine(pluginFolder, val.Value) : val.Value);
}
else if (!string.IsNullOrWhiteSpace(((object)val).ToString()))
{
Plugin.LOGGER.LogWarning((object)"The provided icon file extension is not supported. Please make sure it'stream either a .png or .jpg file. Fallback to default icon...");
val.Value = ((ConfigEntryBase)val).DefaultValue.ToString();
iconPath = Path.Combine(pluginFolder, ((ConfigEntryBase)val).DefaultValue.ToString());
}
if (!iconPath.Equals("") && File.Exists(iconPath))
{
UnityWebRequest req = UnityWebRequestTexture.GetTexture(Utility.ConvertToWWWFormat(iconPath));
((AsyncOperation)req.SendWebRequest()).completed += delegate
{
//IL_0025: 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)
Texture2D content = DownloadHandlerTexture.GetContent(req);
HOVER_ICON = Sprite.Create(content, new Rect(0f, 0f, (float)((Texture)content).width, (float)((Texture)content).height), new Vector2(0.5f, 0.5f), 100f);
Plugin.LOGGER.LogInfo((object)("Loaded icon: " + Path.GetFileName(iconPath)));
};
return;
}
string text = val.Value.ToString();
if (string.IsNullOrWhiteSpace(text) || text.Equals("HoverIcon.png") || text.Equals("CrossIcon.png") || text.Equals("DotIcon.png"))
{
string text2 = string.Format("touchscreen.Resources.{0}", string.IsNullOrWhiteSpace(text) ? "HoverIcon.png" : text);
Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text2);
Texture2D val2 = new Texture2D(0, 0);
using (MemoryStream memoryStream = new MemoryStream())
{
manifestResourceStream.CopyTo(memoryStream);
ImageConversion.LoadImage(val2, memoryStream.ToArray());
}
HOVER_ICON = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f);
Plugin.LOGGER.LogInfo((object)("Loaded resource icon: " + text2.Split(".")[2]));
}
else
{
Plugin.LOGGER.LogWarning((object)(" > Unable to locate hover icon at provided path: " + iconPath));
}
}
}
public static class InputUtil
{
private delegate void Execute();
private static ScreenScript _screen_script = null;
internal static InputAction INPUT_PRIMARY;
internal static InputAction INPUT_SECONDARY;
internal static InputAction INPUT_QUICKSWITCH;
internal static InputAction INPUT_ALT_QUICKSWITCH;
private static Execute _primaryExecute = delegate
{
};
private static Execute _secondaryExecute = delegate
{
};
private static Execute _quickSwitchExecute = delegate
{
};
private static Execute _altQuickSwitchExecute = delegate
{
};
internal static Plugin.Func<Ray, PlayerControllerB> LOOK_RAY = (PlayerControllerB ply) => new Ray(((Component)ply.gameplayCamera).transform.position, ((Component)ply.gameplayCamera).transform.forward);
public static ScreenScript SCREEN_SCRIPT
{
get
{
return _screen_script;
}
internal set
{
if (Object.op_Implicit((Object)(object)value))
{
setupActions(value);
}
else
{
clearActions();
}
_screen_script = value;
}
}
public static bool inVR { get; private set; } = false;
public static string GetButtonDescription(InputAction action)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
bool flag = Object.op_Implicit((Object)(object)StartOfRound.Instance) && StartOfRound.Instance.localPlayerUsingController;
bool flag2 = flag && (Gamepad.current is DualShockGamepad || Gamepad.current is DualShock3GamepadHID || Gamepad.current is DualShock4GamepadHID);
InputBinding? val = null;
Enumerator<InputBinding> enumerator = action.bindings.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
InputBinding current = enumerator.Current;
if (inVR && ((InputBinding)(ref current)).effectivePath.StartsWith("<XRController>"))
{
val = current;
break;
}
if (flag && ((InputBinding)(ref current)).effectivePath.StartsWith("<Gamepad>"))
{
val = current;
break;
}
if (!flag && (((InputBinding)(ref current)).effectivePath.StartsWith("<Keyboard>") || ((InputBinding)(ref current)).effectivePath.StartsWith("<Mouse>")))
{
val = current;
break;
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
object obj;
if (!val.HasValue)
{
obj = "";
}
else
{
InputBinding value = val.Value;
obj = ((InputBinding)(ref value)).effectivePath;
}
string text = (string)obj;
string[] array = text.Split("/");
return ((array.Length > 1) ? text : "") switch
{
"<Mouse>/leftButton" => "LΜB",
"<Mouse>/rightButton" => "RΜB",
"<Keyboard>/escape" => "ESC",
"<Gamepad>/buttonNorth" => flag2 ? "△" : "Y",
"<Gamepad>/buttonEast" => flag2 ? "◯" : "B",
"<Gamepad>/buttonSouth" => flag2 ? "X" : "A",
"<Gamepad>/buttonWest" => flag2 ? "□" : "X",
"<Gamepad>/leftStickPress" => "L-Stick",
"<Gamepad>/rightStickPress" => "R-Stick",
"<Gamepad>/leftShoulder" => flag2 ? "L1" : "L-Shoulder",
"<Gamepad>/leftTrigger" => flag2 ? "L2" : "L-Trigger",
"<Gamepad>/rightShoulder" => flag2 ? "R1" : "R-Shoulder",
"<Gamepad>/rightTrigger" => flag2 ? "R2" : "R-Trigger",
"<XRController>{RightHand}/triggerButton" => "R-Trigger",
"<XRController>{RightHand}/gripButton" => "R-Grip",
"<XRController>{LeftHand}/triggerButton" => "L-Trigger",
"<XRController>{LeftHand}/gripButton" => "L-Grip",
"<XRController>{RightHand}/primaryButton" => "R-PrimaryButton",
"<XRController>{LeftHand}/primaryButton" => "L-PrimaryButton",
"<XRController>{RightHand}/secondaryButton" => "R-SecondaryButton",
"<XRController>{LeftHand}/secondaryButton" => "L-SecondaryButton",
_ => (array.Length > 1) ? array[1].ToUpper() : "?",
};
}
private static InputAction CreateKeybind(string key, string binding, Action<CallbackContext> action)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
InputAction val = new InputAction(key, (InputActionType)1, binding, (string)null, (string)null, (string)null);
val.performed += action;
val.Enable();
Plugin.LOGGER.LogInfo((object)("Set " + key + " button to: " + GetButtonDescription(val)));
return val;
}
private static void setupActions(ScreenScript script)
{
Plugin.LOGGER.LogInfo((object)" > Setup actions");
_primaryExecute = delegate
{
script.OnPlayerInteraction(isAlt: false);
};
_secondaryExecute = delegate
{
script.OnPlayerInteraction(isAlt: true);
};
_quickSwitchExecute = delegate
{
script.OnPlayerQuickSwitch(isAlt: false);
};
_altQuickSwitchExecute = delegate
{
script.OnPlayerQuickSwitch(isAlt: true);
};
}
private static void clearActions()
{
Plugin.LOGGER.LogInfo((object)" > Clear actions");
_primaryExecute = delegate
{
};
_secondaryExecute = delegate
{
};
_quickSwitchExecute = delegate
{
};
_altQuickSwitchExecute = delegate
{
};
}
internal static void Setup()
{
if (Chainloader.PluginInfos.TryGetValue("io.daxcess.lcvr", out var value))
{
inVR = LCVRUtil.Setup(value);
}
Plugin.Supplier<bool> supplier = () => TouchScreenInputClass.Instance != null;
if (!inVR && Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value2) && supplier())
{
INPUT_PRIMARY.performed += delegate
{
_primaryExecute();
};
INPUT_SECONDARY.performed += delegate
{
_secondaryExecute();
};
INPUT_QUICKSWITCH.performed += delegate
{
_quickSwitchExecute();
};
INPUT_ALT_QUICKSWITCH.performed += delegate
{
_altQuickSwitchExecute();
};
Plugin.LOGGER.LogInfo((object)$" > Hooked into InputUtils {value2.Metadata.Version}");
}
else
{
INPUT_PRIMARY = CreateKeybind("Touchscreen:Primary", inVR ? ConfigUtil.CONFIG_VR_PRIMARY.Value : ConfigUtil.CONFIG_PRIMARY.Value, delegate
{
_primaryExecute();
});
INPUT_SECONDARY = CreateKeybind("Touchscreen:Secondary", inVR ? ConfigUtil.CONFIG_VR_SECONDARY.Value : ConfigUtil.CONFIG_SECONDARY.Value, delegate
{
_secondaryExecute();
});
INPUT_QUICKSWITCH = CreateKeybind("Touchscreen:QuickSwitch", inVR ? ConfigUtil.CONFIG_VR_QUICK_SWITCH.Value : ConfigUtil.CONFIG_QUICK_SWITCH.Value, delegate
{
_quickSwitchExecute();
});
INPUT_ALT_QUICKSWITCH = CreateKeybind("Touchscreen:AltQuickSwitch", inVR ? ConfigUtil.CONFIG_VR_ALT_QUICK_SWITCH.Value : ConfigUtil.CONFIG_ALT_QUICK_SWITCH.Value, delegate
{
_altQuickSwitchExecute();
});
}
}
}
public static class PlanetUtil
{
private static Plugin.Func<bool, string> _onPlanetCheck = (string _) => false;
public static bool IsPlanet(Scene scene)
{
if (Object.op_Implicit((Object)(object)StartOfRound.Instance))
{
if (_onPlanetCheck(((Scene)(ref scene)).name))
{
return true;
}
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val in levels)
{
if (((Scene)(ref scene)).name.Equals(val.sceneName))
{
return true;
}
}
}
return false;
}
public static void checkPlugins()
{
Plugin.Supplier<bool> supplier = () => !Settings.UseOriginalLethalExpansion.Value;
PluginInfo value2;
if (Chainloader.PluginInfos.TryGetValue("com.github.lethalmods.lethalexpansioncore", out var value) && supplier())
{
_onPlanetCheck = (string x) => x.Equals("InitSceneLaunchOptions") && LethalExpansion.isInGame;
Plugin.LOGGER.LogInfo((object)$" > Hooked into LethalExpansionCore {value.Metadata.Version}");
}
else if (Chainloader.PluginInfos.TryGetValue("LethalExpansion", out value2))
{
_onPlanetCheck = (string x) => x.Equals("InitSceneLaunchOptions") && LethalExpansion.isInGame;
Plugin.LOGGER.LogInfo((object)$" > Hooked into LethalExpansion {value2.Metadata.Version}");
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TouchScreen";
public const string PLUGIN_NAME = "TouchScreen";
public const string PLUGIN_VERSION = "1.1.3";
}
}