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;
}
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;
}
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;
}
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);
}
}
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);
}
Aggregations