LifetimeComponent.re.ts 620 B

1234567891011121314151617181920212223242526272829
  1. import * as RE from 'rogue-engine';
  2. export default class LifetimeComponent extends RE.Component {
  3. @RE.props.num() elapsedLifeDuration: number = 100
  4. elapsed = 0
  5. @RE.props.num() minHeight: number = -10
  6. awake() {
  7. this.elapsed = 0
  8. }
  9. start() {
  10. }
  11. update() {
  12. this.elapsed += RE.Runtime.deltaTime
  13. if(this.elapsedLifeDuration != 0 && this.elapsed >= this.elapsedLifeDuration) {
  14. RE.App.currentScene.remove(this.object3d)
  15. }
  16. if(this.object3d.position.y <= this.minHeight) {
  17. RE.App.currentScene.remove(this.object3d)
  18. }
  19. }
  20. }
  21. RE.registerComponent(LifetimeComponent);