import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { VM } from "../../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
import { Checkpoint } from "../../checkpoint/Checkpoint";

/** 
 * 游戏玩家数据 
 */
@ecs.register('AccountModel')
export class AccountModelComp extends ecs.Comp {

    /** 提供 VM 组件使用的数据 */
    private vm: any = {};

    checkpoint: Checkpoint = null!;

    private _name: string = "";
    /** 昵称 */
    get name(): string {
        return this._name;
    }
    set name(value: string) {
        this._name = value;
        this.vm.name = value;
    }

    vmAdd() {
        VM.add(this.vm, "Account");
    }

    vmRemove() {
        VM.remove("Account");
    }

    reset() {
        this.vmRemove();

        this.name = "";
    }

}