mirror of
				https://github.com/Reuh/ubiquitousse.git
				synced 2025-10-27 17:19:31 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			582 B
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			582 B
		
	
	
	
		
			Text
		
	
	
	
	
	
| --- Timer system
 | |
| -- Handles ubiquitousse timers.
 | |
| 
 | |
| let timer = require((...):match("^(.-)ecs%.timer").."scene")
 | |
| 
 | |
| return {
 | |
| 	name = "timer",
 | |
| 	filter = "timer",
 | |
| 	default = {
 | |
| 		-- timer object
 | |
| 	},
 | |
| 	process = :(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
 | |
| }
 |