mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 21:44:05 +09:00
fix: fixtures not placing actorblocks
This commit is contained in:
@@ -636,7 +636,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
ingameController.update(delta)
|
||||
|
||||
if (!paused) {
|
||||
|
||||
printdbg(this, "Clear tile change queues")
|
||||
// completely consume block change queues because why not
|
||||
terrainChangeQueue.clear()
|
||||
wallChangeQueue.clear()
|
||||
@@ -877,7 +877,9 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
if (it is CuedByTerrainChange) {
|
||||
printdbg(this, "actor is CuedByTerrainChange: ${terrainChangeQueue}")
|
||||
terrainChangeQueue.forEach { cue ->
|
||||
printdbg(this, "Ingame actors terrainChangeCue: ${cue}")
|
||||
it.updateForWorldChange(cue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.IngameInstance
|
||||
import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
@@ -53,7 +54,7 @@ open class FixtureBase(
|
||||
}
|
||||
|
||||
fun forEachBlockbox(action: (Int, Int) -> Unit) {
|
||||
worldBlockPos?.let { (posX, posY) ->
|
||||
worldBlockPos!!.let { (posX, posY) ->
|
||||
for (y in posY until posY + blockBox.height) {
|
||||
for (x in posX until posX + blockBox.width) {
|
||||
action(x, y)
|
||||
@@ -96,22 +97,25 @@ open class FixtureBase(
|
||||
|
||||
if (hasCollision) return false
|
||||
|
||||
|
||||
// fill the area with the filler blocks
|
||||
forEachBlockbox { x, y ->
|
||||
if (blockBox.collisionType == BlockBox.ALLOW_MOVE_DOWN) {
|
||||
// if the collision type is allow_move_down, only the top surface tile should be "the platform"
|
||||
// lower part must not have such property (think of the table!)
|
||||
// TODO does this ACTUALLY work ?!
|
||||
world!!.setTileTerrain(x, y, if (y == posY) BlockBox.ALLOW_MOVE_DOWN else BlockBox.NO_COLLISION, false)
|
||||
}
|
||||
else
|
||||
world!!.setTileTerrain(x, y, blockBox.collisionType, false)
|
||||
}
|
||||
printdbg(this, "spawn ${nameFun()}")
|
||||
|
||||
// set the position of this actor
|
||||
worldBlockPos = Point2i(posX, posY)
|
||||
|
||||
// fill the area with the filler blocks
|
||||
forEachBlockbox { x, y ->
|
||||
printdbg(this, "fillerblock ${blockBox.collisionType} at ($x, $y)")
|
||||
if (blockBox.collisionType == BlockBox.ALLOW_MOVE_DOWN) {
|
||||
// if the collision type is allow_move_down, only the top surface tile should be "the platform"
|
||||
// lower part must not have such property (think of the table!)
|
||||
// TODO does this ACTUALLY work ?!
|
||||
world!!.setTileTerrain(x, y, if (y == posY) BlockBox.ALLOW_MOVE_DOWN else BlockBox.NO_COLLISION, false)
|
||||
}
|
||||
else
|
||||
world!!.setTileTerrain(x, y, blockBox.collisionType, false)
|
||||
}
|
||||
|
||||
|
||||
this.isVisible = true
|
||||
this.hitbox.setFromWidthHeight(posX * TILE_SIZED, posY * TILE_SIZED, blockBox.width * TILE_SIZED, blockBox.height * TILE_SIZED)
|
||||
|
||||
@@ -148,6 +152,7 @@ open class FixtureBase(
|
||||
* E.g. if a fixture block that is inside of BlockBox is missing, destroy and drop self.
|
||||
*/
|
||||
override fun updateForWorldChange(cue: IngameInstance.BlockChangeQueueItem) {
|
||||
printdbg(this, "updateForWorldChange ${nameFun()}")
|
||||
// check for marker blocks.
|
||||
// if at least one of them is missing, destroy all the markers and drop self as an item
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ object BlockBase {
|
||||
}
|
||||
|
||||
// return false if the tile is already there
|
||||
// FIXME doesn't work for WALLs?
|
||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK &&
|
||||
gameItem.dynamicID == ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y) ||
|
||||
gameItem.inventoryCategory == GameItem.Category.WALL &&
|
||||
|
||||
Reference in New Issue
Block a user