/** @format */ import {ECSSystem} from '../lib/ECSSystem' import {GenFilterKey} from '../lib/ECSComponent' import {FightWorld} from '../worlds/FightWorld' import {ComDie} from '../components/ComDie' import {ComRole} from '../components/ComRole' import {ComDizzy} from '../components/ComDizzy' import {ComBehaviorTree} from '../components/ComBehaviorTree' const FILTER_DIZZY_TIME = GenFilterKey([ComDizzy, ComRole, ComBehaviorTree], [ComDie]) export class SysDizzy 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_DIZZY_TIME) filter.walk((entity: number) => { let comDizzy = world.getComponent(entity, ComDizzy) if (!comDizzy.dirty) return comDizzy.countDown -= dt if (comDizzy.countDown <= 0) { comDizzy.dirty = false } return false }) } }