mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
more particles
This commit is contained in:
@@ -18,6 +18,7 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
|||||||
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
|
import net.torvald.terrarum.modulebasegame.gameactors.DroppedItem
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
|
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
|
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
|
||||||
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.RenderTag
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -54,13 +55,10 @@ object PickaxeCore {
|
|||||||
for (oy in 0 until mh) for (ox in 0 until mw) {
|
for (oy in 0 until mh) for (ox in 0 until mw) {
|
||||||
val x = mx + xoff + ox
|
val x = mx + xoff + ox
|
||||||
val y = my + yoff + oy
|
val y = my + yoff + oy
|
||||||
|
|
||||||
val (wx, wy) = INGAME.world.coerceXY(x, y)
|
|
||||||
|
|
||||||
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
||||||
val actorvalue = actor.actorValue
|
val actorvalue = actor.actorValue
|
||||||
val tile = INGAME.world.getTileFromTerrain(x, y)
|
val tile = INGAME.world.getTileFromTerrain(x, y)
|
||||||
val tileNum = INGAME.world.layerTerrain.unsafeGetTile(wx, wy)
|
|
||||||
|
|
||||||
item?.using = true
|
item?.using = true
|
||||||
|
|
||||||
@@ -97,7 +95,7 @@ object PickaxeCore {
|
|||||||
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(tileNum, x, y, 9)
|
makeDust(tile, x, y, 9)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,19 +107,28 @@ object PickaxeCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val pixelOffs = intArrayOf(2, 7, 12) // hard-coded assuming TILE_SIZE=16
|
private val pixelOffs = intArrayOf(2, 7, 12) // hard-coded assuming TILE_SIZE=16
|
||||||
fun makeDust(tileNum: Int, x: Int, y: Int, density: Int = 9, drawCol: Color = Color.WHITE) {
|
fun makeDust(tile: ItemID, x: Int, y: Int, density: Int = 9, drawCol: Color = Color.WHITE) {
|
||||||
val pw = 3
|
val pw = 3
|
||||||
val ph = 3
|
val ph = 3
|
||||||
val xo = App.GLOBAL_RENDER_TIMER and 1
|
val xo = App.GLOBAL_RENDER_TIMER and 1
|
||||||
val yo = App.GLOBAL_RENDER_TIMER.ushr(1) and 1
|
val yo = App.GLOBAL_RENDER_TIMER.ushr(1) and 1
|
||||||
|
|
||||||
|
val renderTag = App.tileMaker.getRenderTag(tile)
|
||||||
|
val baseTilenum = renderTag.tileNumber
|
||||||
|
val representativeTilenum = when (renderTag.maskType) {
|
||||||
|
RenderTag.MASK_47 -> 17
|
||||||
|
RenderTag.MASK_PLATFORM -> 7
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
val tileNum = baseTilenum + representativeTilenum // the particle won't match the visible tile anyway because of the seasons stuff
|
||||||
|
|
||||||
val indices = (0..8).toList().shuffled().subList(0, density)
|
val indices = (0..8).toList().shuffled().subList(0, density)
|
||||||
for (it in indices) {
|
for (it in indices) {
|
||||||
val u = pixelOffs[it % 3]
|
val u = pixelOffs[it % 3]
|
||||||
val v = pixelOffs[it / 3]
|
val v = pixelOffs[it / 3]
|
||||||
val pos = Vector2(
|
val pos = Vector2(
|
||||||
TILE_SIZED * x + u + xo,
|
TILE_SIZED * x + u + xo + 0.5,
|
||||||
TILE_SIZED * y + v + yo - ph,
|
TILE_SIZED * y + v + yo + 2,
|
||||||
)
|
)
|
||||||
val veloMult = Vector2(
|
val veloMult = Vector2(
|
||||||
1.0 * (if (Math.random() < 0.5) -1 else 1),
|
1.0 * (if (Math.random() < 0.5) -1 else 1),
|
||||||
|
|||||||
@@ -56,13 +56,10 @@ object SledgehammerCore {
|
|||||||
val x = mx + xoff + ox
|
val x = mx + xoff + ox
|
||||||
val y = my + yoff + oy
|
val y = my + yoff + oy
|
||||||
|
|
||||||
val (wx, wy) = INGAME.world.coerceXY(x, y)
|
|
||||||
|
|
||||||
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
val mousePoint = Point2d(x.toDouble(), y.toDouble())
|
||||||
val actorvalue = actor.actorValue
|
val actorvalue = actor.actorValue
|
||||||
val wall = INGAME.world.getTileFromWall(x, y)
|
val wall = INGAME.world.getTileFromWall(x, y)
|
||||||
val tileTerrain = INGAME.world.getTileFromTerrain(x, y)
|
val tileTerrain = INGAME.world.getTileFromTerrain(x, y)
|
||||||
val tileNum = INGAME.world.layerWall.unsafeGetTile(wx, wy)
|
|
||||||
|
|
||||||
val wallNear = listOf(
|
val wallNear = listOf(
|
||||||
INGAME.world.getTileFromWall(x, (y - 1).coerceAtLeast(0)),
|
INGAME.world.getTileFromWall(x, (y - 1).coerceAtLeast(0)),
|
||||||
@@ -102,7 +99,7 @@ object SledgehammerCore {
|
|||||||
if (drop.isNotBlank()) {
|
if (drop.isNotBlank()) {
|
||||||
INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED))
|
INGAME.queueActorAddition(DroppedItem("wall@$drop", (x + 0.5) * TILE_SIZED, (y + 1.0) * TILE_SIZED))
|
||||||
}
|
}
|
||||||
PickaxeCore.makeDust(tileNum, x, y, 9, App.tileMaker.wallOverlayColour)
|
PickaxeCore.makeDust(wall, x, y, 9, App.tileMaker.wallOverlayColour)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user