Class CreatureProtectionArea

All Implemented Interfaces:
Killer, Cloneable, Iterable<String>, Serializable

public class CreatureProtectionArea extends AreaEntity
An area prevents creatures from entering. This allows a layered chain of criteria. Think of this as a creature firewall.
  • Field Details

    • defaultBlocked

      protected boolean defaultBlocked
      Whether to block on no match.
    • entries

      protected List<CreatureProtectionArea.Entry> entries
      The list (if any specific) of blocked creatures.
  • Constructor Details

    • CreatureProtectionArea

      public CreatureProtectionArea()
      Create a 1x1 creature protection area.
    • CreatureProtectionArea

      public CreatureProtectionArea(int width, int height)
      Create a creature protection area.
      Parameters:
      width - The area width.
      height - The area height.
    • CreatureProtectionArea

      public CreatureProtectionArea(int width, int height, boolean defaultBlocked)
      Create a creature protection area.
      Parameters:
      width - The area width.
      height - The area height.
      defaultBlocked - Whether blocked on no match.
  • Method Details

    • add

      public void add(String clazz)
      Add a blocked criteria entry.
      Parameters:
      clazz - A creature class to match (or null for any).
    • add

      public void add(String clazz, String subclazz)
      Add a blocked criteria entry.
      Parameters:
      clazz - A creature class to match (or null for any).
      subclazz - A creature subclass to match (or null for any).
    • add

      public void add(String clazz, String subclazz, boolean blocked)
      Add a criteria entry.
      Parameters:
      clazz - A creature class to match (or null for any).
      subclazz - A creature subclass to match (or null for any).
      blocked - Whether to block.
    • matchesCriteria

      protected boolean matchesCriteria(Creature creature, boolean defaultAnswer)
      Does a creature match a criteria entry.
      Parameters:
      creature - The creature to compare.
      defaultAnswer - The answer if no match is found.
      Returns:
      The matching criteria, or default response.
    • isObstacle

      public boolean isObstacle(Entity entity)
      Checks whether a creature can enter.
      Overrides:
      isObstacle in class Entity
      Parameters:
      entity - The entity to check against.
      Returns:
      true if a matching creature is given.