DEADSOFTWARE

Input handler modules code generation
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / keyboard / OpenInventoryKeyboardInputHandler.kt
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.IKeyboardInputHandler
6 import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler
7 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
8 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
9 import ru.deadsoftware.cavedroid.game.ui.windows.GameWindowsManager
10 import javax.inject.Inject
12 @GameScope
13 @KeyboardInputHandler
14 class OpenInventoryKeyboardInputHandler @Inject constructor(
15 private val gameWindowsManager: GameWindowsManager,
16 ) : IKeyboardInputHandler {
18 override fun checkConditions(action: KeyboardInputAction): Boolean {
19 return action.actionKey is KeyboardInputActionKey.OpenInventory &&
20 !action.isKeyDown && gameWindowsManager.getCurrentWindow() == GameUiWindow.NONE
21 }
23 override fun handle(action: KeyboardInputAction) {
24 gameWindowsManager.openInventory()
25 }
26 }