use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class OccupiedCondition method check.
@Override
public boolean check(Ref ref) {
Coordinates c = getCoordinates(ref);
if (c == null) {
return true;
}
boolean result;
if (permitCollision) {
result = !game.getMovementManager().getPathingManager().isGroundPassable(ref.getSourceObj(), c);
} else {
result = game.getMovementManager().getPathingManager().isOccupied(c);
}
// .getObjCompMap().get(c);
if (result) {
for (Obj obj : game.getObjectsOnCoordinate(c)) {
if (game.getVisionMaster().checkInvisible(obj)) {
if (permitInvisCollision) {
result = false;
continue;
}
}
try {
if (ref.getSourceObj().checkProperty(G_PROPS.STANDARD_PASSIVES, "" + UnitEnums.STANDARD_PASSIVES.FLYING)) {
if (obj.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ) {
if (obj.checkProperty(G_PROPS.STANDARD_PASSIVES, "" + UnitEnums.STANDARD_PASSIVES.TALL)) {
result = false;
}
continue;
}
}
} catch (Exception e) {
}
return true;
}
}
return result;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ShapeEffect method initTargeting.
@Override
public void initTargeting() {
// init unit group
Coordinates baseCoordinate = getBaseCoordinate();
int base_width = radius.getInt(ref);
int distance = this.distance.getInt(ref);
coordinates = DC_PositionMaster.getShapedCoordinates(baseCoordinate, getFacing(), base_width, distance, getShape());
DequeImpl<Obj> objects = new DequeImpl<>();
objects.addAllCast(getGame().getMaster().getUnitsForCoordinates(coordinates));
Filter.filter(objects, targetType);
if (allyOrEnemyOnly != null) {
if (allyOrEnemyOnly) {
FilterMaster.applyFilter(objects, FILTERS.ALLY, ref, false);
} else {
FilterMaster.applyFilter(objects, FILTERS.ENEMY, ref, false);
}
}
if (notSelf) {
FilterMaster.applyFilter(objects, FILTERS.NOT_SELF, ref, false);
}
if (targetType.equals(DC_TYPE.TERRAIN)) {
// C_TYPE equals if contains() !
objects.addAll(game.getCellsForCoordinates(coordinates));
}
targeting = new AutoTargeting(new GroupImpl(objects));
setFilteringConditions(new Conditions());
targeting.setConditions(getFilteringConditions());
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class StackingRule method canBeMovedOnto.
private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
HashMap<Coordinates, Boolean> bools = cache.get(unit);
boolean result = false;
if (maxSpaceTakenPercentage == 100) {
if (bools != null) {
if (bools.containsKey(c)) {
return bools.get(c);
}
} else {
bools = new HashMap<>();
cache.put(unit, bools);
}
}
// get all units on the cell
DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
if (!units.contains(u)) {
if (!u.isAnnihilated())
// continue; TODO why was Type necessary?
units.addCast(!u.isDead() ? u.getType() : u);
if (u.isWall())
if (!u.isDead())
return false;
}
}
// check if '1 unit per cell' is on
if (maxSpaceTakenPercentage <= 0) {
if (!units.isEmpty()) {
return false;
}
}
if (unit == null) {
unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
}
Obj cell;
if (!game.isSimulation()) {
cell = game.getCellByCoordinate(c);
} else {
cell = new DC_Cell(c, game);
}
if (cell == null) {
return false;
}
if (z == null) {
if (unit instanceof Unit) {
Unit heroObj = (Unit) unit;
z = heroObj.getZ();
}
}
// TODO ???
if (game.isSimulation()) {
if (units.size() > 1) {
return false;
}
}
// no passable/overlaying!
int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
if (c != null) {
if (!game.isSimulation()) {
space = cell.getIntParam(PARAMS.SPACE);
}
}
int girth = 0;
for (Entity u : units) {
if (u == unit) {
continue;
}
// }
if (UnitAnalyzer.isWall(u)) {
// if (!UnitAnalyzer.isFlying(unit)) {
return false;
// }
}
if (u.isDead())
girth += u.getIntParam(PARAMS.GIRTH) / 3;
else
girth += u.getIntParam(PARAMS.GIRTH);
// TODO if (DoorMaster.isDoor((BattleFieldObject) u)) {
//
// }
// main.system.auxiliary.LogMaster.log(1, "****************** " +
// u.getName()
// + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
}
// [QUICK FIX]
if (unit.getIntParam(PARAMS.GIRTH) == 0) {
girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
} else {
girth += unit.getIntParam(PARAMS.GIRTH);
}
// main.system.auxiliary.LogMaster.log(1, "****************** " + space
// + " Space vs " + girth
// + " Girth on " + c + " for " + unit);
space = space * maxSpaceTakenPercentage / 100;
if (space >= girth) {
result = true;
} else {
if (unit.getIntParam(PARAMS.GIRTH) > space) {
if (units.isEmpty()) {
result = true;
}
}
}
if (// only cache for default cases!
maxSpaceTakenPercentage == 100) {
bools.put(c, result);
}
return result;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ActionAnimation method drawActivate.
protected boolean drawActivate(AnimPhase phase) {
if (action.isAttackOrStandardAttack()) {
return false;
}
Image image = action.getIcon().getImage();
Coordinates c = getTargetCoordinates();
if (c == null) {
c = getSourceCoordinates();
}
// TODO can we getOrCreate the cellComp's graphics?
int zoom = action.getGame().getBattleField().getGrid().getGridComp().getZoom();
int h = GuiManager.getCellHeight() * zoom / 100;
int w = GuiManager.getCellWidth() * zoom / 100;
Point point = action.getGame().getBattleField().getGrid().getGridComp().getPointForCoordinateWithOffset(c);
int x = (int) (point.getX() + (w - image.getWidth(null)) / 2);
int y = (int) (point.getY() + (h - image.getHeight(null)) / 2);
// try it!
g.drawImage(image, x, y, null);
return true;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class AnimationManager method updatePoints.
public Coordinates updatePoints(List<PhaseAnimation> anims) {
for (PhaseAnimation anim : anims) {
boolean result = anim.updatePoints();
if (!result) {
if (anim.isCameraPanningOn()) {
pendingCameraAdjustmentAnims.add(anim);
// see what anims are beyond the edges for current offset
}
// find the minimum number of omitted anims?
// usage cases - replaying mass-anims or single anims -
// centering ;
}
}
if (pendingCameraAdjustmentAnims.isEmpty()) {
return bufferedOffset;
}
offset = game.getBattleField().getGrid().getOffsetCoordinate();
if (offset == null) {
offset = new Coordinates(0, 0);
}
int y = offset.y;
int x = offset.x;
int y1 = offset.y;
int x1 = offset.x;
int minNumber = getMinNumberOfAnimsOutOfBounds(y, x, y1, x1, true);
Coordinates bufferedCoordinate = offset;
int minNumber2 = getMinNumberOfAnimsOutOfBounds(y, x, y1, x1, false);
if (minNumber < minNumber2) {
offset = bufferedCoordinate;
}
adjustOffset(offset);
return bufferedOffset;
}
Aggregations