diff --git a/assets/mods/basegame/sprites/taimu.properties b/assets/mods/basegame/sprites/taimu.properties index d659f61ec..cd3581c22 100644 --- a/assets/mods/basegame/sprites/taimu.properties +++ b/assets/mods/basegame/sprites/taimu.properties @@ -34,7 +34,9 @@ SKELETON_STAND=HEADGEAR 0,78;\ ARM_REST_LEFT 8,66;\ TAIL_0 2,40 -# skeleton_stand is used for testing purpose +! When you move the arms/hands, make sure you move the HELD_ITEM as well + +# RUNNING might need its own skeleton... ANIM_RUN=DELAY 0.3;ROW 2;SKELETON SKELETON_STAND ANIM_RUN_1=LEG_REST_RIGHT 2,2;LEG_REST_LEFT -2,0;TAIL_0 1,0;TORSO_1 0,-999 ANIM_RUN_2=ALL 0,2;LEG_REST_RIGHT 0,-2;LEG_REST_LEFT 0,2;TAIL_0 -1,0;TORSO_1 0,-999 @@ -43,4 +45,4 @@ ANIM_RUN_4=ALL 0,2;LEG_REST_RIGHT 0,2;LEG_REST_LEFT 0,-2;TAIL_0 1,0;TORSO_1 0,-9 ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND ANIM_IDLE_1=TORSO_1 0,-999;HEAD 0,-1 -ANIM_IDLE_2=TORSO_0 0,-999;ARM_REST_LEFT 0,1;ARM_REST_RIGHT 0,1;BUST_0 0,1 +ANIM_IDLE_2=TORSO_0 0,-999;ARM_REST_LEFT 0,1;ARM_REST_RIGHT 0,1;HELD_ITEM 0,1;BUST_0 0,1 diff --git a/assets/mods/basegame/sprites/taimu_glow.properties b/assets/mods/basegame/sprites/taimu_glow.properties index 8856c11d9..a67d48b7f 100644 --- a/assets/mods/basegame/sprites/taimu_glow.properties +++ b/assets/mods/basegame/sprites/taimu_glow.properties @@ -34,7 +34,9 @@ SKELETON_STAND=HEADGEAR 0,78;\ ARM_REST_LEFT 8,66;\ TAIL_0 2,40 -# skeleton_stand is used for testing purpose +! When you move the arms/hands, make sure you move the HELD_ITEM as well + +# RUNNING might need its own skeleton... ANIM_RUN=DELAY 0.3;ROW 2;SKELETON SKELETON_STAND ANIM_RUN_1=LEG_REST_RIGHT 2,2;LEG_REST_LEFT -2,0;TAIL_0 1,0;TORSO_1 0,-999 ANIM_RUN_2=ALL 0,2;LEG_REST_RIGHT 0,-2;LEG_REST_LEFT 0,2;TAIL_0 -1,0;TORSO_1 0,-999 @@ -43,4 +45,4 @@ ANIM_RUN_4=ALL 0,2;LEG_REST_RIGHT 0,2;LEG_REST_LEFT 0,-2;TAIL_0 1,0;TORSO_1 0,-9 ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND ANIM_IDLE_1=TORSO_1 0,-999;HEAD 0,-1 -ANIM_IDLE_2=TORSO_0 0,-999;ARM_REST_LEFT 0,1;ARM_REST_RIGHT 0,1;BUST_0 0,1 +ANIM_IDLE_2=TORSO_0 0,-999;ARM_REST_LEFT 0,1;ARM_REST_RIGHT 0,1;HELD_ITEM 0,1;BUST_0 0,1 diff --git a/assets/mods/basegame/sprites/test_sprite.properties b/assets/mods/basegame/sprites/test_sprite.properties index 1cc19ba23..71c34af69 100644 --- a/assets/mods/basegame/sprites/test_sprite.properties +++ b/assets/mods/basegame/sprites/test_sprite.properties @@ -33,7 +33,9 @@ SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\ ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\ TAIL0 0,13 -# skeleton_stand is used for testing purpose +! When you move the arms/hands, make sure you move the HELD_ITEM as well + +# RUNNING might need its own skeleton... ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND ANIM_RUN_1=LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0 ANIM_RUN_2=ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1 diff --git a/src/net/torvald/spriteassembler/AssembleSheetPixmap.kt b/src/net/torvald/spriteassembler/AssembleSheetPixmap.kt index f14978efe..2e70fcd6e 100644 --- a/src/net/torvald/spriteassembler/AssembleSheetPixmap.kt +++ b/src/net/torvald/spriteassembler/AssembleSheetPixmap.kt @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.utils.GdxRuntimeException import net.torvald.terrarum.gameitems.GameItem import net.torvald.terrarum.linearSearch +import net.torvald.terrarum.linearSearchBy import net.torvald.terrarum.savegame.ByteArray64InputStream import net.torvald.terrarum.savegame.ByteArray64Reader import net.torvald.terrarum.savegame.SimpleFileSystem @@ -175,12 +176,41 @@ object AssembleSheetPixmap { ) { val tmpFrame = Pixmap(props.frameWidth, props.frameHeight, Pixmap.Format.RGBA8888) - transformList.forEach { (name, pos) -> - bodypartImages[name]?.let { image -> - val imgCentre = bodypartOrigins[name]!!.invertX() - val drawPos = props.origin + pos + imgCentre + transformList.forEach { (name, bodypartPos) -> + if (name == "HELD_ITEM") { + injectedItem?.itemImage?.let { textureRegion -> + // TODO FIXME tiles are not being drawn + val texdata = textureRegion.texture.textureData + texdata.prepare() + val imageSheet = texdata.consumePixmap() - tmpFrame.drawPixmap(image, drawPos.x, props.frameHeight - drawPos.y - 1) + val drawPos = props.origin + bodypartPos + + val pu = (textureRegion.u * texdata.width).toInt() + val pv = (textureRegion.v * texdata.height).toInt() + val pu2 = (textureRegion.u2 * texdata.width).toInt() + val pv2 = (textureRegion.v2 * texdata.height).toInt() + val imageHeight = textureRegion.regionHeight + + for (y in pv until pv2) { for (x in pu until pu2) { + val pixel = imageSheet.getPixel(x, y) + tmpFrame.drawPixel( + drawPos.x + x - pu, + (props.frameHeight - drawPos.y - 1) + y - pv - imageHeight, + pixel + ) + } } + + imageSheet.dispose() + } + } + else { + bodypartImages[name]?.let { image -> + val imgCentre = bodypartOrigins[name]!!.invertX() + val drawPos = props.origin + bodypartPos + imgCentre + + tmpFrame.drawPixmap(image, drawPos.x, props.frameHeight - drawPos.y - 1) + } } } @@ -190,7 +220,6 @@ object AssembleSheetPixmap { (row - 1) * props.frameHeight ) - // TODO use injectedItem tmpFrame.dispose()