import Buffer from "../_Utilities/Buffer";
import Actor_Attribute_Manager from "./Managers/Actor_Attribute_Manager";
import Entity_Manager from "../Entity/Entity_Manager";
import Entity_Scale_Manager from "../Entity/Managers/Entity_Scale_Manager";
export default class Actor_Manager {
    static get(actor_ID) {
        return Buffer.get_Data("4ed80338-5c2b-40fb-9ac4-5d2c50a8da6b", actor_ID);
    }
    static remove(actor_ID) {
        return Buffer.delete_Data("4ed80338-5c2b-40fb-9ac4-5d2c50a8da6b", actor_ID);
    }
    static interact(player, actor) {
        actor.interaction.callback(player, actor.entity);
    }
    static spawn(dimension_ID, template, location, rotation) {
        const entity = Entity_Manager.spawn(dimension_ID, "bgs:actor", location, rotation);
        if (template.name != undefined)
            entity.nameTag = template.name;
        const actor = {
            entity: entity,
            name: template.name,
            persistent: template.persistent,
            attributes: template.attributes,
            characteristics: template.characteristics,
            interaction: template.interaction,
        };
        Buffer.set_Data("4ed80338-5c2b-40fb-9ac4-5d2c50a8da6b", actor.entity.id, actor);
        Actor_Attribute_Manager.initialize(actor, actor.attributes);
        Entity_Scale_Manager.set(entity, actor.characteristics.scale);
        entity.triggerEvent("bgs:attack_" + actor.characteristics.attack);
        entity.triggerEvent("bgs:behavior_" + actor.characteristics.behavior);
        entity.triggerEvent("bgs:family_" + actor.characteristics.family);
        entity.setProperty("bgs:geometry", actor.characteristics.geometry);
        entity.setProperty("bgs:material", actor.characteristics.material);
        entity.setProperty("bgs:texture", actor.characteristics.texture);
        const point = { x: entity.location.x, y: entity.location.y + 3, z: entity.location.z };
        entity.dimension.spawnParticle("bgs:dot", point);
    }
    static filter(family, name_Tag) {
        const actors = Array.from(Buffer.get("4ed80338-5c2b-40fb-9ac4-5d2c50a8da6b").values());
        if (family == undefined && name_Tag == undefined)
            return actors;
        let filter = actors;
        if (family != undefined)
            filter = filter.filter((agent) => agent.characteristics.family == family);
        if (name_Tag != undefined)
            filter = filter.filter((agent) => agent.entity.nameTag == name_Tag);
        return filter;
    }
}
