From 828ef6a0dff6f9b09c8987b958855c79e02c641a Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 5 Aug 2021 18:29:09 +0900 Subject: [PATCH] precedence of the elvis operator is still confusing :( --- src/net/torvald/terrarum/gameactors/ActorWithBody.kt | 10 +++++----- src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 73c2776a5..ada6b327e 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -157,7 +157,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties) @Transient val MASS_LOWEST = 0.1 // Kilograms /** Apparent mass. Use "avBaseMass" for base mass */ val mass: Double - get() = actorValue.getAsDouble(AVKey.BASEMASS) ?: MASS_DEFAULT * Math.pow(scale, 3.0) + get() = (actorValue.getAsDouble(AVKey.BASEMASS) ?: MASS_DEFAULT) * Math.pow(scale, 3.0) /*set(value) { // use "var avBaseMass: Double" if (value <= 0) throw IllegalArgumentException("mass cannot be less than or equal to zero.") @@ -1157,7 +1157,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties) for (y in tyStart..tyEnd) { for (x in txStart..txEnd) { - val tile = world!!.getTileFromTerrain(x, y) ?: Block.STONE + val tile = world!!.getTileFromTerrain(x, y) if (feet) { if (shouldICollideWithThisFeet(tile)) @@ -1198,7 +1198,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties) var hasFloor = false for (x in pxStart..pxEnd) { - val tile = world!!.getTileFromTerrain(x / TILE_SIZE, y / TILE_SIZE) ?: Block.STONE + val tile = world!!.getTileFromTerrain(x / TILE_SIZE, y / TILE_SIZE) if (feet) { if (shouldICollideWithThisFeet(tile)) { @@ -1499,8 +1499,8 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties) var density = 0 forEachOccupyingFluid { // get max density for each tile - if (it?.isFluid() ?: false && it?.getProp()?.density ?: 0 > density) { - density = it?.getProp()?.density ?: 0 + if (it?.isFluid() == true && it.getProp().density > density) { + density = it.getProp().density } } diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 1c3206ea2..7b35be4e0 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -119,11 +119,11 @@ class BasicDebugInfoWindow : UICanvas() { + ccG + "${WorldCamera.y}") - printLine(batch, 3, "veloX reported $ccG${player.externalV.x}") - printLine(batch, 4, "veloY reported $ccG${player.externalV.y}") + printLine(batch, 3, "veloX external $ccG${player.externalV.x}") + printLine(batch, 4, "veloY external $ccG${player.externalV.y}") - printLine(batch, 5, "p_WalkX $ccG${player.controllerV?.x}") - printLine(batch, 6, "p_WalkY $ccG${player.controllerV?.y}") + printLine(batch, 5, "veloX control $ccG${player.controllerV?.x}") + printLine(batch, 6, "veloY control $ccG${player.controllerV?.y}") printLineColumn(batch, 2, 3, "veloX measured $ccG${xdelta / updateCount}") printLineColumn(batch, 2, 4, "veloY measured $ccG${ydelta / updateCount}")