From 802d5d645c3f87a81d1d5f9e83efd201ad470bee Mon Sep 17 00:00:00 2001 From: LokiSharp Date: Mon, 3 May 2021 16:55:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf:=20=E8=B0=83=E6=95=B4=20Creep=20Releas?= =?UTF-8?q?e=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/room/spawn/CreepRelease.ts | 5 +++-- src/modules/room/spawn/nameGetter.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/room/spawn/CreepRelease.ts b/src/modules/room/spawn/CreepRelease.ts index 40dcd954..26d001a8 100644 --- a/src/modules/room/spawn/CreepRelease.ts +++ b/src/modules/room/spawn/CreepRelease.ts @@ -421,9 +421,10 @@ export default class RoomCreepReleaseController { * * @param targetFlagName 进攻旗帜名称 * @param num 要孵化的数量 + * @param keepSpawn 是否持续生成 * @param wayPoint 路径点 */ - public attacker(targetFlagName = "", num = 1, wayPoint?: WayPoint): string { + public attacker(targetFlagName = "", num = 1, keepSpawn = false, wayPoint?: WayPoint): string { if (num <= 0 || num > 10) num = 1; for (let i = 0; i < num; i++) { @@ -432,7 +433,7 @@ export default class RoomCreepReleaseController { role: "attacker", data: { targetFlagName: targetFlagName || DEFAULT_FLAG_NAME.ATTACK, - keepSpawn: false, + keepSpawn, wayPoint } }); diff --git a/src/modules/room/spawn/nameGetter.ts b/src/modules/room/spawn/nameGetter.ts index 9114cf0b..b31af0d6 100644 --- a/src/modules/room/spawn/nameGetter.ts +++ b/src/modules/room/spawn/nameGetter.ts @@ -28,5 +28,5 @@ export class GetName { public static boostDismantler = (roomName: string): string => `${roomName} dismantler ${Game.time}`; public static boostRangedAttacker = (roomName: string): string => `${roomName} boostRangedAttacker ${Game.time}`; public static defender = (roomName: string): string => `${roomName} defender`; - public static scout = (roomName: string, index: number): string => `${roomName} scout ${Game.time}-${index}`; + public static scout = (roomName: string, index: number): string => `${roomName} scout ${index}`; } From c2eb18fe7eb14f857b7942ccc6180262727a230f Mon Sep 17 00:00:00 2001 From: Logic <923132714@qq.com> Date: Tue, 4 May 2021 16:12:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Fix=20#25=20=E9=87=8D=E6=96=B0=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E6=97=B6=E4=BC=9A=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根据 Game._needSaveConstructionData 判断是否需要获取 waitingConstruction --- src/modules/ConstructionController/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/ConstructionController/index.ts b/src/modules/ConstructionController/index.ts index f3a253dd..16cf88b0 100644 --- a/src/modules/ConstructionController/index.ts +++ b/src/modules/ConstructionController/index.ts @@ -39,8 +39,10 @@ export const buildCompleteSite: { [constructionSiteId: string]: Structure } = {} */ const saveWaiting = function (): void { if (!Game._needSaveConstructionData) return; - if (waitingConstruction.length <= 0) delete Memory[SAVE_KEY]; - else Memory[SAVE_KEY] = JSON.stringify(waitingConstruction); + if (waitingConstruction.length <= 0) { + Game._needSaveConstructionData = false; + delete Memory[SAVE_KEY]; + } else Memory[SAVE_KEY] = JSON.stringify(waitingConstruction); }; /** @@ -48,6 +50,7 @@ const saveWaiting = function (): void { * 在全局重置时调用 */ export function initConstructionController(): void { + if (!Game._needSaveConstructionData) return; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access waitingConstruction = JSON.parse(Memory[SAVE_KEY] || "[]").map(({ pos, type }) => { // 这里把位置重建出来