20 package net.sf.gridarta.model.validation.checks;
22 import java.awt.Point;
23 import java.util.Arrays;
24 import java.util.Collection;
25 import java.util.HashSet;
37 import org.jetbrains.annotations.NotNull;
45 public class BlockedSpawnPointChecker<G
extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>> extends
AbstractValidator<G, A, R> implements
MapValidator<G, A, R> {
51 private static final int[]
FREE_ARR_X = { 0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, -3, -3, -3, -3, -2, -1, };
57 private static final int[]
FREE_ARR_Y = { 0, -1, -1, 0, 1, 1, 1, 0, -1, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -3, -2, -1, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0, -1, -2, -3, -3, -3, };
60 assert FREE_ARR_X.length == FREE_ARR_Y.length;
67 private final Collection<Integer>
typeNumbers =
new HashSet<>();
75 super(validatorPreferences);
76 this.typeNumbers.addAll(Arrays.asList(typeNumbers));
92 final Point pos =
new Point();
94 for (
final G gameObject : mapSquare) {
95 mapSquare.getMapLocation(pos);
97 for (
final G invObject : gameObject.recursive()) {
113 if (!typeNumbers.contains(head.
getTypeNo())) {
118 for (
int i = 0; i < spawnRange; i++) {
119 if (!blocked.isBlocked(pos.x + FREE_ARR_X[i], pos.y + FREE_ARR_Y[i])) {
void validateMap(@NotNull final MapModel< G, A, R > mapModel, @NotNull final ErrorCollector< G, A, R > errorCollector)
Validate a map.
T getHead()
Return the head part of a multi-part object.
A MapValidator to assert that mobs or spawn points aren't on blocked squares.
A MapModel reflects the data of a map.
This is the base class for validators.
This package contains the framework for validating maps.
Interface for Map Validators.
final Collection< Integer > typeNumbers
The object types to check.
BlockedSpawnPointChecker(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final Integer... typeNumbers)
Creates a new instance.
void checkSpawnPoints(@NotNull final Iterable< MapSquare< G, A, R >> mapModel, @NotNull final BlockedMatrix< G, A, R > blocked, @NotNull final ErrorCollector< G, A, R > errorCollector)
Checks for blocked spawn points.
String LAST_HEAL
The name of the "last_heal" attribute.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Configuration parameters for Validators.
GameObjects are the objects based on Archetypes found on maps.
Indicates a spawn point that has can never spawn a mob because all possible destinations are blocked...
int getAttributeInt(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as.
final ValidatorPreferences validatorPreferences
The ValidatorPreferences to use.
Determines whether a map square is blocked.
An interface for classes that collect errors.
static final int [] FREE_ARR_Y
The y offset for checking blocked squares.
void checkSpawnPoint(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final BlockedMatrix< G, A, R > blocked, @NotNull final ErrorCollector< G, A, R > errorCollector)
Checks one game object.
Interface for MapArchObjects.
int getTypeNo()
Returns the type number of this Archetype.
static final int [] FREE_ARR_X
The x offset for checking blocked squares.