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);
}
}
}
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);
}
}
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);
}
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);
}
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);
}
}
}
}
Aggregations