Add shareware support and spawn correctly for difficulty levels

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 17:01:01 +01:00
parent 690ac1e7e6
commit 278c73a256
19 changed files with 383 additions and 238 deletions

View File

@@ -1,15 +1,17 @@
import 'package:wolf_dart/features/difficulty/difficulty.dart';
import 'package:wolf_dart/features/entities/collectible.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/enemies/dog.dart';
import 'package:wolf_dart/features/entities/entity.dart';
import 'package:wolf_dart/features/entities/map_objects.dart';
typedef EntitySpawner =
Entity? Function(
int objId,
double x,
double y,
int difficultyLevel,
Difficulty difficulty,
);
abstract class EntityRegistry {
@@ -24,11 +26,14 @@ abstract class EntityRegistry {
int objId,
double x,
double y,
int difficultyLevel,
Difficulty difficulty,
int maxSprites,
) {
// 1. Difficulty check before even looking for a spawner
if (!MapObject.shouldSpawn(objId, difficulty)) return null;
for (final spawner in _spawners) {
Entity? entity = spawner(objId, x, y, difficultyLevel);
Entity? entity = spawner(objId, x, y, difficulty);
if (entity != null) {
// Safety bounds check for the VSWAP array