DEADSOFTWARE

d22cd947ee0b78616fc6bbcc5fad042f60fd0870
[cavedroid.git] /
1 package ru.deadsoftware.cavedroid.game.input.handler.keyboard
3 import ru.deadsoftware.cavedroid.game.GameScope
4 import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler
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 ru.deadsoftware.cavedroid.misc.annotations.multibinding.BindKeyboardInputHandler
9 import javax.inject.Inject
11 @GameScope
12 @BindKeyboardInputHandler
13 class SelectHotbarSlotKeyboardInputHandler @Inject constructor(
14 private val mobsController: MobsController,
15 ) : IKeyboardInputHandler {
17 override fun checkConditions(action: KeyboardInputAction): Boolean {
18 return action.actionKey is KeyboardInputActionKey.SelectHotbarSlot &&
19 action.isKeyDown
20 }
22 override fun handle(action: KeyboardInputAction) {
23 mobsController.player.inventory.activeSlot = (action.actionKey as KeyboardInputActionKey.SelectHotbarSlot).slot
24 }
26 }