Files
wolf_dart/lib/features/entities/decorative.dart

59 lines
1.6 KiB
Dart

import 'package:wolf_dart/features/difficulty/difficulty.dart';
import 'package:wolf_dart/features/entities/entity.dart';
class Decorative extends Entity {
Decorative({
required super.x,
required super.y,
required super.spriteIndex,
required super.mapId,
super.state = EntityState.staticObj, // Defaults to static
});
// Checks if the Map ID belongs to a standard decoration
static bool isDecoration(int objId) {
// ID 124 is a dead guard in WL1, but an SS guard in WL6.
// However, for spawning purposes, if the SS trySpawn fails,
// we only want to treat it as a decoration if it's not a live actor.
if (objId == 124 || objId == 125) return true;
if (objId >= 23 && objId <= 70) {
// Exclude collectibles defined in MapObject
if ((objId >= 43 && objId <= 44) || (objId >= 47 && objId <= 56)) {
return false;
}
return true;
}
return false;
}
static int getSpriteIndex(int objId) {
if (objId == 124) return 95; // Dead guard sprite index
if (objId == 125) return 96; // Dead Aardwolf/Other body
// Standard decorations are typically offset by 21 in the VSWAP
return objId - 21;
}
static Decorative? trySpawn(
int objId,
double x,
double y,
Difficulty difficulty, {
bool isSharewareMode = false,
}) {
if (isDecoration(objId)) {
return Decorative(
x: x,
y: y,
spriteIndex: getSpriteIndex(objId),
mapId: objId,
state: objId == 124 ? EntityState.dead : EntityState.staticObj,
);
}
// Not a decoration!
return null;
}
}