Major refactor and organization, optimizations to chunk, world and renderer
This commit is contained in:
38
Core/Input.cs
Normal file
38
Core/Input.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
|
||||
namespace Voxel.Core
|
||||
{
|
||||
public static class Input
|
||||
{
|
||||
private static Dictionary<Keys, bool> _keystates = new Dictionary<Keys, bool>();
|
||||
private static Dictionary<MouseButton, bool> _mouseButtonStates = new Dictionary<MouseButton, bool>();
|
||||
|
||||
public static Action<MouseWheelEventArgs> OnMouseWheel;
|
||||
|
||||
public static bool GetMouseButton(MouseButton button)
|
||||
{
|
||||
return _mouseButtonStates.TryGetValue(button, out bool pressed) && pressed;
|
||||
}
|
||||
|
||||
public static void SetMouseButton(MouseButton button, bool pressed)
|
||||
{
|
||||
_mouseButtonStates[button] = pressed;
|
||||
}
|
||||
|
||||
public static bool GetKey(Keys key)
|
||||
{
|
||||
return _keystates.TryGetValue(key, out bool pressed) && pressed;
|
||||
}
|
||||
|
||||
public static void SetKey(Keys key, bool pressed)
|
||||
{
|
||||
_keystates[key] = pressed;
|
||||
}
|
||||
|
||||
public static void MouseWheel(MouseWheelEventArgs e)
|
||||
{
|
||||
OnMouseWheel.Invoke(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user