import { Vec3 } from 'cc'; /** 出现相对落地尺寸默认 */ export const SUMMON_JUMP_SCALE_FROM = 0.5; /** 出生后放到落地尺寸秒 */ export const SUMMON_JUMP_GROW_SEC = 0.3; /** 放到落地尺寸后停留再跳出秒 */ export const SUMMON_JUMP_HOLD_SEC = 1; /** 召唤跳出缩放(相对怪物默认) */ export interface SummonJumpScaleLook { /** 出现时相对落地尺寸 */ scaleFrom: number; /** 落地相对 Monster.size;空则 1 */ scaleMul?: number; /** 第一段放到此相对落地尺寸;空则 grow 直接到落地 */ scaleHold?: number; /** 第一段放大秒 */ growSec: number; /** 起跳前停顿秒 */ holdSec: number; /** 跳跃速度相对默认;空则 1 */ jumpSpeed?: number; } /** 跳出起点 */ interface JumpStart { /** 怪物实体 */ entity: number; /** 世界 X */ x: number; /** 世界 Y */ y: number; /** 世界 Z */ z: number; } /** 本批出怪共用起点 */ interface PendingStart { /** 世界 X */ x: number; /** 世界 Y */ y: number; /** 世界 Z */ z: number; /** 非空时覆盖默认缩放 */ look?: SummonJumpScaleLook; } /** * 技能召唤跳出:unitSpawned 前写入出生点,表现层取出。 */ export class SummonJumpPending { private static readonly _starts: JumpStart[] = []; private static _pending: PendingStart | null = null; /** * 出怪前写入本批起点。 * @param world 出生世界坐标 * @param look 非空时覆盖默认缩放 */ static setPendingStart(world: Readonly, look?: SummonJumpScaleLook): void { SummonJumpPending._pending = { x: world.x, y: world.y, z: world.z, look }; } /** 本批缩放 */ static peekPendingLook(): SummonJumpScaleLook | null { return SummonJumpPending._pending?.look ?? null; } /** 本批出怪结束 */ static clearPendingStart(): void { SummonJumpPending._pending = null; } /** * 取出跳出起点:先实体标记,再本批 pending。 * @param entity 怪物 * @param out 输出 */ static takeJumpStart(entity: number, out?: Vec3): boolean { const list = SummonJumpPending._starts; for (let i = list.length - 1; i >= 0; i--) { if (list[i].entity !== entity) continue; if (out) out.set(list[i].x, list[i].y, list[i].z); list.splice(i, 1); return true; } const pend = SummonJumpPending._pending; if (!pend) return false; if (out) out.set(pend.x, pend.y, pend.z); return true; } /** 离场清理 */ static clear(): void { SummonJumpPending._starts.length = 0; SummonJumpPending._pending = null; } }