[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / keyboard / SelectHotbarSlotKeyboardInputHandler.kt
1 package ru.deadsoftware.cavedroid.game.input.handler.keyboard
3 import ru.deadsoftware.cavedroid.game.GameScope
4 import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
5 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
6 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
7 import ru.deadsoftware.cavedroid.game.mobs.MobsController
8 import javax.inject.Inject
10 @GameScope
11 class SelectHotbarSlotKeyboardInputHandler @Inject constructor(
12 private val mobsController: MobsController,
13 ) : IGameInputHandler<KeyboardInputAction> {
15 override fun checkConditions(action: KeyboardInputAction): Boolean {
16 return action.actionKey is KeyboardInputActionKey.SelectHotbarSlot &&
17 action.isKeyDown
18 }
20 override fun handle(action: KeyboardInputAction) {
21 mobsController.player.inventory.activeSlot = (action.actionKey as KeyboardInputActionKey.SelectHotbarSlot).slot
22 }
24 }