/*
RSK World – Tower Defense 3D (EnemyFactory)
For support, licensing, or custom development inquiries: help@rskworld.in • Phone/WhatsApp: +91 9330539277
Website: RSK World • Business Inquiries: help@rskworld.in
🤝 Contributing: Suggestions and improvements are welcome!
*/

import { Enemy } from './Enemy.js';
import { EnemyGLTF } from './EnemyGLTF.js';
import { EnemyToon } from './EnemyToon.js';

export class EnemyFactory {
	constructor(pathPoints, types) {
		this.path = pathPoints;
		this.types = types;
	}

	spawn(typeKey) {
		const cfg = this.types[typeKey];
		if (!cfg) return new Enemy(this.path);
		
		// Map special types to the new Enemy class variants
		if (typeKey === 'dragon' || typeKey === 'crobot') {
			return new Enemy(this.path, {
				speed: cfg.speed,
				health: cfg.health,
				radius: cfg.radius,
				isFlying: cfg.isFlying,
				variant: typeKey
			});
		}

		if (cfg.url) {
			return new EnemyGLTF(this.path, cfg.url, {
				speed: cfg.speed,
				health: cfg.health,
				scale: cfg.scale,
				radius: cfg.radius,
				animName: cfg.animName,
				isFlying: cfg.isFlying
			});
		}
		// Default to toon human style if no URL
		return new EnemyToon(this.path, {
			speed: cfg.speed,
			health: cfg.health,
			scale: cfg.scale,
			radius: cfg.radius,
			variant: cfg.variant || typeKey
		});
	}
}
