mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
support for screen-overlay actors; buildingmaker has light now
This commit is contained in:
@@ -3,15 +3,13 @@ package net.torvald.terrarum.modulebasegame
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.IngameInstance
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.Yaml
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
import net.torvald.terrarum.modulebasegame.ui.Notification
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerToolbox
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
@@ -56,18 +54,24 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
val uiContainer = ArrayList<UICanvas>()
|
||||
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.FRONT) {
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
||||
|
||||
override var referenceID: ActorID? = Terrarum.generateUniqueReferenceID(renderOrder)
|
||||
val body = TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16)
|
||||
override val hitbox = Hitbox(0.0, 0.0, 16.0, 16.0)
|
||||
|
||||
init {
|
||||
this.actorValue[AVKey.LUMR] = 1.0
|
||||
this.actorValue[AVKey.LUMG] = 1.0
|
||||
}
|
||||
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
batch.color = Color.YELLOW
|
||||
batch.draw(body.get(0, 0), hitbox.startX.toFloat(), hitbox.startY.toFloat())
|
||||
}
|
||||
|
||||
override fun drawGlow(batch: SpriteBatch) { }
|
||||
|
||||
override fun dispose() {
|
||||
body.dispose()
|
||||
}
|
||||
@@ -89,10 +93,13 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
protected var updateDeltaCounter = 0.0
|
||||
protected val updateRate = 1.0 / Terrarum.TARGET_INTERNAL_FPS
|
||||
|
||||
private val actorsRenderTop = ArrayList<ActorWithBody>()
|
||||
private val actorsRenderOverlay = ArrayList<ActorWithBody>()
|
||||
|
||||
init {
|
||||
actorsRenderTop.add(blockPointingCursor)
|
||||
gameWorld.time.setTimeOfToday(WorldTime.HOUR_SEC * 10)
|
||||
gameWorld.globalLight = Color(.8f,.8f,.8f,.8f)
|
||||
|
||||
actorsRenderOverlay.add(blockPointingCursor)
|
||||
|
||||
uiContainer.add(uiToolbox)
|
||||
uiContainer.add(notifier)
|
||||
@@ -160,7 +167,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
private fun renderGame() {
|
||||
IngameRenderer(world as GameWorldExtension, actorsRenderFront = actorsRenderTop, uisToDraw = uiContainer)
|
||||
IngameRenderer(world as GameWorldExtension, actorsRenderOverlay = actorsRenderOverlay, uisToDraw = uiContainer)
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
@@ -171,7 +178,9 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
println("[BuildingMaker] Resize event")
|
||||
}
|
||||
|
||||
|
||||
override fun dispose() {
|
||||
IngameRenderer.dispose()
|
||||
}
|
||||
|
||||
private val menuYaml = Yaml("""
|
||||
- File
|
||||
|
||||
@@ -64,6 +64,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
private val actorsRenderMiddle = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderMidTop = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderFront = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderOverlay= ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
|
||||
|
||||
//var screenZoom = 1.0f // definition moved to IngameInstance
|
||||
@@ -572,6 +573,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
actorsRenderMiddle,
|
||||
actorsRenderMidTop,
|
||||
actorsRenderFront,
|
||||
actorsRenderOverlay,
|
||||
particlesContainer,
|
||||
actorNowPlaying,
|
||||
uiContainer
|
||||
|
||||
@@ -24,7 +24,8 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
*/
|
||||
object IngameRenderer {
|
||||
|
||||
private lateinit var batch: SpriteBatch
|
||||
/** for non-private use, use with care! */
|
||||
lateinit var batch: SpriteBatch
|
||||
private lateinit var camera: OrthographicCamera
|
||||
|
||||
private lateinit var lightmapFboA: FrameBuffer
|
||||
@@ -59,11 +60,12 @@ object IngameRenderer {
|
||||
|
||||
operator fun invoke(
|
||||
world: GameWorldExtension,
|
||||
actorsRenderBehind: List<ActorWithBody>? = null,
|
||||
actorsRenderMiddle: List<ActorWithBody>? = null,
|
||||
actorsRenderMidTop: List<ActorWithBody>? = null,
|
||||
actorsRenderFront : List<ActorWithBody>? = null,
|
||||
particlesContainer: CircularArray<ParticleBase>? = null,
|
||||
actorsRenderBehind : List<ActorWithBody>? = null,
|
||||
actorsRenderMiddle : List<ActorWithBody>? = null,
|
||||
actorsRenderMidTop : List<ActorWithBody>? = null,
|
||||
actorsRenderFront : List<ActorWithBody>? = null,
|
||||
actorsRenderOverlay: List<ActorWithBody>? = null,
|
||||
particlesContainer : CircularArray<ParticleBase>? = null,
|
||||
player: ActorWithBody? = null,
|
||||
uisToDraw: ArrayList<UICanvas>? = null
|
||||
) {
|
||||
@@ -86,6 +88,7 @@ object IngameRenderer {
|
||||
prepLightmapRGBA()
|
||||
drawToRGB(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||
drawToA(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||
drawOverlayActors(actorsRenderOverlay)
|
||||
|
||||
// clear main or whatever super-FBO being used
|
||||
//clearBuffer()
|
||||
@@ -391,6 +394,27 @@ object IngameRenderer {
|
||||
blendNormal(batch)
|
||||
}
|
||||
|
||||
private fun drawOverlayActors(actors: List<ActorWithBody>?) {
|
||||
fboRGB_lightMixed.inAction(camera, batch) {
|
||||
|
||||
batch.inUse {
|
||||
batch.shader = null
|
||||
batch.color = Color.WHITE
|
||||
}
|
||||
|
||||
setCameraPosition(0f, 0f)
|
||||
// BlocksDrawer.renderWhateverGlow_WALL
|
||||
|
||||
batch.inUse {
|
||||
moveCameraToWorldCoord()
|
||||
actors?.forEach { it.drawBody(batch) }
|
||||
}
|
||||
|
||||
setCameraPosition(0f, 0f)
|
||||
// BlocksDrawer.renderWhateverGlow_TERRAIN
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun init() {
|
||||
if (!initDone) {
|
||||
|
||||
Reference in New Issue
Block a user