mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
now with watchdogs
This commit is contained in:
@@ -668,6 +668,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
uiContainer.add(it(this))
|
||||
}
|
||||
|
||||
ModMgr.GameWatchdogLoader.watchdogs.forEach {
|
||||
registerWatchdog(it.key, it.value)
|
||||
}
|
||||
|
||||
// these need to appear on top of any others
|
||||
uiContainer.add(notifier)
|
||||
|
||||
@@ -878,6 +882,12 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private var deltaTeeCleared = false
|
||||
|
||||
private val terrarumWorldWatchdogs = TreeMap<String, TerrarumWorldWatchdog>()
|
||||
|
||||
fun registerWatchdog(identifier: String, watchdog: TerrarumWorldWatchdog) {
|
||||
terrarumWorldWatchdogs[identifier] = watchdog
|
||||
}
|
||||
|
||||
/**
|
||||
* Ingame (world) related updates; UI update must go to renderGame()
|
||||
*/
|
||||
@@ -896,8 +906,6 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
//hypothetical_input_capturing_function_if_you_finally_decided_to_forgo_gdx_input_processor_and_implement_your_own_to_synchronise_everything()
|
||||
|
||||
WorldSimulator.resetForThisFrame()
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// camera-related updates //
|
||||
@@ -964,6 +972,13 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
fillUpWirePortsView(fixtures)
|
||||
}
|
||||
}
|
||||
terrarumWorldWatchdogs.entries.forEach {
|
||||
measureDebugTime("Ingame.Watchdog.${it.key}*") {
|
||||
if (WORLD_UPDATE_TIMER % it.value.runIntervalByTick.toLong() == 0L) {
|
||||
it.value(world)
|
||||
}
|
||||
}
|
||||
}
|
||||
oldCamX = WorldCamera.x
|
||||
oldPlayerX = actorNowPlaying?.hitbox?.canonicalX ?: 0.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user