Merge branch 'mazes'

This commit is contained in:
SenseiKiwi
2014-01-04 03:22:26 -04:00
6 changed files with 80 additions and 41 deletions

View File

@@ -0,0 +1,69 @@
package StevenDimDoors.experimental;
import StevenDimDoors.mod_pocketDim.Point3D;
public class BoundingBox
{
protected Point3D minCorner;
protected Point3D maxCorner;
public BoundingBox(int x, int y, int z, int width, int height, int length)
{
this.minCorner = new Point3D(x, y, z);
this.maxCorner = new Point3D(x + width - 1, y + height - 1, z + length - 1);
}
public BoundingBox(Point3D minCorner, Point3D maxCorner)
{
this.minCorner = minCorner;
this.maxCorner = maxCorner;
}
public int width()
{
return (maxCorner.getX() - minCorner.getX() + 1);
}
public int height()
{
return (maxCorner.getY() - minCorner.getY() + 1);
}
public int length()
{
return (maxCorner.getZ() - minCorner.getZ() + 1);
}
public Point3D minCorner()
{
return minCorner;
}
public Point3D maxCorner()
{
return maxCorner;
}
public boolean contains(int x, int y, int z)
{
return ((minCorner.getX() <= x && x <= maxCorner.getX()) &&
(minCorner.getY() <= y && y <= maxCorner.getY()) &&
(minCorner.getZ() <= z && z <= maxCorner.getZ()));
}
public boolean intersects(BoundingBox other)
{
// To be clear, having one box inside another counts as intersecting
boolean xi = (this.minCorner.getX() <= other.minCorner.getX() && other.minCorner.getX() <= this.maxCorner.getX()) ||
(other.minCorner.getX() <= this.minCorner.getX() && this.minCorner.getX() <= other.maxCorner.getX());
boolean yi = (this.minCorner.getY() <= other.minCorner.getY() && other.minCorner.getY() <= this.maxCorner.getY()) ||
(other.minCorner.getY() <= this.minCorner.getY() && this.minCorner.getY() <= other.maxCorner.getY());
boolean zi = (this.minCorner.getZ() <= other.minCorner.getZ() && other.minCorner.getZ() <= this.maxCorner.getZ()) ||
(other.minCorner.getZ() <= this.minCorner.getZ() && this.minCorner.getZ() <= other.maxCorner.getZ());
return xi && yi && zi;
}
}

View File

@@ -21,6 +21,8 @@ public class MazeBuilder
buildRooms(design.getRoomGraph(), world, offset); buildRooms(design.getRoomGraph(), world, offset);
carveDoorways(design.getRoomGraph(), world, offset, decay, random); carveDoorways(design.getRoomGraph(), world, offset, decay, random);
//placeDoors(design, world, offset);
applyRandomDestruction(design, world, offset, decay, random); applyRandomDestruction(design, world, offset, decay, random);
} }

View File

@@ -7,6 +7,7 @@ public class MazeDesign
private PartitionNode root; private PartitionNode root;
private DirectedGraph<PartitionNode, DoorwayData> rooms; private DirectedGraph<PartitionNode, DoorwayData> rooms;
private ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores; private ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores;
private ArrayList<BoundingBox> protectedAreas;
public MazeDesign(PartitionNode root, DirectedGraph<PartitionNode, DoorwayData> rooms, public MazeDesign(PartitionNode root, DirectedGraph<PartitionNode, DoorwayData> rooms,
ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores) ArrayList<IGraphNode<PartitionNode, DoorwayData>> cores)
@@ -31,6 +32,11 @@ public class MazeDesign
return cores; return cores;
} }
public ArrayList<BoundingBox> getProtectedAreas()
{
return protectedAreas;
}
public int width() public int width()
{ {
return root.width(); return root.width();

View File

@@ -2,41 +2,22 @@ package StevenDimDoors.experimental;
import StevenDimDoors.mod_pocketDim.Point3D; import StevenDimDoors.mod_pocketDim.Point3D;
public class PartitionNode public class PartitionNode extends BoundingBox
{ {
private Point3D minCorner;
private Point3D maxCorner;
private PartitionNode parent; private PartitionNode parent;
private PartitionNode leftChild = null; private PartitionNode leftChild = null;
private PartitionNode rightChild = null; private PartitionNode rightChild = null;
public PartitionNode(int width, int height, int length) public PartitionNode(int width, int height, int length)
{ {
super(new Point3D(0, 0, 0), new Point3D(width - 1, height - 1, length - 1));
parent = null; parent = null;
minCorner = new Point3D(0, 0, 0);
maxCorner = new Point3D(width - 1, height - 1, length - 1);
} }
private PartitionNode(PartitionNode parent, Point3D minCorner, Point3D maxCorner) private PartitionNode(PartitionNode parent, Point3D minCorner, Point3D maxCorner)
{ {
super(minCorner, maxCorner);
this.parent = parent; this.parent = parent;
this.minCorner = minCorner;
this.maxCorner = maxCorner;
}
public int width()
{
return (maxCorner.getX() - minCorner.getX() + 1);
}
public int height()
{
return (maxCorner.getY() - minCorner.getY() + 1);
}
public int length()
{
return (maxCorner.getZ() - minCorner.getZ() + 1);
} }
public boolean isLeaf() public boolean isLeaf()
@@ -54,16 +35,6 @@ public class PartitionNode
return rightChild; return rightChild;
} }
public Point3D minCorner()
{
return minCorner;
}
public Point3D maxCorner()
{
return maxCorner;
}
public PartitionNode parent() public PartitionNode parent()
{ {
return parent; return parent;
@@ -123,13 +94,6 @@ public class PartitionNode
} }
} }
public boolean contains(int x, int y, int z)
{
return ((minCorner.getX() <= x && x <= maxCorner.getX()) &&
(minCorner.getY() <= y && y <= maxCorner.getY()) &&
(minCorner.getZ() <= z && z <= maxCorner.getZ()));
}
public PartitionNode findPoint(int x, int y, int z) public PartitionNode findPoint(int x, int y, int z)
{ {
// Find the lowest node that contains the specified point or return null // Find the lowest node that contains the specified point or return null

View File

@@ -302,7 +302,6 @@ public class DungeonSchematic extends Schematic {
private static void createExitDoorLink(World world, NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter) private static void createExitDoorLink(World world, NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
{ {
//Transform the door's location to the pocket coordinate system //Transform the door's location to the pocket coordinate system
Point3D location = point.clone(); Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter); BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);

View File

@@ -20,7 +20,6 @@ public class PocketProvider extends WorldProvider
{ {
private DDProperties properties; private DDProperties properties;
private MonolithSpawner spawner; private MonolithSpawner spawner;
@SuppressWarnings("unused") // ?
private IRenderHandler skyRenderer; private IRenderHandler skyRenderer;
public PocketProvider() public PocketProvider()