Search in sources :

Example 16 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class Level method getWallObjData.

private String getWallObjData() {
    String wallObjData = "";
    for (DC_Obj obj : getWallObjects()) {
        String objString = DC_ObjInitializer.getObjString(obj);
        Integer chance = obj.getIntParam(G_PARAMS.CHANCE);
        if (chance > 0) {
            objString += StringMaster.wrapInParenthesis(chance + "%");
        }
        wallObjData += objString + DC_ObjInitializer.OBJ_SEPARATOR;
    }
    return wallObjData;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj)

Example 17 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class GridPanel method bindEvents.

private void bindEvents() {
    GuiEventManager.bind(GuiEventType.ANIMATION_QUEUE_FINISHED, (p) -> {
        resetVisible();
    });
    GuiEventManager.bind(GuiEventType.UPDATE_LAST_SEEN_VIEWS, p -> {
        List<BattleFieldObject> list = (List<BattleFieldObject>) p.get();
        for (BattleFieldObject sub : viewMap.keySet()) {
            GridUnitView view = (GridUnitView) viewMap.get(sub);
            if (list.contains(sub)) {
                setVisible(view.getLastSeenView(), true);
            } else {
                setVisible(view.getLastSeenView(), false);
            }
        }
    });
    GuiEventManager.bind(UNIT_GREYED_OUT_ON, obj -> {
        BattleFieldObject bfObj = (BattleFieldObject) obj.get();
        if (bfObj.isOverlaying())
            return;
        UnitView unitView = getUnitView(bfObj);
        unitView.setFlickering(true);
        unitView.setGreyedOut(true);
    // unitView.setVisible(true);
    });
    GuiEventManager.bind(UNIT_GREYED_OUT_OFF, obj -> {
        BattleFieldObject bfObj = (BattleFieldObject) obj.get();
        if (bfObj.isOverlaying())
            return;
        UnitView unitView = getUnitView(bfObj);
        unitView.setGreyedOut(false);
        unitView.setFlickering(false);
        // ActorMaster.getActionsOfClass(unitView, AlphaAction.class);
        unitView.getActions().clear();
    // unitView.setVisible(true);
    });
    GuiEventManager.bind(UNIT_STARTS_MOVING, obj -> {
        detachUnitView((BattleFieldObject) obj.get());
    });
    // GuiEventManager.bind(GRID_OBJ_HOVER_ON, (event) -> {
    // resetZIndices();
    // });
    // GuiEventManager.bind(GRID_OBJ_HOVER_OFF, (event) -> {
    // resetZIndices();
    // });
    GuiEventManager.bind(UNIT_MOVED, obj -> {
        moveUnitView((BattleFieldObject) obj.get());
    });
    GuiEventManager.bind(UPDATE_GUI, obj -> {
        if (!VisionManager.isVisionHacked())
            if (OutlineMaster.isAutoOutlinesOff())
                if (OutlineMaster.isOutlinesOn()) {
                    updateOutlines();
                }
        firstUpdateDone = true;
        resetVisibleRequired = true;
        updateRequired = true;
        DungeonScreen.getInstance().updateGui();
    });
    GuiEventManager.bind(SELECT_MULTI_OBJECTS, obj -> {
        Pair<Set<DC_Obj>, TargetRunnable> p = (Pair<Set<DC_Obj>, TargetRunnable>) obj.get();
        if (p.getLeft().isEmpty()) {
            FloatingTextMaster.getInstance().createFloatingText(TEXT_CASES.REQUIREMENT, "No targets available!", Eidolons.getGame().getManager().getControlledObj());
            return;
        }
        Map<Borderable, Runnable> map = new HashMap<>();
        for (DC_Obj obj1 : p.getLeft()) {
            Borderable b = viewMap.get(obj1);
            if (b == null) {
                b = cells[obj1.getX()][rows - 1 - obj1.getY()];
            }
            if (b instanceof GridUnitView) {
                final GridUnitView gridView = (GridUnitView) b;
                final UnitView unitView = gridView.getInitiativeQueueUnitView();
                map.put(unitView, () -> p.getRight().run(obj1));
            }
            map.put(b, () -> p.getRight().run(obj1));
        }
        GuiEventManager.trigger(SHOW_BLUE_BORDERS, map);
    });
    GuiEventManager.bind(DESTROY_UNIT_MODEL, param -> {
        BattleFieldObject unit = (BattleFieldObject) param.get();
        removeUnitView(unit);
    });
    GuiEventManager.bind(INGAME_EVENT_TRIGGERED, onIngameEvent());
    GuiEventManager.bind(UPDATE_GRAVEYARD, obj -> {
        final Coordinates coordinates = (Coordinates) obj.get();
        cells[coordinates.getX()][rows - 1 - coordinates.getY()].updateGraveyard();
    });
    GuiEventManager.bind(ACTIVE_UNIT_SELECTED, obj -> {
        BattleFieldObject hero = (BattleFieldObject) obj.get();
        DungeonScreen.getInstance().activeUnitSelected(hero);
        if (hero instanceof Unit)
            animMaster.getConstructor().tryPreconstruct((Unit) hero);
        BaseView view = viewMap.get(hero);
        if (view == null) {
            System.out.println("viewMap not initiatilized at ACTIVE_UNIT_SELECTED!");
            return;
        }
        if (view.getParent() instanceof GridCellContainer) {
            ((GridCellContainer) view.getParent()).popupUnitView((GridUnitView) view);
        }
        viewMap.values().stream().forEach(v -> v.setActive(false));
        view.setActive(true);
        if (hero.isMine()) {
            GuiEventManager.trigger(SHOW_TEAM_COLOR_BORDER, view);
            GuiEventManager.trigger(BOTTOM_PANEL_UPDATE, new PanelActionsDataSource((Unit) hero));
        } else {
            GuiEventManager.trigger(SHOW_TEAM_COLOR_BORDER, view);
            GuiEventManager.trigger(BOTTOM_PANEL_UPDATE, null);
        }
        if (!firstUpdateDone) {
            DC_Game.game.getVisionMaster().triggerGuiEvents();
            GuiEventManager.trigger(UPDATE_GUI, null);
            GuiEventManager.trigger(UPDATE_LIGHT);
        }
        if (HelpMaster.isDefaultTextOn())
            if (!welcomeInfoShown) {
                new Thread(() -> {
                    WaitMaster.WAIT(2000);
                    GuiEventManager.trigger(SHOW_TEXT_CENTERED, HelpMaster.getWelcomeText());
                }, " thread").start();
                welcomeInfoShown = true;
            }
    });
    // GuiEventManager.bind(UPDATE_UNIT_VISIBLE, obj -> {
    // final Pair<Unit, Boolean> pair = (Pair<Unit, Boolean>) obj.get();
    // final BaseView baseView = viewMap.get(pair.getLeft());
    // if (baseView instanceof GridUnitView) {
    // final Boolean isVisible = pair.getRight();
    // //TODO ???
    // ((GridUnitView) baseView).setVisibleVal(isVisible ? 100 : 50);
    // }
    // });
    GuiEventManager.bind(UNIT_VISIBLE_ON, p -> {
        if (p.get() instanceof Collection) {
            for (Object sub : ((Collection) p.get())) {
                setVisible((BattleFieldObject) sub, true);
            }
            return;
        }
        setVisible((BattleFieldObject) p.get(), true);
    });
    GuiEventManager.bind(UNIT_VISIBLE_OFF, p -> {
        if (p.get() instanceof Collection) {
            for (Object sub : ((Collection) p.get())) {
                setVisible((BattleFieldObject) sub, false);
            }
            return;
        }
        setVisible((BattleFieldObject) p.get(), false);
    });
    GuiEventManager.bind(UPDATE_UNIT_ACT_STATE, obj -> {
        final Pair<Unit, Boolean> pair = (Pair<Unit, Boolean>) obj.get();
        final BaseView baseView = viewMap.get(pair.getLeft());
        if (baseView instanceof GridUnitView) {
            final boolean mobilityState = pair.getRight();
            ((GridUnitView) baseView).getInitiativeQueueUnitView().setQueueMoving(mobilityState);
        }
    });
    GuiEventManager.bind(GuiEventType.HP_BAR_UPDATE_MANY, p -> {
        List list = (List) p.get();
        list.forEach(o -> updateHpBar(o));
    });
    GuiEventManager.bind(GuiEventType.HP_BAR_UPDATE, p -> {
        updateHpBar(p.get());
    });
}
Also used : Unit(eidolons.entity.obj.unit.Unit) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) Coordinates(main.game.bf.Coordinates) DC_Obj(eidolons.entity.obj.DC_Obj) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) PanelActionsDataSource(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.PanelActionsDataSource) BattleFieldObject(eidolons.entity.obj.BattleFieldObject)

