import { Component } from '../core/Component.js'; export class Combat extends Component { constructor() { super('Combat'); this.attackDamage = 10; this.defense = 5; this.attackSpeed = 1.0; // Attacks per second this.attackRange = 50; this.lastAttackTime = 0; this.attackCooldown = 0; // Combat state this.isAttacking = false; this.attackDirection = 0; // Angle in radians this.knockbackResistance = 0.5; } /** * Check if can attack */ canAttack(currentTime) { return (currentTime - this.lastAttackTime) >= (1.0 / this.attackSpeed); } /** * Perform attack */ attack(currentTime, direction) { if (!this.canAttack(currentTime)) return false; this.lastAttackTime = currentTime; this.isAttacking = true; this.attackDirection = direction; this.attackCooldown = 0.3; // Attack animation duration return true; } /** * Update attack state */ update(deltaTime) { if (this.attackCooldown > 0) { this.attackCooldown -= deltaTime; if (this.attackCooldown <= 0) { this.isAttacking = false; } } } }