Search in sources :

Example 16 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class SightMaster method getSpectrumCoordinates.

public DequeImpl<Coordinates> getSpectrumCoordinates(Integer range, Integer side_penalty, Integer back_bonus, BattleFieldObject source, boolean vision, FACING_DIRECTION facing, boolean extended) {
    DequeImpl<Coordinates> list = new DequeImpl<>();
    BattleFieldObject unit = null;
    Coordinates orig = source.getCoordinates();
    if (source instanceof BattleFieldObject) {
        unit = (BattleFieldObject) source;
    }
    if (facing == null) {
        if (unit != null) {
            facing = unit.getFacing();
        }
    }
    DIRECTION direction;
    if (facing == null) {
        facing = FacingMaster.getRandomFacing();
    }
    direction = facing.getDirection();
    if (range == null) {
        range = source.getIntParam(PARAMS.SIGHT_RANGE);
        if (extended) {
            range = MathMaster.applyModIfNotZero(range, source.getIntParam(PARAMS.SIGHT_RANGE_EXPANSION));
        }
    }
    if (side_penalty == null) {
        side_penalty = source.getIntParam(PARAMS.SIDE_SIGHT_PENALTY);
        if (extended) {
            side_penalty = MathMaster.applyModIfNotZero(side_penalty, source.getIntParam(PARAMS.SIGHT_RANGE_EXPANSION_SIDES));
        }
    }
    if (back_bonus == null) {
        back_bonus = source.getIntParam(PARAMS.BEHIND_SIGHT_BONUS);
        if (!extended)
            back_bonus--;
    // back_bonus = MathMaster.applyModIfNotZero(back_bonus, source
    // .getIntParam(PARAMS.SIGHT_RANGE_EXPANSION_BACKWARD));
    }
    addLine(orig.getAdjacentCoordinate(direction), range, list, direction, true);
    addSides(list, orig, direction, range - side_penalty, false);
    DIRECTION backDirection = DirectionMaster.flip(direction);
    Coordinates backCoordinate = orig.getAdjacentCoordinate(backDirection);
    if (back_bonus > 0) {
        if (backCoordinate != null) {
            addLine(backCoordinate, back_bonus, list, backDirection, true);
        // if (back_bonus > side_penalty)
        // addSides(list, backCoordinate, backDirection, back_bonus -
        // side_penalty, false);
        }
    }
    Collection<Coordinates> blocked = getBlockedList(list, source, facing);
    list.removeAll(blocked);
    list.add(source.getCoordinates());
    return list;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION) DequeImpl(main.system.datatypes.DequeImpl)

Example 17 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class ChangeFacingEffect method applyThis.

@Override
public boolean applyThis() {
    if (!(ref.getTargetObj() instanceof Unit)) {
        return false;
    }
    Unit obj = (Unit) ref.getTargetObj();
    FACING_DIRECTION oldDirection = obj.getFacing();
    FACING_DIRECTION newDirection = null;
    if (isClockwise() == null) {
        for (FACING_DIRECTION f : FACING_DIRECTION.values()) {
            Obj active = ref.getObj(KEYS.ACTIVE);
            if (active == null) {
                return false;
            }
            if (FacingMaster.getSingleFacing(f, obj, (BfObj) active.getRef().getTargetObj()) == UnitEnums.FACING_SINGLE.IN_FRONT) {
                newDirection = f;
                break;
            }
        }
    } else {
        newDirection = FacingMaster.rotate(oldDirection, isClockwise());
    }
    obj.setFacing(newDirection);
    game.fireEvent(new Event(getEventTypeDone(), ref));
    return true;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) BfObj(main.entity.obj.BfObj) Obj(main.entity.obj.Obj) BfObj(main.entity.obj.BfObj) Event(main.game.logic.event.Event) Unit(eidolons.entity.obj.unit.Unit)

Example 18 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class Positioner method adjustCoordinate.

public static Coordinates adjustCoordinate(Entity entity, Coordinates c, FACING_DIRECTION facing, Predicate<Coordinates> filterPredicate) {
    if (c == null) {
        return null;
    }
    Loop loop = new Loop(50);
    Coordinates coordinate = new Coordinates(c.x, c.y);
    while (loop.continues()) {
        // TODO remove from adj. list to limit
        // iterations to 8!
        DIRECTION direction = ArenaPositioner.getRandomSpawnAdjustDirection();
        coordinate = c.getAdjacentCoordinate(direction);
        if (coordinate != null) {
            if (filterPredicate != null)
                if (!filterPredicate.test(coordinate))
                    continue;
            if (!DC_Game.game.isSimulation()) {
                if (DC_Game.game.getBattleFieldManager().canMoveOnto(entity, coordinate)) {
                    break;
                }
            }
            if (new StackingRule(DC_Game.game).canBeMovedOnto(entity, coordinate)) {
                break;
            }
        }
    }
    // second layer in case first one is fully
    loop = new Loop(50);
    // blocked
    while (!loop.continues() && !DC_Game.game.getBattleFieldManager().canMoveOnto(entity, c) || // (DC_Game.game.getBattleField().getGrid().isCoordinateObstructed(coordinate)
    coordinate == null) {
        Coordinates adjacentCoordinate = c.getAdjacentCoordinate(ArenaPositioner.getRandomSpawnAdjustDirection());
        coordinate = adjustCoordinate(adjacentCoordinate, facing);
    }
    if (coordinate.isInvalid()) {
        return null;
    }
    return coordinate;
}
Also used : Loop(main.system.auxiliary.Loop) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) StackingRule(eidolons.game.battlecraft.rules.action.StackingRule)

Example 19 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION 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);
    }
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 20 with FACING_DIRECTION

use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.

the class BuildHelper method getCoordinates.

private List<Coordinates> getCoordinates(Coordinates baseCoordinate, int width, int height, boolean flipX, boolean flipY) {
    FACING_DIRECTION lengthDirection = (flipY) ? FACING_DIRECTION.NORTH : FACING_DIRECTION.SOUTH;
    FACING_DIRECTION widthDirection = (flipX) ? FACING_DIRECTION.WEST : FACING_DIRECTION.EAST;
    return DC_PositionMaster.getRectangle(true, lengthDirection, widthDirection, baseCoordinate, height, width);
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION)

Aggregations

FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)31 Coordinates (main.game.bf.Coordinates)17 Unit (eidolons.entity.obj.unit.Unit)5 ArrayList (java.util.ArrayList)5 Ref (main.entity.Ref)5 ObjType (main.entity.type.ObjType)5 Obj (main.entity.obj.Obj)4 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)3 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)3 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)3 TemplateSelectiveTargeting (eidolons.ability.targeting.TemplateSelectiveTargeting)2 UnitLevelManager (eidolons.client.cc.logic.UnitLevelManager)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)2 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)2 Conditions (main.elements.conditions.Conditions)2 AutoTargeting (main.elements.targeting.AutoTargeting)2 MultiTargeting (main.elements.targeting.MultiTargeting)2 SelectiveTargeting (main.elements.targeting.SelectiveTargeting)2 Targeting (main.elements.targeting.Targeting)2