mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 10:04:05 +09:00
wires are now visible when not selected, but gets covered by the terrain to make them appear natural
This commit is contained in:
@@ -202,7 +202,7 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
return actor
|
return actor
|
||||||
}
|
}
|
||||||
|
|
||||||
//fun SortedArrayList<*>.binarySearch(actor: Actor) = this.toArrayList().binarySearch(actor.referenceID!!)
|
//fun SortedArrayList<*>.binarySearch(actor: Actor) = this.toArrayList().binarySearch(actor.referenceID)
|
||||||
//fun SortedArrayList<*>.binarySearch(ID: Int) = this.toArrayList().binarySearch(ID)
|
//fun SortedArrayList<*>.binarySearch(ID: Int) = this.toArrayList().binarySearch(ID)
|
||||||
|
|
||||||
open fun removeActor(ID: Int) = removeActor(getActorByID(ID))
|
open fun removeActor(ID: Int) = removeActor(getActorByID(ID))
|
||||||
@@ -217,7 +217,7 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
open fun removeActor(actor: Actor?) {
|
open fun removeActor(actor: Actor?) {
|
||||||
if (actor == null) return
|
if (actor == null) return
|
||||||
|
|
||||||
val indexToDelete = actorContainerActive.searchFor(actor.referenceID!!) { it.referenceID!! }
|
val indexToDelete = actorContainerActive.searchFor(actor.referenceID) { it.referenceID }
|
||||||
if (indexToDelete != null) {
|
if (indexToDelete != null) {
|
||||||
actorContainerActive.remove(indexToDelete)
|
actorContainerActive.remove(indexToDelete)
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
open fun addNewActor(actor: Actor?) {
|
open fun addNewActor(actor: Actor?) {
|
||||||
if (actor == null) return
|
if (actor == null) return
|
||||||
|
|
||||||
if (theGameHasActor(actor.referenceID!!)) {
|
if (theGameHasActor(actor.referenceID)) {
|
||||||
throw Error("The actor $actor already exists in the game")
|
throw Error("The actor $actor already exists in the game")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -241,18 +241,18 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
if (actorContainerActive.size == 0)
|
if (actorContainerActive.size == 0)
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
actorContainerActive.searchFor(ID) { it.referenceID!! } != null
|
actorContainerActive.searchFor(ID) { it.referenceID } != null
|
||||||
|
|
||||||
fun isInactive(ID: Int): Boolean =
|
fun isInactive(ID: Int): Boolean =
|
||||||
if (actorContainerInactive.size == 0)
|
if (actorContainerInactive.size == 0)
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
actorContainerInactive.searchFor(ID) { it.referenceID!! } != null
|
actorContainerInactive.searchFor(ID) { it.referenceID } != null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* actorContainerActive extensions
|
* actorContainerActive extensions
|
||||||
*/
|
*/
|
||||||
fun theGameHasActor(actor: Actor?) = if (actor == null) false else theGameHasActor(actor.referenceID!!)
|
fun theGameHasActor(actor: Actor?) = if (actor == null) false else theGameHasActor(actor.referenceID)
|
||||||
|
|
||||||
fun theGameHasActor(ID: Int): Boolean =
|
fun theGameHasActor(ID: Int): Boolean =
|
||||||
isActive(ID) || isInactive(ID)
|
isActive(ID) || isInactive(ID)
|
||||||
|
|||||||
@@ -13,15 +13,21 @@ object ReferencingRanges {
|
|||||||
val ACTORS = 0x1000_0000..0x7FFF_FFFF // too much actors
|
val ACTORS = 0x1000_0000..0x7FFF_FFFF // too much actors
|
||||||
|
|
||||||
// Actor IDs are assigned in 256 groups, single actor can have 256 sub-actors
|
// Actor IDs are assigned in 256 groups, single actor can have 256 sub-actors
|
||||||
val ACTORS_BEHIND = 0x1000_0000..0x1FFF_FFFF // Rendered behind (e.g. tapestries)
|
// we're leaving last 65536 entries unassignable so that some special actors would use them
|
||||||
val ACTORS_MIDDLE = 0x2000_0000..0x4FFF_FFFF // Regular actors (e.g. almost all of them)
|
val ACTORS_BEHIND = 0x1000_0000..0x1FFE_FFFF // Rendered behind (e.g. tapestries)
|
||||||
val ACTORS_MIDTOP = 0x5000_0000..0x5FFF_FFFF // Special (e.g. weapon swung, bullets, dropped item, particles)
|
val ACTORS_MIDDLE = 0x2000_0000..0x4FFE_FFFF // Regular actors (e.g. almost all of them)
|
||||||
val ACTORS_FRONT = 0x6000_0000..0x6EFF_FFFF // Rendered front (e.g. fake tile)
|
val ACTORS_MIDTOP = 0x5000_0000..0x5FFE_FFFF // Special (e.g. weapon swung, bullets, dropped item, particles)
|
||||||
|
val ACTORS_FRONT = 0x6000_0000..0x6FFE_FFFF // Rendered front (e.g. fake tile)
|
||||||
|
|
||||||
val ACTORS_WIRES = 0x6FFF_0000..0x6FFF_FFFF // Rendered front--wires
|
// IDs doesn't effect the render order at all, but we're kinda enforcing these ID ranging.
|
||||||
val ACTORS_WIRES_HELPER = 0x7000_0000..0x7000_FFFF // Rendered overlay--wiring port icons and logic gates
|
// However, these two wire-related actor will break the rule. But as we want them to render on top of others
|
||||||
|
// in the same render orders, we're giveng them relatively high IDs for them.
|
||||||
|
val ACTORS_WIRES = 0x7FFF_E000..0x7FFF_EFFF // Rendered front--wires
|
||||||
|
val ACTORS_WIRES_HELPER = 0x7FFF_F000..0x7FFF_FF00 // Rendered overlay--wiring port icons and logic gates
|
||||||
|
|
||||||
val ACTORS_OVERLAY = 0x7001_0000..0x7FFF_FFFF // Rendered as screen overlay, not affected by light nor environment overlays
|
val ACTORS_OVERLAY = 0x7001_0000..0x7FFE_FFFF // Rendered as screen overlay, not affected by light nor environment overlays
|
||||||
|
|
||||||
|
// Actor ID 0x7FFF_FFFF is pre-assigned to the block cursor!
|
||||||
|
|
||||||
val PREFIX_DYNAMICITEM = "dyn"
|
val PREFIX_DYNAMICITEM = "dyn"
|
||||||
val PREFIX_ACTORITEM = "actor"
|
val PREFIX_ACTORITEM = "actor"
|
||||||
|
|||||||
@@ -268,26 +268,22 @@ object Terrarum : Disposable {
|
|||||||
inline val updateRate: Double
|
inline val updateRate: Double
|
||||||
get() = 1.0 / Gdx.graphics.rawDeltaTime
|
get() = 1.0 / Gdx.graphics.rawDeltaTime
|
||||||
|
|
||||||
private val noSubActorClass = hashSetOf(Actor.RenderOrder.WIRES)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usage:
|
* Usage:
|
||||||
*
|
*
|
||||||
* override var referenceID: Int = generateUniqueReferenceID()
|
* override var referenceID: Int = generateUniqueReferenceID()
|
||||||
*/
|
*/
|
||||||
fun generateUniqueReferenceID(renderOrder: Actor.RenderOrder): ActorID {
|
fun generateUniqueReferenceID(renderOrder: Actor.RenderOrder): ActorID {
|
||||||
|
fun renderOrderToRange(renderOrder: Actor.RenderOrder) = when (renderOrder) {
|
||||||
|
Actor.RenderOrder.BEHIND -> Actor.RANGE_BEHIND
|
||||||
|
Actor.RenderOrder.MIDDLE -> Actor.RANGE_MIDDLE
|
||||||
|
Actor.RenderOrder.MIDTOP -> Actor.RANGE_MIDTOP
|
||||||
|
Actor.RenderOrder.FRONT -> Actor.RANGE_FRONT
|
||||||
|
Actor.RenderOrder.OVERLAY-> Actor.RANGE_OVERLAY
|
||||||
|
}
|
||||||
fun hasCollision(value: ActorID) =
|
fun hasCollision(value: ActorID) =
|
||||||
try {
|
try {
|
||||||
Terrarum.ingame?.theGameHasActor(value) == true ||
|
Terrarum.ingame?.theGameHasActor(value) == true
|
||||||
value < ItemCodex.ACTORID_MIN ||
|
|
||||||
value !in when (renderOrder) {
|
|
||||||
Actor.RenderOrder.BEHIND -> Actor.RANGE_BEHIND
|
|
||||||
Actor.RenderOrder.MIDDLE -> Actor.RANGE_MIDDLE
|
|
||||||
Actor.RenderOrder.MIDTOP -> Actor.RANGE_MIDTOP
|
|
||||||
Actor.RenderOrder.FRONT -> Actor.RANGE_FRONT
|
|
||||||
Actor.RenderOrder.OVERLAY-> Actor.RANGE_OVERLAY
|
|
||||||
Actor.RenderOrder.WIRES -> Actor.RANGE_WIRES
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (gameNotInitialisedException: KotlinNullPointerException) {
|
catch (gameNotInitialisedException: KotlinNullPointerException) {
|
||||||
false
|
false
|
||||||
@@ -295,7 +291,9 @@ object Terrarum : Disposable {
|
|||||||
|
|
||||||
var ret: Int
|
var ret: Int
|
||||||
do {
|
do {
|
||||||
ret = HQRNG().nextInt().and(if (noSubActorClass.contains(renderOrder)) 0x7FFFFFFF else 0x7FFFFF00) // set new ID
|
val range = renderOrderToRange(renderOrder)
|
||||||
|
val size = range.last - range.first + 1
|
||||||
|
ret = (HQRNG().nextInt().rem(size) + range.first) and 0x7FFF_FF00 // make room for sub-actors
|
||||||
} while (hasCollision(ret)) // check for collision
|
} while (hasCollision(ret)) // check for collision
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,15 +12,14 @@ typealias ActorID = Int
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2015-12-31.
|
* Created by minjaesong on 2015-12-31.
|
||||||
*/
|
*/
|
||||||
abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable {
|
abstract class Actor(var renderOrder: RenderOrder, id: ActorID?) : Comparable<Actor>, Runnable {
|
||||||
|
|
||||||
enum class RenderOrder {
|
enum class RenderOrder {
|
||||||
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
|
||||||
FRONT, // fake tiles
|
FRONT, // fake tiles
|
||||||
OVERLAY, // screen overlay, not affected by lightmap
|
OVERLAY // screen overlay, not affected by lightmap
|
||||||
WIRES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -29,9 +28,6 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
|||||||
val RANGE_MIDTOP = ReferencingRanges.ACTORS_MIDTOP // 1
|
val RANGE_MIDTOP = ReferencingRanges.ACTORS_MIDTOP // 1
|
||||||
val RANGE_FRONT = ReferencingRanges.ACTORS_FRONT // 0.9375
|
val RANGE_FRONT = ReferencingRanges.ACTORS_FRONT // 0.9375
|
||||||
val RANGE_OVERLAY= ReferencingRanges.ACTORS_OVERLAY // 0.9375
|
val RANGE_OVERLAY= ReferencingRanges.ACTORS_OVERLAY // 0.9375
|
||||||
|
|
||||||
val RANGE_WIRES = ReferencingRanges.ACTORS_WIRES // 0.0002
|
|
||||||
val RANGE_WIRES_HELPER = ReferencingRanges.ACTORS_WIRES_HELPER // 0.0002
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun update(delta: Float)
|
abstract fun update(delta: Float)
|
||||||
@@ -40,7 +36,7 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
|||||||
* Valid RefID is equal to or greater than 16777216.
|
* Valid RefID is equal to or greater than 16777216.
|
||||||
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
||||||
*/
|
*/
|
||||||
open var referenceID: ActorID = Terrarum.generateUniqueReferenceID(renderOrder) // in old time this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
open var referenceID: ActorID = id ?: Terrarum.generateUniqueReferenceID(renderOrder) // in old time this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
||||||
var actorValue = ActorValue(this) // FIXME cyclic reference on GSON
|
var actorValue = ActorValue(this) // FIXME cyclic reference on GSON
|
||||||
@Volatile var flagDespawn = false
|
@Volatile var flagDespawn = false
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ import kotlin.math.sign
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2016-01-13.
|
* Created by minjaesong on 2016-01-13.
|
||||||
*/
|
*/
|
||||||
open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties) :
|
open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, id: ActorID? = null) :
|
||||||
Actor(renderOrder) {
|
Actor(renderOrder, id) {
|
||||||
|
|
||||||
|
|
||||||
@Transient val COLLISION_TEST_MODE = false
|
@Transient val COLLISION_TEST_MODE = false
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ import net.torvald.terrarum.gameitem.ItemID
|
|||||||
import net.torvald.terrarum.toInt
|
import net.torvald.terrarum.toInt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* FIXME Constructor is super expensive
|
||||||
|
*
|
||||||
* Created by minjaesong on 2021-07-30.
|
* Created by minjaesong on 2021-07-30.
|
||||||
*/
|
*/
|
||||||
class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.IMMOBILE) {
|
class WireActor(id: ActorID) : ActorWithBody(RenderOrder.OVERLAY, PhysProperties.IMMOBILE, id) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val WIRE_NEARBY = arrayOf(
|
val WIRE_NEARBY = arrayOf(
|
||||||
@@ -24,7 +26,6 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
referenceID = id
|
|
||||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
|
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e: GdxRuntimeException) {
|
catch (e: GdxRuntimeException) {
|
||||||
printdbg(this, e.message)
|
printdbgerr(this, "Error initialising controller: ${e.message}")
|
||||||
e.stackTrace.forEach { printdbgerr(this, "\t$it") }
|
e.stackTrace.forEach { printdbgerr(this, "\t$it") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,23 +63,15 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
*/
|
*/
|
||||||
//val ACTORCONTAINER_INITIAL_SIZE = 64
|
//val ACTORCONTAINER_INITIAL_SIZE = 64
|
||||||
val PARTICLES_MAX = AppLoader.getConfigInt("maxparticles")
|
val PARTICLES_MAX = AppLoader.getConfigInt("maxparticles")
|
||||||
//val actorContainerActive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
//val actorContainerInactive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX, true)
|
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX, true)
|
||||||
val uiContainer = UIContainer()
|
val uiContainer = UIContainer()
|
||||||
|
|
||||||
private val actorsRenderBehind = SortedArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
private val actorsRenderMiddle = SortedArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
private val actorsRenderMidTop = SortedArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
private val actorsRenderFront = SortedArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
private val actorsRenderOverlay= SortedArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
|
||||||
|
|
||||||
// these are required because actors always change their position
|
// these are required because actors always change their position
|
||||||
private var visibleActorsRenderBehind: List<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderBehind: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderMiddle: List<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderMiddle: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderMidTop: List<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderMidTop: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderFront: List<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderFront: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
private var visibleActorsRenderOverlay: List<ActorWithBody> = ArrayList(1)
|
private var visibleActorsRenderOverlay: ArrayList<ActorWithBody> = ArrayList(1)
|
||||||
|
|
||||||
//var screenZoom = 1.0f // definition moved to IngameInstance
|
//var screenZoom = 1.0f // definition moved to IngameInstance
|
||||||
//val ZOOM_MAXIMUM = 4.0f // definition moved to IngameInstance
|
//val ZOOM_MAXIMUM = 4.0f // definition moved to IngameInstance
|
||||||
@@ -196,12 +188,6 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
var selectedWireRenderClass = ""
|
var selectedWireRenderClass = ""
|
||||||
/**
|
|
||||||
* unlike faketiles which gets placed onto the world just like ordinary fixtures, wires are dynamically
|
|
||||||
* "rendered" into wire-actors, and we need to keep track of them in some way (and definitely NOT create
|
|
||||||
* 65536 actors all at once)
|
|
||||||
*/
|
|
||||||
private var allocatedWireActorsCount = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -683,7 +669,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
if (uiFixture?.isClosed == true) { uiFixture = null }
|
if (uiFixture?.isClosed == true) { uiFixture = null }
|
||||||
|
|
||||||
// fill up visibleActorsRenderFront for wires
|
// fill up visibleActorsRenderFront for wires
|
||||||
measureDebugTime("Ingame.WiresRenderAndDraw") {
|
measureDebugTime("Ingame.FillUpWiresBuffer") {
|
||||||
fillUpWiresBuffer()
|
fillUpWiresBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,19 +687,12 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val maxRenderableWires = ReferencingRanges.ACTORS_WIRES.endInclusive - ReferencingRanges.ACTORS_WIRES.first + 1
|
private val maxRenderableWires = ReferencingRanges.ACTORS_WIRES.endInclusive - ReferencingRanges.ACTORS_WIRES.first + 1
|
||||||
|
private val wireActorsContainer = Array(maxRenderableWires) { WireActor(ReferencingRanges.ACTORS_WIRES.first + it).let {
|
||||||
|
addNewActor(it)
|
||||||
|
/*^let*/ it
|
||||||
|
} }
|
||||||
|
|
||||||
private fun fillUpWiresBuffer() {
|
private fun fillUpWiresBuffer() {
|
||||||
fun getOrMakeWireActor(num: Int): WireActor {
|
|
||||||
return try {
|
|
||||||
getActorByID(ReferencingRanges.ACTORS_WIRES.first + num) as WireActor
|
|
||||||
}
|
|
||||||
catch (_: IllegalArgumentException) {
|
|
||||||
val actor = WireActor(ReferencingRanges.ACTORS_WIRES.first + num)
|
|
||||||
addNewActor(actor)
|
|
||||||
actor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val for_y_start = (WorldCamera.y.toFloat() / TILE_SIZE).floorInt()
|
val for_y_start = (WorldCamera.y.toFloat() / TILE_SIZE).floorInt()
|
||||||
val for_y_end = for_y_start + BlocksDrawer.tilesInVertical - 1
|
val for_y_end = for_y_start + BlocksDrawer.tilesInVertical - 1
|
||||||
|
|
||||||
@@ -724,37 +703,46 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
for (y in for_y_start..for_y_end) {
|
for (y in for_y_start..for_y_end) {
|
||||||
for (x in for_x_start..for_x_end) {
|
for (x in for_x_start..for_x_end) {
|
||||||
if (wiringCounter >= maxRenderableWires) break
|
if (wiringCounter >= maxRenderableWires) break
|
||||||
|
world.getAllWiresFrom(x, y)?.forEach {
|
||||||
|
val wireActor = wireActorsContainer[wiringCounter]
|
||||||
|
|
||||||
val wires = world.getAllWiresFrom(x, y)
|
wireActor.setWire(it, x, y)
|
||||||
|
|
||||||
wires?.forEach {
|
|
||||||
val wireActor = getOrMakeWireActor(wiringCounter)
|
|
||||||
|
|
||||||
if (WireCodex[it].renderClass == selectedWireRenderClass || selectedWireRenderClass == "wire_render_all") {
|
if (WireCodex[it].renderClass == selectedWireRenderClass || selectedWireRenderClass == "wire_render_all") {
|
||||||
wireActor.isUpdate = true
|
wireActor.renderOrder = Actor.RenderOrder.OVERLAY
|
||||||
wireActor.isVisible = true
|
|
||||||
wireActor.forceDormant = false
|
|
||||||
wireActor.setWire(it, x, y)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wireActor.isUpdate = false
|
wireActor.renderOrder = Actor.RenderOrder.BEHIND
|
||||||
wireActor.isVisible = false
|
|
||||||
wireActor.forceDormant = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wireActor.isUpdate = true
|
||||||
|
wireActor.isVisible = true
|
||||||
|
wireActor.forceDormant = false
|
||||||
|
|
||||||
wiringCounter += 1
|
wiringCounter += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i in wiringCounter until maxRenderableWires) {
|
||||||
|
wireActorsContainer[i].isUpdate = false
|
||||||
|
wireActorsContainer[i].isVisible = false
|
||||||
|
wireActorsContainer[i].forceDormant = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun filterVisibleActors() {
|
private fun filterVisibleActors() {
|
||||||
visibleActorsRenderBehind = actorsRenderBehind.filter { it.inScreen(world) }
|
visibleActorsRenderBehind.clear()
|
||||||
visibleActorsRenderMiddle = actorsRenderMiddle.filter { it.inScreen(world) }
|
visibleActorsRenderMiddle.clear()
|
||||||
visibleActorsRenderMidTop = actorsRenderMidTop.filter { it.inScreen(world) }
|
visibleActorsRenderMidTop.clear()
|
||||||
visibleActorsRenderFront = actorsRenderFront.filter { it.inScreen(world) }
|
visibleActorsRenderFront.clear()
|
||||||
visibleActorsRenderOverlay=actorsRenderOverlay.filter { it.inScreen(world) }
|
visibleActorsRenderOverlay.clear()
|
||||||
|
|
||||||
|
actorContainerActive.forEach {
|
||||||
|
if (it is ActorWithBody)
|
||||||
|
actorToRenderQueue(it).add(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun repossessActor() {
|
private fun repossessActor() {
|
||||||
@@ -906,13 +894,13 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
private val cameraWindowX = WorldCamera.x.toDouble()..WorldCamera.xEnd.toDouble()
|
private val cameraWindowX = WorldCamera.x.toDouble()..WorldCamera.xEnd.toDouble()
|
||||||
private val cameraWindowY = WorldCamera.y.toDouble()..WorldCamera.yEnd.toDouble()
|
private val cameraWindowY = WorldCamera.y.toDouble()..WorldCamera.yEnd.toDouble()
|
||||||
|
|
||||||
private fun actorToRenderQueue(actor: ActorWithBody): SortedArrayList<ActorWithBody> {
|
private fun actorToRenderQueue(actor: ActorWithBody): ArrayList<ActorWithBody> {
|
||||||
return when (actor.renderOrder) {
|
return when (actor.renderOrder) {
|
||||||
Actor.RenderOrder.BEHIND -> actorsRenderBehind
|
Actor.RenderOrder.BEHIND -> visibleActorsRenderBehind
|
||||||
Actor.RenderOrder.MIDDLE -> actorsRenderMiddle
|
Actor.RenderOrder.MIDDLE -> visibleActorsRenderMiddle
|
||||||
Actor.RenderOrder.MIDTOP -> actorsRenderMidTop
|
Actor.RenderOrder.MIDTOP -> visibleActorsRenderMidTop
|
||||||
Actor.RenderOrder.FRONT, Actor.RenderOrder.WIRES -> actorsRenderFront
|
Actor.RenderOrder.FRONT -> visibleActorsRenderFront
|
||||||
Actor.RenderOrder.OVERLAY-> actorsRenderOverlay
|
Actor.RenderOrder.OVERLAY-> visibleActorsRenderOverlay
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -977,7 +965,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
throw Error("The actor $actor already exists in the game")
|
throw Error("The actor $actor already exists in the game")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (actor.referenceID < ReferencingRanges.ACTORS_WIRES.first) {
|
if (actor.referenceID !in ReferencingRanges.ACTORS_WIRES && actor.referenceID !in ReferencingRanges.ACTORS_WIRES_HELPER) {
|
||||||
printdbg(this, "Adding actor $actor")
|
printdbg(this, "Adding actor $actor")
|
||||||
printStackTrace(this)
|
printStackTrace(this)
|
||||||
}
|
}
|
||||||
@@ -1096,11 +1084,11 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
actorsRenderBehind.forEach { it.dispose() }
|
visibleActorsRenderBehind.forEach { it.dispose() }
|
||||||
actorsRenderMiddle.forEach { it.dispose() }
|
visibleActorsRenderMiddle.forEach { it.dispose() }
|
||||||
actorsRenderMidTop.forEach { it.dispose() }
|
visibleActorsRenderMidTop.forEach { it.dispose() }
|
||||||
actorsRenderFront.forEach { it.dispose() }
|
visibleActorsRenderFront.forEach { it.dispose() }
|
||||||
actorsRenderOverlay.forEach { it.dispose() }
|
visibleActorsRenderOverlay.forEach { it.dispose() }
|
||||||
|
|
||||||
uiContainer.forEach {
|
uiContainer.forEach {
|
||||||
it?.handler?.dispose()
|
it?.handler?.dispose()
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
|
import net.torvald.terrarum.gameactors.ActorID
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.gameactors.PhysProperties
|
import net.torvald.terrarum.gameactors.PhysProperties
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.gameitem.ItemID
|
||||||
@@ -32,9 +33,10 @@ open class FixtureBase(
|
|||||||
renderOrder: RenderOrder = RenderOrder.MIDDLE,
|
renderOrder: RenderOrder = RenderOrder.MIDDLE,
|
||||||
val nameFun: () -> String,
|
val nameFun: () -> String,
|
||||||
val mainUI: UICanvas? = null,
|
val mainUI: UICanvas? = null,
|
||||||
val inventory: FixtureInventory? = null
|
val inventory: FixtureInventory? = null,
|
||||||
|
id: ActorID? = null
|
||||||
// disabling physics (not allowing the fixture to move) WILL make things easier in many ways
|
// disabling physics (not allowing the fixture to move) WILL make things easier in many ways
|
||||||
) : ActorWithBody(renderOrder, PhysProperties.IMMOBILE), CuedByTerrainChange {
|
) : ActorWithBody(renderOrder, PhysProperties.IMMOBILE, id), CuedByTerrainChange {
|
||||||
|
|
||||||
var blockBox: BlockBox = blockBox0
|
var blockBox: BlockBox = blockBox0
|
||||||
protected set // something like TapestryObject will want to redefine this
|
protected set // something like TapestryObject will want to redefine this
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
|
||||||
import net.torvald.terrarum.ceilInt
|
import net.torvald.terrarum.ceilInt
|
||||||
|
import net.torvald.terrarum.gameactors.ActorID
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user