From b012e2305c8c0a85e3e556c5befb12203aab72c4 Mon Sep 17 00:00:00 2001
From: sinaioutlander <49360850+sinaioutlander@users.noreply.github.com>
Date: Wed, 7 Oct 2020 16:20:34 +1100
Subject: [PATCH] Cleanups
---
src/Explorer.csproj | 1 +
src/ExplorerBepInPlugin.cs | 2 +-
src/ILRepack.targets | 1 -
src/Input/InputManager.cs | 29 ++++++++---------------------
src/Input/NoInput.cs | 25 +++++++++++++++++++++++++
5 files changed, 35 insertions(+), 23 deletions(-)
create mode 100644 src/Input/NoInput.cs
diff --git a/src/Explorer.csproj b/src/Explorer.csproj
index ef14fec..52a2762 100644
--- a/src/Explorer.csproj
+++ b/src/Explorer.csproj
@@ -220,6 +220,7 @@
+
diff --git a/src/ExplorerBepInPlugin.cs b/src/ExplorerBepInPlugin.cs
index d32b458..83a4e24 100644
--- a/src/ExplorerBepInPlugin.cs
+++ b/src/ExplorerBepInPlugin.cs
@@ -14,7 +14,7 @@ using BepInEx.IL2CPP;
namespace Explorer
{
- [BepInPlugin(ExplorerCore.GUID, ExplorerCore.NAME, ExplorerCore.VERSION)]
+ [BepInPlugin(ExplorerCore.GUID, "Explorer", ExplorerCore.VERSION)]
#if CPP
public class ExplorerBepInPlugin : BasePlugin
#else
diff --git a/src/ILRepack.targets b/src/ILRepack.targets
index ab1e843..f2ba0df 100644
--- a/src/ILRepack.targets
+++ b/src/ILRepack.targets
@@ -2,7 +2,6 @@
-
diff --git a/src/Input/InputManager.cs b/src/Input/InputManager.cs
index 532b7ce..6885cc0 100644
--- a/src/Input/InputManager.cs
+++ b/src/Input/InputManager.cs
@@ -7,19 +7,12 @@ namespace Explorer
{
public static class InputManager
{
- // If no Input modules loaded at all
- public static bool NO_INPUT { get; private set; }
-
- // If using new InputSystem module
- public static bool USING_NEW_INPUT { get; private set; }
-
private static AbstractInput inputModule;
public static void Init()
{
if (InputSystem.TKeyboard != null || TryLoadModule("Unity.InputSystem", InputSystem.TKeyboard))
{
- USING_NEW_INPUT = true;
inputModule = new InputSystem();
}
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.Input", LegacyInput.TInput))
@@ -30,26 +23,20 @@ namespace Explorer
if (inputModule == null)
{
ExplorerCore.LogWarning("Could not find any Input module!");
- NO_INPUT = true;
- }
- else
- {
- inputModule.Init();
+ inputModule = new NoInput();
}
+ inputModule.Init();
+
bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
}
- public static Vector3 MousePosition => inputModule?.MousePosition ?? Vector3.zero;
+ public static Vector3 MousePosition => inputModule.MousePosition;
- public static bool GetKeyDown(KeyCode key) => inputModule?.GetKeyDown(key) ?? false;
+ public static bool GetKeyDown(KeyCode key) => inputModule.GetKeyDown(key);
+ public static bool GetKey(KeyCode key) => inputModule.GetKey(key);
- public static bool GetKey(KeyCode key) => inputModule?.GetKey(key) ?? false;
-
- /// 0 = left, 1 = right, 2 = middle.
- public static bool GetMouseButtonDown(int btn) => inputModule?.GetMouseButtonDown(btn) ?? false;
-
- /// 0 = left, 1 = right, 2 = middle.
- public static bool GetMouseButton(int btn) => inputModule?.GetMouseButton(btn) ?? false;
+ public static bool GetMouseButtonDown(int btn) => inputModule.GetMouseButtonDown(btn);
+ public static bool GetMouseButton(int btn) => inputModule.GetMouseButton(btn);
}
}
diff --git a/src/Input/NoInput.cs b/src/Input/NoInput.cs
new file mode 100644
index 0000000..10c1ba8
--- /dev/null
+++ b/src/Input/NoInput.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace Explorer.Input
+{
+ // Just a stub for games where no Input module was able to load at all.
+
+ public class NoInput : AbstractInput
+ {
+ public override Vector2 MousePosition => Vector2.zero;
+
+ public override bool GetKey(KeyCode key) => false;
+
+ public override bool GetKeyDown(KeyCode key) => false;
+
+ public override bool GetMouseButton(int btn) => false;
+
+ public override bool GetMouseButtonDown(int btn) => false;
+
+ public override void Init() { }
+ }
+}