DEADSOFTWARE

Input handler modules code generation
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / keyboard / FlyDownKeyboardInputHandler.kt
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.IKeyboardInputHandler
6 import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler
7 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
8 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
9 import ru.deadsoftware.cavedroid.game.mobs.MobsController
10 import ru.deadsoftware.cavedroid.game.mobs.player.Player
11 import javax.inject.Inject
13 @GameScope
14 @KeyboardInputHandler
15 class FlyDownKeyboardInputHandler @Inject constructor(
16 private val mainConfig: MainConfig,
17 private val mobsController: MobsController,
18 ) : IKeyboardInputHandler {
20 override fun checkConditions(action: KeyboardInputAction): Boolean {
21 return action.actionKey is KeyboardInputActionKey.Down &&
22 mobsController.player.isFlyMode &&
23 (mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
24 }
26 override fun handle(action: KeyboardInputAction) {
27 if (action.isKeyDown) {
28 mobsController.player.velocity.y = mobsController.player.speed
29 } else {
30 mobsController.player.velocity.y = 0f
31 }
32 }
34 }