Created
June 18, 2023 20:42
-
-
Save AxGord/58ecd1e845f2b7878a8e78e8e56701af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pony.events.Event1; | |
import pony.events.Signal1; | |
import pony.magic.DI; | |
import pony.magic.HasListener; | |
import pony.magic.HasSignal; | |
import pony.time.DT; | |
import pony.time.DeltaTime; | |
@:nullSafety(Strict) class DynamicDeltaTimeService implements HasSignal implements HasListener implements DI { | |
@:auto public final onUpdate: Signal1<DT>; | |
@:service private final deltaTime: DeltaTimeService; | |
@:bindable public var speed: Float = 0; | |
public function new(speed: Float = 1) { | |
this.speed = speed; | |
} | |
@:listen(deltaTime.onUpdate, speed > 0) | |
private function updateHandler(dt: DT): Void { | |
eUpdate(dt * speed); | |
} | |
public function destroy(): Void { | |
destroySignals(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment