-
Notifications
You must be signed in to change notification settings - Fork 16
/
ControlKeyHandler.cs
33 lines (29 loc) · 1.26 KB
/
ControlKeyHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using EndlessClient.Controllers;
using EndlessClient.GameExecution;
using EOLib.Domain.Map;
using Microsoft.Xna.Framework.Input;
using Optional;
namespace EndlessClient.Input
{
public class ControlKeyHandler : InputHandlerBase
{
private readonly IControlKeyController _controlKeyController;
public ControlKeyHandler(IEndlessGameProvider endlessGameProvider,
IUserInputProvider userInputProvider,
IUserInputTimeRepository userInputTimeRepository,
IControlKeyController controlKeyController,
ICurrentMapStateRepository currentMapStateRepository)
: base(endlessGameProvider, userInputProvider, userInputTimeRepository, currentMapStateRepository)
{
_controlKeyController = controlKeyController;
}
protected override Option<Keys> HandleInput()
{
if (IsKeyHeld(Keys.LeftControl) && _controlKeyController.Attack())
return Option.Some(Keys.LeftControl);
if (IsKeyHeld(Keys.RightControl) && _controlKeyController.Attack())
return Option.Some(Keys.RightControl);
return Option.None<Keys>();
}
}
}