import BaseSystem from "../systems/BaseSystem";
import BaseMachine from "../slotMachines/BaseMachine";

export default class BlockExitStateSystem extends BaseSystem {
  public state: 'active' | 'stopped' = 'stopped'
  private blockExitState: boolean = false;

  constructor(machine:BaseMachine) {
    super(machine);
    this.machine.inputs.blockExitState = false;
  }

  static override requiredInputs = ['blockExitState'];

  override onEnter() {
    this.state = 'active'
  }

  override onLeave() {
    // Do nothing
  }

  override update(_dt: number) {
    if (this.blockExitState && !this.machine.inputs.blockExitState) this.state = 'stopped';
    this.blockExitState = this.machine.inputs.blockExitState
  }
}
