Search in sources :

Example 1 with Obj

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;
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj)

Example 2 with Obj

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

Example 3 with Obj

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);
    }
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Cell(eidolons.entity.obj.DC_Cell) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) INTERACTIVE_ELEMENT(eidolons.swing.components.obj.drawing.DrawMaster.INTERACTIVE_ELEMENT) Unit(eidolons.entity.obj.unit.Unit)

Example 4 with Obj

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
}
Also used : FilteringCondition(main.elements.conditions.FilteringCondition) Condition(main.elements.conditions.Condition) Obj(main.entity.obj.Obj)

Example 5 with Obj

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

Aggregations

Obj (main.entity.obj.Obj)127 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)34 DC_Obj (eidolons.entity.obj.DC_Obj)30 Coordinates (main.game.bf.Coordinates)27 Unit (eidolons.entity.obj.unit.Unit)24 ArrayList (java.util.ArrayList)19 Ref (main.entity.Ref)15 DC_SpellObj (eidolons.entity.active.DC_SpellObj)14 BuffObj (main.entity.obj.BuffObj)13 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)12 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)11 ActiveObj (main.entity.obj.ActiveObj)10 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)9 PassiveAbilityObj (main.ability.PassiveAbilityObj)9 ObjType (main.entity.type.ObjType)8 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)7 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)7 PARAMETER (main.content.values.parameters.PARAMETER)7 Conditions (main.elements.conditions.Conditions)6 MicroObj (main.entity.obj.MicroObj)6