DEADSOFTWARE

ef4e696c2833613708f25c8ee99a2e458ffae5e4
[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.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 ToggleGameModeKeyboardInputHandler @Inject constructor(
12 private val mobsController: MobsController
13 ) : IGameInputHandler<KeyboardInputAction> {
16 override fun checkConditions(action: KeyboardInputAction): Boolean {
17 return action.actionKey is KeyboardInputActionKey.SwitchGameMode && action.isKeyDown
18 }
20 override fun handle(action: KeyboardInputAction) {
21 if (mobsController.player.gameMode == 1) {
22 mobsController.player.gameMode = 0
23 } else if (mobsController.player.gameMode == 0) {
24 mobsController.player.gameMode = 1
25 }
26 }
29 }