feat: add poc
This commit is contained in:
parent
43d27b04d9
commit
4a4fa05ce4
53 changed files with 6191 additions and 0 deletions
27
src/systems/HealthRegenerationSystem.js
Normal file
27
src/systems/HealthRegenerationSystem.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { System } from '../core/System.js';
|
||||
|
||||
/**
|
||||
* System to handle health regeneration
|
||||
*/
|
||||
export class HealthRegenerationSystem extends System {
|
||||
constructor() {
|
||||
super('HealthRegenerationSystem');
|
||||
this.requiredComponents = ['Health'];
|
||||
this.priority = 35;
|
||||
}
|
||||
|
||||
process(deltaTime, entities) {
|
||||
entities.forEach(entity => {
|
||||
const health = entity.getComponent('Health');
|
||||
if (!health || health.regeneration <= 0) return;
|
||||
|
||||
// Regenerate health over time
|
||||
// Only regenerate if not recently damaged (5 seconds)
|
||||
const timeSinceDamage = (Date.now() - health.lastDamageTime) / 1000;
|
||||
if (timeSinceDamage > 5) {
|
||||
health.heal(health.regeneration * deltaTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue