Search in sources :

Example 11 with DequeImpl

use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.

the class SpectrumEffect method applyThis.

public boolean applyThis() {
    if (range == null)
        range = new Formula(rangeFormula).getInt(ref);
    Integer backwardRange = 0;
    Integer sidePenalty = 0;
    if (vision) {
        range = new Formula(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SIGHT_RANGE)).getInt(ref);
        // TODO
        backwardRange = null;
        // will be taken from unit
        sidePenalty = null;
    }
    if (ref.getObj(source) instanceof BattleFieldObject)
        bfObj = ((BattleFieldObject) ref.getObj(source));
    else {
    // TODO
    }
    FACING_DIRECTION facing = bfObj.getFacing();
    if (circular) {
        backwardRange = range;
        facing = FACING_DIRECTION.NORTH;
    } else {
        sidePenalty = 1;
    }
    List<Coordinates> coordinates = new ArrayList<>(getGame().getVisionMaster().getSightMaster().getSpectrumCoordinates(range, sidePenalty, backwardRange, bfObj, vision, facing));
    // boolean x-ray ++ tall/short/etc
    if (effects == null) {
        initEffects();
    }
    for (Coordinates c : coordinates) {
        // TODO WHAT IF IT'S ON A DIFFERENT Z-LEVEL?
        // applyThrough = true; // ?
        // if (!applyThrough)
        // if (!(getGame().getObjectByCoordinate(c, true) instanceof
        // DC_Cell))
        // continue;
        DequeImpl<? extends Obj> objects = new DequeImpl<>(getGame().getObjectsOnCoordinate(getGame().getDungeon().getZ(), c, null, true, applyThrough));
        if (applyThrough) {
            objects.addCast(getGame().getCellByCoordinate(c));
        }
        for (Obj o : objects) {
            ref.setMatch(o.getId());
            if (filterConditions != null) {
                if (!filterConditions.preCheck(ref)) {
                    continue;
                }
            }
            Integer target = o.getId();
            // target = getGame().getCellByCoordinate(c).getId();
            if (getGame().getObjectById(target) == null) {
                continue;
            }
            for (Effect effect : effects.getEffects()) {
                Ref REF = Ref.getCopy(ref);
                REF.setTarget(target);
                if (reductionForDistance != null) {
                    // for the first time
                    effect.resetOriginalFormula();
                    // to set original
                    effect.resetOriginalFormula();
                    String reduction = reductionForDistance;
                    if (reductionForDistanceModifier != null)
                        reduction += (reductionForDistanceModifier);
                    Formula effectFormula = effect.getFormula();
                    reduction = reduction.replace(X, effectFormula.toString());
                    int distance = PositionMaster.getDistance(REF.getSourceObj(), REF.getTargetObj());
                    reduction = reduction.replace("distance", distance + "");
                    effectFormula.append(reduction);
                    // TODO
                    Integer amount = effectFormula.getInt(ref);
                    if (amount < 0) {
                        effect.setAmount(amount);
                    }
                    effect.setAmount(amount);
                }
                effect.apply(REF);
            }
        }
    }
    return true;
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Formula(main.system.math.Formula) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Obj(main.entity.obj.Obj) DC_Effect(eidolons.ability.effects.DC_Effect) Effect(main.ability.effects.Effect) DequeImpl(main.system.datatypes.DequeImpl)

Example 12 with DequeImpl

use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.

the class DC_ActionManager method resetActions.

