mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +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),
|
||||
|
||||
@@ -9,9 +9,12 @@ import net.torvald.terrarum.gameactors.BlockMarkerActor
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
|
||||
|
||||
class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
@Transient private val tooltipHash = System.nanoTime()
|
||||
|
||||
override var baseToolSize: Double? = PickaxeCore.BASE_MASS_AND_SIZE
|
||||
override var inventoryCategory = Category.TOOL
|
||||
override val canBeDynamic = false
|
||||
@@ -62,9 +65,11 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
|
||||
}
|
||||
|
||||
if (sb.isNotEmpty()) {
|
||||
UIItemInventoryCellCommonRes.tooltipShowing[tooltipHash] = true
|
||||
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(sb.toString())
|
||||
}
|
||||
else {
|
||||
UIItemInventoryCellCommonRes.tooltipShowing[tooltipHash] = false
|
||||
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(null)
|
||||
}
|
||||
}
|
||||
@@ -73,5 +78,6 @@ class WireGraphDebugger(originalID: ItemID) : GameItem(originalID) {
|
||||
(Terrarum.ingame!! as TerrarumIngame).selectedWireRenderClass = ""
|
||||
(Terrarum.ingame!! as TerrarumIngame).setTooltipMessage(null)
|
||||
blockMarker.isVisible = false
|
||||
UIItemInventoryCellCommonRes.tooltipShowing.remove(tooltipHash)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
@@ -39,7 +38,7 @@ abstract class UIItemInventoryCellBase(
|
||||
abstract override fun update(delta: Float)
|
||||
abstract override fun render(frameDelta: Float, batch: SpriteBatch, camera: OrthographicCamera)
|
||||
|
||||
protected val hash = System.nanoTime()
|
||||
protected val tooltipHash = System.nanoTime()
|
||||
|
||||
/** Custom highlight rule to highlight tihs button to primary accent colour (blue by default).
|
||||
* Set to `null` to use default rule:
|
||||
|
||||
@@ -132,7 +132,7 @@ class UIItemInventoryElemSimple(
|
||||
|
||||
|
||||
// set tooltip accordingly
|
||||
if (tooltipShowing[hash] != true && mouseUp) {
|
||||
if (tooltipShowing[tooltipHash] != true && mouseUp) {
|
||||
// printdbg(this, "calling INGAME.setTooltipMessage by $hash")
|
||||
|
||||
val grey = App.fontGame.toColorCode(11, 11, 11)
|
||||
@@ -145,7 +145,7 @@ class UIItemInventoryElemSimple(
|
||||
|
||||
INGAME.setTooltipMessage(finalStr)
|
||||
|
||||
tooltipShowing[hash] = true
|
||||
tooltipShowing[tooltipHash] = true
|
||||
// printdbg(this, tooltipShowing.entries)
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class UIItemInventoryElemSimple(
|
||||
}
|
||||
|
||||
if (item == null || !mouseUp) {
|
||||
tooltipShowing[hash] = false
|
||||
tooltipShowing[tooltipHash] = false
|
||||
}
|
||||
|
||||
// see IFs above?
|
||||
@@ -169,10 +169,10 @@ class UIItemInventoryElemSimple(
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
tooltipShowing.remove(hash)
|
||||
tooltipShowing.remove(tooltipHash)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
tooltipShowing.remove(hash)
|
||||
tooltipShowing.remove(tooltipHash)
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.IS_DEVELOPMENT_BUILD
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.ui.InventoryCellColourTheme
|
||||
@@ -164,7 +162,7 @@ class UIItemInventoryElemWide(
|
||||
|
||||
|
||||
// set tooltip accordingly
|
||||
if (tooltipShowing[hash] != true && item != null && mouseUp) {
|
||||
if (tooltipShowing[tooltipHash] != true && item != null && mouseUp) {
|
||||
// printdbg(this, "calling INGAME.setTooltipMessage by $hash")
|
||||
|
||||
val grey = App.fontGame.toColorCode(11, 11, 11)
|
||||
@@ -177,13 +175,13 @@ class UIItemInventoryElemWide(
|
||||
|
||||
INGAME.setTooltipMessage(finalStr)
|
||||
|
||||
tooltipShowing[hash] = true
|
||||
tooltipShowing[tooltipHash] = true
|
||||
// printdbg(this, tooltipShowing.entries)
|
||||
}
|
||||
}
|
||||
|
||||
if (item == null || !mouseUp) {
|
||||
tooltipShowing[hash] = false
|
||||
tooltipShowing[tooltipHash] = false
|
||||
}
|
||||
|
||||
// see IFs above?
|
||||
@@ -191,10 +189,10 @@ class UIItemInventoryElemWide(
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
tooltipShowing.remove(hash)
|
||||
tooltipShowing.remove(tooltipHash)
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
tooltipShowing.remove(hash)
|
||||
tooltipShowing.remove(tooltipHash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user