Search in sources :

Example 1 with Door

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;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) Door(eidolons.game.module.dungeoncrawl.objects.Door)

Example 2 with Door

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));
}
Also used : Coordinates(main.game.bf.Coordinates) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Door(eidolons.game.module.dungeoncrawl.objects.Door)

Aggregations

Door (eidolons.game.module.dungeoncrawl.objects.Door)2 Coordinates (main.game.bf.Coordinates)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Obj (main.entity.obj.Obj)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1