Search in sources :

Example 1 with DC_UnitModel

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));
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) Obj(main.entity.obj.Obj)

Example 2 with DC_UnitModel

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;
}
Also used : DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) Coordinates(main.game.bf.Coordinates)

Example 3 with DC_UnitModel

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));
}
Also used : DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) DC_Cell(eidolons.entity.obj.DC_Cell)

Example 4 with DC_UnitModel

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;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) BfObj(main.entity.obj.BfObj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) DC_HeroSlotItem(eidolons.entity.item.DC_HeroSlotItem) FACING_SINGLE(main.content.enums.entity.UnitEnums.FACING_SINGLE)

Example 5 with DC_UnitModel

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;
}
Also used : Path(main.game.bf.pathing.Path) DC_UnitModel(eidolons.entity.obj.unit.DC_UnitModel) Obj(main.entity.obj.Obj)

Aggregations

DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)7 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)3 Obj (main.entity.obj.Obj)2 Coordinates (main.game.bf.Coordinates)2 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Cell (eidolons.entity.obj.DC_Cell)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)1 BfObj (main.entity.obj.BfObj)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1 Path (main.game.bf.pathing.Path)1