From 574fa211605f6ad57657712412bf6198bc9ad86e Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Tue, 27 May 2025 10:51:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=AB=98=E7=BA=A7=E5=8A=A8=E7=94=BBticker?= =?UTF-8?q?=E8=B7=A8=E5=B1=82=E6=91=A7=E6=AF=81=E7=9A=84=E5=90=8C=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E8=BA=AB=E8=A2=AB=E6=91=A7=E6=AF=81=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E4=BF=9D=E7=95=99=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/data.js | 4 ++-- project/plugins.js | 18 +++++++++--------- runtime.d.ts | 4 +++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/project/data.js b/project/data.js index b1454bde..78b79255 100644 --- a/project/data.js +++ b/project/data.js @@ -532,7 +532,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "type": "function", - "function": "function(){\n// 默认读取弹幕数据\nif (core.hasFlag('comment') && !core.isReplaying()) {\n\tcore.plugin.getComment();\n\tsetTimeout(core.plugin.drawCommentSign, 1000);\n}\n}" + "function": "function(){\n// 默认读取弹幕数据\nif (core.hasFlag('comment') && !core.isReplaying()) {\n\tnew Promise(res => {\n\t\t\tsetTimeout(res, 1000);\n\t\t})\n\t\t.then(value => {\n\t\t\treturn new Promise(res => {\n\t\t\t\tcore.plugin.getComment();\n\t\t\t\tsetTimeout(res, 1000);\n\t\t\t})\n\t\t})\n\t\t.then(value => {\n\t\t\tcore.plugin.drawCommentSign();\n\t\t})\n}\n}" } ], "shops": [ @@ -746,6 +746,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "enableRouteFolding": true, "disableShopOnDamage": false, "blurFg": false, - "chaseThroughEnemy": false, + "chaseThroughEnemy": false } } \ No newline at end of file diff --git a/project/plugins.js b/project/plugins.js index a3440825..9dc37cee 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -1153,18 +1153,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = if (main.replayChecking) __enable = false; if (!__enable) { core.plugin.animate = {}; - this.aniMap = new Map(); + this.tickerSet = new Set(); this.deleteAllAnis = () => { }; return; } - /** 键为一个自建Ticker, 值为摧毁它的事件 */ - this.aniMap = new Map(); + /** 该集合中的所有Ticker在跨层时需要被摧毁 */ + this.tickerSet = new Set(); /** 对Map中所有Ticker执行摧毁事件 */ this.deleteAllAnis = function () { - core.plugin.aniMap.forEach((destroyEvent, ani) => destroyEvent(ani)); - core.plugin.aniMap.clear(); + core.plugin.tickerSet.forEach((ticker) => ticker.destroy()); } // var M = Object.defineProperty; @@ -1202,6 +1201,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = this.funcs.clear(); } destroy() { + core.plugin.tickerSet.delete(this); this.clear(), this.stop(); } stop() { @@ -1894,7 +1894,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = const { Transition, hyper, Ticker } = core.plugin.animate ?? {}; // 磁吸特效的时长,单位毫秒 - const transitionTime = 600; + const transitionTime = 400; const transitionList = []; @@ -2119,7 +2119,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = const index = transitionList.findIndex(v => v === t); transitionList.splice(index, 1); } // 摧毁Transition t - core.plugin.aniMap.set(t, onDestory); + core.plugin.tickerSet.add(t.ticker); t.mode(hyper('sin', 'out')) .time(transitionTime) .absolute() @@ -2388,12 +2388,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = function drawCommentStr(content, x, y, vx) { if (core.isReplaying() || !Animation) return; const ani = new Animation(); - core.plugin.aniMap.set(ani, (ani) => ani.ticker.destroy()); + core.plugin.tickerSet.add(ani.ticker); ani.ticker.add(() => { core.fillText(ctxName, content, x + ani.x, y, 'white', '16px Verdana'); }) // 弹幕的最大长度5600,再长属于异常数据 - const aim = 600 + Math.min(core.calWidth(ctxName, content, '16px Verdana'), 5000); + const aim = 100 + Math.min(core.calWidth(ctxName, content, '16px Verdana'), 5000); ani.mode(linear()) .time(aim / vx) .absolute() diff --git a/runtime.d.ts b/runtime.d.ts index e0fde997..4f8f7f70 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -3058,7 +3058,9 @@ interface plugin { animate: { Animation: any, AnimationBase: any, Ticker: any, Transition: any, bezier: any, bezierPath: any, circle: any, hyper: any, inverseTrigo: any, linear: any, power: any, shake: any, sleep: any, trigo: any, - } & {} + } + /** 该集合中的所有Ticker在跨层时需要被摧毁 */ + tickerSet: Set /** 打开一个道具商店 */ openItemShop: (itemShopId: string) => void