use of ivorius.ivtoolkit.maze.components.MazeRoom in project RecurrentComplex by Ivorforce.
the class TableDataSourceMazePath method pathFromDirection.
public static SavedMazePathConnection pathFromDirection(EnumFacing side, int[] room) {
int pathDim = side.getFrontOffsetX() != 0 ? 0 : side.getFrontOffsetY() != 0 ? 1 : side.getFrontOffsetZ() != 0 ? 2 : -1;
int offset = side.getFrontOffsetX() + side.getFrontOffsetY() + side.getFrontOffsetZ();
return new SavedMazePathConnection(pathDim, new MazeRoom(room[0], room[1], room[2]), offset > 0, ConnectorStrategy.DEFAULT_PATH, Collections.emptyList());
}
use of ivorius.ivtoolkit.maze.components.MazeRoom in project RecurrentComplex by Ivorforce.
the class MazeComponentStructure method getSize.
public int[] getSize() {
int[] lowest = null;
int[] highest = null;
for (MazeRoom room : rooms) {
for (int i = 0; i < room.getDimensions(); i++) {
if (lowest == null) {
lowest = room.getCoordinates();
highest = room.getCoordinates();
} else {
if (room.getCoordinate(i) < lowest[i])
lowest[i] = room.getCoordinate(i);
else if (room.getCoordinate(i) > highest[i])
highest[i] = room.getCoordinate(i);
}
}
}
if (lowest == null)
throw new UnsupportedOperationException();
int[] size = IvVecMathHelper.sub(highest, lowest);
for (int i = 0; i < size.length; i++) size[i]++;
return size;
}
use of ivorius.ivtoolkit.maze.components.MazeRoom in project RecurrentComplex by Ivorforce.
the class SavedMazeComponent method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("roomArea", Constants.NBT.TAG_COMPOUND)) {
rooms.readFromNBT(compound.getCompoundTag("roomArea"));
} else if (// Legacy
compound.hasKey("rooms", Constants.NBT.TAG_LIST)) {
rooms.clear();
rooms.addAll(Lists.transform(NBTTagLists.compoundsFrom(compound, "rooms"), input -> {
MazeRoom room = new MazeRoom(IvNBTHelper.readIntArrayFixedSize("coordinates", 3, compound));
int[] coordinates = room.getCoordinates();
return new Selection.Area(true, coordinates, coordinates.clone());
}));
}
exitPaths.clear();
exitPaths.addAll(NBTCompoundObjects.readListFrom(compound, "exits", SavedMazePathConnection::new));
defaultConnector.id = compound.hasKey("defaultConnector", Constants.NBT.TAG_STRING) ? compound.getString("defaultConnector") : ConnectorStrategy.DEFAULT_PATH;
if (!compound.hasKey("reachability"))
// Only used by WorldScriptMazeGenerator back then, and they don't want to group by default
reachability.groupByDefault = false;
else
reachability.readFromNBT(compound.getCompoundTag("reachability"));
}
Aggregations