use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.
the class DC_HeroManager method addQuickItem_.
private int addQuickItem_(Unit hero, DC_HeroItemObj itemObj) {
hero.removeFromInventory(itemObj);
// } else
if (itemObj instanceof DC_WeaponObj) {
hero.getQuickItems().add(new DC_QuickItemObj(itemObj.getType(), hero.getOwner(), game, hero.getRef(), true));
} else {
hero.getQuickItems().add((DC_QuickItemObj) itemObj);
}
update(hero);
return 1;
}
use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.
the class PanelActionsDataSource method getQuickSlotActions.
@Override
public List<ActionValueContainer> getQuickSlotActions() {
final DequeImpl<DC_QuickItemObj> items = unit.getQuickItems();
if (items == null)
return (List<ActionValueContainer>) ListMaster.fillWithNullElements(new ArrayList<ActionValueContainer>(), unit.getRemainingQuickSlots());
List<ActionValueContainer> list = items.stream().map((DC_QuickItemObj key) -> {
boolean valid = key.getActive().canBeManuallyActivated();
final ActionValueContainer valueContainer = new ActionValueContainer(valid, getOrCreateR(key.getImagePath()), key::invokeClicked);
ActionCostTooltip tooltip = new ActionCostTooltip(key.getActive());
tooltip.setUserObject(new ActionCostSourceImpl(key.getActive()));
valueContainer.addListener(tooltip.getController());
return valueContainer;
}).collect(Collectors.toList());
ObjType type = DataManager.getType(StringMaster.getWellFormattedString(STD_SPEC_ACTIONS.Use_Inventory.name()), DC_TYPE.ACTIONS);
TextureRegion invTexture = TextureCache.getOrCreateR(type.getImagePath());
DC_UnitAction action = unit.getAction(StringMaster.getWellFormattedString(STD_SPEC_ACTIONS.Use_Inventory.name()));
if (action == null)
return list;
boolean valid = action.canBeManuallyActivated();
ActionValueContainer invButton = new ActionValueContainer(valid, invTexture, () -> {
action.clicked();
});
list.add(invButton);
for (int i = 0; i < unit.getRemainingQuickSlots() - 1; i++) {
list.add(null);
}
return list;
}
use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.
the class RadialManager method configureAttackParentNode.
protected static RadialValueContainer configureAttackParentNode(List<RadialValueContainer> list, RADIAL_PARENT_NODE parentNode, DC_Obj target, DC_ActiveObj parent) {
if (parent.getActiveWeapon().isRanged()) {
if (parent.getRef().getObj(Ref.KEYS.AMMO) == null) {
for (DC_QuickItemObj ammo : parent.getOwnerObj().getQuickItems()) {
final RadialValueContainer valueContainer = new RadialValueContainer(getOrCreateR(ammo.getImagePath()), getRunnable(target, ammo.getActive()));
addSimpleTooltip(valueContainer, ammo.getName());
list.add(valueContainer);
}
}
}
RadialValueContainer valueContainer = new RadialValueContainer(new TextureRegion(getTextureForActive(parent, target)), null, checkValid(parent, target), parent, target);
addSimpleTooltip(valueContainer, parentNode.getName());
valueContainer.setChildNodes(list);
return valueContainer;
}
use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.
the class AmmoEffect method applyThis.
@Override
public boolean applyThis() {
DC_WeaponObj rangedWeapon = (DC_WeaponObj) ref.getObj(KEYS.RANGED);
if (add) {
DC_QuickItemObj ammo = (DC_QuickItemObj) ref.getActive().getRef().getObj(KEYS.AMMO);
rangedWeapon.setAmmo(ammo);
} else {
rangedWeapon.setAmmo(null);
}
return true;
}
use of eidolons.entity.item.DC_QuickItemObj in project Eidolons by IDemiurge.
the class TossItemEffect method applyThis.
/*
* size? from hand?
*
* interrupt?
*/
@Override
public boolean applyThis() {
Unit source = (Unit) ref.getSourceObj();
Ref REF = ref.getCopy();
conditions = new OrConditions(DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_ITEM), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.MY_WEAPON));
if (!new SelectiveTargeting(conditions).select(REF)) {
ref.getActive().setCancelled(true);
return false;
}
DC_HeroItemObj item = (DC_HeroItemObj) REF.getTargetObj();
conditions = new Conditions(// ++ Max distance?
new DistanceCondition(ref.getActive().getIntParam(PARAMS.RANGE, false) + ""), // new NumericCondition("{match_c_n_of_actions}", "1"),
new CanActCondition(KEYS.MATCH), new NotCondition(ConditionMaster.getSelfFilterCondition()), DC_ConditionMaster.getSelectiveTargetingTemplateConditions(SELECTIVE_TARGETING_TEMPLATES.ANY_ALLY));
// non-immobile, ++facing?
if (!new SelectiveTargeting(conditions).select(REF)) {
ref.getActive().setCancelled(true);
return false;
}
Unit unit = (Unit) REF.getTargetObj();
boolean result = roll(source, unit, item);
if (item instanceof DC_QuickItemObj) {
DC_QuickItemObj quickItem = (DC_QuickItemObj) item;
source.removeQuickItem(quickItem);
if (result) {
unit.addQuickItem(quickItem);
} else {
dropped(item, unit);
}
} else {
source.unequip(item, null);
if (result) {
// TODO equip in hand if
unit.addItemToInventory(item);
} else // possible? spend AP?
{
dropped(item, unit);
}
}
// ref.getObj(KEYS.ITEM);
unit.modifyParameter(PARAMS.C_N_OF_ACTIONS, -1);
return true;
}
Aggregations