DEADSOFTWARE

a17e6d253c960154dabdafa71daf38f2937a827c
[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.KeyboardInputHandler
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 javax.inject.Inject
11 @GameScope
12 @KeyboardInputHandler
13 class ToggleGameModeKeyboardInputHandler @Inject constructor(
14 private val mobsController: MobsController
15 ) : IKeyboardInputHandler {
18 override fun checkConditions(action: KeyboardInputAction): Boolean {
19 return action.actionKey is KeyboardInputActionKey.SwitchGameMode && action.isKeyDown
20 }
22 override fun handle(action: KeyboardInputAction) {
23 if (mobsController.player.gameMode == 1) {
24 mobsController.player.gameMode = 0
25 } else if (mobsController.player.gameMode == 0) {
26 mobsController.player.gameMode = 1
27 }
28 }
31 }