mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 13:11:53 +00:00
Added Event types
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
|
||||
namespace GlitchyEngine.Events
|
||||
{
|
||||
public abstract class KeyEvent : Event
|
||||
{
|
||||
protected int32 _keyCode;
|
||||
|
||||
[Inline]
|
||||
public int32 KeyCode => _keyCode;
|
||||
|
||||
public override EventCategory Category => .Input | .Keyboard
|
||||
|
||||
protected this(int32 keyCode)
|
||||
{
|
||||
_keyCode = keyCode;
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyPressedEvent : KeyEvent, IEvent
|
||||
{
|
||||
private int32 _repeatCount;
|
||||
|
||||
public int32 RepeatCount => _repeatCount;
|
||||
|
||||
public override EventType EventType => .KeyPressed;
|
||||
public static EventType StaticType => .KeyPressed;
|
||||
|
||||
public override StringView Name => "KeyPressed";
|
||||
|
||||
public this(int32 keyCode, int32 repeatCount) : base(keyCode)
|
||||
{
|
||||
_repeatCount = repeatCount;
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.AppendF("KeyPressedEvent: {} ({} repeats)", _keyCode, _repeatCount);
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyReleasedEvent : KeyEvent, IEvent
|
||||
{
|
||||
public override EventType EventType => .KeyReleased;
|
||||
public static EventType StaticType => .KeyReleased;
|
||||
|
||||
public override StringView Name => "KeyReleased";
|
||||
|
||||
public this(int32 keyCode) : base(keyCode) { }
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.AppendF("KeyReleasedEvent: {}", _keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user