System.register(["cc"], function (_export, _context) { "use strict"; var _cclegacy, Timer, _crd; function get_new_timer(step) { return new Timer(step); } _export("default", get_new_timer); return { setters: [function (_cc) { _cclegacy = _cc.cclegacy; }], execute: function () { _crd = true; _cclegacy._RF.push({}, "890248SdzRIsa6dPHIO+Qxy", "Timer", undefined); Timer = class Timer { get elapsedTime() { return this._elapsedTime; } /** 触发间隔时间(秒) */ get step() { return this._step; } set step(step) { this._step = step; // 每次修改时间 this._elapsedTime = 0; // 逝去时间 } get coundown() { return this._step - this._elapsedTime; } get progress() { return this._elapsedTime / this._step; } constructor(step) { if (step === void 0) { step = 0; } this._elapsedTime = 0; this._step = -1; this.step = step; } /** * 序列化(数据库存储) */ serialize() { var data = { "step": this._step, "elapsed": this._elapsedTime }; return data; } /** * 反序列化 */ unserialize(data) { if (!data) return; this._step = data.step; this._elapsedTime = data.elapsed; } update(dt) { if (this.step <= 0) return false; this._elapsedTime += dt; if (this._elapsedTime >= this._step) { this._elapsedTime -= this._step; return true; } return false; } reset() { this._elapsedTime = 0; } stop() { this._elapsedTime = 0; this.step = -1; } }; _cclegacy._RF.pop(); _crd = false; } }; }); //# sourceMappingURL=2d88cd09787c5deb93ff6b3c4eb1c7adc8dd6555.js.map