import Item from "./item"
import user from "./user";
import shop from "./shop";
import pg from "../pg";
class Dress {
    public _list: Array<Item>
    public defaultSkin = {
        cover: "ani/cover.png",
        type: 3,
        meta_value: {
            nodes: {
                "eat": {
                    "tex_png": "ani/eating/eating_tex.png",
                    "ske_json": "ani/eating/eating_ske.json",
                    "tex_json": "ani/eating/eating_tex.json",
                    "armature": "",
                    // "play": "default"
                },
                "walk": {
                    "tex_png": "ani/walkinghungryhappy/walkinghungryhappy_tex.png",
                    "ske_json": "ani/walkinghungryhappy/walkinghungryhappy_ske.json",
                    "tex_json": "ani/walkinghungryhappy/walkinghungryhappy_tex.json",
                    "armature": "Armature",
                    "animation": "happy",
                    // "play": ""
                }
            }
        },
    };
    constructor() {
        console.log('dress start')
        this._list = [];
    }
    parse(list: any) {
        if (!list) return;
        this._list = [this.defaultSkin, ...list];
    }

    get list() {
        let currentIndex = 0
        if (this._list.length > 1) {

        }
        return this._list.map((it, i) =>{
            it.current = user.isCurrentDress(it.id)
            return it;
        });
    }

    has(item_id) {
        return this._list.indexOf(item_id) > -1;
    }
    setDressItem(node, id) {
        const item = this._list.find(li => li.id == id);
        if (!item) {
            return;
        }
        
        



        pg.view.setNetImg(node, item.itemImage, true).then(() => {
            node.active = true;
            if (rect) {
                node.x = rect.x;
                node.y = rect.y;
                node.width = rect.width;
                node.height = rect.height;
            }
        });
        
    }
}
const dress = new Dress();
export default dress;
