Search in sources :

Example 1 with ITEM_SLOT

use of main.content.enums.entity.ItemEnums.ITEM_SLOT 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)

Example 2 with ITEM_SLOT

use of main.content.enums.entity.ItemEnums.ITEM_SLOT in project Eidolons by IDemiurge.

the class HeroItemSlots method init.

public void init() {
    for (ITEM_SLOT slot : ItemEnums.ITEM_SLOT.values()) {
        Entity type = null;
        switch(slot) {
            case ARMOR:
                type = getType(slot, DC_TYPE.ARMOR);
                break;
            case MAIN_HAND:
                type = getType(slot, DC_TYPE.WEAPONS);
                break;
            case OFF_HAND:
                type = getType(slot, DC_TYPE.WEAPONS);
                break;
        }
        initItem(slot, type);
    }
}
Also used : ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) Entity(main.entity.Entity)

Example 3 with ITEM_SLOT

use of main.content.enums.entity.ItemEnums.ITEM_SLOT in project Eidolons by IDemiurge.

the class ItemCondition method check.

@Override
public boolean check(Ref ref) {
    if (ref.getGame().isSimulation()) {
        return true;
    }
    if (slot == null) {
        slot = (weapon) ? ItemEnums.ITEM_SLOT.MAIN_HAND.toString() : ItemEnums.ITEM_SLOT.ARMOR.toString();
    }
    Entity item;
    Unit unit = (Unit) ref.getObj(obj_ref);
    if (unit == null) {
        return false;
    }
    if (slot.equalsIgnoreCase(KEYS.RANGED.toString())) {
        item = unit.getRef().getObj(KEYS.RANGED);
    } else {
        if (slot.equalsIgnoreCase("weapon"))
            item = unit.getItem(!ref.getActive().isOffhand() ? ITEM_SLOT.MAIN_HAND : ITEM_SLOT.OFF_HAND);
        else
            item = unit.getItem(new EnumMaster<ITEM_SLOT>().retrieveEnumConst(ITEM_SLOT.class, slot, true));
    }
    if (item == null) {
        return false;
    }
    if (// any item in the slot
    prop == null) {
        return true;
    }
    String string = item.getProp(prop);
    return new StringComparison(string, val, strict).preCheck(ref);
// String prop2 = ref.getObj(obj_string).getProp(slot);
// if (StringMaster.isEmpty(prop2)) {
// try {
// prop2 = "" + ref.getObj(obj_string).getRef().getObj(slot).getId();
// } catch (Exception e) {
// return false;
// }
// }
// item = DataManager.getType(prop2, C_OBJ_TYPE.ITEMS);
// return StringMaster.compare(string, val, true);
}
Also used : Entity(main.entity.Entity) ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) StringComparison(main.elements.conditions.StringComparison) EnumMaster(main.system.auxiliary.EnumMaster) Unit(eidolons.entity.obj.unit.Unit)

Example 4 with ITEM_SLOT

use of main.content.enums.entity.ItemEnums.ITEM_SLOT in project Eidolons by IDemiurge.

the class EquipEffect method applyThis.

@Override
public boolean applyThis() {
    if (item == null) {
        if (quickItem) {
            item = (DC_HeroItemObj) ref.getObj(KEYS.ITEM);
        } else {
            item = (DC_HeroItemObj) ref.getObj((weapon) ? KEYS.WEAPON : KEYS.ARMOR);
        }
    }
    // preCheck if item can be equipped at all!
    Unit hero = (Unit) ref.getTargetObj();
    ITEM_SLOT slot = ItemEnums.ITEM_SLOT.ARMOR;
    // preCheck if main hand is occupied
    boolean mainHand = true;
    // item.getProp(prop)
    if (hero.getMainWeapon() != null && hero.getOffhandWeapon() == null) {
        mainHand = false;
    }
    if (weapon || quickItem) {
        slot = (mainHand || quickItem) ? ItemEnums.ITEM_SLOT.MAIN_HAND : ItemEnums.ITEM_SLOT.OFF_HAND;
    }
    ref.setID((weapon || quickItem) ? KEYS.WEAPON : KEYS.ARMOR, item.getId());
    return hero.equip(item, slot);
}
Also used : ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) Unit(eidolons.entity.obj.unit.Unit)

Example 5 with ITEM_SLOT

use of main.content.enums.entity.ItemEnums.ITEM_SLOT in project Eidolons by IDemiurge.

the class InventoryTransactionManager method equipOriginalItems.

public static void equipOriginalItems(Unit to, Obj from) {
    for (Obj i : to.getGame().getDroppedItemManager().getDroppedItems(to.getGame().getCellByCoordinate(to.getCoordinates()))) {
        if (i.getRef().getSourceObj() == from) {
            ITEM_SLOT slot = null;
            if (i.getOBJ_TYPE_ENUM() == DC_TYPE.ARMOR) {
                slot = ItemEnums.ITEM_SLOT.ARMOR;
            } else {
                if (from.getRef().getObj(KEYS.WEAPON) == i) {
                    slot = ItemEnums.ITEM_SLOT.MAIN_HAND;
                } else if (from.getRef().getObj(KEYS.OFFHAND) == i) {
                    slot = ItemEnums.ITEM_SLOT.OFF_HAND;
                }
            }
            if (slot == null) {
                if (i instanceof DC_WeaponObj) {
                    DC_WeaponObj weaponObj = (DC_WeaponObj) i;
                    if (weaponObj.getWeaponClass() == ItemEnums.WEAPON_CLASS.MAIN_HAND_ONLY || weaponObj.getWeaponClass() == ItemEnums.WEAPON_CLASS.TWO_HANDED || weaponObj.getWeaponClass() == ItemEnums.WEAPON_CLASS.DOUBLE) {
                        slot = ItemEnums.ITEM_SLOT.MAIN_HAND;
                    } else if (to.getMainWeapon() != null) {
                        slot = ItemEnums.ITEM_SLOT.OFF_HAND;
                    } else {
                        slot = ItemEnums.ITEM_SLOT.MAIN_HAND;
                    }
                }
            }
            // ITEM_SLOT.MAIN_HAND;
            to.getGame().getDroppedItemManager().pickedUp(i);
            i.setRef(to.getRef());
            // equip() !
            if (slot == null) {
                to.getQuickItems().add((DC_QuickItemObj) i);
            } else {
                to.equip((DC_HeroItemObj) i, slot);
            }
        }
    }
}
Also used : ITEM_SLOT(main.content.enums.entity.ItemEnums.ITEM_SLOT) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) Obj(main.entity.obj.Obj) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj)

Aggregations

ITEM_SLOT (main.content.enums.entity.ItemEnums.ITEM_SLOT)5 Entity (main.entity.Entity)3 Unit (eidolons.entity.obj.unit.Unit)2 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 StringComparison (main.elements.conditions.StringComparison)1 Obj (main.entity.obj.Obj)1 EnumMaster (main.system.auxiliary.EnumMaster)1