DEADSOFTWARE

Input handler modules code generation
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / GameInputHandler.kt
1 package ru.deadsoftware.cavedroid.game.input
3 import ru.deadsoftware.cavedroid.game.input.action.IGameInputAction
4 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
5 import ru.deadsoftware.cavedroid.game.input.action.MouseInputAction
6 import ru.fredboy.cavedroid.ksp.annotations.GenerateSetMultibindingsModule
8 @GenerateSetMultibindingsModule(
9 interfaceClass = IKeyboardInputHandler::class,
10 modulePackage = "ru.deadsoftware.cavedroid.game.input",
11 moduleName = "KeyboardInputHandlersModule"
12 )
13 annotation class KeyboardInputHandler
15 @GenerateSetMultibindingsModule(
16 interfaceClass = IMouseInputHandler::class,
17 modulePackage = "ru.deadsoftware.cavedroid.game.input",
18 moduleName = "MouseInputHandlersModule"
19 )
20 annotation class MouseInputHandler
22 interface IKeyboardInputHandler : IGameInputHandler<KeyboardInputAction>
24 interface IMouseInputHandler : IGameInputHandler<MouseInputAction>
26 interface IGameInputHandler<A : IGameInputAction> {
28 /**
29 * Implementation should check if conditions for handling an input are satisfied
30 * For example - inventory input handler should return false if inventory is closed
31 */
32 fun checkConditions(action: A): Boolean
34 /**
35 * Handle given input action.
36 * This will not be called if [checkConditions] returned false
37 */
38 fun handle(action: A)
40 }