summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 445466c)
raw | patch | inline | side by side (parent: 445466c)
author | fredboy <fredboy@protonmail.com> | |
Fri, 3 May 2024 12:44:15 +0000 (19:44 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Fri, 3 May 2024 12:44:15 +0000 (19:44 +0700) |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt b/core/src/ru/deadsoftware/cavedroid/game/input/KeyboardInputHandlersModule.kt
index f590398c30db185354b2ae2738c664649be7e4fa..80533d9a8a356530ed89f3139489ec65300dc516 100644 (file)
return handler
}
+ @Binds
+ @IntoSet
+ @GameScope
+ fun bindSwimUpKeyboardInputHandler(handler: SwimUpKeyboardInputHandler): IGameInputHandler<KeyboardInputAction> {
+ return handler
+ }
+
+ @Binds
+ @IntoSet
+ @GameScope
+ fun bindStopSwimKeyboardInputHandler(handler: StopSwimKeyboardInputHandler): IGameInputHandler<KeyboardInputAction> {
+ return handler
+ }
+
}
\ No newline at end of file
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/action/keys/KeyboardInputActionKey.kt b/core/src/ru/deadsoftware/cavedroid/game/input/action/keys/KeyboardInputActionKey.kt
index fb59efbf4dae71cc79b726ca51f28717ee66c655..cfac1328881d7de1171a66bbeb09bd521924b255 100644 (file)
data object Left : KeyboardInputActionKey
data object Right : KeyboardInputActionKey
data object Down : KeyboardInputActionKey
-
- data object Jump : KeyboardInputActionKey
+ data object Up : KeyboardInputActionKey
data object Crouch : KeyboardInputActionKey
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyUpKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/FlyUpKeyboardInputHandler.kt
index 2c6efc90beb2dee1f4efaab5127ca7814312e6c6..6038c271940e3a381ca937316b2d7fca208993fd 100644 (file)
) : IGameInputHandler<KeyboardInputAction> {
override fun checkConditions(action: KeyboardInputAction): Boolean {
- return action.actionKey is KeyboardInputActionKey.Jump &&
+ return action.actionKey is KeyboardInputActionKey.Up &&
+ !mobsController.player.swim &&
mobsController.player.isFlyMode &&
(mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/JumpKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/JumpKeyboardInputHandler.kt
index 1fbc9fb76b02c7926d9d6881336db5d1465adc12..762763b2d293b515699a9a75c272d65942fc26a1 100644 (file)
) : IGameInputHandler<KeyboardInputAction> {
override fun checkConditions(action: KeyboardInputAction): Boolean {
- return action.actionKey is KeyboardInputActionKey.Jump &&
+ return action.actionKey is KeyboardInputActionKey.Up &&
mobsController.player.canJump() && !mobsController.player.isFlyMode &&
action.isKeyDown &&
(mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/MoveCursorControlsModeKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/MoveCursorControlsModeKeyboardInputHandler.kt
index ac82cb8f62e6887a8be27ebf87b08361b14eadde..acae4b15b2e07a6af0b5f2cf5210463b26d5d684 100644 (file)
mobsController.player.controlMode == Player.ControlMode.CURSOR && action.isKeyDown &&
(action.actionKey is KeyboardInputActionKey.Left ||
action.actionKey is KeyboardInputActionKey.Right ||
- action.actionKey is KeyboardInputActionKey.Jump ||
+ action.actionKey is KeyboardInputActionKey.Up ||
action.actionKey is KeyboardInputActionKey.Down)
}
when (action.actionKey) {
KeyboardInputActionKey.Left -> player.cursorX--
KeyboardInputActionKey.Right -> player.cursorX++
- KeyboardInputActionKey.Jump -> player.cursorY--
+ KeyboardInputActionKey.Up -> player.cursorY--
KeyboardInputActionKey.Down -> player.cursorY++
else -> return
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt
--- /dev/null
+++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/StopSwimKeyboardInputHandler.kt
@@ -0,0 +1,30 @@
+package ru.deadsoftware.cavedroid.game.input.handler.keyboard
+
+import ru.deadsoftware.cavedroid.MainConfig
+import ru.deadsoftware.cavedroid.game.GameScope
+import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
+import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
+import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
+import ru.deadsoftware.cavedroid.game.mobs.MobsController
+import ru.deadsoftware.cavedroid.game.mobs.Player
+import ru.deadsoftware.cavedroid.game.world.GameWorld
+import javax.inject.Inject
+
+@GameScope
+class StopSwimKeyboardInputHandler @Inject constructor(
+ private val mainConfig: MainConfig,
+ private val mobsController: MobsController,
+ private val gameWorld: GameWorld,
+) : IGameInputHandler<KeyboardInputAction> {
+
+ override fun checkConditions(action: KeyboardInputAction): Boolean {
+ return action.actionKey is KeyboardInputActionKey.Up && !action.isKeyDown &&
+ mobsController.player.swim &&
+ (mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
+ }
+
+ override fun handle(action: KeyboardInputAction) {
+ mobsController.player.swim = false
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SwimUpKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/SwimUpKeyboardInputHandler.kt
--- /dev/null
@@ -0,0 +1,36 @@
+package ru.deadsoftware.cavedroid.game.input.handler.keyboard
+
+import ru.deadsoftware.cavedroid.MainConfig
+import ru.deadsoftware.cavedroid.game.GameScope
+import ru.deadsoftware.cavedroid.game.input.IGameInputHandler
+import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
+import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
+import ru.deadsoftware.cavedroid.game.mobs.MobsController
+import ru.deadsoftware.cavedroid.game.mobs.Player
+import ru.deadsoftware.cavedroid.game.world.GameWorld
+import javax.inject.Inject
+
+@GameScope
+class SwimUpKeyboardInputHandler @Inject constructor(
+ private val mainConfig: MainConfig,
+ private val mobsController: MobsController,
+ private val gameWorld: GameWorld,
+) : IGameInputHandler<KeyboardInputAction> {
+
+ private fun checkSwim(): Boolean {
+ return gameWorld.getForeMap(mobsController.player.mapX, mobsController.player.lowerMapY).isFluid()
+ }
+
+ override fun checkConditions(action: KeyboardInputAction): Boolean {
+ return action.actionKey is KeyboardInputActionKey.Up && action.isKeyDown &&
+ !mobsController.player.swim &&
+ !mobsController.player.canJump() &&
+ checkSwim() && !mobsController.player.isFlyMode &&
+ (mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
+ }
+
+ override fun handle(action: KeyboardInputAction) {
+ mobsController.player.swim = true
+ }
+
+}
\ No newline at end of file
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt
index 6a73a9bc54f316db61c68134ce2f8355035aaf46..05989775e0a5b9245c27e9ef51bc8919a6f92f08 100644 (file)
--- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt
+++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/keyboard/TurnOnFlyModeKeyboardInputHandler.kt
) : IGameInputHandler<KeyboardInputAction> {
override fun checkConditions(action: KeyboardInputAction): Boolean {
- return mobsController.player.gameMode == 1 && action.actionKey is KeyboardInputActionKey.Jump &&
+ return mobsController.player.gameMode == 1 && action.actionKey is KeyboardInputActionKey.Up &&
+ !mobsController.player.swim &&
!mobsController.player.isFlyMode && !mobsController.player.canJump() && action.isKeyDown &&
(mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/mapper/KeyboardInputActionMapper.kt b/core/src/ru/deadsoftware/cavedroid/game/input/mapper/KeyboardInputActionMapper.kt
index ca91f486951fdf0b737ede5f84d8fbd3e92df3dd..f2ed1260b476365b917e6c527efa066e4fe0cb45 100644 (file)
val actionKey = when (key) {
Input.Keys.A, Input.Keys.LEFT -> KeyboardInputActionKey.Left
Input.Keys.D, Input.Keys.RIGHT -> KeyboardInputActionKey.Right
- Input.Keys.W, Input.Keys.SPACE -> KeyboardInputActionKey.Jump
+ Input.Keys.W, Input.Keys.SPACE -> KeyboardInputActionKey.Up
Input.Keys.S -> KeyboardInputActionKey.Down
Input.Keys.E -> KeyboardInputActionKey.OpenInventory