Added a class to map object ids so they can be called by name

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 16:00:37 +01:00
parent dfc6a94e88
commit 690ac1e7e6
4 changed files with 128 additions and 31 deletions

View File

@@ -10,6 +10,7 @@ import 'package:wolf_dart/features/entities/door_manager.dart';
import 'package:wolf_dart/features/entities/enemies/enemy.dart';
import 'package:wolf_dart/features/entities/entity.dart';
import 'package:wolf_dart/features/entities/entity_registry.dart';
import 'package:wolf_dart/features/entities/map_objects.dart';
import 'package:wolf_dart/features/entities/pushwall_manager.dart';
import 'package:wolf_dart/features/input/input_manager.dart';
import 'package:wolf_dart/features/map/wolf_map.dart';
@@ -76,27 +77,24 @@ class _WolfRendererState extends State<WolfRenderer>
for (int x = 0; x < 64; x++) {
int objId = objectLevel[y][x];
if (objId >= 19 && objId <= 22) {
if (objId >= MapObjectId.playerNorth &&
objId <= MapObjectId.playerWest) {
double spawnAngle = 0.0;
switch (objId) {
case 19:
case MapObjectId.playerNorth:
spawnAngle = 3 * math.pi / 2;
break;
case 20:
case MapObjectId.playerEast:
spawnAngle = 0.0;
break;
case 21:
case MapObjectId.playerSouth:
spawnAngle = math.pi / 2;
break;
case 22:
case MapObjectId.playerWest:
spawnAngle = math.pi;
break;
}
player = Player(
x: x + 0.5,
y: y + 0.5,
angle: spawnAngle,
);
player = Player(x: x + 0.5, y: y + 0.5, angle: spawnAngle);
} else {
Entity? newEntity = EntityRegistry.spawn(
objId,
@@ -344,7 +342,7 @@ class _WolfRendererState extends State<WolfRenderer>
// Map ID 44 is usually the Ammo Clip in the Object Grid/Registry
Entity? droppedAmmo = EntityRegistry.spawn(
49, // The ID for an ammo clip collectible
MapObjectId.ammoClip,
entity.x,
entity.y,
widget.difficulty.level,