fix: 修复Boss渲染层级错误,确保Boss始终显示在最前
Boss单位在渲染排序时未获得足够高的优先级,导致可能被其他单位遮挡。 现在为Boss单位添加专门的渲染优先级字段(bossPriority),并在排序时作为第一排序条件。 同时为Boss的spawnOrder添加偏移量,确保同优先级内Boss保持正确的生成顺序。
This commit is contained in:
@@ -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<number, MoveFacConfig> = {
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user