import { System } from '../core/System.ts'; import { SystemName, ComponentType } from '../core/Constants.ts'; import type { Entity } from '../core/Entity.ts'; import type { Health } from '../components/Health.ts'; /** * System responsible for managing health regeneration for entities over time. */ export class HealthRegenerationSystem extends System { constructor() { super(SystemName.HEALTH_REGEN); this.requiredComponents = [ComponentType.HEALTH]; this.priority = 35; } /** * Process health regeneration for entities that haven't been damaged recently. * @param deltaTime - Time elapsed since last frame in seconds * @param entities - Entities matching system requirements */ process(deltaTime: number, entities: Entity[]): void { entities.forEach((entity) => { const health = entity.getComponent(ComponentType.HEALTH); if (!health || health.regeneration <= 0) return; const timeSinceDamage = (Date.now() - health.lastDamageTime) / 1000; if (timeSinceDamage > 5) { health.heal(health.regeneration * deltaTime); } }); } }