use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class Level method addObj.
// TODO *added*
public void addObj(Unit obj, boolean stack) {
Coordinates c = obj.getCoordinates();
addObj(obj, c, stack);
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class Location method initEntrances.
public void initEntrances() {
if (StringMaster.isEmpty(entranceData)) {
entranceData = getProperty(PROPS.DUNGEON_MAIN_ENTRANCES, true);
}
if (StringMaster.isEmpty(entranceData)) {
return;
}
String enterData = entranceData.split(DungeonLevelMaster.ENTRANCE_SEPARATOR)[0];
String name = VariableManager.removeVarPart(enterData);
Coordinates c = new Coordinates(true, VariableManager.getVar(enterData));
for (Entrance e : getEntrances()) {
if (e.getCoordinates().equals(c)) {
if (e.getName().equals(name)) {
setMainEntrance(e);
}
}
}
if (getMainEntrance() == null) {
setMainEntrance(new Entrance(c.x, c.y, DataManager.getType(name, DC_TYPE.BF_OBJ), getDungeon(), getDungeon()));
}
if (entranceData.split(DungeonLevelMaster.ENTRANCE_SEPARATOR).length < 2) {
return;
}
String exitData = entranceData.split(DungeonLevelMaster.ENTRANCE_SEPARATOR)[1];
name = VariableManager.removeVarPart(exitData);
c = new Coordinates(true, VariableManager.getVar(exitData));
for (Entrance e : getEntrances()) {
if (e.getCoordinates().equals(c)) {
if (e.getName().equals(name)) {
setMainExit(e);
}
}
}
if (getMainExit() == null) {
setMainExit(new Entrance(c.x, c.y, DataManager.getType(name, DC_TYPE.BF_OBJ), getDungeon(), getDungeon()));
}
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class LocationBuilder method buildDungeonPlan.
// static use and save as templates...
public DungeonPlan buildDungeonPlan(Location location) {
if (helper == null) {
helper = new BuildHelper(location, params);
helper.setPlan(plan);
}
if (StringMaster.isEmpty(helper.getParams().getValue(BUILD_PARAMS.FILLER_TYPE))) {
{
if (!location.isUnderground()) {
// return;
}
plan = new DungeonPlan(testTemplate, location);
int x1 = 0;
int x2 = params.getIntValue(BUILD_PARAMS.WIDTH);
if (x2 <= 0) {
x2 = location.getCellsX();
} else {
location.setParam(PARAMS.BF_WIDTH, x2);
}
int y1 = 0;
int y2 = params.getIntValue(BUILD_PARAMS.HEIGHT);
if (y2 <= 0) {
y2 = location.getCellsY();
} else {
location.setParam(PARAMS.BF_HEIGHT, y2);
}
MapZone zone = new MapZone(location.getDungeon(), 0, x1, x2, y1, y2);
List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithin(x1 - 1, x2 - 1, y1 - 1, y2 - 1);
new MapBlock(0, BLOCK_TYPE.ROOM, zone, plan, coordinates);
plan.getZones().add(zone);
return plan;
}
}
if (TestDungeonInitializer.PRESET_PLAN != null) {
File file = FileManager.getFile(PathFinder.getDungeonLevelFolder() + TestDungeonInitializer.PRESET_PLAN);
if (file.isFile()) {
String data = FileManager.readFile(file);
DungeonPlan plan = null;
try {
plan = loadDungeonMap(data);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
return plan;
}
}
// preset in location-mission, based
// on Level?
// yes, any dungeon could have any template more or less,
template = location.getTemplate();
if (testMode) {
template = testTemplate;
}
if (template == null) {
template = DUNGEON_TEMPLATES.CLASSIC;
}
List<MapBlock> blocks = null;
Map<ObjType, Coordinates> objMap = null;
plan = new DungeonPlan(template, location);
location.setPlan(plan);
plan.setBlocks(blocks);
plan.setObjMap(objMap);
plan.setZones(createMapZones());
// Entrance exit = dungeon.getMainExit();
// Entrance entrance = dungeon.getMainEntrance();
// plan.setBaseAnchor(
// entrance.getCoordinates()
// );
// plan.setEndAnchor(exit.getCoordinates());
// if (!dungeon.isIgnoreRotate())
plan.setRotated(location.isRotated());
plan.setFlippedX(location.isFlippedX());
plan.setFlippedY(location.isFlippedY());
placeMainRooms();
if (!location.isSurface()) {
placeCulDeSacs();
}
if (!location.isSurface() && !helper.getParams().isNoRandomRooms()) {
placeAdditionalRooms();
}
if (!location.isSurface() && !helper.getParams().isNoCorridors()) {
linkWithCorridors();
}
return plan;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class LocationBuilder method placeCulDeSacs.
// public static ObjType getDungeonTypeFromLevelData(String data) {
// return null;
// }
private void placeCulDeSacs() {
int n = helper.getParams().CUL_DE_SACS;
n = MathMaster.applyMod(n, getDungeon().getPlan().getWidthMod());
n = RandomWizard.getRandomIntBetween(n / 2, n * 2);
Loop.startLoop(10000);
while (!Loop.loopEnded()) {
MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
FACING_DIRECTION direction = FacingMaster.getRandomFacing();
Coordinates baseCoordinate = helper.getRandomWallCoordinate(direction, block);
if (helper.tryPlaceCorridor(block, baseCoordinate, direction, true)) {
n--;
}
if (n < 0) {
break;
}
}
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class LocationBuilder method constructBlock.
@Refactor
public static // TODO the way it's done, we can't have Structures in non-Location dungeons!!!
MapBlock constructBlock(Node node, int id, MapZone zone, DungeonPlan map, Dungeon dungeon) {
List<Coordinates> coordinates = new ArrayList<>();
Map<Coordinates, ? extends Obj> objectMap = new HashMap<>();
MapBlock b = new MapBlock(id, null, zone, map, coordinates);
// TODO b-data, coordinates, objects
for (Node subNode : XML_Converter.getNodeList(node)) {
if (StringMaster.compareByChar(subNode.getNodeName(), COORDINATES_NODE)) {
coordinates = CoordinatesMaster.getCoordinatesFromString(subNode.getTextContent());
} else if (StringMaster.compareByChar(subNode.getNodeName(), OBJ_NODE)) {
// TODO BETTER IN TYPES?
objectMap = DC_ObjInitializer.initMapBlockObjects(dungeon, b, subNode.getTextContent());
// TODO encounters?
} else {
// BLOCK TYPE
if (StringMaster.compareByChar(subNode.getNodeName(), BLOCK_TYPE_NODE)) {
BLOCK_TYPE type = new EnumMaster<BLOCK_TYPE>().retrieveEnumConst(BLOCK_TYPE.class, subNode.getTextContent());
b.setType(type);
}
if (StringMaster.compareByChar(subNode.getNodeName(), ROOM_TYPE_NODE)) {
ROOM_TYPE type = new EnumMaster<ROOM_TYPE>().retrieveEnumConst(ROOM_TYPE.class, subNode.getTextContent());
b.setRoomType(type);
}
}
}
b.setCoordinates(coordinates);
if (objectMap == null) {
return b;
}
b.getMap().putAll(objectMap);
b.getObjects().addAll(objectMap.values());
return b;
}
Aggregations