Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit b012e23

Browse files
committed
Cleanups
1 parent e309821 commit b012e23

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

src/Explorer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
<Compile Include="Input\InputManager.cs" />
221221
<Compile Include="Input\InputSystem.cs" />
222222
<Compile Include="Input\LegacyInput.cs" />
223+
<Compile Include="Input\NoInput.cs" />
223224
<Compile Include="Menu\CursorControl.cs" />
224225
<Compile Include="Menu\MainMenu\Pages\OptionsPage.cs" />
225226
<Compile Include="Tests\TestClass.cs" />

src/ExplorerBepInPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Explorer
1616
{
17-
[BepInPlugin(ExplorerCore.GUID, ExplorerCore.NAME, ExplorerCore.VERSION)]
17+
[BepInPlugin(ExplorerCore.GUID, "Explorer", ExplorerCore.VERSION)]
1818
#if CPP
1919
public class ExplorerBepInPlugin : BasePlugin
2020
#else

src/ILRepack.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Target Name="ILRepacker" AfterTargets="Build">
44

5-
<!-- Merging DLLs -->
65
<ItemGroup>
76
<InputAssemblies Include="$(OutputPath)$(AssemblyName).dll" />
87
<InputAssemblies Include="..\lib\mcs.dll" />

src/Input/InputManager.cs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@ namespace Explorer
77
{
88
public static class InputManager
99
{
10-
// If no Input modules loaded at all
11-
public static bool NO_INPUT { get; private set; }
12-
13-
// If using new InputSystem module
14-
public static bool USING_NEW_INPUT { get; private set; }
15-
1610
private static AbstractInput inputModule;
1711

1812
public static void Init()
1913
{
2014
if (InputSystem.TKeyboard != null || TryLoadModule("Unity.InputSystem", InputSystem.TKeyboard))
2115
{
22-
USING_NEW_INPUT = true;
2316
inputModule = new InputSystem();
2417
}
2518
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.Input", LegacyInput.TInput))
@@ -30,26 +23,20 @@ public static void Init()
3023
if (inputModule == null)
3124
{
3225
ExplorerCore.LogWarning("Could not find any Input module!");
33-
NO_INPUT = true;
34-
}
35-
else
36-
{
37-
inputModule.Init();
26+
inputModule = new NoInput();
3827
}
3928

29+
inputModule.Init();
30+
4031
bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
4132
}
4233

43-
public static Vector3 MousePosition => inputModule?.MousePosition ?? Vector3.zero;
44-
45-
public static bool GetKeyDown(KeyCode key) => inputModule?.GetKeyDown(key) ?? false;
46-
47-
public static bool GetKey(KeyCode key) => inputModule?.GetKey(key) ?? false;
34+
public static Vector3 MousePosition => inputModule.MousePosition;
4835

49-
/// <param name="btn">0 = left, 1 = right, 2 = middle.</param>
50-
public static bool GetMouseButtonDown(int btn) => inputModule?.GetMouseButtonDown(btn) ?? false;
36+
public static bool GetKeyDown(KeyCode key) => inputModule.GetKeyDown(key);
37+
public static bool GetKey(KeyCode key) => inputModule.GetKey(key);
5138

52-
/// <param name="btn">0 = left, 1 = right, 2 = middle.</param>
53-
public static bool GetMouseButton(int btn) => inputModule?.GetMouseButton(btn) ?? false;
39+
public static bool GetMouseButtonDown(int btn) => inputModule.GetMouseButtonDown(btn);
40+
public static bool GetMouseButton(int btn) => inputModule.GetMouseButton(btn);
5441
}
5542
}

src/Input/NoInput.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using UnityEngine;
6+
7+
namespace Explorer.Input
8+
{
9+
// Just a stub for games where no Input module was able to load at all.
10+
11+
public class NoInput : AbstractInput
12+
{
13+
public override Vector2 MousePosition => Vector2.zero;
14+
15+
public override bool GetKey(KeyCode key) => false;
16+
17+
public override bool GetKeyDown(KeyCode key) => false;
18+
19+
public override bool GetMouseButton(int btn) => false;
20+
21+
public override bool GetMouseButtonDown(int btn) => false;
22+
23+
public override void Init() { }
24+
}
25+
}

0 commit comments

Comments
 (0)