use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class SpectrumEffect method applyThis.
public boolean applyThis() {
if (range == null)
range = new Formula(rangeFormula).getInt(ref);
Integer backwardRange = 0;
Integer sidePenalty = 0;
if (vision) {
range = new Formula(StringMaster.getValueRef(KEYS.SOURCE, PARAMS.SIGHT_RANGE)).getInt(ref);
// TODO
backwardRange = null;
// will be taken from unit
sidePenalty = null;
}
if (ref.getObj(source) instanceof BattleFieldObject)
bfObj = ((BattleFieldObject) ref.getObj(source));
else {
// TODO
}
FACING_DIRECTION facing = bfObj.getFacing();
if (circular) {
backwardRange = range;
facing = FACING_DIRECTION.NORTH;
} else {
sidePenalty = 1;
}
List<Coordinates> coordinates = new ArrayList<>(getGame().getVisionMaster().getSightMaster().getSpectrumCoordinates(range, sidePenalty, backwardRange, bfObj, vision, facing));
// boolean x-ray ++ tall/short/etc
if (effects == null) {
initEffects();
}
for (Coordinates c : coordinates) {
// TODO WHAT IF IT'S ON A DIFFERENT Z-LEVEL?
// applyThrough = true; // ?
// if (!applyThrough)
// if (!(getGame().getObjectByCoordinate(c, true) instanceof
// DC_Cell))
// continue;
DequeImpl<? extends Obj> objects = new DequeImpl<>(getGame().getObjectsOnCoordinate(getGame().getDungeon().getZ(), c, null, true, applyThrough));
if (applyThrough) {
objects.addCast(getGame().getCellByCoordinate(c));
}
for (Obj o : objects) {
ref.setMatch(o.getId());
if (filterConditions != null) {
if (!filterConditions.preCheck(ref)) {
continue;
}
}
Integer target = o.getId();
// target = getGame().getCellByCoordinate(c).getId();
if (getGame().getObjectById(target) == null) {
continue;
}
for (Effect effect : effects.getEffects()) {
Ref REF = Ref.getCopy(ref);
REF.setTarget(target);
if (reductionForDistance != null) {
// for the first time
effect.resetOriginalFormula();
// to set original
effect.resetOriginalFormula();
String reduction = reductionForDistance;
if (reductionForDistanceModifier != null)
reduction += (reductionForDistanceModifier);
Formula effectFormula = effect.getFormula();
reduction = reduction.replace(X, effectFormula.toString());
int distance = PositionMaster.getDistance(REF.getSourceObj(), REF.getTargetObj());
reduction = reduction.replace("distance", distance + "");
effectFormula.append(reduction);
// TODO
Integer amount = effectFormula.getInt(ref);
if (amount < 0) {
effect.setAmount(amount);
}
effect.setAmount(amount);
}
effect.apply(REF);
}
}
}
return true;
}
use of main.system.datatypes.DequeImpl 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);
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class MiniGrid method refreshComp.
public void refreshComp(Integer index, Coordinates c, MiniObjComp objComp) {
if (index != null) {
this.comp.setComponentZOrder(objComp.getComp(), index);
}
DC_Obj obj = objComp.getObj();
if (c == null) {
c = obj.getCoordinates();
}
List<? extends DC_Obj> objects = getGame().getObjectsOnCoordinate(c);
ArrayList<Unit> overlaying = new ArrayList<>();
for (Unit o : map.getDungeon().getGame().getObjectsOnCoordinate(c)) {
if (o.isOverlaying()) {
overlaying.add(o);
}
}
// TODO WHAT IF THERE ARE STACKED OBJECT + OVERLAYING??? FUTURE...
// for non-Level Editor
objComp.setObjects(new DequeImpl(objects).getRemoveAll(overlaying));
// sort top?
objComp.setObj(obj);
// TODO WHAT ABOUT OVERLAYING OBJECTS?
objComp.initSize(getSize());
// Chronos.mark(obj + " objComp refresh");
objComp.refresh();
// Chronos.logTimeElapsedForMark(obj + " objComp refresh");
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class JUnitClearshotTest method getObjects.
protected DequeImpl<? extends DC_Obj> getObjects(boolean inside, boolean cellsOrObjects) {
DequeImpl<? extends DC_Obj> list = new DequeImpl<>();
List<Coordinates> coordinates = getCoordinatesList(inside);
coordinates = filterCoordinates(new ArrayList<>(coordinates));
for (Coordinates c : coordinates) {
if (cellsOrObjects)
list.addCast(game.getCellByCoordinate(c));
else
list.addAllCast(game.getObjectsAt(c));
}
return list;
}
use of main.system.datatypes.DequeImpl in project Eidolons by IDemiurge.
the class BfObjInitializer method initContainedItems.
public DequeImpl<? extends DC_HeroItemObj> initContainedItems(PROPS prop, DequeImpl<? extends DC_HeroItemObj> list, boolean quick) {
if (StringMaster.isEmpty(getProperty(prop))) {
if (list == null) {
return new DequeImpl<>();
}
if (list.isEmpty() || game.isSimulation()) {
return new DequeImpl<>();
}
}
if (list == null || (!game.isSimulation() && getEntity().isItemsInitialized())) {
setProperty(prop, StringMaster.constructContainer(StringMaster.convertToIdList(list)));
} else {
List<String> idList = new ArrayList<>();
Collection<DC_HeroItemObj> items = new ArrayList<>();
for (String subString : StringMaster.open(getProperty(prop))) {
ObjType type = DataManager.getType(subString, DC_ContentManager.getTypeForProperty(prop));
// || !StringMaster.isInteger(subString)
DC_HeroItemObj item = null;
if (game.isSimulation()) {
item = (DC_HeroItemObj) getGame().getSimulationObj(getEntity(), type, prop);
}
if (item == null) {
if (type == null) {
item = (DC_HeroItemObj) game.getObjectById(StringMaster.getInteger(subString));
} else {
item = ItemFactory.createItemObj(type, getEntity().getOriginalOwner(), getGame(), getRef(), quick);
}
if (item != null) {
if (!game.isSimulation()) {
idList.add(item.getId() + "");
} else {
getGame().addSimulationObj(getEntity(), type, item, prop);
}
}
}
if (item == null) {
LogMaster.log(1, getName() + " has null items in item container " + prop);
} else {
items.add(item);
}
}
list = new DequeImpl<>(items);
if (!game.isSimulation()) {
setProperty(prop, StringMaster.constructContainer(idList));
}
}
if (list == null) {
return new DequeImpl<>();
}
return list;
}
Aggregations