AccountModelComp.ts 858 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  2. import { VM } from "../../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
  3. import { Checkpoint } from "../../checkpoint/Checkpoint";
  4. /**
  5. * 游戏玩家数据
  6. */
  7. @ecs.register('AccountModel')
  8. export class AccountModelComp extends ecs.Comp {
  9. /** 提供 VM 组件使用的数据 */
  10. private vm: any = {};
  11. checkpoint: Checkpoint = null!;
  12. private _name: string = "";
  13. /** 昵称 */
  14. get name(): string {
  15. return this._name;
  16. }
  17. set name(value: string) {
  18. this._name = value;
  19. this.vm.name = value;
  20. }
  21. vmAdd() {
  22. VM.add(this.vm, "Account");
  23. }
  24. vmRemove() {
  25. VM.remove("Account");
  26. }
  27. reset() {
  28. this.vmRemove();
  29. this.name = "";
  30. }
  31. }