use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_MapMaster method addBlock.
public void addBlock(MapBlock block) {
clearArea(block.getCoordinates(), true);
Set<MapZone> zones = new HashSet<>();
// remove from other blocks?
for (Coordinates c : block.getCoordinates()) {
MapBlock b = getPlan().getBlockByCoordinate(c);
if (b != null) {
b.getCoordinates().remove(c);
zones.add(b.getZone());
// blocks.add(b);
// hard to Undo...
b.getCoordinates().remove(c);
// perhaps I can keep a copy of the *PLAN* or even *LEVEL* to
// return to?
}
}
if (zones.isEmpty()) {
zones.addAll(getPlan().getZones());
}
MapZone zone = (MapZone) zones.toArray()[0];
if (zones.size() > 1) {
int index = DialogMaster.optionChoice(zones.toArray(), "Choose zone");
if (index != -1) {
zone = (MapZone) zones.toArray()[index];
}
}
zone.addBlock(block);
block.setZone(zone);
LevelEditor.getMainPanel().getPlanPanel().getTreePanel().blockAdded(block);
getPlan().getBlocks().add(block);
// for (MapBlock b: blocks){
// b.getCoordinates().removeAll(block.getCoordinates());
// }
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_MapMaster method removeBlock.
public void removeBlock(MapBlock block) {
// fill
LevelEditor.getMainPanel().getPlanPanel().getTreePanel().blockRemoved(block);
LE_ObjMaster.removeObjects(block.getCoordinates());
LE_ObjMaster.fill(block.getCoordinates(), DataManager.getType(block.getZone().getFillerType(), DC_TYPE.BF_OBJ));
for (MapBlock b : getPlan().getBlocks()) {
// connected
b.getConnectedBlocks().remove(block);
}
getPlan().getBlocks().remove(block);
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class Level method removeObj.
public void removeObj(DC_Obj obj) {
Chronos.mark("removing " + obj);
Unit unit = null;
if (obj instanceof Unit) {
unit = (Unit) obj;
}
if (obj instanceof Entrance) {
if (location.getMainEntrance() != null) {
location.setMainEntrance(null);
location.getPlan().setEntranceLayout(null);
} else if (location.getMainExit() == null) {
location.setMainExit(null);
location.getPlan().setExitLayout(null);
}
location.getEntrances().remove(obj);
}
// TODO getOrCreate Top object!
// ++ ZOrder...
Coordinates coordinates = obj.getCoordinates();
LevelEditor.getSimulation().remove(obj);
// TODO ???
// obj = dungeon.getMinimap().getGrid().getTopObj(coordinates);
// if (obj != null)
// if (!unit.isOverlaying())TODO
MapBlock b = LevelEditor.getMapMaster().getBlock();
if (b == null) {
b = getBlockForCoordinate(coordinates, false);
}
if (b != null) {
boolean result = !b.removeObject(obj, coordinates);
if (result) {
if (unit.isLandscape()) {
b.addCoordinate(obj.getCoordinates());
}
}
} else {
b = LevelEditor.getMainPanel().getPlanPanel().getSelectedBlock();
if (b == null) {
b = getBlockForCoordinate(coordinates, true);
} else if (!CoordinatesMaster.isAdjacent(b.getCoordinates(), coordinates)) {
b = getBlockForCoordinate(coordinates, true);
}
if (b != null) {
if (!unit.isOverlaying()) {
b.addCoordinate(obj.getCoordinates());
}
}
}
if (unit != null) {
if (!unit.isOverlaying()) // if (LevelEditor.isMinimapMode())
{
if (LE_MapViewComp.isMinimapMode()) {
LevelEditor.getMainPanel().getMiniGrid().refreshComp(null, obj.getCoordinates());
} else {
LE_MapViewComp comp = LevelEditor.getMainPanel().getMapViewComp();
comp.getGrid().getCompForObject(obj).refresh();
comp.getGrid().refresh();
comp.getGrid().getCompForObject(obj).refresh();
comp.getGrid().getPanel().repaint();
}
}
}
// TODO ADD COORDINATE!
Chronos.logTimeElapsedForMark("removing " + obj);
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class DungeonBuilder method initDynamicObjData.
protected void initDynamicObjData(Location location, DungeonPlan plan) {
int z = location.getIntParam(G_PARAMS.Z_LEVEL);
for (MapBlock b : plan.getBlocks()) {
ArrayList<Obj> objects = new ArrayList<>(b.getObjects());
for (Obj obj : objects) {
// TODO of course - the issue was that I added an object to
// block too! ... init?
BattleFieldObject unit = (BattleFieldObject) obj;
if (z != 0) {
unit.setZ(z);
}
}
}
for (MapZone zone : plan.getZones()) {
ObjType wallType = DataManager.getType(zone.getFillerType(), DC_TYPE.BF_OBJ);
if (wallType == null)
continue;
List<Coordinates> list = zone.getCoordinates();
for (MapBlock b : zone.getBlocks()) {
list.removeAll(b.getCoordinates());
}
for (Coordinates c : list) {
getGame().getManager().getObjCreator().createUnit(wallType, c.x, c.y, Player.NEUTRAL, new Ref(game));
}
}
for (Obj obj : plan.getWallObjects()) {
BattleFieldObject unit = (BattleFieldObject) obj;
if (z != 0) {
unit.setZ(z);
}
}
if (plan.getDirectionMap() != null) {
try {
DC_ObjInitializer.initDirectionMap(z, plan.getDirectionMap());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
if (plan.getFlipMap() != null) {
try {
DC_ObjInitializer.initFlipMap(z, plan.getFlipMap());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LocationBuilder method linkWithCorridors.
private void linkWithCorridors() {
// TODO link each room, some more than once...
// TODO
List<MapBlock> blocksToLink = new ArrayList<>(plan.getBlocks());
for (MapBlock b : plan.getBlocks()) {
if (b.getType() == BLOCK_TYPE.CULDESAC) {
blocksToLink.remove(b);
}
}
// TODO fail condition? u
Loop.startLoop(10000);
while (!blocksToLink.isEmpty()) {
List<MapBlock> blocksToRemove = new ArrayList<>();
for (MapBlock block : blocksToLink) {
if (block.getConnectedBlocks().size() > 1) {
blocksToRemove.add(block);
continue;
}
FACING_DIRECTION direction = FacingMaster.getRandomFacing();
Coordinates baseCoordinate = helper.getRandomWallCoordinate(direction, block);
if (helper.tryPlaceCorridor(block, baseCoordinate, direction)) {
if (// TODO depends!
block.getConnectedBlocks().size() > 1) {
blocksToRemove.add(block);
}
}
}
if (Loop.loopEnded()) {
break;
}
blocksToLink.removeAll(blocksToRemove);
}
}
Aggregations