mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
copper sign actually spawns but still wip
This commit is contained in:
Binary file not shown.
@@ -51,6 +51,7 @@ abstract class Actor : Comparable<Actor>, Runnable {
|
|||||||
|
|
||||||
|
|
||||||
enum class RenderOrder {
|
enum class RenderOrder {
|
||||||
|
FAR_BEHIND, // wires
|
||||||
BEHIND, // tapestries, some particles (obstructed by terrain)
|
BEHIND, // tapestries, some particles (obstructed by terrain)
|
||||||
MIDDLE, // actors
|
MIDDLE, // actors
|
||||||
MIDTOP, // bullets, thrown items
|
MIDTOP, // bullets, thrown items
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wireActor.renderOrder = Actor.RenderOrder.BEHIND
|
wireActor.renderOrder = Actor.RenderOrder.FAR_BEHIND
|
||||||
}
|
}
|
||||||
|
|
||||||
wireActor.isUpdate = true
|
wireActor.isUpdate = true
|
||||||
@@ -458,14 +458,15 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
_testMarkerDrawCalls = 0L
|
_testMarkerDrawCalls = 0L
|
||||||
|
|
||||||
IngameRenderer.invoke(delta, false,
|
IngameRenderer.invoke(delta, false,
|
||||||
screenZoom,
|
screenZoom,
|
||||||
listOf(),
|
listOf(),
|
||||||
listOf(),
|
listOf(),
|
||||||
listOf(),
|
listOf(),
|
||||||
listOf(),
|
listOf(),
|
||||||
if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays,
|
listOf(),
|
||||||
particles,
|
if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays,
|
||||||
uiContainer = uiContainer
|
particles,
|
||||||
|
uiContainer = uiContainer
|
||||||
)
|
)
|
||||||
|
|
||||||
App.setDebugTime("Test.MarkerDrawCalls", _testMarkerDrawCalls)
|
App.setDebugTime("Test.MarkerDrawCalls", _testMarkerDrawCalls)
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ object IngameRenderer : Disposable {
|
|||||||
frameDelta: Float,
|
frameDelta: Float,
|
||||||
gamePaused: Boolean,
|
gamePaused: Boolean,
|
||||||
zoom: Float = 1f,
|
zoom: Float = 1f,
|
||||||
|
actorsRenderFarBehind : List<ActorWithBody>,
|
||||||
actorsRenderBehind : List<ActorWithBody>,
|
actorsRenderBehind : List<ActorWithBody>,
|
||||||
actorsRenderMiddle : List<ActorWithBody>,
|
actorsRenderMiddle : List<ActorWithBody>,
|
||||||
actorsRenderMidTop : List<ActorWithBody>,
|
actorsRenderMidTop : List<ActorWithBody>,
|
||||||
@@ -240,11 +241,13 @@ object IngameRenderer : Disposable {
|
|||||||
player: ActorWithBody? = null,
|
player: ActorWithBody? = null,
|
||||||
uiContainer: UIContainer? = null,
|
uiContainer: UIContainer? = null,
|
||||||
) {
|
) {
|
||||||
renderingActorsCount = (actorsRenderBehind.size) +
|
renderingActorsCount =
|
||||||
(actorsRenderMiddle.size) +
|
(actorsRenderFarBehind.size) +
|
||||||
(actorsRenderMidTop.size) +
|
(actorsRenderBehind.size) +
|
||||||
(actorsRenderFront.size) +
|
(actorsRenderMiddle.size) +
|
||||||
(actorsRenderOverlay.size)
|
(actorsRenderMidTop.size) +
|
||||||
|
(actorsRenderFront.size) +
|
||||||
|
(actorsRenderOverlay.size)
|
||||||
renderingUIsCount = uiContainer?.countVisible() ?: 0
|
renderingUIsCount = uiContainer?.countVisible() ?: 0
|
||||||
|
|
||||||
invokeInit()
|
invokeInit()
|
||||||
@@ -259,15 +262,15 @@ object IngameRenderer : Disposable {
|
|||||||
measureDebugTime("Renderer.LightRun*") {
|
measureDebugTime("Renderer.LightRun*") {
|
||||||
// recalculate for even frames, or if the sign of the cam-x changed
|
// recalculate for even frames, or if the sign of the cam-x changed
|
||||||
if (App.GLOBAL_RENDER_TIMER % 3 == 0 || Math.abs(WorldCamera.x - oldCamX) >= world.width * 0.85f * TILE_SIZEF || newWorldLoadedLatch) {
|
if (App.GLOBAL_RENDER_TIMER % 3 == 0 || Math.abs(WorldCamera.x - oldCamX) >= world.width * 0.85f * TILE_SIZEF || newWorldLoadedLatch) {
|
||||||
LightmapRenderer.recalculate(actorsRenderBehind + actorsRenderFront + actorsRenderMidTop + actorsRenderMiddle + actorsRenderOverlay)
|
LightmapRenderer.recalculate(actorsRenderFarBehind + actorsRenderBehind + actorsRenderFront + actorsRenderMidTop + actorsRenderMiddle + actorsRenderOverlay)
|
||||||
}
|
}
|
||||||
oldCamX = WorldCamera.x
|
oldCamX = WorldCamera.x
|
||||||
}
|
}
|
||||||
|
|
||||||
prepLightmapRGBA()
|
prepLightmapRGBA()
|
||||||
BlocksDrawer.renderData()
|
BlocksDrawer.renderData()
|
||||||
drawToRGB(frameDelta, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
drawToRGB(frameDelta, actorsRenderFarBehind, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||||
drawToA(frameDelta, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
drawToA(frameDelta, actorsRenderFarBehind, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||||
drawOverlayActors(frameDelta, actorsRenderOverlay)
|
drawOverlayActors(frameDelta, actorsRenderOverlay)
|
||||||
|
|
||||||
if (player != null && player is Pocketed) drawAimGuide(frameDelta, player)
|
if (player != null && player is Pocketed) drawAimGuide(frameDelta, player)
|
||||||
@@ -464,6 +467,7 @@ object IngameRenderer : Disposable {
|
|||||||
|
|
||||||
private fun drawToRGB(
|
private fun drawToRGB(
|
||||||
frameDelta: Float,
|
frameDelta: Float,
|
||||||
|
actorsRenderFarBehind: List<ActorWithBody>?,
|
||||||
actorsRenderBehind: List<ActorWithBody>?,
|
actorsRenderBehind: List<ActorWithBody>?,
|
||||||
actorsRenderMiddle: List<ActorWithBody>?,
|
actorsRenderMiddle: List<ActorWithBody>?,
|
||||||
actorsRenderMidTop: List<ActorWithBody>?,
|
actorsRenderMidTop: List<ActorWithBody>?,
|
||||||
@@ -485,6 +489,7 @@ object IngameRenderer : Disposable {
|
|||||||
batch.shader = shaderForActors
|
batch.shader = shaderForActors
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
moveCameraToWorldCoord()
|
moveCameraToWorldCoord()
|
||||||
|
actorsRenderFarBehind?.forEach { it.drawBody(frameDelta, batch) }
|
||||||
actorsRenderBehind?.forEach { it.drawBody(frameDelta, batch) }
|
actorsRenderBehind?.forEach { it.drawBody(frameDelta, batch) }
|
||||||
particlesContainer?.forEach { it.drawBody(frameDelta, batch) }
|
particlesContainer?.forEach { it.drawBody(frameDelta, batch) }
|
||||||
}
|
}
|
||||||
@@ -523,6 +528,7 @@ object IngameRenderer : Disposable {
|
|||||||
batch.shader = shaderForActors
|
batch.shader = shaderForActors
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
moveCameraToWorldCoord()
|
moveCameraToWorldCoord()
|
||||||
|
actorsRenderFarBehind?.forEach { it.drawEmissive(frameDelta, batch) }
|
||||||
actorsRenderBehind?.forEach { it.drawEmissive(frameDelta, batch) }
|
actorsRenderBehind?.forEach { it.drawEmissive(frameDelta, batch) }
|
||||||
particlesContainer?.forEach { it.drawEmissive(frameDelta, batch) }
|
particlesContainer?.forEach { it.drawEmissive(frameDelta, batch) }
|
||||||
}
|
}
|
||||||
@@ -628,6 +634,7 @@ object IngameRenderer : Disposable {
|
|||||||
|
|
||||||
private fun drawToA(
|
private fun drawToA(
|
||||||
frameDelta: Float,
|
frameDelta: Float,
|
||||||
|
actorsRenderFarBehind: List<ActorWithBody>?,
|
||||||
actorsRenderBehind: List<ActorWithBody>?,
|
actorsRenderBehind: List<ActorWithBody>?,
|
||||||
actorsRenderMiddle: List<ActorWithBody>?,
|
actorsRenderMiddle: List<ActorWithBody>?,
|
||||||
actorsRenderMidTop: List<ActorWithBody>?,
|
actorsRenderMidTop: List<ActorWithBody>?,
|
||||||
@@ -652,6 +659,7 @@ object IngameRenderer : Disposable {
|
|||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
moveCameraToWorldCoord()
|
moveCameraToWorldCoord()
|
||||||
|
actorsRenderFarBehind?.forEach { it.drawGlow(frameDelta, batch) }
|
||||||
actorsRenderBehind?.forEach { it.drawGlow(frameDelta, batch) }
|
actorsRenderBehind?.forEach { it.drawGlow(frameDelta, batch) }
|
||||||
particlesContainer?.forEach { it.drawGlow(frameDelta, batch) }
|
particlesContainer?.forEach { it.drawGlow(frameDelta, batch) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX, true)
|
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX, true)
|
||||||
|
|
||||||
// these are required because actors always change their position
|
// these are required because actors always change their position
|
||||||
|
private var visibleActorsRenderFarBehind: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderBehind: ArrayList<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderBehind: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderMiddle: ArrayList<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderMiddle: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderMidTop: ArrayList<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderMidTop: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
@@ -1094,6 +1095,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
frameDelta,
|
frameDelta,
|
||||||
paused,
|
paused,
|
||||||
screenZoom,
|
screenZoom,
|
||||||
|
visibleActorsRenderFarBehind,
|
||||||
visibleActorsRenderBehind,
|
visibleActorsRenderBehind,
|
||||||
visibleActorsRenderMiddle,
|
visibleActorsRenderMiddle,
|
||||||
visibleActorsRenderMidTop,
|
visibleActorsRenderMidTop,
|
||||||
@@ -1261,7 +1263,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wireActor.renderOrder = Actor.RenderOrder.BEHIND
|
wireActor.renderOrder = Actor.RenderOrder.FAR_BEHIND
|
||||||
}
|
}
|
||||||
|
|
||||||
wireActor.isUpdate = true
|
wireActor.isUpdate = true
|
||||||
@@ -1312,6 +1314,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun filterVisibleActors() {
|
private fun filterVisibleActors() {
|
||||||
|
visibleActorsRenderFarBehind.clear()
|
||||||
visibleActorsRenderBehind.clear()
|
visibleActorsRenderBehind.clear()
|
||||||
visibleActorsRenderMiddle.clear()
|
visibleActorsRenderMiddle.clear()
|
||||||
visibleActorsRenderMidTop.clear()
|
visibleActorsRenderMidTop.clear()
|
||||||
@@ -1511,6 +1514,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
private fun actorToRenderQueue(actor: ActorWithBody): ArrayList<ActorWithBody> {
|
private fun actorToRenderQueue(actor: ActorWithBody): ArrayList<ActorWithBody> {
|
||||||
return when (actor.renderOrder) {
|
return when (actor.renderOrder) {
|
||||||
|
Actor.RenderOrder.FAR_BEHIND -> visibleActorsRenderFarBehind
|
||||||
Actor.RenderOrder.BEHIND -> visibleActorsRenderBehind
|
Actor.RenderOrder.BEHIND -> visibleActorsRenderBehind
|
||||||
Actor.RenderOrder.MIDDLE -> visibleActorsRenderMiddle
|
Actor.RenderOrder.MIDDLE -> visibleActorsRenderMiddle
|
||||||
Actor.RenderOrder.MIDTOP -> visibleActorsRenderMidTop
|
Actor.RenderOrder.MIDTOP -> visibleActorsRenderMidTop
|
||||||
@@ -1772,6 +1776,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
visibleActorsRenderFarBehind.forEach { it.dispose() }
|
||||||
visibleActorsRenderBehind.forEach { it.dispose() }
|
visibleActorsRenderBehind.forEach { it.dispose() }
|
||||||
visibleActorsRenderMiddle.forEach { it.dispose() }
|
visibleActorsRenderMiddle.forEach { it.dispose() }
|
||||||
visibleActorsRenderMidTop.forEach { it.dispose() }
|
visibleActorsRenderMidTop.forEach { it.dispose() }
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
listOf(),
|
listOf(),
|
||||||
listOf(),
|
listOf(),
|
||||||
listOf(),
|
listOf(),
|
||||||
|
listOf(),
|
||||||
particles,
|
particles,
|
||||||
uiContainer = uiContainer
|
uiContainer = uiContainer
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ open class Electric : FixtureBase {
|
|||||||
getWireStateAt(offsetX, offsetY, "digital_bit").x <= ELECTRIC_THRESHOLD_LOW ||
|
getWireStateAt(offsetX, offsetY, "digital_bit").x <= ELECTRIC_THRESHOLD_LOW ||
|
||||||
getWireEmissionAt(offsetX, offsetY).x <= ELECTRIC_THRESHOLD_LOW
|
getWireEmissionAt(offsetX, offsetY).x <= ELECTRIC_THRESHOLD_LOW
|
||||||
|
|
||||||
private val oldSinkStatus: Array<Vector2>
|
protected var oldSinkStatus: Array<Vector2>
|
||||||
private val newSinkStatus: Array<Vector2>
|
protected var newSinkStatus: Array<Vector2>
|
||||||
|
|
||||||
open fun updateOnWireGraphTraversal(offsetX: Int, offsetY: Int, sinkType: WireEmissionType) {
|
open fun updateOnWireGraphTraversal(offsetX: Int, offsetY: Int, sinkType: WireEmissionType) {
|
||||||
val index = pointToBlockBoxIndex(offsetX, offsetY)
|
val index = pointToBlockBoxIndex(offsetX, offsetY)
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import com.badlogic.gdx.graphics.Texture
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.CommonResourcePool
|
|
||||||
import net.torvald.terrarum.ModMgr
|
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.toInt
|
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
import org.dyn4j.geometry.Vector2
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,17 +26,40 @@ class FixtureTextSignCopper : Electric {
|
|||||||
var text = "헬로 월드!"
|
var text = "헬로 월드!"
|
||||||
var panelCount = 5
|
var panelCount = 5
|
||||||
|
|
||||||
|
private var initialised = false
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 2, 2),
|
BlockBox(BlockBox.NO_COLLISION, 2, 2),
|
||||||
renderOrder = RenderOrder.BEHIND,
|
renderOrder = RenderOrder.BEHIND,
|
||||||
nameFun = { Lang["ITEM_COPPER_SIGN"] }
|
nameFun = { Lang["ITEM_COPPER_SIGN"] }
|
||||||
)
|
) {
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(text: String, panelCount: Int) : super(
|
||||||
|
BlockBox(BlockBox.NO_COLLISION, panelCount, 2),
|
||||||
|
renderOrder = RenderOrder.BEHIND,
|
||||||
|
nameFun = { Lang["ITEM_COPPER_SIGN"] }
|
||||||
|
) {
|
||||||
|
this.text = text
|
||||||
|
this.panelCount = panelCount
|
||||||
|
reload()
|
||||||
|
}
|
||||||
|
|
||||||
override fun spawn(posX: Int, posY: Int, installersUUID: UUID?): Boolean = spawn(posX, posY, installersUUID, panelCount.coerceAtLeast(2), 2)
|
override fun spawn(posX: Int, posY: Int, installersUUID: UUID?): Boolean = spawn(posX, posY, installersUUID, panelCount.coerceAtLeast(2), 2)
|
||||||
|
|
||||||
override fun reload() {
|
override fun reload() {
|
||||||
super.reload()
|
super.reload()
|
||||||
|
|
||||||
|
if (!initialised) {
|
||||||
|
initialised = true
|
||||||
|
|
||||||
|
blockBox = BlockBox(BlockBox.NO_COLLISION, panelCount, 2)
|
||||||
|
setHitboxDimension(TILE_SIZE * blockBox.width, TILE_SIZE * blockBox.height, 0, 2)
|
||||||
|
oldSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() }
|
||||||
|
newSinkStatus = Array(blockBox.width * blockBox.height) { Vector2() }
|
||||||
|
}
|
||||||
|
|
||||||
// must be re-spawned on reload to make it visible after load
|
// must be re-spawned on reload to make it visible after load
|
||||||
spawn(
|
spawn(
|
||||||
intTilewiseHitbox.canonicalX.toInt(),
|
intTilewiseHitbox.canonicalX.toInt(),
|
||||||
@@ -100,11 +121,11 @@ class FixtureTextSignCopper : Electric {
|
|||||||
|
|
||||||
makeNewSprite(TextureRegionPack(Texture(pixmapSprite), W * panelCount, H / 2)).let {
|
makeNewSprite(TextureRegionPack(Texture(pixmapSprite), W * panelCount, H / 2)).let {
|
||||||
it.setRowsAndFrames(2, 1)
|
it.setRowsAndFrames(2, 1)
|
||||||
it.delays = FloatArray(1) { Float.POSITIVE_INFINITY }
|
it.delays = FloatArray(2) { Float.POSITIVE_INFINITY }
|
||||||
}
|
}
|
||||||
makeNewSpriteEmissive(TextureRegionPack(Texture(pixmapSpriteEmsv), W * panelCount, H / 2)).let {
|
makeNewSpriteEmissive(TextureRegionPack(Texture(pixmapSpriteEmsv), W * panelCount, H / 2)).let {
|
||||||
it.setRowsAndFrames(2, 1)
|
it.setRowsAndFrames(2, 1)
|
||||||
it.delays = FloatArray(1) { Float.POSITIVE_INFINITY }
|
it.delays = FloatArray(2) { Float.POSITIVE_INFINITY }
|
||||||
}
|
}
|
||||||
|
|
||||||
textOverlay = SheetSpriteAnimation(this).also {
|
textOverlay = SheetSpriteAnimation(this).also {
|
||||||
|
|||||||
Reference in New Issue
Block a user