mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
get player head texture wip
This commit is contained in:
@@ -40,10 +40,7 @@ internal object CommandInterpreter {
|
||||
|
||||
var commandObj: ConsoleCommand? = null
|
||||
try {
|
||||
if (single_command.name.toLowerCase().startsWith("qqq")) {
|
||||
commandObj = CommandDict["QuitApp"]
|
||||
}
|
||||
else if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
|
||||
if (commandsNoAuth.contains(single_command.name.toLowerCase())) {
|
||||
commandObj = CommandDict[single_command.name.toLowerCase()]
|
||||
}
|
||||
else {
|
||||
|
||||
15
src/net/torvald/terrarum/console/Pause.kt
Normal file
15
src/net/torvald/terrarum/console/Pause.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-12-20.
|
||||
*/
|
||||
object Pause : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
Terrarum.ingame?.pause()
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
}
|
||||
}
|
||||
15
src/net/torvald/terrarum/console/Unpause.kt
Normal file
15
src/net/torvald/terrarum/console/Unpause.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-12-20.
|
||||
*/
|
||||
object Unpause : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
Terrarum.ingame?.resume()
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
@@ -1726,6 +1727,10 @@ open class ActorWithBody : Actor {
|
||||
flagDespawn = true
|
||||
}
|
||||
|
||||
open fun getSpriteHead(): TextureRegion? {
|
||||
return sprite?.textureRegion?.get(0,0)
|
||||
}
|
||||
|
||||
|
||||
private fun forEachOccupyingTileNum(consumer: (ItemID?) -> Unit) {
|
||||
if (world == null) return
|
||||
@@ -1908,12 +1913,15 @@ inline fun drawBodyInGoodPosition(startX: Float, startY: Float, drawFun: (x: Flo
|
||||
val offendingPad2 = WorldCamera.width + 1
|
||||
|
||||
if (WorldCamera.x >= offendingPad && startX < WorldCamera.width) {
|
||||
// App.batch.color = Color.RED
|
||||
drawFun(startX + INGAME.world.width * TILE_SIZEF, startY)
|
||||
}
|
||||
// else if (WorldCamera.x <= offendingPad2 && startX > offendingPad) {
|
||||
// drawFun(startX - INGAME.world.width * TILE_SIZEF, startY)
|
||||
// }
|
||||
else if (WorldCamera.x <= offendingPad2 && startX > offendingPad) {
|
||||
// App.batch.color = Color.BLUE
|
||||
drawFun(startX - INGAME.world.width * TILE_SIZEF, startY)
|
||||
}
|
||||
else {
|
||||
// App.batch.color = Color.WHITE
|
||||
drawFun(startX , startY)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,6 @@ class WireActor : ActorWithBody {
|
||||
}
|
||||
}
|
||||
sprite!!.currentFrame = ret
|
||||
sprite!!.flipVertical = true // turns out the sprites are rendered upside-down by default :(
|
||||
}
|
||||
|
||||
private fun getNearbyTilesPos(x: Int, y: Int): Array<Point2i> {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -129,6 +129,13 @@ class ConsoleWindow : UICanvas() {
|
||||
}
|
||||
|
||||
uiItems.forEach { it.render(batch, camera) }
|
||||
|
||||
Terrarum.ingame?.let {
|
||||
batch.color = Color.WHITE
|
||||
it.actorNowPlaying?.getSpriteHead()!!.let {
|
||||
batch.draw(it, drawOffX + 10f, drawOffY + height + 4f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun inputStrobed(e: TerrarumKeyboardEvent) {
|
||||
@@ -279,15 +286,15 @@ class ConsoleWindow : UICanvas() {
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
Terrarum.ingame?.setTooltipMessage(null)
|
||||
println("Close -- I made the game to pause: $iMadeTheGameToPause")
|
||||
if (iMadeTheGameToPause) {
|
||||
Terrarum.ingame?.resume()
|
||||
println("Close -- resume game")
|
||||
}
|
||||
iMadeTheGameToPause = false
|
||||
Terrarum.ingame?.setTooltipMessage(null)
|
||||
drawOffY = -height.toFloat()
|
||||
openingTimeCounter = 0f
|
||||
iMadeTheGameToPause = false
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
Reference in New Issue
Block a user