mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +09:00
wire debugger tooltip fix/electronic components now need floor OR wall to spawn
This commit is contained in:
@@ -28,6 +28,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
@Transient open val spawnNeedsWall: Boolean = false
|
||||
@Transient open val spawnNeedsFloor: Boolean = true
|
||||
|
||||
// if both spawnNeedsWall and spawnNeedsFloor are true, the condition will be interpreted as OR-condition
|
||||
|
||||
/** Real time, in nanoseconds */
|
||||
@Transient var spawnRequestedTime: Long = 0L
|
||||
protected set
|
||||
@@ -166,22 +168,33 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
cannotSpawn = everyBlockboxPos.any { (x, y) -> !BlockCodex[world!!.getTileFromTerrain(x, y)].hasTag("INCONSEQUENTIAL") }
|
||||
|
||||
|
||||
var cannotSpawnNoWall = false
|
||||
var cannotSpawnNoFloor = false
|
||||
|
||||
// check for walls, if spawnNeedsWall = true
|
||||
if (spawnNeedsWall) {
|
||||
cannotSpawn = cannotSpawn or everyBlockboxPos.any { (x, y) -> !BlockCodex[world!!.getTileFromWall(x, y)].isSolid }
|
||||
cannotSpawnNoWall = everyBlockboxPos.any { (x, y) -> !BlockCodex[world!!.getTileFromWall(x, y)].isSolid }
|
||||
}
|
||||
|
||||
// check for floors, if spawnNeedsFloor == true
|
||||
if (spawnNeedsFloor) {
|
||||
val y = posY + blockBox.height
|
||||
val xs = posX until posX + blockBox.width
|
||||
cannotSpawn = cannotSpawn or xs.any { x ->
|
||||
cannotSpawnNoFloor = xs.any { x ->
|
||||
world!!.getTileFromTerrain(x, y).let {
|
||||
!canSpawnOnThisFloor(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (spawnNeedsWall && spawnNeedsFloor)
|
||||
cannotSpawn = cannotSpawn or (cannotSpawnNoWall && cannotSpawnNoFloor)
|
||||
else if (spawnNeedsFloor)
|
||||
cannotSpawn = cannotSpawn or cannotSpawnNoFloor
|
||||
else if (spawnNeedsWall)
|
||||
cannotSpawn = cannotSpawn or cannotSpawnNoWall
|
||||
|
||||
return !cannotSpawn
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import org.dyn4j.geometry.Vector2
|
||||
*/
|
||||
class FixtureLogicSignalAdder : Electric, Reorientable {
|
||||
|
||||
@Transient override val spawnNeedsWall = false
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 2, 2),
|
||||
|
||||
@@ -34,8 +34,8 @@ interface Reorientable {
|
||||
*/
|
||||
class FixtureLogicSignalBlocker : Electric, Reorientable {
|
||||
|
||||
@Transient override val spawnNeedsWall = false
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 2, 2),
|
||||
|
||||
@@ -13,7 +13,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
class FixtureLogicSignalBulb : Electric {
|
||||
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||
|
||||
@@ -14,7 +14,8 @@ import org.dyn4j.geometry.Vector2
|
||||
*/
|
||||
class FixtureLogicSignalEmitter : Electric {
|
||||
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.dyn4j.geometry.Vector2
|
||||
*/
|
||||
class FixtureLogicSignalLatch : Electric, Reorientable {
|
||||
|
||||
@Transient override val spawnNeedsWall = false
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 2, 3),
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.dyn4j.geometry.Vector2
|
||||
class FixtureLogicSignalRepeaterHorz : Electric, Reorientable {
|
||||
|
||||
|
||||
@Transient override val spawnNeedsWall = false
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 2, 1),
|
||||
|
||||
@@ -14,7 +14,8 @@ import org.dyn4j.geometry.Vector2
|
||||
*/
|
||||
class FixtureLogicSignalSwitchManual : Electric {
|
||||
|
||||
@Transient override val spawnNeedsFloor = false
|
||||
@Transient override val spawnNeedsFloor = true
|
||||
@Transient override val spawnNeedsWall = true
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||
|
||||
Reference in New Issue
Block a user