0f656d8eac5a6ab38cb9f1e9e07a5a4d97d631e5
1 package ru.deadsoftware.cavedroid.game.input.handler.keyboard
3 import ru.deadsoftware.cavedroid.MainConfig
4 import ru.deadsoftware.cavedroid.game.GameScope
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.mobs.MobsController
9 import ru.deadsoftware.cavedroid.game.mobs.player.Player
10 import javax.inject.Inject
12 @GameScope
13 class ToggleControlsModeKeyboardInputHandler @Inject constructor(
14 private val mainConfig: MainConfig,
15 private val mobsController: MobsController,
16 ) : IGameInputHandler<KeyboardInputAction> {
18 override fun checkConditions(action: KeyboardInputAction): Boolean {
19 return action.actionKey is KeyboardInputActionKey.SwitchControlsMode && action.isKeyDown
20 && mainConfig.isTouch
21 }
23 override fun handle(action: KeyboardInputAction) {
24 if (mobsController.player.controlMode == Player.ControlMode.WALK) {
25 mobsController.player.controlMode = Player.ControlMode.CURSOR
26 } else {
27 mobsController.player.controlMode = Player.ControlMode.WALK
28 }
29 }
31 }