123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /** @format */
- import {ECSSystem} from '../lib/ECSSystem'
- import {GenFilterKey} from '../lib/ECSComponent'
- import {FightWorld} from '../worlds/FightWorld'
- import {ComDie} from '../components/ComDie'
- import {ComNodeConfig} from '../components/ComNodeConfig'
- import {ComCocosNode} from '../components/ComCocosNode'
- import {ComTransform} from '../components/ComTransform'
- import {ComRole} from '../components/ComRole'
- import {ComRoleSpine} from '../components/ComRoleSpine'
- import {ComBehaviorTree} from '../components/ComBehaviorTree'
- const FILTER_DIE = GenFilterKey([ComCocosNode, ComDie])
- export class SysDie extends ECSSystem {
- /** 连接 */
- public onAdd(world: FightWorld): void {}
- /** 断开连接 */
- public onRemove(world: FightWorld): void {}
- /** 添加实体 */
- public onEntityEnter(world: FightWorld, entity: number): void {}
- /** */
- public onEntityLeave(world: FightWorld, entity: number): void {}
- /** 更新 */
- public onUpdate(world: FightWorld, dt: number): void {
- let filter = world.getFilter(FILTER_DIE)
- filter.walk((entity: number) => {
- let comDie = world.getComponent(entity, ComDie)
- comDie.countDown -= dt
- if (comDie.countDown <= 0) {
- if (comDie.spineEntity) {
- world.removeNodeEntity(comDie.spineEntity)
- }
- world.removeNodeEntity(entity)
- }
- return false
- })
- }
- }
|