use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.
the class Action method getTargeting.
public Targeting getTargeting() {
Targeting targeting = active.getTargeting();
if (targeting == null) {
active.construct();
targeting = active.getTargeting();
}
if (targeting == null) {
try {
// list?
targeting = TargetingMaster.findTargeting(active, SelectiveTargeting.class);
// preCheck
// both?
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
return targeting;
}
use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.
the class Targeter method canTargetAny.
public boolean canTargetAny() {
Targeting targeting = getTargeting();
if (!(targeting instanceof SelectiveTargeting)) {
return true;
}
Map<FACING_DIRECTION, Boolean> map = getTargetingAnyCache().get(getOwnerObj().getCoordinates());
if (map == null) {
map = new HashMap<>();
targetingAnyCache.put(getOwnerObj().getCoordinates(), map);
}
Boolean canTargetAny = map.get(getOwnerObj().getFacing());
if (canTargetAny == null) {
canTargetAny = !targeting.getFilter().getObjects(getRef()).isEmpty();
}
map.put(getOwnerObj().getFacing(), canTargetAny);
return canTargetAny;
}
use of main.elements.targeting.Targeting in project Eidolons by IDemiurge.
the class Targeter method canBeTargeted.
public boolean canBeTargeted(Integer id, boolean caching) {
Targeting targeting = getTargeting();
Map<FACING_DIRECTION, Map<Integer, Boolean>> map = getTargetingCache().get(getOwnerObj().getCoordinates());
if (map == null) {
map = new HashMap<>();
getTargetingCache().put(getOwnerObj().getCoordinates(), map);
}
Map<Integer, Boolean> map2 = map.get(getOwnerObj().getFacing());
if (map2 == null) {
map2 = new HashMap<>();
map.put(getOwnerObj().getFacing(), map2);
}
// TODO for ai?
Boolean result = map2.get(id);
if (caching) {
if (result != null)
return result;
}
if (targeting == null) {
// TODO ??
if (getEntity().getActives().size() > 1) {
return true;
}
if (!getEntity().getActives().isEmpty()) {
if (getEntity().getActives().get(0).getAbilities().getAbils().size() > 1) {
return true;
}
}
return false;
}
Ref REF = getEntity().getRef().getCopy();
REF.setMatch(id);
if (targeting instanceof MultiTargeting) {
// TODO ??
}
Conditions conditions = targeting.getFilter().getConditions();
if (result != null) {
if (result) {
if (!conditions.preCheck(REF)) {
return false;
}
}
if (!result) {
if (conditions.preCheck(REF)) {
return true;
}
}
}
if (conditions.isEmpty())
if (targeting instanceof TemplateSelectiveTargeting)
((TemplateSelectiveTargeting) targeting).initTargeting();
getEntity().getRef().getSourceObj().getRef().setInfoEntity(getEntity());
result = conditions.preCheck(REF);
map2.put(id, result);
return result;
}
Aggregations