requireKeyExists method

void requireKeyExists(
  1. EntityDef entity,
  2. LevelScope scope,
  3. List<LevelIssue> out
)

Reports that a key this entity demands exists nowhere in the level.

Implementation

void requireKeyExists(
  EntityDef entity,
  LevelScope scope,
  List<LevelIssue> out,
) {
  final wanted = entity.string('key');
  if (wanted == null) return;
  if (scope.keys.contains(wanted)) return;
  out.add(
    LevelIssue(
      Severity.error,
      'needs the "$wanted" key, and no ${EntityTypes.key} entity in this '
      'level provides one',
      where: scope.describe(entity),
    ),
  );
}