feat(渲染): 重构渲染层级管理并添加BOSS层级
移除动态渲染层级更新逻辑,改为在实体加载时设置固定层级 - 在Hero和Monster的load方法中设置初始siblingIndex - 添加BOSS枚举值到IndexSet - 为Monster添加溢出保护,防止层级索引过大 - 删除墓地位置判断等不再需要的逻辑
This commit is contained in:
@@ -2,7 +2,7 @@ import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,Sprite
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { BoxSet, FacSet } from "../common/config/GameSet";
|
||||
import { BoxSet, FacSet, IndexSet } from "../common/config/GameSet";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { BuffConf, SkillSet } from "../common/config/SkillSet";
|
||||
@@ -47,6 +47,12 @@ export class Monster extends ecs.Entity {
|
||||
if (collider) collider.enabled = false; // 先禁用 // 延迟一帧启用碰撞体
|
||||
node.setPosition(pos)
|
||||
|
||||
// 🔥 设置初始 SiblingIndex - 防止溢出
|
||||
const baseLane = lane === 0 ? IndexSet.MON1 : IndexSet.MON2;
|
||||
// 使用模运算防止索引溢出,确保在安全范围内循环
|
||||
const safeSpawnOrder = spawnOrder % 999; // 限制在999以内,避免溢出到其他层级
|
||||
const initialSiblingIndex = baseLane + safeSpawnOrder;
|
||||
node.setSiblingIndex(initialSiblingIndex);
|
||||
|
||||
var view = node.getComponent(HeroViewComp)!;
|
||||
const model = this.get(HeroAttrsComp);
|
||||
|
||||
Reference in New Issue
Block a user