@Override
public void resetActions(Entity entity) {
    if (!(entity instanceof Unit)) {
        return;
    }
    Unit unit = (Unit) entity;
    DequeImpl<ActiveObj> actives;
    // #1: reset prop with ids if nothing is changed
    // if (ListMaster.isNotEmpty(actives) && entity.isActivesReady()) {
    // entity.setProperty(ACTIVES, StringMaster
    // .constructContainer(StringMaster.convertToIdList(actives)));
    // return;
    // }
    actives = new DequeImpl<>();
    // #2: reset the list if prop has been modified (via Add/Remove effects
    // ++ items). They should set ActivesReady to false for that.
    // or upon init
    unit.setActionMap(new HashMap<>());
    // if (!unit.isStandardActionsAdded())
    if (!unit.isBfObj()) {
        actives.addAll(getStandardActions(unit));
    }
    String activesProp = entity.getProperty(ACTIVES);
    for (String typeName : StringMaster.open(activesProp)) {
        ObjType type = DataManager.getType(typeName, DC_TYPE.ACTIONS);
        DC_UnitAction action;
        if (type == null) {
            try {
                action = (DC_UnitAction) game.getObjectById(Integer.valueOf(typeName));
            } catch (Exception e) {
                continue;
            }
        } else {
            action = getOrCreateAction(typeName, entity);
        }
        // idList.add(action.getId() + "");
        actives.add(action);
    }
    // list = new DequeImpl<>(items);
    actives.removeIf(activeObj -> !isActionAvailable(activeObj, ExplorationMaster.isExplorationOn()));
    try {
        addSpecialActions(unit, actives);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    if (ExplorationMaster.isExplorationOn())
        try {
            actives.removeIf(activeObj -> unit.getGame().getDungeonMaster().getExplorationMaster().getActionHandler().isActivationDisabledByExploration((DC_ActiveObj) activeObj));
            List<DC_ActiveObj> actions = unit.getGame().getDungeonMaster().getExplorationMaster().getActionHandler().getExplorationActions(unit);
            actives.addAll(actions);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    unit.setActives(new ArrayList<>(actives));
    if (!unit.isBfObj()) {
        addHiddenActions(unit, unit.getActives());
    }
    try {
        constructActionMaps(unit);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    // entity.setProperty(ACTIVES, StringMaster
    // .constructContainer(StringMaster.convertToIdList(actives)));
    entity.setActivesReady(true);
    for (ActiveObj a : actives) {
        if (activesProp.contains(a.getName())) {
            activesProp += a.getName() + ";";
        }
    }
    entity.setProperty(ACTIVES, activesProp);
}
Also used : DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) Active(main.entity.obj.Active) Trap(eidolons.game.module.dungeoncrawl.objects.Trap) ActionManager(main.game.logic.generic.ActionManager) Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) ActionEnums(main.content.enums.entity.ActionEnums) Ref(main.entity.Ref) VariableManager(main.data.ability.construct.VariableManager) ExtraAttacksRule(eidolons.game.battlecraft.rules.combat.attack.extra_attack.ExtraAttacksRule) ACTION_TYPE(main.content.enums.entity.ActionEnums.ACTION_TYPE) Player(main.game.logic.battle.player.Player) Weaver(main.system.threading.Weaver) DC_TYPE(main.content.DC_TYPE) GenericEnums(main.content.enums.GenericEnums) DungeonLevelMaster(eidolons.game.module.dungeoncrawl.dungeon.DungeonLevelMaster) ItemEnums(main.content.enums.entity.ItemEnums) ContentManager(main.content.ContentManager) DC_Game(eidolons.game.core.game.DC_Game) ExplorationMaster(eidolons.game.module.dungeoncrawl.explore.ExplorationMaster) ActionType(main.entity.type.ActionType) PARAMETER(main.content.values.parameters.PARAMETER) UnitAnalyzer(eidolons.game.battlecraft.rules.UnitAnalyzer) DualAttackMaster(eidolons.game.battlecraft.rules.combat.attack.dual.DualAttackMaster) java.util(java.util) ActiveObj(main.entity.obj.ActiveObj) MicroGame(main.game.core.game.MicroGame) DequeImpl(main.system.datatypes.DequeImpl) PARAMS(eidolons.content.PARAMS) StringMaster(main.system.auxiliary.StringMaster) DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) STD_ACTION_MODES(main.content.CONTENT_CONSTS2.STD_ACTION_MODES) FleeRule(eidolons.game.battlecraft.rules.mechanics.FleeRule) FEATURE(eidolons.game.battlecraft.rules.RuleMaster.FEATURE) G_PROPS(main.content.values.properties.G_PROPS) ActionGenerator(eidolons.ability.ActionGenerator) LogMaster(main.system.auxiliary.log.LogMaster) ObjType(main.entity.type.ObjType) ListMaster(main.system.auxiliary.data.ListMaster) PROPS(eidolons.content.PROPS) Obj(main.entity.obj.Obj) KEYS(main.entity.Ref.KEYS) TrapMaster(eidolons.game.module.dungeoncrawl.objects.TrapMaster) Entity(main.entity.Entity) ACTION_TYPE_GROUPS(main.content.enums.entity.ActionEnums.ACTION_TYPE_GROUPS) DataManager(main.data.DataManager) RuleMaster(eidolons.game.battlecraft.rules.RuleMaster) Unit(eidolons.entity.obj.unit.Unit) UnitEnums(main.content.enums.entity.UnitEnums) EnumMaster(main.system.auxiliary.EnumMaster) ActiveObj(main.entity.obj.ActiveObj) ObjType(main.entity.type.ObjType) Unit(eidolons.entity.obj.unit.Unit)

Example 13 with DequeImpl

use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.

the class MiniGrid method refreshComp.

