Search in sources :

Example 1 with Entity

use of main.entity.Entity in project Eidolons by IDemiurge.

the class StackingRule method canBeMovedOnto.

private boolean canBeMovedOnto(Integer maxSpaceTakenPercentage, Entity unit, Coordinates c, Integer z, List<? extends Entity> otherUnits) {
    HashMap<Coordinates, Boolean> bools = cache.get(unit);
    boolean result = false;
    if (maxSpaceTakenPercentage == 100) {
        if (bools != null) {
            if (bools.containsKey(c)) {
                return bools.get(c);
            }
        } else {
            bools = new HashMap<>();
            cache.put(unit, bools);
        }
    }
    // get all units on the cell
    DequeImpl<? extends Entity> units = new DequeImpl<>(otherUnits);
    for (BattleFieldObject u : game.getObjectsOnCoordinate(z, c, false, false, false)) {
        if (!units.contains(u)) {
            if (!u.isAnnihilated())
                // continue; TODO why was Type necessary?
                units.addCast(!u.isDead() ? u.getType() : u);
            if (u.isWall())
                if (!u.isDead())
                    return false;
        }
    }
    // check if '1 unit per cell' is on
    if (maxSpaceTakenPercentage <= 0) {
        if (!units.isEmpty()) {
            return false;
        }
    }
    if (unit == null) {
        unit = DataManager.getType(HeroCreator.BASE_HERO, DC_TYPE.CHARS);
    }
    Obj cell;
    if (!game.isSimulation()) {
        cell = game.getCellByCoordinate(c);
    } else {
        cell = new DC_Cell(c, game);
    }
    if (cell == null) {
        return false;
    }
    if (z == null) {
        if (unit instanceof Unit) {
            Unit heroObj = (Unit) unit;
            z = heroObj.getZ();
        }
    }
    // TODO ???
    if (game.isSimulation()) {
        if (units.size() > 1) {
            return false;
        }
    }
    // no passable/overlaying!
    int space = StringMaster.getInteger(PARAMS.SPACE.getDefaultValue());
    if (c != null) {
        if (!game.isSimulation()) {
            space = cell.getIntParam(PARAMS.SPACE);
        }
    }
    int girth = 0;
    for (Entity u : units) {
        if (u == unit) {
            continue;
        }
        // }
        if (UnitAnalyzer.isWall(u)) {
            // if (!UnitAnalyzer.isFlying(unit)) {
            return false;
        // }
        }
        if (u.isDead())
            girth += u.getIntParam(PARAMS.GIRTH) / 3;
        else
            girth += u.getIntParam(PARAMS.GIRTH);
    // TODO  if (DoorMaster.isDoor((BattleFieldObject) u)) {
    // 
    // }
    // main.system.auxiliary.LogMaster.log(1, "****************** " +
    // u.getName()
    // + "'s Girth " + u.getIntParam(PARAMS.GIRTH));
    }
    // [QUICK FIX]
    if (unit.getIntParam(PARAMS.GIRTH) == 0) {
        girth += StringMaster.getInteger(PARAMS.GIRTH.getDefaultValue());
    } else {
        girth += unit.getIntParam(PARAMS.GIRTH);
    }
    // main.system.auxiliary.LogMaster.log(1, "****************** " + space
    // + " Space vs " + girth
    // + " Girth on " + c + " for " + unit);
    space = space * maxSpaceTakenPercentage / 100;
    if (space >= girth) {
        result = true;
    } else {
        if (unit.getIntParam(PARAMS.GIRTH) > space) {
            if (units.isEmpty()) {
                result = true;
            }
        }
    }
    if (// only cache for default cases!
    maxSpaceTakenPercentage == 100) {
        bools.put(c, result);
    }
    return result;
}
Also used : Entity(main.entity.Entity) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Cell(eidolons.entity.obj.DC_Cell) ActiveObj(main.entity.obj.ActiveObj) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Obj(main.entity.obj.Obj) DequeImpl(main.system.datatypes.DequeImpl)

Example 2 with Entity

use of main.entity.Entity in project Eidolons by IDemiurge.

the class DC_RequirementsManager method getRequirements.

