use of main.entity.obj.ActiveObj in project Eidolons by IDemiurge.
the class DC_GameManager method checkSelectedObj.
private void checkSelectedObj(Obj obj) {
boolean selectionObj = selectingSet.contains(obj);
if (!selectionObj) {
if (C_OBJ_TYPE.BF_OBJ.equals(obj.getOBJ_TYPE_ENUM())) {
selectionObj = selectingSet.contains(getGame().getCellByCoordinate(obj.getCoordinates()));
}
}
if (!selectionObj) {
// if (MessageManager.confirm(CANCEL_SELECTING)) {
ActiveObj activatingAction = getActivatingAction();
if (activatingAction != null) {
activatingAction.playCancelSound();
}
selectingStopped(true);
return;
}
DC_SoundMaster.playStandardSound(STD_SOUNDS.CLICK_TARGET_SELECTED);
try {
selectingStopped(false);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
WaitMaster.receiveInput(WAIT_OPERATIONS.SELECT_BF_OBJ, obj.getId());
}
}
use of main.entity.obj.ActiveObj in project Eidolons by IDemiurge.
the class ActivesConstructor method constructActive.
public static void constructActive(TARGETING_MODE mode, DC_ActiveObj entity) {
if (mode == AbilityEnums.TARGETING_MODE.MULTI) {
addMultiTargetingMods(entity);
return;
}
if (entity.checkBool(GenericEnums.STD_BOOLS.MULTI_TARGETING)) {
// constructMultiAbilities(entity);
return;
}
if (entity.getActives() == null) {
return;
}
List<ActiveObj> list = new ArrayList<>(entity.getActives());
Effects effects = new Effects();
for (Active active : list) {
for (Ability abil : ((AbilityObj) active).getAbilities().getAbils()) {
for (Effect effect : abil.getEffects().getEffects()) {
// anything?
if (effect instanceof DC_Effect) {
DC_Effect effect2 = (DC_Effect) effect;
effect2.setAnimationActive(entity);
}
effects.add(effect);
}
}
}
// TODO what if the effects should have different targetings like in
// damage+light?
String saveRoll = entity.getProperty(PROPS.ROLL_TYPES_TO_SAVE);
if (!StringMaster.isEmpty(saveRoll)) {
wrapInSaveRollEffect(effects, saveRoll);
}
String wrap = entity.getProperty(PROPS.EFFECTS_WRAP);
Effect wrappedEffect;
if (StringMaster.isEmpty(wrap)) {
wrappedEffect = wrapEffects(mode, effects, entity);
} else {
EFFECTS_WRAP WRAP = new EnumMaster<EFFECTS_WRAP>().retrieveEnumConst(EFFECTS_WRAP.class, wrap);
wrappedEffect = wrapEffects(WRAP, effects, entity);
}
Targeting targeting = getTargeting(mode, entity);
if (targeting == null) {
try {
targeting = entity.getActives().get(0).getActives().get(0).getTargeting();
} catch (Exception e) {
// targeting = getDefaultSingleTargeting(entity);TODO necessary?
}
}
if (targeting != null)
entity.setTargeting(targeting);
Abilities abilities = new Abilities();
abilities.add(new ActiveAbility(null, wrappedEffect));
entity.setAbilities(abilities);
// TODO wrapping in RollEffect - each single effect or the resulting
// wrapped Effects?
}
use of main.entity.obj.ActiveObj in project Eidolons by IDemiurge.
the class TargetingMaster method findTargeting.
public static Targeting findTargeting(ActiveObj active, Class<SelectiveTargeting> CLASS) {
Targeting t = active.getTargeting();
if (checkTargeting(CLASS, t)) {
return t;
}
t = findTargetingInAbils(active, CLASS);
if (t != null) {
return t;
}
for (ActiveObj a : active.getActives()) {
if (// 2 layers maximum, i hope
active instanceof DC_ActiveObj) {
t = findTargeting(a, CLASS);
}
if (t != null) {
return t;
} else {
for (ActiveObj a2 : a.getActives()) {
t = findTargetingInAbils(a2, CLASS);
if (t != null) {
return t;
}
}
}
}
return null;
}
use of main.entity.obj.ActiveObj in project Eidolons by IDemiurge.
the class DC_ActionManager method newAction.
@Override
public DC_UnitAction newAction(String typeName, Entity entity) {
Map<String, ActiveObj> map = actionsCache.get(entity);
if (map == null) {
map = new HashMap<>();
actionsCache.put(entity, map);
}
if (map.get(typeName) != null) {
return (DC_UnitAction) map.get(typeName);
}
ActionType type = (ActionType) DataManager.getType(typeName, DC_TYPE.ACTIONS);
if (type == null) {
LogMaster.log(1, "no such active: " + typeName);
return null;
}
Ref ref = Ref.getCopy(entity.getRef());
return newAction(type, ref, entity.getOwner(), game);
}
use of main.entity.obj.ActiveObj 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);
}
Aggregations