mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
fixed a bug where actors lightbox won't follow the actor's scale
This commit is contained in:
@@ -16,17 +16,16 @@ internal object SetScale : ConsoleCommand {
|
|||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2 || args.size == 3) {
|
if (args.size == 2 || args.size == 3) {
|
||||||
try {
|
try {
|
||||||
val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying
|
val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying ?: return
|
||||||
if (player == null) return
|
|
||||||
|
|
||||||
|
|
||||||
val targetID = if (args.size == 3) args[1].toInt() else player.referenceID
|
val targetID = if (args.size == 3) args[2].toInt() else player.referenceID
|
||||||
val scale = args[if (args.size == 3) 2 else 1].toDouble()
|
val scale = args[1].toDouble()
|
||||||
|
|
||||||
val target = INGAME.getActorByID(targetID)
|
val target = INGAME.getActorByID(targetID)
|
||||||
|
|
||||||
if (target !is ActorWithBody) {
|
if (target !is ActorWithBody) {
|
||||||
EchoError("Target is not ActorWBMovable")
|
EchoError("Target is not ActorWithBody")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target.actorValue[AVKey.SCALE] = scale
|
target.actorValue[AVKey.SCALE] = scale
|
||||||
@@ -41,6 +40,6 @@ internal object SetScale : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun printUsage() {
|
override fun printUsage() {
|
||||||
Echo("Usage: setscale scale | setscale actorID scale")
|
Echo("Usage: setscale scale | setscale scale actorID")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,12 +99,14 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
* (Use ArrayList for normal circumstances)
|
* (Use ArrayList for normal circumstances)
|
||||||
*/
|
*/
|
||||||
override val lightBoxList: List<Lightbox>
|
override val lightBoxList: List<Lightbox>
|
||||||
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.
|
// 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<Lightbox>
|
override val shadeBoxList: List<Lightbox>
|
||||||
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.
|
// 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
|
@Transient val BASE_DENSITY = 980.0
|
||||||
|
|
||||||
|
|||||||
@@ -348,10 +348,10 @@ object LightmapRenderer {
|
|||||||
|
|
||||||
// put lanterns to the area the luminantBox is occupying
|
// put lanterns to the area the luminantBox is occupying
|
||||||
lightBoxCopy.forEach { (lightBox, colour) ->
|
lightBoxCopy.forEach { (lightBox, colour) ->
|
||||||
val lightBoxX = it.hitbox.startX + lightBox.startX
|
val lightBoxX = it.hitbox.startX + (lightBox.startX * it.scale)
|
||||||
val lightBoxY = it.hitbox.startY + lightBox.startY
|
val lightBoxY = it.hitbox.startY + (lightBox.startY * it.scale)
|
||||||
val lightBoxW = lightBox.width
|
val lightBoxW = lightBox.width * it.scale
|
||||||
val lightBoxH = lightBox.height
|
val lightBoxH = lightBox.height * it.scale
|
||||||
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
||||||
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
||||||
for (x in lightBoxX.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
|
// put shades to the area the luminantBox is occupying
|
||||||
shadeBoxCopy.forEach { (shadeBox, colour) ->
|
shadeBoxCopy.forEach { (shadeBox, colour) ->
|
||||||
val lightBoxX = it.hitbox.startX + shadeBox.startX
|
val lightBoxX = it.hitbox.startX + (shadeBox.startX * it.scale)
|
||||||
val lightBoxY = it.hitbox.startY + shadeBox.startY
|
val lightBoxY = it.hitbox.startY + (shadeBox.startY * it.scale)
|
||||||
val lightBoxW = shadeBox.width
|
val lightBoxW = shadeBox.width * it.scale
|
||||||
val lightBoxH = shadeBox.height
|
val lightBoxH = shadeBox.height * it.scale
|
||||||
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
for (y in lightBoxY.div(TILE_SIZE).floorInt()
|
||||||
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
..lightBoxY.plus(lightBoxH).div(TILE_SIZE).floorInt()) {
|
||||||
for (x in lightBoxX.div(TILE_SIZE).floorInt()
|
for (x in lightBoxX.div(TILE_SIZE).floorInt()
|
||||||
|
|||||||
Reference in New Issue
Block a user