47 lines
1.0 KiB
Plaintext
47 lines
1.0 KiB
Plaintext
|
|
/*
|
||
|
|
文件名:Timer.nut
|
||
|
|
路径:Core/Timer/Timer.nut
|
||
|
|
创建日期:2025-02-11 23:25
|
||
|
|
文件用途:定时器
|
||
|
|
*/
|
||
|
|
class _Timer_ {
|
||
|
|
Exec_Tree = null;
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
//执行树
|
||
|
|
Exec_Tree = [];
|
||
|
|
|
||
|
|
//注册Proc
|
||
|
|
_Game_Logic_Func_._Timer_Proc <- Proc.bindenv(this);
|
||
|
|
|
||
|
|
getroottable().Timer <- this;
|
||
|
|
}
|
||
|
|
|
||
|
|
//下帧执行
|
||
|
|
function SetNextFrame(target_func, ...) {
|
||
|
|
local target_arg_list = [];
|
||
|
|
target_arg_list.push(getroottable());
|
||
|
|
for (local i = 0; i< vargv.len(); i++) {
|
||
|
|
target_arg_list.push(vargv[i]);
|
||
|
|
}
|
||
|
|
//设置下一次执行
|
||
|
|
local func_info = [];
|
||
|
|
|
||
|
|
func_info.push(target_func);
|
||
|
|
func_info.push(target_arg_list);
|
||
|
|
Exec_Tree.push(func_info);
|
||
|
|
}
|
||
|
|
|
||
|
|
function Proc(Dt, Lister) {
|
||
|
|
foreach(Info in Exec_Tree) {
|
||
|
|
//函数
|
||
|
|
local func = Info[0];
|
||
|
|
//参数
|
||
|
|
local func_args = Info[1];
|
||
|
|
//执行函数
|
||
|
|
func.acall(func_args);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
_Timer_();
|