particles when blocks are being mined

This commit is contained in:
minjaesong
2023-10-12 15:47:51 +09:00
parent 93f1430c5c
commit 58fa1dd56c
2 changed files with 33 additions and 17 deletions

View File

@@ -79,23 +79,31 @@ object PickaxeCore {
} }
// filter passed, do the job // filter passed, do the job
val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!! val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
val (oreOnTile, _) = INGAME.world.getTileFromOre(x, y) val (oreOnTile, _) = INGAME.world.getTileFromOre(x, y)
INGAME.world.inflictTerrainDamage( INGAME.world.inflictTerrainDamage(
x, y, x, y,
Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg
)?.let { tileBroken -> ).let { tileBroken ->
if (Math.random() < dropProbability) { // tile busted
val drop = if (oreOnTile != Block.AIR) if (tileBroken != null) {
OreCodex[oreOnTile].item if (Math.random() < dropProbability) {
else val drop = if (oreOnTile != Block.AIR)
BlockCodex[tileBroken].drop OreCodex[oreOnTile].item
else
BlockCodex[tileBroken].drop
if (drop.isNotBlank()) { if (drop.isNotBlank()) {
INGAME.queueActorAddition(DroppedItem(drop, (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED)) INGAME.queueActorAddition(DroppedItem(drop, (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED))
}
makeDust(tile, x, y, 9)
} }
makeDust(tile, x, y, 9) }
// tile not busted
if (Math.random() < actionInterval) {
makeDust(tile, x, y, 1)
} }
} }

View File

@@ -88,18 +88,26 @@ object SledgehammerCore {
} }
// filter passed, do the job // filter passed, do the job
val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!! val actionInterval = actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
val swingDmgToFrameDmg = delta.toDouble() / actionInterval
INGAME.world.inflictWallDamage( INGAME.world.inflictWallDamage(
x, y, x, y,
Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg Calculate.pickaxePower(actor, item?.material) * swingDmgToFrameDmg
)?.let { tileBroken -> ).let { tileBroken ->
if (Math.random() < dropProbability) { // tile busted
val drop = BlockCodex[tileBroken].drop if (tileBroken != null) {
if (drop.isNotBlank()) { if (Math.random() < dropProbability) {
INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED)) val drop = BlockCodex[tileBroken].drop
if (drop.isNotBlank()) {
INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED))
}
PickaxeCore.makeDust(wall, x, y, 9, App.tileMaker.wallOverlayColour)
} }
PickaxeCore.makeDust(wall, x, y, 9, App.tileMaker.wallOverlayColour) }
// tile not busted
if (Math.random() < actionInterval) {
PickaxeCore.makeDust(wall, x, y, 1, App.tileMaker.wallOverlayColour)
} }
} }