This commit is contained in:
walkpan
2025-02-01 00:14:25 +08:00
parent c5c01c6cf4
commit bffbb9077e
91 changed files with 2067 additions and 1327 deletions

View File

@@ -0,0 +1,18 @@
export class CombatEvent {
static readonly type = 'CombatEvent';
constructor(
public readonly attacker: ecs.Entity,
public readonly target: ecs.Entity,
public readonly damage: number
) {}
}
// 事件监听示例
oops.message.on(CombatEvent.type, (event: CombatEvent) => {
const targetModel = event.target.get(HeroModel);
targetModel.hp = Math.max(targetModel.hp - event.damage, 0);
if (targetModel.hp <= 0) {
event.target.add(Status).setDead();
}
});