public void refreshComp(Integer index, Coordinates c, MiniObjComp objComp) {
    if (index != null) {
        this.comp.setComponentZOrder(objComp.getComp(), index);
    }
    DC_Obj obj = objComp.getObj();
    if (c == null) {
        c = obj.getCoordinates();
    }
    List<? extends DC_Obj> objects = getGame().getObjectsOnCoordinate(c);
    ArrayList<Unit> overlaying = new ArrayList<>();
    for (Unit o : map.getDungeon().getGame().getObjectsOnCoordinate(c)) {
        if (o.isOverlaying()) {
            overlaying.add(o);
        }
    }
    // TODO WHAT IF THERE ARE STACKED OBJECT + OVERLAYING??? FUTURE...
    // for non-Level Editor
    objComp.setObjects(new DequeImpl(objects).getRemoveAll(overlaying));
    // sort top?
    objComp.setObj(obj);
    // TODO WHAT ABOUT OVERLAYING OBJECTS?
    objComp.initSize(getSize());
    // Chronos.mark(obj + " objComp refresh");
    objComp.refresh();
// Chronos.logTimeElapsedForMark(obj + " objComp refresh");
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Unit(eidolons.entity.obj.unit.Unit) DequeImpl(main.system.datatypes.DequeImpl)

Example 14 with DequeImpl

use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.

the class JUnitClearshotTest method getObjects.

protected DequeImpl<? extends DC_Obj> getObjects(boolean inside, boolean cellsOrObjects) {
    DequeImpl<? extends DC_Obj> list = new DequeImpl<>();
    List<Coordinates> coordinates = getCoordinatesList(inside);
    coordinates = filterCoordinates(new ArrayList<>(coordinates));
    for (Coordinates c : coordinates) {
        if (cellsOrObjects)
            list.addCast(game.getCellByCoordinate(c));
        else
            list.addAllCast(game.getObjectsAt(c));
    }
    return list;
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) DequeImpl(main.system.datatypes.DequeImpl)

Example 15 with DequeImpl

use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.

the class BfObjInitializer method initContainedItems.

public DequeImpl<? extends DC_HeroItemObj> initContainedItems(PROPS prop, DequeImpl<? extends DC_HeroItemObj> list, boolean quick) {
    if (StringMaster.isEmpty(getProperty(prop))) {
        if (list == null) {
            return new DequeImpl<>();
        }
        if (list.isEmpty() || game.isSimulation()) {
            return new DequeImpl<>();
        }
    }
    if (list == null || (!game.isSimulation() && getEntity().isItemsInitialized())) {
        setProperty(prop, StringMaster.constructContainer(StringMaster.convertToIdList(list)));
    } else {
        List<String> idList = new ArrayList<>();
        Collection<DC_HeroItemObj> items = new ArrayList<>();
        for (String subString : StringMaster.open(getProperty(prop))) {
            ObjType type = DataManager.getType(subString, DC_ContentManager.getTypeForProperty(prop));
            // || !StringMaster.isInteger(subString)
            DC_HeroItemObj item = null;
            if (game.isSimulation()) {
                item = (DC_HeroItemObj) getGame().getSimulationObj(getEntity(), type, prop);
            }
            if (item == null) {
                if (type == null) {
                    item = (DC_HeroItemObj) game.getObjectById(StringMaster.getInteger(subString));
                } else {
                    item = ItemFactory.createItemObj(type, getEntity().getOriginalOwner(), getGame(), getRef(), quick);
                }
                if (item != null) {
                    if (!game.isSimulation()) {
                        idList.add(item.getId() + "");
                    } else {
                        getGame().addSimulationObj(getEntity(), type, item, prop);
                    }
                }
            }
            if (item == null) {
                LogMaster.log(1, getName() + " has null items in item container " + prop);
            } else {
                items.add(item);
            }
        }
        list = new DequeImpl<>(items);
        if (!game.isSimulation()) {
            setProperty(prop, StringMaster.constructContainer(idList));
        }
    }
    if (list == null) {
        return new DequeImpl<>();
    }
    return list;
}
Also used : ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj) DequeImpl(main.system.datatypes.DequeImpl)

Aggregations

DequeImpl (main.system.datatypes.DequeImpl)16 Coordinates (main.game.bf.Coordinates)8 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)7 Unit (eidolons.entity.obj.unit.Unit)6 ArrayList (java.util.ArrayList)4 Obj (main.entity.obj.Obj)4 Vector2 (com.badlogic.gdx.math.Vector2)3 DC_Obj (eidolons.entity.obj.DC_Obj)3 DC_Game (eidolons.game.core.game.DC_Game)3 Entrance (eidolons.game.module.dungeoncrawl.dungeon.Entrance)3 Ref (main.entity.Ref)3 Gdx (com.badlogic.gdx.Gdx)2 Keys (com.badlogic.gdx.Input.Keys)2 Batch (com.badlogic.gdx.graphics.g2d.Batch)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)2 Group (com.badlogic.gdx.scenes.scene2d.Group)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 Align (com.badlogic.gdx.utils.Align)2