import * as RE from 'rogue-engine';

export default class LifetimeComponent extends RE.Component {
  @RE.props.num() elapsedLifeDuration: number = 100
  elapsed = 0
  @RE.props.num() minHeight: number = -10
  awake() {
    this.elapsed = 0
  }

  start() {

  }

  update() {
    this.elapsed += RE.Runtime.deltaTime

    if(this.elapsedLifeDuration != 0 && this.elapsed >= this.elapsedLifeDuration) {
      RE.App.currentScene.remove(this.object3d)
    }

    if(this.object3d.position.y <= this.minHeight) {
      RE.App.currentScene.remove(this.object3d)
    }
  }
}

RE.registerComponent(LifetimeComponent);
        