import * as RE from 'rogue-engine';
import RaycastReceiver from '../RaycastReceiver.re';

export default class ContinueReceiver extends RaycastReceiver {
  onMouseOver(intersect) {
    this.isHovering = true
    this.object3d.currentObj = intersect.object
    
    this.object3d.currentObj.material.color.set(0xff0000)
    RE.Runtime.rogueDOMContainer.style.cursor = "pointer"
  }

  onMouseOut(){
    this.isHovering = false
    this.object3d.currentObj.material.color.set(0xffffff)
    RE.Runtime.rogueDOMContainer.style.cursor = "default"
  }

  update() {
    if(!this.isHovering) {
      return
    }
    if(RE.Input.mouse.getButtonUp(0) || RE.Input.touch.endTouches.length > 0) {
      RE.Runtime.rogueDOMContainer.style.cursor = "default"
      RE.App.loadScene("Main")
    }
  }
}

RE.registerComponent(ContinueReceiver);
