36 lines
1020 B
Dart
36 lines
1020 B
Dart
import 'package:wolf_dart/features/entities/decorative.dart';
|
|
import 'package:wolf_dart/features/entities/enemies/brown_guard.dart';
|
|
import 'package:wolf_dart/features/entities/entity.dart';
|
|
|
|
typedef EntitySpawner =
|
|
Entity? Function(int objId, double x, double y, int difficultyLevel);
|
|
|
|
abstract class EntityRegistry {
|
|
// Add future enemies (SSGuard, Dog, etc.) to this list!
|
|
static final List<EntitySpawner> _spawners = [
|
|
Decorative.trySpawn,
|
|
BrownGuard.trySpawn,
|
|
];
|
|
|
|
static Entity? spawn(
|
|
int objId,
|
|
double x,
|
|
double y,
|
|
int difficultyLevel,
|
|
int maxSprites,
|
|
) {
|
|
for (final spawner in _spawners) {
|
|
Entity? entity = spawner(objId, x, y, difficultyLevel);
|
|
|
|
if (entity != null) {
|
|
// Safety bounds check for the VSWAP array
|
|
if (entity.spriteIndex >= 0 && entity.spriteIndex < maxSprites) {
|
|
return entity;
|
|
}
|
|
return null; // VSWAP doesn't have this sprite!
|
|
}
|
|
}
|
|
return null; // No class claimed this Map ID
|
|
}
|
|
}
|