use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class PathSequenceConstructor method getTargetCells.
private List<Coordinates> getTargetCells(Action targetAction) {
if (targetAction.isDummy()) {
return new ListMaster<Coordinates>().getList(targetAction.getTarget().getCoordinates());
}
if (targetAction.getActive().getName().equalsIgnoreCase(StringMaster.getWellFormattedString(STD_SPEC_ACTIONS.Guard_Mode.toString()))) {
return new ListMaster<Coordinates>().toList_(targetAction.getTask().getObjArg().getCoordinates());
}
Boolean fastPickClosestToTargetOrSelf = null;
if (TimeLimitMaster.isFastPickCell()) {
if (targetAction.getActive().isRanged()) {
fastPickClosestToTargetOrSelf = false;
}
if (targetAction.getActive().isMelee()) {
// if (targetAction.getSource().getAiType()!= AI_TYPE.SNEAK) TODO just behind!
fastPickClosestToTargetOrSelf = true;
}
}
Coordinates originalCoordinate = getUnit().getCoordinates();
List<Coordinates> list = cellsCache.get(targetAction.getTargeting());
if (list != null) {
return list;
}
list = new ArrayList<>();
try {
if (fastPickClosestToTargetOrSelf != null) {
double min = Integer.MAX_VALUE;
DC_Obj center = fastPickClosestToTargetOrSelf ? targetAction.getTarget() : targetAction.getSource();
for (Coordinates c : center.getCoordinates().getAdjacentCoordinates()) {
if (// TODO
!TargetingMaster.isValidTargetingCell(targetAction, c, getUnit())) {
continue;
}
double distance = PositionMaster.getExactDistance(c, originalCoordinate);
if (distance <= min) {
list = new ListMaster<Coordinates>().getList(c);
min = distance;
}
}
}
if (list.isEmpty()) {
// TODO prioritizedCells;
List<Coordinates> coordinatesList = null;
if (!ListMaster.isNotEmpty(coordinatesList)) {
coordinatesList = getUnit().getGame().getBattleField().getGrid().getCoordinatesList();
}
// prune by distance/direction from target?
for (Coordinates c : coordinatesList) {
if (!TargetingMaster.isValidTargetingCell(targetAction, c, getUnit())) {
continue;
}
// TODO causes visuals!
getUnit().setCoordinates(c);
if (TargetingMaster.canBeTargeted(targetAction, true, true)) {
list.add(c);
}
}
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
getUnit().setCoordinates(originalCoordinate);
}
if (list.size() > 1) {
list = getPruneMaster().pruneTargetCells(targetAction, list);
}
if (getUnit().getUnitAI().getLogLevel() > UnitAI.LOG_LEVEL_BASIC) {
LogMaster.log(LOG_CHANNEL.AI_DEBUG, "***" + targetAction + " has target cells for PB: " + list);
}
cellsCache.put(targetAction.getTargeting(), list);
return list;
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class TurnSequenceConstructor method getTurnSequence.
public List<Action> getTurnSequence(Action action) {
Conditions conditions = (action.getTargeting().getFilter().getConditions());
FacingCondition condition = null;
FACING_SINGLE template = null;
DC_Obj target = action.getTarget();
Unit source = (Unit) action.getRef().getSourceObj();
for (Condition c : conditions) {
if (c instanceof FacingCondition) {
condition = (FacingCondition) c;
break;
}
List<Object> list = ClassMaster.getInstances(c, FacingCondition.class);
if (!list.isEmpty()) {
List<Action> front_sequence = getTurnSequence(FACING_SINGLE.IN_FRONT, source, target.getCoordinates());
List<Action> side_sequence = null;
if (action.getSource().hasBroadReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.BROAD_REACH)) // front_sequence.remove(front_sequence.size() - 1);
{
side_sequence = getTurnSequence(FACING_SINGLE.TO_THE_SIDE, source, target.getCoordinates());
}
List<Action> hind_sequence = null;
if (action.getSource().hasHindReach() || action.getActive().checkPassive(UnitEnums.STANDARD_PASSIVES.HIND_REACH)) {
hind_sequence = getTurnSequence(FACING_SINGLE.BEHIND, source, target.getCoordinates());
}
return new ListMaster<Action>().getSmallest(front_sequence, hind_sequence, side_sequence);
}
}
// }
if (condition == null) {
return new ArrayList<>();
}
if (ArrayMaster.isNotEmpty(condition.getTemplate())) {
template = condition.getTemplate()[0];
}
return getTurnSequence(template, source, target.getCoordinates());
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class DrawMaster method draw.
public void draw(CellComp cellComp, Graphics compGraphics, int zoom, boolean editorMode) {
this.cellComp = cellComp;
this.zoom = zoom;
initSizes();
Map<Rectangle, Object> mouseMap = new XLinkedMap<>();
cellComp.setMouseMap(mouseMap);
Unit topObj = cellComp.getTopObj();
if (isSingleObj()) {
Image image = cellComp.getGame().getVisionMaster().getVisibilityMaster().getDisplayImageForUnit(topObj);
if (image != null) {
compGraphics.drawImage(image, 0, 0, null);
if (topObj.isWall()) {
drawWallOverlays(topObj, compGraphics, cellComp.getCoordinates());
}
if (GRAPHICS_TEST_MODE) {
DC_Obj obj = cellComp.getTopObjOrCell();
drawCI(obj, compGraphics);
if (FULL_GRAPHICS_TEST_MODE) {
compGraphics.drawString("" + obj.getOutlineType(), 0, GuiManager.getCellHeight() - 40);
String tooltip = cellComp.getGame().getVisionMaster().getHintMaster().getTooltip(obj);
if (tooltip != null) {
compGraphics.drawString("" + tooltip, 0, GuiManager.getCellHeight() - 20);
}
drawSightBlockInfo(cellComp, compGraphics, zoom);
}
}
drawSpecialOverlays(cellComp, compGraphics, zoom);
return;
}
}
// no overlays at all? Animations at least?
if (isFramePaintZoom()) {
if (!isMultiObj()) {
try {
drawCellFrame(compGraphics);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
if (!cellComp.isTerrain()) {
try {
drawObjComps(compGraphics);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
} else {
try {
drawTerrainObj(compGraphics);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
if (!cellComp.isTerrain()) {
if (topObj.isInfoSelected() || topObj.isActiveSelected()) {
BufferedImage compOverlayImage = ImageManager.getNewBufferedImage(getCompWidth(), getCompHeight());
drawComponentOverlays(compOverlayImage.getGraphics());
BfGridComp.getOverlayMap().put(new XLine(new Point(topObj.getX(), topObj.getY()), new Point(5 - getObjCount() * 2, 0)), compOverlayImage);
} else {
drawComponentOverlays(compGraphics);
}
}
drawOverlayingObjects(compGraphics, cellComp);
// perhaps should work with Obj instead?
if (isAnimationPaintZoom()) {
if (cellComp.isAnimated()) {
try {
drawAnimations(cellComp, compGraphics);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
if (GRAPHICS_TEST_MODE) {
drawCI(topObj, compGraphics);
}
if (GRAPHICS_TEST_MODE || isEditorMode() || DC_Game.game.isDebugMode()) {
Coordinates coordinates = cellComp.getCoordinates();
BfGridComp grid = cellComp.getGrid();
if (grid == null) {
grid = cellComp.getGame().getBattleField().getGrid().getGridComp();
}
if (coordinates.x - grid.getOffsetX() == 0) {
drawCoordinateMarkings(coordinates.y, compGraphics, false);
}
if (coordinates.y - grid.getOffsetY() == 0) {
drawCoordinateMarkings(coordinates.x, compGraphics, true);
}
if (cellComp.isInfoSelected()) {
drawCoordinateMarkings(coordinates.x, compGraphics, true);
drawCoordinateMarkings(coordinates.y, compGraphics, false);
}
}
if (isSightVisualsOn()) {
// Unit obj = cellComp.getGame().getManager().getActiveObj();
// // if (!obj.isMine()) return ;
// boolean extended = !obj.getSightSpectrumCoordinates(false).contains(
// cellComp.getCoordinates());
// if (!extended) {
// extended = obj.getSightSpectrumCoordinates(true)
// .contains(cellComp.getCoordinates());
// if (!extended) {
// return;
// }
// }
//
// drawSightVisualsOnCell((Graphics2D) compGraphics, extended, cellComp.getObjects().size() > 0);
// drawSightBlockInfo(cellComp, compGraphics, zoom);
}
drawSpecialOverlays(cellComp, compGraphics, zoom);
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class DrawMaster method drawTerrainObj.
private void drawTerrainObj(Graphics g) {
// TODO checkGraves() => tooltip+selectable skulls!
drawCellImage(g);
drawCorpses(g);
drawItems(g);
if (GRAPHICS_TEST_MODE) {
DC_Obj obj = cellComp.getTerrainObj();
drawCI(obj, g);
}
}
use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.
the class DrawMasterStatic method drawWatchVisuals.
private static void drawWatchVisuals(java.util.List<DC_Obj> watchedObjects, Unit watcher, Graphics g, int zoom, java.util.List<DC_Obj> list, boolean active, boolean lines_images) {
int w = ImageManager.STD_IMAGES.WATCHER.getWidth() * zoom / 100;
int h = ImageManager.STD_IMAGES.WATCHER.getHeight() * zoom / 100;
Point p = getPointFromCoordinates(lines_images, w, h, watcher.getCoordinates(), watcher.getFacing().getDirection(), zoom);
for (DC_Obj watched : watchedObjects) {
Point p2 = getPointFromCoordinates(lines_images, w, h, watched.getCoordinates(), DirectionMaster.rotate180(DirectionMaster.getRelativeDirection(watcher, watched)), zoom);
if (lines_images) {
g.setColor(watcher.isMine() ? ColorManager.CYAN : ColorManager.CRIMSON);
int offsetX = 0;
int offsetY = 0;
if (!watcher.getFacing().isVertical()) {
offsetX = !watcher.getFacing().isCloserToZero() ? 3 : -3;
} else {
offsetY = !watcher.getFacing().isCloserToZero() ? 3 : -3;
}
// TODO
g.drawLine(p.x + offsetX, p.y + offsetY, p2.x, p2.y);
// punctir...
// visualize clear shot too?
// Painter.paintImagesInLine(g, new XLine(portrait, p2),
// STD_IMAGES.EYE.getEmitterPath(),
// 40 * zoom / 100);
} else {
Image image = ImageManager.STD_IMAGES.WATCHER.getImage();
drawImage(g, image, p.x, p.y);
image = ImageManager.STD_IMAGES.WATCHED.getImage();
drawImage(g, image, p2.x, p2.y);
}
}
}
Aggregations