use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class DC_AI_Logic method getPriorityUnit.
@Override
public Obj getPriorityUnit() {
Obj UNIT;
int greatest_priority = 0;
int index = -1;
int i = 0;
for (Obj unit : units) {
int priority = getPriorityForUnit(unit, units);
index++;
if (priority > greatest_priority) {
greatest_priority = priority;
i = index;
}
}
UNIT = (Obj) units.toArray()[i];
return UNIT;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class ActionManager method checkWaitForBlockingAlly.
private Integer checkWaitForBlockingAlly() {
Coordinates c = getUnit().getCoordinates().getAdjacentCoordinate(getUnit().getFacing().getDirection());
Obj obj = getUnit().getGame().getObjectVisibleByCoordinate(c);
if (obj instanceof Unit) {
if (((Unit) obj).canActNow()) // if (!((DC_HeroObj) obj).checkStatus(STATUS.WAITING))
{
return obj.getId();
}
}
return null;
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class BfMouseListener method mouseClicked.
@Override
public void mouseClicked(MouseEvent e) {
if (checkAnimationClick(e)) {
return;
}
if (checkDynamicButtonClick(e)) {
return;
}
point = e.getPoint();
cellComp = gridComp.getCompByPoint(e.getPoint());
Point relativePoint = new Point(point.x % gridComp.getCellWidth(), point.y % gridComp.getCellHeight());
objClicked = null;
for (Rectangle rect : cellComp.getMouseMap().keySet()) {
if (rect.contains(relativePoint)) {
Object object = cellComp.getMouseMap().get(rect);
if (object instanceof INTERACTIVE_ELEMENT) {
INTERACTIVE_ELEMENT element = (INTERACTIVE_ELEMENT) object;
switch(element) {
case STACK:
// if (CoreEngine.isLevelEditor())
objClicked = DialogMaster.objChoice("Which object?", cellComp.getObjects().toArray(new DC_Obj[cellComp.getObjects().size()]));
break;
case AP:
break;
case COUNTERS:
break;
case ITEMS:
Collection<? extends Obj> droppedItems = cellComp.getGame().getDroppedItemManager().getDroppedItems(cellComp.getTerrainObj());
break;
case LOCKS:
break;
case TRAPS:
break;
}
// break ;
} else if (object instanceof Obj) {
if (object instanceof Unit) {
if (objClicked != null) {
int index = cellComp.getObjects().indexOf(objClicked);
int index2 = cellComp.getObjects().indexOf(object);
LogMaster.log(1, objClicked + "'s " + index + " vs " + object + "'s " + index2);
if (index > index2) // TODO so we need to keep this always sorted...
{
continue;
}
}
Unit unit = (Unit) object;
if (unit.isOverlaying()) {
// corpseClicked(unit);
if (unit.getVisibilityLevel() == VisionEnums.VISIBILITY_LEVEL.CONCEALED) {
continue;
}
objClicked = unit;
break;
} else {
objClicked = unit;
continue;
}
} else if (object instanceof DC_Cell) {
if (e.isAltDown()) {
objClicked = (DC_Obj) object;
break;
} else if (objClicked == null) {
objClicked = (DC_Obj) object;
}
// ?
continue;
}
}
// if (objClicked == null)
// return; // ??
}
}
if (objClicked == null) {
objClicked = cellComp.getTopObjOrCell();
}
if (CoreEngine.isLevelEditor()) {
if (objClicked instanceof DC_Cell) {
return;
}
}
boolean right = SwingUtilities.isRightMouseButton(e);
if (right) {
objClicked.invokeRightClicked();
// gridComp.getGame().getManager().rightClicked(objClicked);
} else {
gridComp.getGame().getManager().objClicked(objClicked);
}
boolean debugMode = gridComp.getGame().isDebugMode();
if (debugMode) {
gridComp.getGame().getDebugMaster().setArg(objClicked);
}
if (e.isAltDown()) {
if (debugMode) {
invokeAltClick(right);
} else {
new Thread(new Runnable() {
public void run() {
gridComp.getGame().getMovementManager().moveTo(objClicked);
}
}, "moveTo thread").start();
}
}
if (e.isShiftDown()) {
invokeShiftClick(right);
}
if (e.isControlDown()) {
invokeControlClick(right);
}
}
use of main.entity.obj.Obj in project Eidolons by IDemiurge.
the class Filter method getObjects.
public Set<T> getObjects() {
if (isDebug()) {
ArrayList<Obj> list = new ArrayList<>(getFilteredObjectPool());
Set<Obj> set = new HashSet<>();
loop: for (Obj obj : list) {
for (Condition c : getConditions()) {
if (!match(c, obj.getId())) {
if (conditionDebugCache != null)
conditionDebugCache.put(obj.getId(), c);
continue loop;
}
}
set.add(obj);
}
return (Set<T>) new HashSet<>(set);
}
Collection<Obj> pool = getFilteredObjectPool();
Set<T> filteredSet = (Set<T>) new HashSet<>(pool);
ArrayList<Obj> list = new ArrayList<>(pool);
for (Condition c : getConditions()) {
for (Obj obj : list) {
if (!match(c, obj.getId())) {
filteredSet.remove(obj);
}
}
}
return filteredSet;
// TODO sort out; use cache
}
use of main.entity.obj.Obj 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;
}
Aggregations