1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 09:09:30 +00:00
ubiquitousse/ecs/commonsystems/timer.can

35 lines
585 B
Text

--- Timer system
-- Handles ubiquitousse timers.
let timer = require((...):match("^(.-)ecs%.timer").."scene")
return {
name = "timer",
filter = "timer",
default = {
-- timer object
},
process = :(e, t, dt)
t:update(dt)
if t:dead() then
@world:remove(t.entity)
end
end,
--- System methods ---
--- Add a new timer
run = :(func)
local t = timer.run(func)
@world:add {
timer = t
}
return t
end,
--- Add a new tween
tween = :(duration, tbl, to, method)
local t = timer.tween(duration, tbl, to, method)
@world:add {
timer = t
}
return t
end
}