From 707f8ab1cb5b5fd40a606386f2d47fe502f77055 Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 31 Dec 2025 10:56:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(hero):=20=E6=B7=BB=E5=8A=A0=E8=8B=B1?= =?UTF-8?q?=E9=9B=84=E5=B1=9E=E6=80=A7=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=8F=8A=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 HeroAttrEvent 组件用于存储属性变更事件队列 添加 HeroAttrEventSystem 系统用于处理属性变更事件并更新角色属性 --- assets/script/game/hero/HeroAttrEvent.ts | 29 +++++++++ assets/script/game/hero/HeroAttrEvent.ts.meta | 9 +++ .../script/game/hero/HeroAttrEventSystem.ts | 61 +++++++++++++++++++ .../game/hero/HeroAttrEventSystem.ts.meta | 9 +++ 4 files changed, 108 insertions(+) create mode 100644 assets/script/game/hero/HeroAttrEvent.ts create mode 100644 assets/script/game/hero/HeroAttrEvent.ts.meta create mode 100644 assets/script/game/hero/HeroAttrEventSystem.ts create mode 100644 assets/script/game/hero/HeroAttrEventSystem.ts.meta diff --git a/assets/script/game/hero/HeroAttrEvent.ts b/assets/script/game/hero/HeroAttrEvent.ts new file mode 100644 index 00000000..b1b4ef31 --- /dev/null +++ b/assets/script/game/hero/HeroAttrEvent.ts @@ -0,0 +1,29 @@ +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { Attrs } from "../common/config/HeroAttrs"; + +/** + * ==================== 伤害事件数据 ==================== + * + * 单个伤害事件的数据结构 + */ +export interface AttrEvent { + /** 伤害属性数据 */ + Attr: Attrs; + Value:number; +} + +/** + * ==================== 伤害队列组件 ==================== + * + * 用途: + + */ +@ecs.register('HeroAttrEvent') +export class HeroAttrEvent extends ecs.Comp { + /** 伤害事件队列 */ + AttrEvent: AttrEvent[] = []; + reset() { + this.AttrEvent = []; + } + +} \ No newline at end of file diff --git a/assets/script/game/hero/HeroAttrEvent.ts.meta b/assets/script/game/hero/HeroAttrEvent.ts.meta new file mode 100644 index 00000000..e9ec6c92 --- /dev/null +++ b/assets/script/game/hero/HeroAttrEvent.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "c363af64-ebfd-4697-ad86-0afef53353f0", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/script/game/hero/HeroAttrEventSystem.ts b/assets/script/game/hero/HeroAttrEventSystem.ts new file mode 100644 index 00000000..ad0fec63 --- /dev/null +++ b/assets/script/game/hero/HeroAttrEventSystem.ts @@ -0,0 +1,61 @@ +import { Timer } from "db://oops-framework/core/common/timer/Timer"; +import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; +import { smc } from "../common/SingletonModuleComp"; +import { Attrs } from "../common/config/HeroAttrs"; +import { HeroUpSet } from "../common/config/heroSet"; +import { HeroSkillsComp } from "./HeroSkills"; +import { HeroAttrsComp } from "./HeroAttrsComp"; +import { HeroAttrEvent } from "./HeroAttrEvent"; +/** + * ==================== 英雄属性更新系统 ==================== + * + * 按照 ECS 设计理念: + * - System(HeroAttrEventSystem):处理属性更新事件 + * + * 系统职责: + * 1. 处理当角色收到attr变更事件时,更新角色属性,并处理动画展示 + + * +/** + * 使用方式: + * 在 RootSystem 中注册此系统,它会自动每帧更新所有拥有 HeroAttrsComp 的实体 + */ +@ecs.register('HeroAttrEventSystem') +export class HeroAttrEventSystem extends ecs.ComblockSystem + implements ecs.IEntityEnterSystem { + + /** + * 过滤器:只处理拥有 HeroAttrsComp 的实体 + */ + filter(): ecs.IMatcher { + return ecs.allOf(HeroAttrsComp,HeroAttrEvent); + } + + /** + * 实体首次进入系统时调用(每个实体只调用一次) + */ + entityEnter(e: ecs.Entity): void { + if(!smc.mission.play || smc.mission.pause) return; + + } + + /** + * 系统首次更新前调用(整个系统只调用一次) + */ + firstUpdate(): void { + console.log("[HeroAttrEventSystem] 系统首次更新"); + } + + + /** + * 启用调试模式(调试时使用) + */ + enableDebug() { + } + + /** + * 禁用调试模式(正式运行) + */ + disableDebug() { + } +} diff --git a/assets/script/game/hero/HeroAttrEventSystem.ts.meta b/assets/script/game/hero/HeroAttrEventSystem.ts.meta new file mode 100644 index 00000000..af5452ca --- /dev/null +++ b/assets/script/game/hero/HeroAttrEventSystem.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "c2a38591-59c8-44e4-b722-41dc6e8db0a1", + "files": [], + "subMetas": {}, + "userData": {} +}