Example 18 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class DefaultActionHandler method doDebugStuffCell.

private static boolean doDebugStuffCell(Unit source, Coordinates c) {
    Ref ref = new Ref(source);
    ref.setMatch(source.getGame().getCellByCoordinate(c).getId());
    ClearShotCondition.clearCache();
    source.getGame().getVisionMaster().getSightMaster().getClearShotCondition().preCheck(ref);
    DC_Obj target = source.getGame().getCellByCoordinate(c);
    target.getGame().getVisionMaster().getGammaMaster().clearCache();
    target.getGame().getVisionMaster().getIlluminationMaster().clearCache();
    int g = target.getGame().getVisionMaster().getGammaMaster().getGamma(source, target);
    return false;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Ref(main.entity.Ref)

Example 19 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class AttackTooltipFactory method createAttackTooltip.

public static AttackTooltip createAttackTooltip(DC_UnitAction el, boolean precalc, boolean costs, boolean additionalInfo, boolean combatMode, DC_Obj target) {
    Pair<PARAMS, PARAMS> pair = ACTION_TOOLTIPS_PARAMS_MAP.get(ACTION_TOOLTIP_HEADER_KEY);
    String name = ActionTooltipMaster.getStringForTableValue(ACTION_TOOLTIP_HEADER_KEY, el);
    final String leftImage = ActionTooltipMaster.getIconPathForTableRow(pair.getLeft());
    final String rightImage = ActionTooltipMaster.getIconPathForTableRow(pair.getRight());
    MultiValueContainer head = new MultiValueContainer(name, leftImage, rightImage);
    VALUE[] baseKeys = ACTION_TOOLTIP_BASE_KEYS;
    final List<MultiValueContainer> base = extractActionValues(el, baseKeys);
    baseKeys = ACTION_TOOLTIP_RANGE_KEYS;
    final List<MultiValueContainer> range = extractActionValues(el, baseKeys);
    List /*<List<MultiValueContainer>>*/
    textsList = new ArrayList<>();
    for (PARAMS[] params : ACTION_TOOLTIP_PARAMS_TEXT) {
        textsList.add(Arrays.stream(params).map(p -> {
            String textForTableValue = ActionTooltipMaster.getTextForTableValue(p, el);
            textForTableValue = TextWrapper.wrapWithNewLine(textForTableValue, 50);
            if (StringUtils.isEmpty(textForTableValue)) {
                return null;
            } else {
                return new MultiValueContainer(textForTableValue, "");
            }
        }).filter(Objects::nonNull).collect(Collectors.toList()));
    }
    AttackTooltip toolTip = new AttackTooltip(el);
    ValueContainer precalcRow = createPrecalcRow(precalc, el, target);
    toolTip.setUserObject(new ActionTooltipSource() {

        @Override
        public MultiValueContainer getHead() {
            return head;
        }

        @Override
        public List<MultiValueContainer> getBase() {
            return base;
        }

        @Override
        public List<MultiValueContainer> getRange() {
            return range;
        }

        @Override
        public List<List<ValueContainer>> getText() {
            return textsList;
        }

        @Override
        public CostTableSource getCostsSource() {
            return () -> ActionCostSourceImpl.getActionCostList(el);
        }

        @Override
        public ValueContainer getPrecalcRow() {
            return precalcRow;
        }
    });
    return toolTip;
}
Also used : UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) Arrays(java.util.Arrays) PARAMS(eidolons.content.PARAMS) TextWrapper(main.system.text.TextWrapper) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) ActionCostSourceImpl(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.ActionCostSourceImpl) ArrayList(java.util.ArrayList) Pair(org.apache.commons.lang3.tuple.Pair) FutureBuilder(eidolons.game.battlecraft.ai.tools.future.FutureBuilder) Tooltip(eidolons.libgdx.gui.tooltips.Tooltip) G_PROPS(main.content.values.properties.G_PROPS) DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) Obj(main.entity.obj.Obj) Collectors(java.util.stream.Collectors) ImageManager(main.system.images.ImageManager) Objects(java.util.Objects) List(java.util.List) TextureCache(eidolons.libgdx.texture.TextureCache) ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) VALUE(main.content.VALUE) ArrayList(java.util.ArrayList) VALUE(main.content.VALUE) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) Objects(java.util.Objects) ArrayList(java.util.ArrayList) List(java.util.List) UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) PARAMS(eidolons.content.PARAMS) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Example 20 with DC_Obj

