30 lines
411 B
Plaintext
30 lines
411 B
Plaintext
|
|
use vlib::Console;
|
||
|
|
|
||
|
|
Set<Entity> tickables
|
||
|
|
f64 lastTick
|
||
|
|
|
||
|
|
interface Tickable {
|
||
|
|
handle tick(f64 dTime)
|
||
|
|
}
|
||
|
|
|
||
|
|
handle start() {
|
||
|
|
defer(tick)
|
||
|
|
}
|
||
|
|
|
||
|
|
handle added(Tickable e) {
|
||
|
|
tickables.add(e)
|
||
|
|
}
|
||
|
|
|
||
|
|
handle removed(Tickable e) {
|
||
|
|
tickables.remove(e)
|
||
|
|
}
|
||
|
|
|
||
|
|
handle internal tick() {
|
||
|
|
f64 time = $Time.sinceStart()
|
||
|
|
f64 dTime = time - lastTick
|
||
|
|
for(Tickable t : tickables) {
|
||
|
|
t.tick()
|
||
|
|
}
|
||
|
|
lastTick = time
|
||
|
|
defer(tick)
|
||
|
|
}
|