use of eidolons.game.module.dungeoncrawl.objects.Door in project Eidolons by IDemiurge.
the class DC_BattleFieldManager method resetWalls.
public void resetWalls() {
doorMap.clear();
Map<Coordinates, BattleFieldObject> wallObjects = new HashMap<>();
for (Obj obj : game.getObjects(DC_TYPE.BF_OBJ)) {
BattleFieldObject bfObj = (BattleFieldObject) obj;
if (bfObj.getZ() == game.getDungeon().getZ()) {
if (bfObj.isWall()) {
wallObjects.put(obj.getCoordinates(), bfObj);
}
if (bfObj instanceof Door) {
doorMap.put(obj.getCoordinates(), ((Door) bfObj).getState());
}
}
}
if (wallMap == null) {
wallMap = new HashMap<>();
}
wallMap.clear();
ArrayList<Coordinates> coordinates = new ArrayList<>(wallObjects.keySet());
for (Coordinates coordinate : coordinates) {
BattleFieldObject wall = wallObjects.get(coordinate);
if (wall.isDead()) {
continue;
}
List<DIRECTION> list = new ArrayList<>();
for (Coordinates c : coordinate.getAdjacent(false)) {
BattleFieldObject adjWall = wallObjects.get(c);
if (adjWall != null) {
if (adjWall.isWall() && !adjWall.isDead()) {
DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
list.add(side);
}
}
}
adjacent: for (Coordinates c : coordinate.getAdjacent(true)) {
BattleFieldObject adjWall = wallObjects.get(c);
if (adjWall != null) {
if (adjWall.isWall() && !adjWall.isDead()) {
DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
if (!side.isDiagonal()) {
continue;
}
for (DIRECTION s : list) {
if (s.isDiagonal()) {
continue;
}
if (side.getXDirection() == s) {
continue adjacent;
}
if (side.getYDirection() == s) {
continue adjacent;
}
}
list.add(side);
}
}
}
if (!list.isEmpty()) {
if (coordinate == null)
continue;
wallMap.put(coordinate, list);
}
}
if (diagonalJoints == null) {
diagonalJoints = new HashMap<>();
}
diagonalJoints.clear();
loop: for (Coordinates c : wallMap.keySet()) {
for (DIRECTION s : wallMap.get(c)) {
if (s.isDiagonal()) {
// for (Coordinates c :
// o.getCoordinates().getAdjacentCoordinates(null)) {
// if (wallObjects.get(c) != null) {
// if (containsAdjacentDiagonal in X direction
// }
// }
List<DIRECTION> list = diagonalJoints.get(c);
if (list == null) {
list = new ArrayList<>();
}
diagonalJoints.put(c, list);
if (list.size() == 1) {
DIRECTION d = list.get(0);
if (s.growX)
if (!d.growX)
continue;
else if (d.growX)
continue;
if (s.growY)
if (!d.growY)
continue;
else if (d.growY)
continue;
}
list.add(s);
continue loop;
}
}
}
wallResetRequired = false;
}
use of eidolons.game.module.dungeoncrawl.objects.Door in project Eidolons by IDemiurge.
the class AtomicAi method getAtomicActionDoor.
public Action getAtomicActionDoor(UnitAI ai) {
Coordinates c = getDoorCoordinates(ai);
if (c == null)
return null;
Door door = (Door) game.getObjectByCoordinate(c);
DC_UnitAction action = game.getDungeonMaster().getDungeonObjMaster(DUNGEON_OBJ_TYPE.DOOR).createAction(DOOR_ACTION.OPEN, ai.getUnit(), door);
return AiActionFactory.newAction(action, ai.getUnit().getRef().getTargetingRef(door));
}
Aggregations