use of eidolons.entity.obj.unit.DC_UnitModel in project Eidolons by IDemiurge.
the class CellCondition method getCoordinates.
@Override
protected Coordinates getCoordinates(Ref ref) {
if (obj_ref == null) {
obj_ref = KEYS.MATCH.toString();
}
if (direction == null) {
return super.getCoordinates(ref);
}
Obj obj = ref.getObj(obj_ref);
FACING_DIRECTION f = null;
if (obj instanceof DC_UnitModel) {
f = ((DC_UnitModel) obj).getFacing();
}
if (f == null) {
return null;
}
return super.getCoordinates(ref).getAdjacentCoordinate(DirectionMaster.getDirectionByFacing(f, direction));
}
use of eidolons.entity.obj.unit.DC_UnitModel in project Eidolons by IDemiurge.
the class SpecialRequirements method check.
@Override
public boolean check(Ref ref) {
Coordinates c;
DC_UnitModel unit;
switch(template) {
case FREE_CELL:
break;
case FREE_CELL_RANGE:
break;
case HAS_ITEM:
break;
case ITEM:
break;
case NOT_FREE_CELL:
break;
case NOT_ITEM:
break;
default:
break;
}
return false;
}
use of eidolons.entity.obj.unit.DC_UnitModel in project Eidolons by IDemiurge.
the class MoveCondition method check.
@Override
public boolean check(Ref ref) {
DC_UnitModel obj = (DC_UnitModel) ref.getSourceObj();
DC_Cell cell = (DC_Cell) ref.getObj(KEYS.MATCH);
return (game.getMovementManager().canMove(obj, cell));
}
use of eidolons.entity.obj.unit.DC_UnitModel in project Eidolons by IDemiurge.
the class FacingCondition method check.
@Override
public boolean check(Ref ref) {
if (!(ref.getSourceObj() instanceof DC_UnitModel)) {
return false;
}
BattleFieldObject obj1 = (BattleFieldObject) ref.getSourceObj();
DC_Obj obj2;
if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
if (!(ref.getObj(KEYS.MATCH) instanceof DC_HeroSlotItem)) {
return false;
}
obj2 = ((DC_HeroAttachedObj) ref.getObj(KEYS.MATCH)).getOwnerObj();
} else {
obj2 = (DC_Obj) ref.getObj(KEYS.MATCH);
}
boolean result = false;
if (getTemplate() != null) {
Coordinates c = obj2.getCoordinates();
if (obj2.isOverlaying())
if (obj2 instanceof BattleFieldObject) {
DIRECTION d = ((BattleFieldObject) obj2).getDirection();
if (d != null) {
c = c.getAdjacentCoordinate(d.rotate180(), 2);
}
// the coordinate to which unit must be facing in order to face the overlaying obj on the other side
}
if (obj1 == null)
return false;
if (c == null)
return false;
FACING_SINGLE facing = FacingMaster.getSingleFacing(obj1.getFacing(), obj1.getCoordinates(), c);
result = Arrays.asList(templates).contains(facing);
if (facing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
if (result) {
if (left_right == null) {
left_right = obj1.checkBool(GenericEnums.STD_BOOLS.LEFT_RIGHT_REACH);
}
if (left_right) {
int degrees = obj1.getFacing().getDirection().getDegrees();
int degrees2 = DirectionMaster.getRelativeDirection(obj1, obj2).getDegrees();
boolean left = degrees > degrees2;
if (left) {
return left_right;
}
return !left_right;
}
}
}
}
return result;
}
use of eidolons.entity.obj.unit.DC_UnitModel in project Eidolons by IDemiurge.
the class DC_Bf_Analyzer method getClosestAttackTarget.
@Override
public Obj getClosestAttackTarget() {
DC_UnitModel unit = (DC_UnitModel) ai.getLogic().getUnit();
Obj enemy_unit = null;
int cost = Integer.MAX_VALUE;
for (Obj obj : getEnemy().getControlledUnits()) {
DC_UnitModel enemyUnit = (DC_UnitModel) obj;
Obj cell = getClosestCell(enemyUnit, false);
if (cell == null) {
continue;
}
Path path = movementManager.getPath(unit, cell);
if (path == null) {
continue;
}
if (cost > path.getIntegerCost()) {
enemy_unit = enemyUnit;
}
}
if (enemy_unit == null) {
enemy_unit = enemy.getHeroObj();
}
LogMaster.log(LogMaster.AI_DEBUG, enemy_unit + " has been picked as closest target for " + ai.getLogic().getUnit());
return enemy_unit;
}
Aggregations