DEADSOFTWARE

Add joystick touch controls
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / mouse / CursorMouseInputHandler.kt
index 6a4b5a4eb968101d134eeeefa7aa9b9e290b51bd..9093680c299d7f46d68acf79c8236eba49a0b843 100644 (file)
@@ -41,20 +41,6 @@ class CursorMouseInputHandler @Inject constructor(
     private fun GameWorld.isCurrentBlockAutoselectable() =
         getForeMap(player.cursorX, player.cursorY).isAutoselectable
 
-    private fun checkCursorBounds() {
-        if (player.gameMode == 0) {
-            val minCursorX = player.mapX - SURVIVAL_CURSOR_RANGE
-            val maxCursorX = player.mapX + SURVIVAL_CURSOR_RANGE
-            val minCursorY = player.middleMapY - SURVIVAL_CURSOR_RANGE
-            val maxCursorY = player.middleMapY + SURVIVAL_CURSOR_RANGE
-
-            player.cursorX = MathUtils.clamp(player.cursorX, minCursorX, maxCursorX)
-            player.cursorY = MathUtils.clamp(player.cursorY, minCursorY, maxCursorY)
-        }
-
-        player.cursorY = MathUtils.clamp(player.cursorY, 0, gameWorld.height - 1)
-    }
-
     private fun setPlayerDirectionToCursor() {
         if (player.controlMode != Player.ControlMode.CURSOR) {
             return
@@ -137,7 +123,7 @@ class CursorMouseInputHandler @Inject constructor(
             !mainConfig.isTouch -> handleMouse(action)
         }
 
-        checkCursorBounds()
+        player.checkCursorBounds(gameWorld)
         setPlayerDirectionToCursor()
 
         if (player.cursorX != pastCursorX || player.cursorY != pastCursorY) {