use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class MetaGoalMaster method getModForOtherArgTask.
private Integer getModForOtherArgTask(Unit unit, Object metaGoalArg, ActionSequence sequence, META_GOAL_TYPE type) {
Unit target = (Unit) unit.getGame().getObjectById((Integer) metaGoalArg);
switch(type) {
case PROTECT:
if (sequence.getTask().getType() == GOAL_TYPE.ATTACK) {
// get threat
float threat = getThreatAnalyzer().getRelativeThreat(target.getAI(), unit);
int mod = getThreatProtectionMod(sequence.getAi(), target);
return (int) (threat * mod);
}
}
return null;
}
use of eidolons.entity.obj.unit.Unit 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.unit.Unit in project Eidolons by IDemiurge.
the class DrawMaster method drawOverlayingObjects.
private void drawOverlayingObjects(Graphics g, CellComp cellComp) {
for (Unit obj : cellComp.getOverlayingObjects()) {
if (!isEditorMode()) {
if (cellComp.getGame().getVisionMaster().getVisibilityMaster().isZeroVisibility(obj)) {
continue;
}
}
DIRECTION d = obj.getDirection();
// if (CoreEngine.isLevelEditor()) {
if (d == null) {
// Map<Unit, DIRECTION> map = obj.getGame().getDirectionMap().get(
// cellComp.getCoordinates());
// if (map != null) {
// d = map.get(obj);
// }
// }
}
int size = overlayingSize;
int x = MigMaster.getCenteredPosition(getObjCompWidth(), size);
if (d != null) {
if (d.growX == null) {
x = MigMaster.getCenteredPosition(getObjCompWidth(), size);
} else {
x = (d.growX) ? getObjCompWidth() - size : 0;
}
}
int y = MigMaster.getCenteredPosition(getObjCompHeight(), size);
if (d != null) {
if (d.growY == null) {
y = MigMaster.getCenteredPosition(getObjCompHeight(), size);
} else {
y = (d.growY) ? getObjCompHeight() - size : 0;
}
}
drawOverlayingObj(g, cellComp, obj, x, y, size);
// }
// NESW
}
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DrawMaster method getStackOffsetX.
private int getStackOffsetX() {
Unit obj = cellComp.getTopObj();
Integer stackOffsetX;
if (!obj.getFacing().isVertical() && obj.getFacing().isCloserToZero()) {
stackOffsetX = getObjCount() * getXOffsetPerObj(getObjCount());
} else {
stackOffsetX = 0;
}
return stackOffsetX;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DrawMaster method drawComponentOverlays.
private void drawComponentOverlays(Graphics g) {
if (cellComp.isAnimated()) {
return;
}
Unit obj = cellComp.getTopObj();
if (obj.isActiveSelected()) {
drawUnitEmblem(g, obj);
if (!isEditorMode()) {
if (!obj.isUnconscious()) {
drawActiveIcons(g, obj);
}
}
} else if (obj.isInfoSelected()) {
drawUnitEmblem(g, obj);
if (!isEditorMode()) {
if (!obj.isUnconscious()) {
drawInfoIcons(g, obj);
}
}
}
// adjust pos for stacked! TODO
if (!obj.isActiveSelected()) {
if (!obj.isInfoSelected()) {
drawPlayerEmblem(g, obj);
drawItems(g);
}
}
if (isEditorMode()) {
return;
}
if (!obj.isBfObj() && cellComp.isTop(obj)) {
drawParamsInfo(g, obj);
}
if (cellComp.getTopObj() == obj) {
drawUnitEmblem(g, obj);
// TODO stacked positioning adjusted to put facing comp outside
if (!obj.isUnconscious()) {
if (DrawHelper.isFacingDrawn(cellComp, obj) || (!obj.isBfObj() && DC_Game.game.isDebugMode())) {
drawFacing(g, obj);
}
}
}
// if (!isEditorMode())
// drawSpecialIcons(g, obj); // ?
drawCorpses(g);
}
Aggregations