diff --git a/src/net/torvald/terrarum/modulebasegame/console/SetScale.kt b/src/net/torvald/terrarum/modulebasegame/console/SetScale.kt index 1109cb535..833f50652 100644 --- a/src/net/torvald/terrarum/modulebasegame/console/SetScale.kt +++ b/src/net/torvald/terrarum/modulebasegame/console/SetScale.kt @@ -16,17 +16,16 @@ internal object SetScale : ConsoleCommand { override fun execute(args: Array) { if (args.size == 2 || args.size == 3) { try { - val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying - if (player == null) return + val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying ?: return - val targetID = if (args.size == 3) args[1].toInt() else player.referenceID - val scale = args[if (args.size == 3) 2 else 1].toDouble() + val targetID = if (args.size == 3) args[2].toInt() else player.referenceID + val scale = args[1].toDouble() val target = INGAME.getActorByID(targetID) if (target !is ActorWithBody) { - EchoError("Target is not ActorWBMovable") + EchoError("Target is not ActorWithBody") } else { target.actorValue[AVKey.SCALE] = scale @@ -41,6 +40,6 @@ internal object SetScale : ConsoleCommand { } override fun printUsage() { - Echo("Usage: setscale scale | setscale actorID scale") + Echo("Usage: setscale scale | setscale scale actorID") } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt index ac5b147c6..1ad3939bd 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt @@ -99,12 +99,14 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L * (Use ArrayList for normal circumstances) */ override val lightBoxList: List - get() = arrayOf(Lightbox(Hitbox(2.0, 2.0, hitbox.width - 3, hitbox.height - 3), actorValueColour)).toList() // things are asymmetric!! + get() = arrayOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), actorValueColour)).toList() // things are asymmetric!! // use getter; dimension of the player may change by time. + // scaling of the lightbox is performed on the LightmapRenderer. Getter is still required because of the changing actorValueColour. Lightbox.light cannot be `() -> Cvec` due to performance and serialising issue. override val shadeBoxList: List - get() = arrayOf(Lightbox(Hitbox(2.0, 2.0, hitbox.width - 3, hitbox.height - 3), actorValueShade)).toList() // things are asymmetric!! + get() = arrayOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), actorValueShade)).toList() // things are asymmetric!! // use getter; dimension of the player may change by time. + // scaling of the shadebox is performed on the LightmapRenderer. Getter is still required because of the changing actorValueColour. Lightbox.light cannot be `() -> Cvec` due to performance and serialising issue. @Transient val BASE_DENSITY = 980.0 diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt index b4483a9c6..a4a75320b 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt @@ -348,10 +348,10 @@ object LightmapRenderer { // put lanterns to the area the luminantBox is occupying lightBoxCopy.forEach { (lightBox, colour) -> - val lightBoxX = it.hitbox.startX + lightBox.startX - val lightBoxY = it.hitbox.startY + lightBox.startY - val lightBoxW = lightBox.width - val lightBoxH = lightBox.height + val lightBoxX = it.hitbox.startX + (lightBox.startX * it.scale) + val lightBoxY = it.hitbox.startY + (lightBox.startY * it.scale) + val lightBoxW = lightBox.width * it.scale + val lightBoxH = lightBox.height * it.scale for (y in lightBoxY.div(TILE_SIZE).floorInt() ..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) { for (x in lightBoxX.div(TILE_SIZE).floorInt() @@ -367,10 +367,10 @@ object LightmapRenderer { // put shades to the area the luminantBox is occupying shadeBoxCopy.forEach { (shadeBox, colour) -> - val lightBoxX = it.hitbox.startX + shadeBox.startX - val lightBoxY = it.hitbox.startY + shadeBox.startY - val lightBoxW = shadeBox.width - val lightBoxH = shadeBox.height + val lightBoxX = it.hitbox.startX + (shadeBox.startX * it.scale) + val lightBoxY = it.hitbox.startY + (shadeBox.startY * it.scale) + val lightBoxW = shadeBox.width * it.scale + val lightBoxH = shadeBox.height * it.scale for (y in lightBoxY.div(TILE_SIZE).floorInt() ..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) { for (x in lightBoxX.div(TILE_SIZE).floorInt()