use of eidolons.entity.obj.BattleFieldObject 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 eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method resetComponents.
@Deprecated
private void resetComponents() {
int offsetX = getOffsetX();
int offsetY = getOffsetY();
LogMaster.log(0, "resetting grid comps with offsetX = " + offsetX + ";offsetY =" + offsetY);
for (int i = 0; i < getDisplayedCellsX(); i++) {
for (int j = 0; j < getDisplayedCellsY(); j++) {
int x = i + getOffsetX();
int y = j + getOffsetY();
Coordinates c = new Coordinates(x, y);
List<BattleFieldObject> objects = game.getObjectsOnCoordinate(getZ(), c, false, true, false);
List<Unit> overlayingObjects = new ArrayList<>(new DequeImpl(game.getObjectsOnCoordinate(getZ(), c, true, true, false)).getRemoveAll(objects));
// visibility preCheck!
CellComp comp = gridComp.getCells()[x][y];
List<BattleFieldObject> list = new ArrayList<>();
for (BattleFieldObject obj : objects) {
if (VisionManager.checkVisible(obj)) {
list.add(obj);
}
}
comp.setSizeFactor(gridComp.getZoom());
comp.setOverlayingObjects(overlayingObjects);
if (list.size() != 0) {
// comp.setObjects(list);
}
comp.refresh();
}
}
comp.refresh();
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method noObstacles.
private boolean noObstacles(int xy, int xy1, int xy2, Obj source, boolean x_y) {
int max = xy2;
int min = xy1;
if (xy1 > xy2) {
max = xy1;
min = xy2;
}
for (int i = min + 1; i < max; i++) {
Coordinates c = (x_y) ? new Coordinates(xy, i) : new Coordinates(i, xy);
List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(getZ(), c, false, false, false);
for (BattleFieldObject obj : objects) {
if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
return false;
}
}
}
return true;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_BattleFieldGrid method noObstaclesOnDiagonal.
@Override
public boolean noObstaclesOnDiagonal(Coordinates c1, Coordinates c2, Obj source) {
boolean above = PositionMaster.isAbove(c1, c2);
boolean left = PositionMaster.isToTheLeft(c1, c2);
int X = c1.x;
int Y = c1.y;
while (X != c2.x || Y != c2.y) {
if (above) {
Y++;
} else {
Y--;
}
if (left) {
X++;
} else {
X--;
}
if (X == c2.x || Y == c2.y) {
break;
}
Coordinates c = new Coordinates(X, Y);
List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(c, false);
for (BattleFieldObject obj : objects) {
if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
return false;
}
}
}
return true;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class GuardRule method checkTargetChanged.
public static BattleFieldObject checkTargetChanged(DC_ActiveObj action) {
BattleFieldObject target = (BattleFieldObject) action.getTargetObj();
// attack.getAttackedUnit();
List<Unit> guards = new ArrayList<>();
Collection<Unit> units = target.getGame().getUnitsForCoordinates(target.getCoordinates());
for (Unit unit : units) {
if (unit.isAlliedTo(target.getOwner())) {
if (unit.getMode() == STD_MODES.GUARDING || unit.checkStatus(STATUS.GUARDING)) {
Ref ref = Ref.getCopy(action.getRef());
ref.setTarget(target.getId());
if (!SneakRule.checkSneak(ref))
guards.add(unit);
}
}
}
// TODO sort
for (Unit guard : guards) {
if (guard == target)
continue;
if (action.isAttackAny()) {
if (action.isRanged()) {
if (checkDefenderTakesMissile(action, guard))
return guard;
continue;
}
Attack attack = EffectFinder.getAttackFromAction(action);
if (checkDefenderTakesAttack(attack, guard))
return guard;
} else {
if (checkDefenderTakesMissile(action, guard))
return guard;
}
}
// what kind of animation would there be?
return null;
}
Aggregations