wire debugger tooltip fix/electronic components now need floor OR wall to spawn

This commit is contained in:
minjaesong
2024-03-15 22:44:46 +09:00
parent cb756cbf3a
commit d22f421bc4
12 changed files with 46 additions and 27 deletions

View File

@@ -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
}

View File

@@ -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),

View File

@@ -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),

View File

@@ -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),

View File

@@ -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),

View File

@@ -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),

View File

@@ -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),

View File

@@ -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),