get player head texture wip

This commit is contained in:
minjaesong
2021-12-20 22:56:16 +09:00
parent 07345e3128
commit 099071bdd0
18 changed files with 431 additions and 40 deletions

View File

@@ -737,6 +737,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
private var worldWidth: Double = 0.0
private var oldCamX = 0
private var oldPlayerX = 0.0
/**
* Ingame (world) related updates; UI update must go to renderGame()
@@ -798,17 +799,19 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
BlockStats.update()
}
// fill up visibleActorsRenderFront for wires, if:
// 0. Camera wrapped
// 0. Camera or player x position wrapped
// 1. new world has been loaded
// 2. something is cued on the wire change queue
// 3. wire renderclass changed
if (Math.abs(WorldCamera.x - oldCamX) >= worldWidth * 0.85 ||
if (Math.abs(WorldCamera.x - oldCamX) >= worldWidth * 0.5 ||
Math.abs((actorNowPlaying?.hitbox?.canonicalX ?: 0.0) - oldPlayerX) >= worldWidth * 0.5 ||
newWorldLoadedLatch || wireChangeQueue.isNotEmpty() || selectedWireRenderClass != oldSelectedWireRenderClass) {
measureDebugTime("Ingame.FillUpWiresBuffer") {
fillUpWiresBuffer()
}
}
oldCamX = WorldCamera.x
oldPlayerX = actorNowPlaying?.hitbox?.canonicalX ?: 0.0
WORLD_UPDATE_TIMER += 1

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.jme3.math.FastMath
import net.torvald.gdx.graphics.Cvec
import net.torvald.spriteanimation.HasAssembledSprite
@@ -655,6 +656,13 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
}
}
override fun getSpriteHead(): TextureRegion? {
return if (this is IngamePlayer)
this.spriteHeadTexture
else if (this is HasAssembledSprite)
this.spriteHeadTexture
else super.getSpriteHead()
}
fun Float.abs() = FastMath.abs(this)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.spriteassembler.ADProperties
import net.torvald.spriteassembler.AssembleSheetPixmap
@@ -29,6 +30,9 @@ class IngamePlayer : ActorHumanoid {
val uuid = UUID.randomUUID()
var worldCurrentlyPlaying: UUID = UUID(0L,0L) // only filled up on save and load; DO NOT USE THIS
var spriteHeadTexture: TextureRegion? = null
/** ADL for main sprite. Necessary. */
@Transient var animDesc: ADProperties? = null
/** ADL for glow sprite. Optional. */
@@ -79,15 +83,24 @@ class IngamePlayer : ActorHumanoid {
* ```
*/
fun reassembleSprite(sprite: SpriteAnimation?, spriteGlow: SpriteAnimation? = null) {
if (animDesc != null && sprite != null)
if (animDesc != null && sprite != null) {
_rebuild(animDesc!!, sprite)
spriteHeadTexture = AssembleSheetPixmap.getHeadFromAssetsDir(animDesc!!)
}
if (animDescGlow != null && spriteGlow != null)
_rebuild(animDescGlow!!, spriteGlow)
}
fun reassembleSprite(disk: SimpleFileSystem, sprite: SpriteAnimation?, spriteGlow: SpriteAnimation? = null) {
if (animDesc != null && sprite != null)
if (animDesc != null && sprite != null) {
_rebuild(disk, -1025L, animDesc!!, sprite)
if (disk.getEntry(-1025L) != null)
spriteHeadTexture = AssembleSheetPixmap.getHeadFromVirtualDisk(disk, -1025L, animDesc!!)
else
spriteHeadTexture = AssembleSheetPixmap.getHeadFromAssetsDir(animDesc!!)
}
if (animDescGlow != null && spriteGlow != null)
_rebuild(disk, -1026L, animDescGlow!!, spriteGlow)
}
@@ -140,5 +153,7 @@ class IngamePlayer : ActorHumanoid {
sprite.nRows = newAnimDelays.size
}
override fun getSpriteHead(): TextureRegion? {
return spriteHeadTexture
}
}

View File

@@ -7,10 +7,10 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.terrarum.*
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.blockstats.MinimapComposer
import net.torvald.terrarum.blockstats.MinimapComposer.MINIMAP_TILE_HEIGHT
import net.torvald.terrarum.blockstats.MinimapComposer.MINIMAP_TILE_WIDTH
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_UI_HEIGHT
import net.torvald.terrarum.ui.Toolkit
@@ -155,6 +155,11 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
batch.color = Color.WHITE
batch.draw(renderTextures[index], tx, ty, MINIMAP_TILE_WIDTH * minimapZoom, MINIMAP_TILE_HEIGHT * minimapZoom)
}
((INGAME.actorContainerInactive + INGAME.actorContainerActive).filter { it is IngamePlayer } as List<IngamePlayer>).forEach {
// it.getSpriteHead()
}
}
}
batch.begin()