Something went wrong. Try again.
Starship Simulator Controls thoriumsim.com
Something went wrong. Try again.
813 B · 26 lines
TypeScript
at develop
123456789101112131415161718192021222324252627import { type Entity, System } from "@thorium/utils/ecs";
export class TimerSystem extends System { static flightMode = ["nova", "legacy"]; test(entity: Entity) { return !!entity.components.timer; } update(entity: Entity, elapsed: number) { if (entity.components.timer && !entity.components.timer?.paused) { entity.updateComponent("timer", { remainingDurationMs: entity.components.timer.remainingDurationMs - elapsed, }); if (entity.components.timer.remainingDurationMs <= 0) { this.complete(entity); } } } complete(entity: Entity) { const completeBlocks = entity.components.timer?.completeBlocks || []; const blockMetadata = entity.components.timer?.blockMetadata || {};
this.ecs.executeBlocks(completeBlocks, blockMetadata);
this.ecs.removeEntityById(entity.id); }}