@Override
public Requirements getRequirements(Entity type, int mode) {
    Map<Entity, Requirements> map = getReqMap(mode);
    if (map != null) {
        if (// TODO
        map.get(type) != null) {
            return map.get(type);
        }
    }
    Requirements req = null;
    OBJ_TYPE TYPE = type.getOBJ_TYPE_ENUM();
    if (TYPE instanceof DC_TYPE) {
        switch((DC_TYPE) TYPE) {
            case ARMOR:
                req = generateItemRequirements(type, mode);
                break;
            case ITEMS:
                req = generateItemRequirements(type, mode);
                break;
            case CLASSES:
                req = generateClassRequirements(type, mode);
                break;
            case SKILLS:
                req = generateSkillRequirements(type, mode);
                break;
            case SPELLS:
                req = generateSpellRequirements(type, mode);
                break;
            case WEAPONS:
                req = generateItemRequirements(type, mode);
                break;
            case UNITS:
                break;
            case ACTIONS:
                break;
            default:
                break;
        }
    }
    if (req == null) {
        return null;
    }
    String additionalRequirements = type.getProperty(PROPS.REQUIREMENTS);
    if (!StringMaster.isEmpty(additionalRequirements)) {
        try {
            req.addAll(toRequirements(additionalRequirements));
        } catch (Exception e) {
            LogMaster.log(1, type + "'s req failed! - " + additionalRequirements);
        // main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (type.isUpgrade() && TYPE != null) {
        Requirement baseTypeRequirement = getBaseTypeRequirement(type, TYPE);
        if (baseTypeRequirement != null) {
            req.add(baseTypeRequirement);
        }
    }
    if (map != null) {
        map.put(type, req);
    }
    return req;
}
Also used : Entity(main.entity.Entity) OBJ_TYPE(main.content.OBJ_TYPE) DC_TYPE(main.content.DC_TYPE)

Example 3 with Entity

use of main.entity.Entity in project Eidolons by IDemiurge.

the class T3InfoPanel method init.

public void init() {
    Entity skill = null;
    try {
        skill = CharacterCreator.getHero().getSkills().get(flipped ? 1 : 0);
    } catch (Exception e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    infoPanel = new DC_PagedInfoPanel(skill);
    ImageIcon icon = ImageManager.getEmptyItemIcon(flipped);
    if (skill != null) {
        icon = skill.getIcon();
    }
    label = new JLabel(icon);
    controlPanel = new G_Panel();
    controlPanel.setPanelSize(new Dimension(122, getPanelSize().height));
    costPool = new PoolComp(skill, PARAMS.XP_COST, "Experience cost", false);
    xpPool = new PoolComp(CharacterCreator.getHero(), PARAMS.XP, "Experience points", true) {
    };
    addComps();
}
Also used : Entity(main.entity.Entity) DC_PagedInfoPanel(eidolons.swing.components.panels.page.info.DC_PagedInfoPanel) PoolComp(eidolons.client.cc.gui.misc.PoolComp) G_Panel(main.swing.generic.components.G_Panel)

Example 4 with Entity

use of main.entity.Entity in project Eidolons by IDemiurge.

the class HeroItemSlots method getType.

private Entity getType(ITEM_SLOT slot, DC_TYPE TYPE) {
    if (hero.getItem(slot) != null) {
        return hero.getItem(slot);
    }
    String string = hero.getProperty(slot.getProp());
    Entity type = DataManager.getType(string, C_OBJ_TYPE.SLOT_ITEMS);
    if (type == null) {
        if (StringMaster.isInteger(string)) {
            Obj obj = hero.getGame().getObjectById(StringMaster.getInteger(string));
            if (obj != null) {
                type = obj.getType();
            } else {
                type = hero.getGame().getTypeById(StringMaster.getInteger(string));
            }
        }
    }
    return type;
}
Also used : Entity(main.entity.Entity) Obj(main.entity.obj.Obj)

Example 5 with Entity

use of main.entity.Entity in project Eidolons by IDemiurge.

the class HeroItemSlots method addComps.

private void addComps() {
    Boolean posSwitch = null;
    for (ITEM_SLOT slot : ItemEnums.ITEM_SLOT.values()) {
        ListItem<Entity> item = itemMap.get(slot);
        String pos;
        if (posSwitch == null) {
            pos = "@pos 32 0";
            posSwitch = true;
        } else if (posSwitch) {
            pos = "@pos " + MigMaster.getCenteredPosition(getSlotPanelWidth(), 64) + " 0";
            posSwitch = false;
        } else {
            pos = "@pos " + (getSlotPanelWidth() - 96) + " 0";
        }
        if (item == null) {
            if (slot != ItemEnums.ITEM_SLOT.ARMOR) {
                boolean offhand = slot == ItemEnums.ITEM_SLOT.OFF_HAND;
                if (hero.getNaturalWeapon(offhand) != null) {
                    item = initItem(slot, hero.getNaturalWeapon(offhand).getType());
                }
            }
        }
        if (item != null) {
            add(item, pos);
        }
    }
}
Also used : ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) Entity(main.entity.Entity)

Aggregations

Entity (main.entity.Entity)41 ObjType (main.entity.type.ObjType)11 Unit (eidolons.entity.obj.unit.Unit)7 PARAMETER (main.content.values.parameters.PARAMETER)5 Obj (main.entity.obj.Obj)5 OBJ_TYPE (main.content.OBJ_TYPE)4 Ref (main.entity.Ref)4 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)3 DC_PagedInfoPanel (eidolons.swing.components.panels.page.info.DC_PagedInfoPanel)3 ArrayList (java.util.ArrayList)3 DC_TYPE (main.content.DC_TYPE)3 ITEM_SLOT (main.content.enums.entity.ItemEnums.ITEM_SLOT)3 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)2 LinkedList (java.util.LinkedList)2 ActiveObj (main.entity.obj.ActiveObj)2 ArcaneEntity (main.logic.ArcaneEntity)2 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 ActionGenerator (eidolons.ability.ActionGenerator)1