sparkletown/sparkle

View on GitHub
src/components/templates/AnimateMap/game/map/systems/AnimationSysem.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { ListIteratingSystem } from "@ash.ts/ash";

import { AnimationComponent } from "../components/AnimationComponent";
import { AnimationNode } from "../nodes/AnimationNode";

export class AnimationSystem extends ListIteratingSystem<AnimationNode> {
  updateNode(node: AnimationNode, delta: number) {
    node.animation.animation.animate(delta);

    node.animation.alive -= delta;

    if (node.animation.alive <= 0) {
      node.entity.remove(AnimationComponent);
    }
  }
}