X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;ds=sidebyside;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2Factions%2Fupdateblock%2FUpdateSandAction.kt;h=ac1ff8a9faa558dc6699180e56c4346686be024e;hb=1e285247085ba04351feb486a0be6aa577f43093;hp=26fb97827c6ed30898977232e0496828bbd201a4;hpb=894d9f1babeff18c9cbb5f83206ff2c549de0bdb;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSandAction.kt b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSandAction.kt index 26fb978..ac1ff8a 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSandAction.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/actions/updateblock/UpdateSandAction.kt @@ -4,20 +4,23 @@ import ru.deadsoftware.cavedroid.game.GameScope import ru.deadsoftware.cavedroid.game.mobs.FallingSand import ru.deadsoftware.cavedroid.game.mobs.MobsController import ru.deadsoftware.cavedroid.game.world.GameWorld +import ru.deadsoftware.cavedroid.misc.annotations.multibinding.BindUpdateBlockAction import javax.inject.Inject @GameScope +@BindUpdateBlockAction(stringKey = UpdateSandAction.BLOCK_KEY) class UpdateSandAction @Inject constructor( private val gameWorld: GameWorld, private val mobsController: MobsController, ) : IUpdateBlockAction { override fun update(x: Int, y: Int) { - val shouldFall = gameWorld.getForeMapBlock(x, y + 1).collision.not() + val shouldFall = gameWorld.getForeMap(x, y + 1).params.hasCollision.not() if (shouldFall) { - gameWorld.setForeMap(x, y, 0) - mobsController.addMob(FallingSand(x * 16f, y * 16f)) + gameWorld.resetForeMap(x, y) + FallingSand(x * 16f, y * 16f) + .apply { attachToController(mobsController) } } }