actors with chunk anchoring wip

This commit is contained in:
minjaesong
2024-09-07 16:06:15 +09:00
parent 68854d3573
commit e3b663b4aa
7 changed files with 26 additions and 1 deletions

View File

@@ -140,7 +140,7 @@ class MusicContainer(
gdxMusic.forceInvoke<Int>("read", arrayOf(readBuf))!!.toLong() // its return value will be useless for looping=true
val read = minOf(readSize.toLong(), (totalSizeInBytes - readCount))
UnsafeHelper.memcpyRaw(readBuf, UnsafeHelper.getArrayOffset(readBuf), null, soundBuf!!.ptr + readCount, read)
UnsafeHelper.memcpyFromArrToPtr(readBuf, 0, soundBuf!!.ptr + readCount, read)
readCount += read

View File

@@ -401,6 +401,22 @@ open class ActorWithBody : Actor {
private var stairPenaltyCounter = 0 // unit: update count. 1 second is roughly 64 updates.
private var stairPenaltyVector = 1.0
/**
* 0: None
* 1: 1x1
* 2: 3x3
* 3: 5x5
* ...
* n: (2n-1)x(2n-1)
*/
@Transient val chunkAnchorRange: Int = 0
/**
* Should nearby chunks be kept in the chunk pool even if the player is far away.
*/
@Transient var chunkAnchoring = false
init {
// some initialiser goes here...
}

View File

@@ -378,6 +378,8 @@ class FixtureAlloyingFurnace : FixtureBase {
}
}
inOperation = (temperature > 0.001f)
chunkAnchoring = inOperation // update immediately instead of waiting for the next update
}
@Transient private val filterIndex = 0

View File

@@ -47,6 +47,8 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
@Transient var mainUI: UICanvas? = null
var inventory: FixtureInventory? = null
@Transient var inOperation = false
// @Transient var mainUIopenFun: ((UICanvas) -> Unit)? = null
internal var actorThatInstalledThisFixture: UUID? = null
@@ -424,6 +426,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
*/
override fun updateImpl(delta: Float) {
super.updateImpl(delta)
chunkAnchoring = inOperation
}
/**

View File

@@ -101,6 +101,7 @@ class FixtureJukebox : Electric, PlaysMusic {
get() = discInventory.isEmpty()
override fun updateImpl(delta: Float) {
inOperation = musicIsPlaying
super.updateImpl(delta)
}

View File

@@ -90,6 +90,7 @@ class FixtureMusicalTurntable : Electric, PlaysMusic {
}
override fun updateImpl(delta: Float) {
inOperation = musicIsPlaying
super.updateImpl(delta)
}

View File

@@ -365,6 +365,8 @@ class FixtureSmelterBasic : FixtureBase {
}
}
inOperation = (temperature > 0.001f)
chunkAnchoring = inOperation // update immediately instead of waiting for the next update
}
@Transient private val filterIndex = 0