import Func from '@/Engine/ECS/Function';
import SysPage from '@/Frameworks/SysPage';
import { STORAGE_TYPE, LocalService } from '@/Frameworks/SysStorage';
import { PAGE_KEY } from '@/Project/constants';
import { FuncMainState } from '../FuncMain';

export enum FuncLimitedSpaceState {
  idle,
  index,
  data
}

export default class FuncLimitedSpace extends Func<FuncLimitedSpaceState> {
  constructor(name: string) {
    super(name);
    super.initStates((sm) => {
      sm.addState(
        FuncLimitedSpaceState.idle,
        this.onIdleStateIn,
        null,
        this.onIdleStateExit,
      );
      sm.addState(
        FuncLimitedSpaceState.index,
        this.onIndexStateIn,
        null,
        this.onIndexStateExit,
      );
      sm.addState(
        FuncLimitedSpaceState.data,
        this.onIndexStateIn,
        null,
        this.onIndexStateExit,
      );
    });
  }
  onIdleStateIn(): void {
    window.GT_APP.funcLimitedSpace.changeState(FuncLimitedSpaceState.index)
    // window.GT_APP.funcLimitedSpace.changeState(FuncLimitedSpaceState.data)
  }
  onIdleStateExit(): void {
  }
  onIndexStateIn(): void {
    SysPage.add(PAGE_KEY.LimitedIndex)
  }
  onIndexStateExit(): void {
    SysPage.removeByKey(PAGE_KEY.LimitedIndex)
  }
  onDataStateIn(): void {
    SysPage.add(PAGE_KEY.LimitedData)
  }
  onDataStateExit(): void {
    SysPage.removeByKey(PAGE_KEY.LimitedData)
  }
}
