|
@@ -1,9 +1,11 @@
|
|
|
package squidpony.squidgrid.zone;
|
|
|
|
|
|
+import squidpony.squidgrid.mapping.DungeonUtility;
|
|
|
import squidpony.squidmath.Coord;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -125,6 +127,16 @@ public interface Zone extends Serializable, Iterable<Coord> {
|
|
|
/** @return {@code this} shifted by {@code (x,y)} */
|
|
|
Zone translate(int x, int y);
|
|
|
|
|
|
+ /** @return Cells adjacent to {@code this} that aren't in {@code this} */
|
|
|
+ Collection<Coord> getExternalBorder();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return A variant of {@code this} where cells adjacent to {@code this}
|
|
|
+ * have been added (i.e. it's {@code this} plus
|
|
|
+ * {@link #getExternalBorder()}).
|
|
|
+ */
|
|
|
+ Zone extend();
|
|
|
+
|
|
|
/**
|
|
|
* A convenience partial implementation. Please try for all new
|
|
|
* implementations of {@link Zone} to be subtypes of this class. It usually
|
|
@@ -257,6 +269,20 @@ public interface Zone extends Serializable, Iterable<Coord> {
|
|
|
return new ListZone(shifted);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ /* Convenience implementation, feel free to override. */
|
|
|
+ public Collection<Coord> getExternalBorder() {
|
|
|
+ return DungeonUtility.border(getAll(), null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ /* Convenience implementation, feel free to override. */
|
|
|
+ public Zone extend() {
|
|
|
+ final List<Coord> list = new ArrayList<Coord>(getAll());
|
|
|
+ list.addAll(getExternalBorder());
|
|
|
+ return new ListZone(list);
|
|
|
+ }
|
|
|
+
|
|
|
private int smallest(boolean xOrY) {
|
|
|
if (isEmpty())
|
|
|
return -1;
|