validate method

  1. @override
void validate(
  1. EntityCheck check
)
override

Checks one entity of this kind, in the context of the level around it, adding what is wrong to the check's EntityCheck.out.

Reports rather than throws: a level with several problems should list all of them, and an editor has to be able to load a broken level in order to fix it.

Implementation

@override
void validate(EntityCheck check) {
  final entity = check.entity;
  final scope = check.scope;
  final out = check.out;
  for (final key in requires) {
    if (entity.properties.containsKey(key)) continue;
    out.add(
      LevelIssue(
        Severity.error,
        'has no "$key", which plugin "$owner" requires of a $type',
        where: scope.describe(entity),
      ),
    );
  }
  if (collider != null) requireSize(entity, scope, out);
}