mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 06:24:06 +09:00
fix: fixtures not placing actorblocks
This commit is contained in:
@@ -103,11 +103,11 @@
|
|||||||
"273";"273";"BLOCK_SCAFFOLDING_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1400";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"273";"273";"BLOCK_SCAFFOLDING_EBONY";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1400";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"274";"274";"BLOCK_SCAFFOLDING_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"670";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"274";"274";"BLOCK_SCAFFOLDING_BIRCH";"0.0312";"0.0312";"0.0312";"0.0312";"1";"670";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"275";"275";"BLOCK_SCAFFOLDING_BLOODROSE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"900";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"275";"275";"BLOCK_SCAFFOLDING_BLOODROSE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"900";"WOOD";"0";"1";"0";"6";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"4091";"0";"ACTORBLOCK_NO_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"4091";"0";"ACTORBLOCK_NO_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"4";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"4092";"0";"ACTORBLOCK_FULL_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"4092";"0";"ACTORBLOCK_FULL_COLLISION";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"4093";"0";"ACTORBLOCK_ALLOW_MOVE_DOWN";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"4093";"0";"ACTORBLOCK_ALLOW_MOVE_DOWN";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"1";"0";"N/A";"0";"0";"16";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"4094";"0";"ACTORBLOCK_NO_PASS_RIGHT";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"4094";"0";"ACTORBLOCK_NO_PASS_RIGHT";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"4";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"4095";"0";"ACTORBLOCK_NO_PASS_LEFT";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
"4095";"0";"ACTORBLOCK_NO_PASS_LEFT";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"NULL";"0";"0";"0";"N/A";"0";"0";"4";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A";"0.0"
|
||||||
"65536";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16";"0.0"
|
"65536";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16";"0.0"
|
||||||
"65537";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32";"0.0"
|
"65537";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32";"0.0"
|
||||||
"-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0"
|
"-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A";"0.0"
|
||||||
|
|||||||
|
@@ -70,9 +70,10 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
val actorContainerActive = SortedArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
val actorContainerActive = SortedArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||||
val actorContainerInactive = SortedArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
val actorContainerInactive = SortedArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||||
|
|
||||||
protected val terrainChangeQueue = Queue<BlockChangeQueueItem>()
|
// FIXME queues will not work; input processing (blocks will queue) and queue consuming cannot be synchronised
|
||||||
protected val wallChangeQueue = Queue<BlockChangeQueueItem>()
|
protected val terrainChangeQueue = ArrayList<BlockChangeQueueItem>()
|
||||||
protected val wireChangeQueue = Queue<BlockChangeQueueItem>() // if 'old' is set and 'new' is blank, it's a wire cutter
|
protected val wallChangeQueue = ArrayList<BlockChangeQueueItem>()
|
||||||
|
protected val wireChangeQueue = ArrayList<BlockChangeQueueItem>() // if 'old' is set and 'new' is blank, it's a wire cutter
|
||||||
|
|
||||||
override fun hide() {
|
override fun hide() {
|
||||||
}
|
}
|
||||||
@@ -151,17 +152,16 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
*
|
*
|
||||||
* Queueing schema is used to make sure things are synchronised.
|
* Queueing schema is used to make sure things are synchronised.
|
||||||
*/
|
*/
|
||||||
open fun queueTerrainChangedEvent(old: ItemID, new: ItemID, position: Long) {
|
open fun queueTerrainChangedEvent(old: ItemID, new: ItemID, x: Int, y: Int) {
|
||||||
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
printdbg(this, "Terrain change enqueued: ${BlockChangeQueueItem(old, new, x, y)}")
|
||||||
terrainChangeQueue.addLast(BlockChangeQueueItem(old, new, x, y))
|
printdbg(this, terrainChangeQueue)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wall version of terrainChanged() event
|
* Wall version of terrainChanged() event
|
||||||
*/
|
*/
|
||||||
open fun queueWallChangedEvent(old: ItemID, new: ItemID, position: Long) {
|
open fun queueWallChangedEvent(old: ItemID, new: ItemID, x: Int, y: Int) {
|
||||||
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
wallChangeQueue.add(BlockChangeQueueItem(old, new, x, y))
|
||||||
wallChangeQueue.addLast(BlockChangeQueueItem(old, new, x, y))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,9 +170,8 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
* @param old previous settings of conduits in bit set format.
|
* @param old previous settings of conduits in bit set format.
|
||||||
* @param new current settings of conduits in bit set format.
|
* @param new current settings of conduits in bit set format.
|
||||||
*/
|
*/
|
||||||
open fun queueWireChangedEvent(wire: ItemID, isRemoval: Boolean, position: Long) {
|
open fun queueWireChangedEvent(wire: ItemID, isRemoval: Boolean, x: Int, y: Int) {
|
||||||
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
wireChangeQueue.add(BlockChangeQueueItem(if (isRemoval) wire else "", if (isRemoval) "" else wire, x, y))
|
||||||
wireChangeQueue.addLast(BlockChangeQueueItem(if (isRemoval) wire else "", if (isRemoval) "" else wire, x, y))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ open class GameWorld : Disposable {
|
|||||||
wallDamages.remove(LandUtil.getBlockAddr(this, x, y))
|
wallDamages.remove(LandUtil.getBlockAddr(this, x, y))
|
||||||
|
|
||||||
if (!bypassEvent)
|
if (!bypassEvent)
|
||||||
Terrarum.ingame?.queueWallChangedEvent(oldWall, itemID, LandUtil.getBlockAddr(this, x, y))
|
Terrarum.ingame?.queueWallChangedEvent(oldWall, itemID, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,7 +313,7 @@ open class GameWorld : Disposable {
|
|||||||
// fluid tiles-item should be modified so that they will also place fluid onto their respective map
|
// fluid tiles-item should be modified so that they will also place fluid onto their respective map
|
||||||
|
|
||||||
if (!bypassEvent)
|
if (!bypassEvent)
|
||||||
Terrarum.ingame?.queueTerrainChangedEvent(oldTerrain, itemID, LandUtil.getBlockAddr(this, x, y))
|
Terrarum.ingame?.queueTerrainChangedEvent(oldTerrain, itemID, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTileWire(x: Int, y: Int, tile: ItemID, bypassEvent: Boolean) {
|
fun setTileWire(x: Int, y: Int, tile: ItemID, bypassEvent: Boolean) {
|
||||||
@@ -328,7 +328,7 @@ open class GameWorld : Disposable {
|
|||||||
wirings[blockAddr]!!.wires.add(tile)
|
wirings[blockAddr]!!.wires.add(tile)
|
||||||
|
|
||||||
if (!bypassEvent)
|
if (!bypassEvent)
|
||||||
Terrarum.ingame?.queueWireChangedEvent(tile, false, LandUtil.getBlockAddr(this, x, y))
|
Terrarum.ingame?.queueWireChangedEvent(tile, false, x, y)
|
||||||
|
|
||||||
|
|
||||||
// figure out wiring graphs
|
// figure out wiring graphs
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ object WorldSimulator {
|
|||||||
if (world.getAllWiresFrom(point.x, point.y)?.filter { WireCodex[it].accepts == wireType }?.isEmpty() != false)
|
if (world.getAllWiresFrom(point.x, point.y)?.filter { WireCodex[it].accepts == wireType }?.isEmpty() != false)
|
||||||
break
|
break
|
||||||
|
|
||||||
printdbg(this, branchesVisited)
|
//printdbg(this, branchesVisited)
|
||||||
|
|
||||||
// get all wires that matches 'accepts' (such as Red/Green/Blue wire) and propagate signal for each of them
|
// get all wires that matches 'accepts' (such as Red/Green/Blue wire) and propagate signal for each of them
|
||||||
world.getAllWiresFrom(point.x, point.y)?.filter { WireCodex[it].accepts == wireType }?.forEach { wire ->
|
world.getAllWiresFrom(point.x, point.y)?.filter { WireCodex[it].accepts == wireType }?.forEach { wire ->
|
||||||
@@ -506,14 +506,14 @@ object WorldSimulator {
|
|||||||
val signal = node.emitState
|
val signal = node.emitState
|
||||||
val cnx = node.connections.toInt() // 1-15
|
val cnx = node.connections.toInt() // 1-15
|
||||||
val nextDirBit = cnx and (15 - point.fromWhere) // cnx minus where the old cursur was; also 1-15
|
val nextDirBit = cnx and (15 - point.fromWhere) // cnx minus where the old cursur was; also 1-15
|
||||||
printdbg(this, "(${point.x}, ${point.y}) from ${point.fromWhere} to $nextDirBit")
|
//printdbg(this, "(${point.x}, ${point.y}) from ${point.fromWhere} to $nextDirBit")
|
||||||
|
|
||||||
// mark current position as visited
|
// mark current position as visited
|
||||||
branchesVisited.add(point.copy())
|
branchesVisited.add(point.copy())
|
||||||
|
|
||||||
// termination condition 1
|
// termination condition 1
|
||||||
if (branchesVisited.linearSearch { it.x == point.x && it.y == point.y }!! < branchesVisited.lastIndex) {
|
if (branchesVisited.linearSearch { it.x == point.x && it.y == point.y }!! < branchesVisited.lastIndex) {
|
||||||
printdbg(this, "(${point.x}, ${point.y}) was already visited")
|
//printdbg(this, "(${point.x}, ${point.y}) was already visited")
|
||||||
dequeue()
|
dequeue()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -549,10 +549,10 @@ object WorldSimulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printdbg(this, "Point = $point")
|
//printdbg(this, "Point = $point")
|
||||||
} // end While
|
} // end While
|
||||||
|
|
||||||
printdbg(this, "------------------------------------------")
|
//printdbg(this, "------------------------------------------")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
ingameController.update(delta)
|
ingameController.update(delta)
|
||||||
|
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
|
printdbg(this, "Clear tile change queues")
|
||||||
// completely consume block change queues because why not
|
// completely consume block change queues because why not
|
||||||
terrainChangeQueue.clear()
|
terrainChangeQueue.clear()
|
||||||
wallChangeQueue.clear()
|
wallChangeQueue.clear()
|
||||||
@@ -877,7 +877,9 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (it is CuedByTerrainChange) {
|
if (it is CuedByTerrainChange) {
|
||||||
|
printdbg(this, "actor is CuedByTerrainChange: ${terrainChangeQueue}")
|
||||||
terrainChangeQueue.forEach { cue ->
|
terrainChangeQueue.forEach { cue ->
|
||||||
|
printdbg(this, "Ingame actors terrainChangeCue: ${cue}")
|
||||||
it.updateForWorldChange(cue)
|
it.updateForWorldChange(cue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.IngameInstance
|
import net.torvald.terrarum.IngameInstance
|
||||||
import net.torvald.terrarum.Point2i
|
import net.torvald.terrarum.Point2i
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
@@ -53,7 +54,7 @@ open class FixtureBase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun forEachBlockbox(action: (Int, Int) -> Unit) {
|
fun forEachBlockbox(action: (Int, Int) -> Unit) {
|
||||||
worldBlockPos?.let { (posX, posY) ->
|
worldBlockPos!!.let { (posX, posY) ->
|
||||||
for (y in posY until posY + blockBox.height) {
|
for (y in posY until posY + blockBox.height) {
|
||||||
for (x in posX until posX + blockBox.width) {
|
for (x in posX until posX + blockBox.width) {
|
||||||
action(x, y)
|
action(x, y)
|
||||||
@@ -96,22 +97,25 @@ open class FixtureBase(
|
|||||||
|
|
||||||
if (hasCollision) return false
|
if (hasCollision) return false
|
||||||
|
|
||||||
|
printdbg(this, "spawn ${nameFun()}")
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the position of this actor
|
// set the position of this actor
|
||||||
worldBlockPos = Point2i(posX, posY)
|
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.isVisible = true
|
||||||
this.hitbox.setFromWidthHeight(posX * TILE_SIZED, posY * TILE_SIZED, blockBox.width * TILE_SIZED, blockBox.height * TILE_SIZED)
|
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.
|
* E.g. if a fixture block that is inside of BlockBox is missing, destroy and drop self.
|
||||||
*/
|
*/
|
||||||
override fun updateForWorldChange(cue: IngameInstance.BlockChangeQueueItem) {
|
override fun updateForWorldChange(cue: IngameInstance.BlockChangeQueueItem) {
|
||||||
|
printdbg(this, "updateForWorldChange ${nameFun()}")
|
||||||
// check for marker blocks.
|
// check for marker blocks.
|
||||||
// if at least one of them is missing, destroy all the markers and drop self as an item
|
// 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
|
// return false if the tile is already there
|
||||||
// FIXME doesn't work for WALLs?
|
|
||||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK &&
|
if (gameItem.inventoryCategory == GameItem.Category.BLOCK &&
|
||||||
gameItem.dynamicID == ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y) ||
|
gameItem.dynamicID == ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y) ||
|
||||||
gameItem.inventoryCategory == GameItem.Category.WALL &&
|
gameItem.inventoryCategory == GameItem.Category.WALL &&
|
||||||
|
|||||||
Reference in New Issue
Block a user