DEADSOFTWARE

Game action modules generation
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / actions / useitem / UseLavaBucketAction.kt
1 package ru.deadsoftware.cavedroid.game.actions.useitem
3 import ru.deadsoftware.cavedroid.game.GameItemsHolder
4 import ru.deadsoftware.cavedroid.game.GameScope
5 import ru.deadsoftware.cavedroid.game.mobs.MobsController
6 import ru.deadsoftware.cavedroid.game.model.item.Item
7 import ru.deadsoftware.cavedroid.game.world.GameWorld
8 import javax.inject.Inject
10 @GameScope
11 @UseItemAction(UseLavaBucketAction.ACTION_KEY)
12 class UseLavaBucketAction @Inject constructor(
13 private val gameWorld: GameWorld,
14 private val mobsController: MobsController,
15 private val gameItemsHolder: GameItemsHolder,
16 ) : IUseItemAction {
18 override fun perform(item: Item.Usable, x: Int, y: Int) {
19 gameWorld.placeToForeground(x, y, gameItemsHolder.getBlock("lava"))
21 if (mobsController.player.gameMode != 1) {
22 mobsController.player.setCurrentInventorySlotItem(gameItemsHolder.getItem("bucket_empty"))
23 }
24 }
26 companion object {
27 const val ACTION_KEY = "use_lava_bucket"
28 }
29 }