use of eidolons.entity.obj.DC_Obj in project Eidolons by IDemiurge.

the class MiniGrid method addObj.

private void addObj(Obj obj) {
    Coordinates c = obj.getCoordinates();
    MiniObjComp objComp = compMap.get(c);
    if (objComp == null) {
        objComp = new MiniObjComp((DC_Obj) obj, map);
        compMap.put(c, objComp);
    }
    if (MiniGrid.isMouseDragOffsetModeOn()) {
    // mouseMap.put(rect, objComp); //or maybe I can map things
    // dynamically on click!
    } else // if (editMode)
    {
        if (objComp.getComp().getMouseListeners().length != 0) {
            objComp.getComp().removeMouseListener(customMouseListener);
        }
        // if (objComp.getComp().getMouseListeners().length == 0) fails?
        objComp.getComp().addMouseListener(customMouseListener);
    }
    comp.add(objComp.getComp(), getMigString(c));
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Coordinates(main.game.bf.Coordinates)

Aggregations

DC_Obj (eidolons.entity.obj.DC_Obj)49 Unit (eidolons.entity.obj.unit.Unit)13 Obj (main.entity.obj.Obj)13 Coordinates (main.game.bf.Coordinates)12 ArrayList (java.util.ArrayList)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 DIRECTION (main.game.bf.Coordinates.DIRECTION)7 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)5 DC_Cell (eidolons.entity.obj.DC_Cell)4 BufferedImage (java.awt.image.BufferedImage)4 List (java.util.List)3 ModifyCounterEffect (eidolons.ability.effects.oneshot.mechanic.ModifyCounterEffect)2 DC_UnitAction (eidolons.entity.active.DC_UnitAction)2 HashMap (java.util.HashMap)2 PARAMETER (main.content.values.parameters.PARAMETER)2 Ref (main.entity.Ref)2 BuffObj (main.entity.obj.BuffObj)2 Pair (org.apache.commons.lang3.tuple.Pair)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1