now with watchdogs

This commit is contained in:
minjaesong
2025-03-02 20:42:03 +09:00
parent 2bb1c8400e
commit f861a2727d
8 changed files with 69 additions and 7 deletions

View File

@@ -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