From 56227d8f3fed1a5112fe7eafd776f5d97d1a069a Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 18 Mar 2026 16:22:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DBoss=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=B1=82=E7=BA=A7=E9=94=99=E8=AF=AF=EF=BC=8C=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?Boss=E5=A7=8B=E7=BB=88=E6=98=BE=E7=A4=BA=E5=9C=A8=E6=9C=80?= =?UTF-8?q?=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Boss单位在渲染排序时未获得足够高的优先级,导致可能被其他单位遮挡。 现在为Boss单位添加专门的渲染优先级字段(bossPriority),并在排序时作为第一排序条件。 同时为Boss的spawnOrder添加偏移量,确保同优先级内Boss保持正确的生成顺序。 --- assets/script/game/hero/MoveComp.ts | 6 ++++-- assets/script/game/map/MissionMonComp.ts | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/assets/script/game/hero/MoveComp.ts b/assets/script/game/hero/MoveComp.ts index ad6dfaf2..69953770 100644 --- a/assets/script/game/hero/MoveComp.ts +++ b/assets/script/game/hero/MoveComp.ts @@ -47,7 +47,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate private renderSortElapsed = 0; private heroMoveMatcher: ecs.IMatcher | null = null; private heroViewMatcher: ecs.IMatcher | null = null; - private readonly renderEntries: { node: Node; frontScore: number; spawnOrder: number; eid: number }[] = []; + private readonly renderEntries: { node: Node; bossPriority: number; frontScore: number; spawnOrder: number; eid: number }[] = []; private renderEntryCount = 0; private readonly facConfigs: Record = { @@ -431,10 +431,11 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate const entryIndex = this.renderEntryCount; let entry = this.renderEntries[entryIndex]; if (!entry) { - entry = { node: actorView.node, frontScore: 0, spawnOrder: 0, eid: 0 }; + entry = { node: actorView.node, bossPriority: 0, frontScore: 0, spawnOrder: 0, eid: 0 }; this.renderEntries.push(entry); } entry.node = actorView.node; + entry.bossPriority = attrs.is_boss ? 1 : 0; entry.frontScore = frontScore; entry.spawnOrder = actorMove.spawnOrder; entry.eid = e.eid; @@ -443,6 +444,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate this.renderEntries.length = this.renderEntryCount; this.renderEntries.sort((a, b) => { + if (a.bossPriority !== b.bossPriority) return a.bossPriority - b.bossPriority; if (a.frontScore !== b.frontScore) return a.frontScore - b.frontScore; if (a.spawnOrder !== b.spawnOrder) return a.spawnOrder - b.spawnOrder; return a.eid - b.eid; diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index 1996e180..14e3338d 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -9,12 +9,14 @@ import { GameEvent } from "../common/config/GameEvent"; import {BoxSet } from "../common/config/GameSet"; import { BossList, BossSpawnCd, MonList, MonType, SpawnBaseCd, SpawnMinCd, SpawnPowerBias, SpawnStageReduce, StageBossGrow, StageDuration, StageGrow, UpType } from "./RogueConfig"; import { HeroAttrsComp } from "../hero/HeroAttrsComp"; +import { MoveComp } from "../hero/MoveComp"; const { ccclass, property } = _decorator; /** 视图层对象 */ @ccclass('MissionMonCompComp') @ecs.register('MissionMonComp', false) export class MissionMonCompComp extends CCComp { + private static readonly BOSS_RENDER_PRIORITY = 1000000; @property({ tooltip: "是否启用调试日志" }) private debugMode: boolean = false; @@ -201,8 +203,13 @@ export class MissionMonCompComp extends CCComp { // 递增全局生成顺序,做溢出保护 this.globalSpawnOrder = (this.globalSpawnOrder + 1) % 999; - // 先用原始配置创建怪物,再覆盖成长后属性 mon.load(pos, scale, uuid, isBoss); + const move = mon.get(MoveComp); + if (move) { + move.spawnOrder = isBoss + ? MissionMonCompComp.BOSS_RENDER_PRIORITY + this.globalSpawnOrder + : this.globalSpawnOrder; + } const model = mon.get(HeroAttrsComp); const base = HeroInfo[uuid]; if (!model || !base) return;