import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { SingletonModuleComp, smc } from "../../common/SingletonModuleComp";
import { PathFindComp, PathFindTriggerComponent } from "../../common/ecs/path/PathFind";
import { Puppet } from "../../puppet/puppet";
import { PuppetViewComp } from "../../puppet/view/PuppetViewComp";
import { Checkpoint } from "../Checkpoint";
import { CheckpointModelComp } from "../model/CheckpointModel";

/**
 * 换肤
 */
@ecs.register('CheckpointPathTrigger')
export class CheckpointPathTriggerComp extends ecs.Comp {


    reset() {

    }
}


export class CheckpointPathTriggerSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {

    filter(): ecs.IMatcher {
        return ecs.allOf(CheckpointModelComp, CheckpointPathTriggerComp);
    }

    entityEnter(e: Checkpoint): void {
       const puppets =  e.CheckpointModel.puppets
       puppets.forEach(val => {
            const pathComp = val.get(PathFindComp)
            if(pathComp){
              val.add(PathFindTriggerComponent)
            }
        })
        e.remove(CheckpointPathTriggerComp)
    }

}