import { Component } from '../core/Component.js'; export class AI extends Component { constructor(behaviorType = 'wander') { super('AI'); this.behaviorType = behaviorType; // 'wander', 'patrol', 'chase', 'flee', 'combat' this.state = 'idle'; // 'idle', 'moving', 'attacking', 'fleeing' this.target = null; // Entity ID to target this.awareness = 0; // 0-1, how aware of player this.alertRadius = 150; this.chaseRadius = 300; this.fleeRadius = 100; // Behavior parameters this.wanderSpeed = 50; this.wanderDirection = Math.random() * Math.PI * 2; this.wanderChangeTime = 0; this.wanderChangeInterval = 2.0; // seconds } /** * Set behavior type */ setBehavior(type) { this.behaviorType = type; } /** * Set target entity */ setTarget(entityId) { this.target = entityId; } /** * Clear target */ clearTarget() { this.target = null; } /** * Update awareness */ updateAwareness(delta, maxAwareness = 1.0) { this.awareness = Math.min(maxAwareness, this.awareness + delta); if (this.awareness <= 0) { this.awareness = 0; } } }