use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class AtomicAi method checkAtomicActionTurn.
private boolean checkAtomicActionTurn(UnitAI ai) {
// check that only enemy actions are needed
boolean result = false;
if (!ai.getType().isCaster()) {
// FacingMaster.getOptimalFacingTowardsUnits()
BattleFieldObject enemy = getAnalyzer().getClosestEnemy(ai.getUnit());
// for (BattleFieldObject enemy : Analyzer.getVisibleEnemies(ai))
FACING_DIRECTION facing = ai.getUnit().getFacing();
FACING_SINGLE relative = FacingMaster.getSingleFacing(facing, ai.getUnit(), enemy);
if (relative == FACING_SINGLE.BEHIND) {
return true;
} else if (relative == FACING_SINGLE.TO_THE_SIDE) {
if (!ai.getUnit().checkPassive(STANDARD_PASSIVES.BROAD_REACH))
result = true;
} else
result = false;
// if we need to get to a cell that is not 'facing' the target?!
if (!result)
return false;
if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(getUnit(), enemy))
return false;
}
return result;
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class AtomicAi method getApproachCoordinate.
private Coordinates getApproachCoordinate(UnitAI ai) {
Collection<Unit> units = getAnalyzer().getVisibleEnemies(ai);
if (units.isEmpty())
return null;
FACING_DIRECTION facing = FacingMaster.getOptimalFacingTowardsUnits(getUnit().getCoordinates(), units, t -> getThreatAnalyzer().getThreat(ai, (Unit) t));
if (facing == null)
return null;
Coordinates c = getUnit().getCoordinates().getAdjacentCoordinate(facing.getDirection());
return Positioner.adjustCoordinate(ai.getUnit(), c, ai.getUnit().getFacing());
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class TurnSequenceConstructor method getTurnSequence.
public List<Action> getTurnSequence(FACING_SINGLE template, Unit source, Coordinates target) {
FACING_DIRECTION original_facing = source.getFacing();
FACING_DIRECTION facing = original_facing;
boolean clockwise = true;
int i = 0;
List<Action> clockwise_list = new ArrayList<>();
if (template == FacingMaster.getSingleFacing(FacingMaster.rotate180(facing), source.getCoordinates(), target)) {
DC_UnitAction specAction = source.getAction("Turn About " + (RandomWizard.random() ? "anti" : "") + "clockwise");
if (specAction != null) {
clockwise_list.add(new Action(specAction));
return clockwise_list;
}
}
while (true) {
if (template == FacingMaster.getSingleFacing(facing, source.getCoordinates(), target)) {
break;
}
facing = FacingMaster.rotate(facing, clockwise);
clockwise_list.add(getTurnAction(clockwise, source));
i++;
if (i > 2) {
break;
}
}
clockwise = false;
i = 0;
List<Action> anticlockwise_list = new ArrayList<>();
facing = original_facing;
while (true) {
if (template == FacingMaster.getSingleFacing(facing, source.getCoordinates(), target)) {
break;
}
facing = FacingMaster.rotate(facing, clockwise);
anticlockwise_list.add(getTurnAction(clockwise, source));
i++;
if (i > 2) {
break;
}
}
return (anticlockwise_list.size() > clockwise_list.size()) ? clockwise_list : anticlockwise_list;
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class DrawMaster method drawFacing.
private void drawFacing(Graphics g, Unit obj) {
FACING_DIRECTION facing = obj.getFacing();
Image img = ImageManager.getFacingImage(facing);
int x = 0;
int y = 0;
int h = img.getHeight(null) * zoom / 100;
int w = img.getWidth(null) * zoom / 100;
int offset = obj.isSelected() ? 6 : 2;
switch(facing) {
case WEST:
x = offset;
y = getObjCompHeight() / 2 - h / 2;
break;
case NORTH:
x = getObjCompWidth() / 2 - w / 2;
y = +offset;
break;
case SOUTH:
x = getObjCompWidth() / 2 - w / 2;
y = getObjCompHeight() - img.getHeight(null) - offset;
break;
case EAST:
x = getObjCompWidth() - w - offset;
y = getObjCompHeight() / 2 - img.getHeight(null) / 2;
break;
case NONE:
break;
}
if (!isSingleObj()) {
x += topObjX;
y += topObjY;
switch(cellComp.getTopObj().getFacing()) {
case SOUTH:
// topObjY?
y = Math.min(getCompHeight() - h, y + h);
break;
case NORTH:
y = Math.max(0, y - h);
break;
case EAST:
x = Math.min(getCompWidth() - w, x + w);
break;
case WEST:
x = Math.max(0, x - w);
break;
}
}
drawImage(g, img, x, y);
}
use of main.game.bf.Coordinates.FACING_DIRECTION in project Eidolons by IDemiurge.
the class AnimMultiplicator method filterCoordinates.
private Collection<Coordinates> filterCoordinates(SPELL_ANIMS template, Set<Coordinates> coordinates) {
if (template != null) {
FACING_DIRECTION facing = getActive().getOwnerObj().getFacing();
List<Coordinates> filtered = new ArrayList<>(coordinates);
Coordinates farthest = CoordinatesMaster.getFarmostCoordinateInDirection(facing.getDirection(), new ArrayList<>(coordinates), null);
switch(template) {
// template.getNumberOfEmitters(getActive())
case RAY:
anim.setForcedDestinationForAll(farthest);
return Arrays.asList(farthest);
case BLAST:
break;
case WAVE:
case SPRAY:
{
boolean xOrY = !facing.isVertical();
filtered.removeIf(c -> farthest.getXorY(xOrY) != c.getXorY(xOrY));
while (filtered.size() < template.getNumberOfEmitters(getActive())) {
List<Coordinates> list = new ArrayList<>(coordinates);
list.removeAll(filtered);
list.removeIf(c -> farthest.getXorY(!xOrY) == c.getXorY(!xOrY));
Coordinates c = CoordinatesMaster.getFarmostCoordinateInDirection(facing.getDirection(), list, null);
if (c != null)
filtered.add(c);
}
if (ListMaster.isNotEmpty(filtered))
return filtered;
else
return coordinates;
}
case RING:
break;
case NOVA:
break;
}
}
return coordinates;
}
Aggregations