Working on fixing enemy identification
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -3,6 +3,49 @@ import 'dart:math' as math;
|
||||
import 'package:wolf_dart/classes/coordinate_2d.dart';
|
||||
import 'package:wolf_dart/features/entities/entity.dart';
|
||||
|
||||
enum EnemyType {
|
||||
guard(mapBaseId: 108, spriteBaseIdx: 50),
|
||||
dog(mapBaseId: 216, spriteBaseIdx: 99),
|
||||
ss(mapBaseId: 180, spriteBaseIdx: 138),
|
||||
mutant(mapBaseId: 252, spriteBaseIdx: 187),
|
||||
officer(mapBaseId: 144, spriteBaseIdx: 238),
|
||||
;
|
||||
|
||||
final int mapBaseId;
|
||||
final int spriteBaseIdx;
|
||||
|
||||
const EnemyType({
|
||||
required this.mapBaseId,
|
||||
required this.spriteBaseIdx,
|
||||
});
|
||||
|
||||
/// Helper to check if a specific TED5 Map ID belongs to this enemy
|
||||
bool claimsMapId(int id) => id >= mapBaseId && id <= mapBaseId + 35;
|
||||
|
||||
/// Helper to find which EnemyType a given Map ID belongs to
|
||||
static EnemyType? fromMapId(int id) {
|
||||
for (final type in EnemyType.values) {
|
||||
if (type.claimsMapId(id)) return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
bool claimsSpriteIndex(int index) {
|
||||
return switch (this) {
|
||||
// Walk, Action, & Death: 50-98
|
||||
EnemyType.guard => index >= 50 && index <= 98,
|
||||
// Walk, Action, & Death: 99-137
|
||||
EnemyType.dog => index >= 99 && index <= 137,
|
||||
// Walk, Action, & Death: 138-186
|
||||
EnemyType.ss => index >= 138 && index <= 186,
|
||||
// Walk, Action, & Death: 187-237
|
||||
EnemyType.mutant => index >= 187 && index <= 237,
|
||||
// Walk, Action, & Death: 238-287
|
||||
EnemyType.officer => index >= 238 && index <= 287,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Enemy extends Entity {
|
||||
Enemy({
|
||||
required super.x,
|
||||
|
||||
Reference in New Issue
Block a user