mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +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 {
|
||||
FAR_BEHIND, // wires
|
||||
BEHIND, // tapestries, some particles (obstructed by terrain)
|
||||
MIDDLE, // actors
|
||||
MIDTOP, // bullets, thrown items
|
||||
|
||||
@@ -432,7 +432,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
||||
}
|
||||
else {
|
||||
wireActor.renderOrder = Actor.RenderOrder.BEHIND
|
||||
wireActor.renderOrder = Actor.RenderOrder.FAR_BEHIND
|
||||
}
|
||||
|
||||
wireActor.isUpdate = true
|
||||
@@ -458,14 +458,15 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
_testMarkerDrawCalls = 0L
|
||||
|
||||
IngameRenderer.invoke(delta, false,
|
||||
screenZoom,
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays,
|
||||
particles,
|
||||
uiContainer = uiContainer
|
||||
screenZoom,
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays,
|
||||
particles,
|
||||
uiContainer = uiContainer
|
||||
)
|
||||
|
||||
App.setDebugTime("Test.MarkerDrawCalls", _testMarkerDrawCalls)
|
||||
|
||||
@@ -231,6 +231,7 @@ object IngameRenderer : Disposable {
|
||||
frameDelta: Float,
|
||||
gamePaused: Boolean,
|
||||
zoom: Float = 1f,
|
||||
actorsRenderFarBehind : List<ActorWithBody>,
|
||||
actorsRenderBehind : List<ActorWithBody>,
|
||||
actorsRenderMiddle : List<ActorWithBody>,
|
||||
actorsRenderMidTop : List<ActorWithBody>,
|
||||
@@ -240,11 +241,13 @@ object IngameRenderer : Disposable {
|
||||
player: ActorWithBody? = null,
|
||||
uiContainer: UIContainer? = null,
|
||||
) {
|
||||
renderingActorsCount = (actorsRenderBehind.size) +
|
||||
(actorsRenderMiddle.size) +
|
||||
(actorsRenderMidTop.size) +
|
||||
(actorsRenderFront.size) +
|
||||
(actorsRenderOverlay.size)
|
||||
renderingActorsCount =
|
||||
(actorsRenderFarBehind.size) +
|
||||
(actorsRenderBehind.size) +
|
||||
(actorsRenderMiddle.size) +
|
||||
(actorsRenderMidTop.size) +
|
||||
(actorsRenderFront.size) +
|
||||
(actorsRenderOverlay.size)
|
||||
renderingUIsCount = uiContainer?.countVisible() ?: 0
|
||||
|
||||
invokeInit()
|
||||
@@ -259,15 +262,15 @@ object IngameRenderer : Disposable {
|
||||
measureDebugTime("Renderer.LightRun*") {
|
||||
// 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) {
|
||||
LightmapRenderer.recalculate(actorsRenderBehind + actorsRenderFront + actorsRenderMidTop + actorsRenderMiddle + actorsRenderOverlay)
|
||||
LightmapRenderer.recalculate(actorsRenderFarBehind + actorsRenderBehind + actorsRenderFront + actorsRenderMidTop + actorsRenderMiddle + actorsRenderOverlay)
|
||||
}
|
||||
oldCamX = WorldCamera.x
|
||||
}
|
||||
|
||||
prepLightmapRGBA()
|
||||
BlocksDrawer.renderData()
|
||||
drawToRGB(frameDelta, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||
drawToA(frameDelta, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||
drawToRGB(frameDelta, actorsRenderFarBehind, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||
drawToA(frameDelta, actorsRenderFarBehind, actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||
drawOverlayActors(frameDelta, actorsRenderOverlay)
|
||||
|
||||
if (player != null && player is Pocketed) drawAimGuide(frameDelta, player)
|
||||
@@ -464,6 +467,7 @@ object IngameRenderer : Disposable {
|
||||
|
||||
private fun drawToRGB(
|
||||
frameDelta: Float,
|
||||
actorsRenderFarBehind: List<ActorWithBody>?,
|
||||
actorsRenderBehind: List<ActorWithBody>?,
|
||||
actorsRenderMiddle: List<ActorWithBody>?,
|
||||
actorsRenderMidTop: List<ActorWithBody>?,
|
||||
@@ -485,6 +489,7 @@ object IngameRenderer : Disposable {
|
||||
batch.shader = shaderForActors
|
||||
batch.color = Color.WHITE
|
||||
moveCameraToWorldCoord()
|
||||
actorsRenderFarBehind?.forEach { it.drawBody(frameDelta, batch) }
|
||||
actorsRenderBehind?.forEach { it.drawBody(frameDelta, batch) }
|
||||
particlesContainer?.forEach { it.drawBody(frameDelta, batch) }
|
||||
}
|
||||
@@ -523,6 +528,7 @@ object IngameRenderer : Disposable {
|
||||
batch.shader = shaderForActors
|
||||
batch.color = Color.WHITE
|
||||
moveCameraToWorldCoord()
|
||||
actorsRenderFarBehind?.forEach { it.drawEmissive(frameDelta, batch) }
|
||||
actorsRenderBehind?.forEach { it.drawEmissive(frameDelta, batch) }
|
||||
particlesContainer?.forEach { it.drawEmissive(frameDelta, batch) }
|
||||
}
|
||||
@@ -628,6 +634,7 @@ object IngameRenderer : Disposable {
|
||||
|
||||
private fun drawToA(
|
||||
frameDelta: Float,
|
||||
actorsRenderFarBehind: List<ActorWithBody>?,
|
||||
actorsRenderBehind: List<ActorWithBody>?,
|
||||
actorsRenderMiddle: List<ActorWithBody>?,
|
||||
actorsRenderMidTop: List<ActorWithBody>?,
|
||||
@@ -652,6 +659,7 @@ object IngameRenderer : Disposable {
|
||||
batch.color = Color.WHITE
|
||||
|
||||
moveCameraToWorldCoord()
|
||||
actorsRenderFarBehind?.forEach { it.drawGlow(frameDelta, batch) }
|
||||
actorsRenderBehind?.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)
|
||||
|
||||
// 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 visibleActorsRenderMiddle: ArrayList<ActorWithBody> = ArrayList(1)
|
||||
private var visibleActorsRenderMidTop: ArrayList<ActorWithBody> = ArrayList(1)
|
||||
@@ -1094,6 +1095,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
frameDelta,
|
||||
paused,
|
||||
screenZoom,
|
||||
visibleActorsRenderFarBehind,
|
||||
visibleActorsRenderBehind,
|
||||
visibleActorsRenderMiddle,
|
||||
visibleActorsRenderMidTop,
|
||||
@@ -1261,7 +1263,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
||||
}
|
||||
else {
|
||||
wireActor.renderOrder = Actor.RenderOrder.BEHIND
|
||||
wireActor.renderOrder = Actor.RenderOrder.FAR_BEHIND
|
||||
}
|
||||
|
||||
wireActor.isUpdate = true
|
||||
@@ -1312,6 +1314,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
private fun filterVisibleActors() {
|
||||
visibleActorsRenderFarBehind.clear()
|
||||
visibleActorsRenderBehind.clear()
|
||||
visibleActorsRenderMiddle.clear()
|
||||
visibleActorsRenderMidTop.clear()
|
||||
@@ -1511,6 +1514,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private fun actorToRenderQueue(actor: ActorWithBody): ArrayList<ActorWithBody> {
|
||||
return when (actor.renderOrder) {
|
||||
Actor.RenderOrder.FAR_BEHIND -> visibleActorsRenderFarBehind
|
||||
Actor.RenderOrder.BEHIND -> visibleActorsRenderBehind
|
||||
Actor.RenderOrder.MIDDLE -> visibleActorsRenderMiddle
|
||||
Actor.RenderOrder.MIDTOP -> visibleActorsRenderMidTop
|
||||
@@ -1772,6 +1776,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
visibleActorsRenderFarBehind.forEach { it.dispose() }
|
||||
visibleActorsRenderBehind.forEach { it.dispose() }
|
||||
visibleActorsRenderMiddle.forEach { it.dispose() }
|
||||
visibleActorsRenderMidTop.forEach { it.dispose() }
|
||||
|
||||
@@ -372,6 +372,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
listOf(),
|
||||
particles,
|
||||
uiContainer = uiContainer
|
||||
)
|
||||
|
||||
@@ -135,8 +135,8 @@ open class Electric : FixtureBase {
|
||||
getWireStateAt(offsetX, offsetY, "digital_bit").x <= ELECTRIC_THRESHOLD_LOW ||
|
||||
getWireEmissionAt(offsetX, offsetY).x <= ELECTRIC_THRESHOLD_LOW
|
||||
|
||||
private val oldSinkStatus: Array<Vector2>
|
||||
private val newSinkStatus: Array<Vector2>
|
||||
protected var oldSinkStatus: Array<Vector2>
|
||||
protected var newSinkStatus: Array<Vector2>
|
||||
|
||||
open fun updateOnWireGraphTraversal(offsetX: Int, offsetY: Int, sinkType: WireEmissionType) {
|
||||
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.TextureRegion
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.toInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -28,17 +26,40 @@ class FixtureTextSignCopper : Electric {
|
||||
var text = "헬로 월드!"
|
||||
var panelCount = 5
|
||||
|
||||
private var initialised = false
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.NO_COLLISION, 2, 2),
|
||||
renderOrder = RenderOrder.BEHIND,
|
||||
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 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
|
||||
spawn(
|
||||
intTilewiseHitbox.canonicalX.toInt(),
|
||||
@@ -100,11 +121,11 @@ class FixtureTextSignCopper : Electric {
|
||||
|
||||
makeNewSprite(TextureRegionPack(Texture(pixmapSprite), W * panelCount, H / 2)).let {
|
||||
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 {
|
||||
it.setRowsAndFrames(2, 1)
|
||||
it.delays = FloatArray(1) { Float.POSITIVE_INFINITY }
|
||||
it.delays = FloatArray(2) { Float.POSITIVE_INFINITY }
|
||||
}
|
||||
|
||||
textOverlay = SheetSpriteAnimation(this).also {
|
||||
|
||||
Reference in New Issue
Block a user