use of main.entity.Entity in project Eidolons by IDemiurge.
the class SituationAnalyzer method getRangedDangerFactor.
public int getRangedDangerFactor(Unit unit) {
int factor = 0;
for (Entity e : Analyzer.getVisibleEnemies(unit.getAI())) {
Unit enemy = (Unit) e;
try {
int rangedThreat = getThreatAnalyzer().getRangedThreat(unit, enemy);
factor += rangedThreat;
LogMaster.log(LOG_CHANNEL.AI_DEBUG, "Ranged threat " + rangedThreat + " from " + enemy.getName());
} catch (Exception ex) {
main.system.ExceptionMaster.printStackTrace(ex);
}
}
int mod = getConstInt(AiConst.DANGER_RANGED_BASE) - ParamPriorityAnalyzer.getUnitLifeFactor(unit);
LogMaster.log(LOG_CHANNEL.AI_DEBUG, "Ranged threat mod " + mod + " for " + unit.getName());
if (mod != 0) {
factor = factor * mod / 100;
}
LogMaster.log(LOG_CHANNEL.AI_DEBUG, "Ranged threat factor " + factor + " for " + unit.getName());
return factor;
}
use of main.entity.Entity in project Eidolons by IDemiurge.
the class TestScriptExecutor method doHighlight.
private void doHighlight(Ref ref, String[] args) {
// GuiEventManager.trigger(GuiEventType.HIGHLIGHT_OFF);
String nameOrKey = args[0];
ObjType type = DataManager.getType(nameOrKey);
Entity entity = null;
if (type != null) {
DC_TYPE TYPE = (DC_TYPE) type.getOBJ_TYPE_ENUM();
entity = findEntity(nameOrKey, ref, TYPE);
} else {
entity = ref.getObj(nameOrKey);
}
// GuiEventManager.trigger(GuiEventType.HIGHLIGHT, entity);
}
use of main.entity.Entity 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.entity.Entity in project Eidolons by IDemiurge.
the class CharacterCreator method typeSelected.
public static void typeSelected(final Entity type) {
if (type != null) {
DC_Game.game.getValueHelper().setEntity(type);
}
if (Launcher.getView() == VIEWS.T3) {
HC_Master.getT3View().selected(type);
return;
}
DC_PagedInfoPanel firstPanel = getHeroPanel().getMiddlePanel().getUpperPanel();
Entity entity = firstPanel.getEntity();
firstPanel.setEntity(type);
firstPanel.refresh();
try {
getHeroPanel().getMiddlePanel().getArc().getUpperIcon().setIcon(new ImageIcon(type.getImage()));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
DC_PagedInfoPanel secondPanel = getHeroPanel().getMiddlePanel().getLowerPanel();
if (secondPanel != null) {
secondPanel.setEntity(entity);
secondPanel.refresh();
try {
getHeroPanel().getMiddlePanel().getArc().getLowerIcon().setIcon(new ImageIcon(entity.getImage()));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
use of main.entity.Entity in project Eidolons by IDemiurge.
the class HeroManager method stepBack.
// for HC
public void stepBack(Unit hero) {
if (!game.isSimulation()) {
return;
}
Stack<ObjType> stack = typeStacks.get(hero);
if (stack == null) {
return;
}
Entity type = stack.pop();
applyChangedType(true, hero, type);
CharacterCreator.setSelectedHeroType(hero.getType());
if (CharacterCreator.getPanel().isPrincipleView()) {
CharacterCreator.getPanel().getPrincipleViewComp().reset();
}
}
Aggregations