import Buffer from "../../_Utilities/Buffer";
export default class Entity_Attribute_Manager {
    static set(id, entity, amount) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        return component.setCurrentValue(amount);
    }
    static reset_Default(id, entity) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        component.resetToDefaultValue();
    }
    static reset_Max(id, entity) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        component.resetToMaxValue();
    }
    static reset_Min(id, entity) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        component.resetToMinValue();
    }
    static get(id, entity) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        return component.currentValue;
    }
    static get_Max(id, entity) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        return component.effectiveMax;
    }
    static get_Min(id, entity) {
        const component = this.component(id, entity);
        if (component == undefined)
            return undefined;
        return component.effectiveMin;
    }
    static increase(id, entity, amount) {
        let health = this.get(id, entity);
        if (health == undefined)
            return false;
        health = health + amount;
        const max_Health = this.get_Max(id, entity);
        if (health > max_Health)
            health = max_Health;
        return this.set(id, entity, health);
    }
    static decrease(id, entity, amount) {
        let health = this.get(id, entity);
        if (health == undefined)
            return false;
        health = health - amount;
        const min_Health = this.get_Min(id, entity);
        if (health < min_Health || health <= 0)
            return false;
        return this.set(id, entity, health);
    }
    static component(id, entity) {
        let component = Buffer.get_Data(id, entity.id);
        if (component != undefined)
            return component;
        component = entity.getComponent(id);
        Buffer.set_Data("id", entity.id, component);
        return component;
    }
}
