DEADSOFTWARE

0111949d495635c4ac0c5fd79483fbdbfe0a8cbb
[cavedroid.git] /
1 package ru.deadsoftware.cavedroid.game.input.handler.keyboard
3 import ru.deadsoftware.cavedroid.game.GameScope
4 import ru.deadsoftware.cavedroid.game.GameUiWindow
5 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
6 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
7 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
8 import ru.deadsoftware.cavedroid.game.windows.GameWindowsManager
9 import javax.inject.Inject
11 @GameScope
12 class CloseGameWindowKeyboardInputHandler @Inject constructor(
13 private val gameWindowsManager: GameWindowsManager
14 ) : IGameInputHandler<KeyboardInputAction> {
16 override fun checkConditions(action: KeyboardInputAction): Boolean {
17 return action.actionKey is KeyboardInputActionKey.OpenInventory &&
18 action.isKeyDown && gameWindowsManager.getCurrentWindow() != GameUiWindow.NONE
19 }
21 override fun handle(action: KeyboardInputAction) {
22 gameWindowsManager.closeWindow()
23 }
24 }