use of main.entity.Ref in project Eidolons by IDemiurge.
the class AiExecutor method execute.
public boolean execute(Action action, boolean free) {
boolean result = false;
Ref ref = action.getRef();
if (free) {
action.getActive().setFree(true);
}
try {
if (!action.getActive().isChanneling()) {
if (ref.getTargetObj() == null) {
if (!(action.getActive().getTargeting() instanceof SelectiveTargeting)) {
result = true;
action.getActive().getHandler().activateOnGameLoopThread();
}
}
}
if (!result) {
action.getActive().getHandler().activateOn(ref);
result = true;
}
// WaitMaster.waitForInput(WAIT_OPERATIONS.ACTION_COMPLETE);
return result;
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
action.getActive().setFree(false);
}
return result;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class ActionSequenceConstructor method getSequences.
private List<ActionSequence> getSequences(Task task, DC_ActiveObj active) {
List<ActionSequence> sequences = new ArrayList<>();
Ref ref = task.getUnit().getRef().getCopy();
Integer arg = TaskManager.checkTaskArgReplacement(task, active);
// if (arg == null) {
// if (isArgNeeded(active)) return;
// }
ref.setTarget(arg);
List<ActionSequence> newSequences = null;
Action action = AiActionFactory.newAction(active, ref);
action.setTask(task);
try {
newSequences = getSequencesWithPathsForAction(action, task.getArg(), task);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (ListMaster.isNotEmpty(newSequences)) {
sequences.addAll(newSequences);
} else {
// if no pathing is required/available [QUICK FIX]
if (!action.canBeTargetedOnAny()) {
return sequences;
}
ActionSequence sequence = constructSingleActionSequence(action, task);
if (sequence != null) {
if (active.isRanged()) {
sequences.addAll(AiUnitActionMaster.splitRangedSequence(sequence));
} else {
sequences.add(sequence);
}
} else {
// if (unit.getUnitAI().getLogLevel() > UnitAI.LOG_LEVEL_NONE)
// TODO smarter logging?
// main.system.auxiliary.LogMaster.log(1, "***" +
// action.toString()
// + " could not be constructed into an action sequence!");
// return;
}
}
return sequences;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class DC_Masteries method boostParameter.
private void boostParameter(int i, PARAMS p, MOD modval) {
Ref ref = new Ref(hero.getGame(), hero.getId());
ref.setTarget(hero.getId());
ref.setBase(true);
ref.setQuiet(true);
new ModifyValueEffect(p, modval, i + "").apply(ref);
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class BehaviorMaster method getAction.
private Action getAction(GOAL_TYPE type, UnitAI ai) {
String action = null;
Integer target = null;
// doesn't the group have standing orders as a whole?..
Unit unit = ai.getUnit();
Ref ref = new Ref(unit);
GroupAI group = ai.getGroup();
// checkBehaviorChange(group); where does that happen?
switch(type) {
case AMBUSH:
break;
case STALK:
break;
case STAND_GUARD:
case PATROL:
PatrolMaster.getPatrolAction(ai);
// having already turned on the Mode
case SEARCH:
case WANDER:
if (ai.isLeader()) {
Boolean change = WanderAi.checkWanderDirectionChange(group, type);
if (change == null) {
action = getIdleAction(ai, type);
change = true;
}
// maybe go meet leader if blocked... or something like it
if (change) {
group.getWanderStepCoordinateStack().push(group.getLeader().getCoordinates());
WanderAi.changeGroupMoveDirection(group, type);
}
}
boolean wait = false;
// ActionSequenceConstructor.getSequence(targetAction, task)
Coordinates targetCoordinates = WanderAi.getCoordinates(type, ai);
if (targetCoordinates == null) {
wait = true;
// if (!recursion)
// return null;
// recursion = true;
// return getAction(type, ai);
} else {
action = STD_ACTIONS.Move.name();
// if (!unit.getAction(action).canBeActivated()) {
// }
ActionPath path = getPathBuilder().init(new ListMaster<DC_ActiveObj>().getList(unit.getAction(action)), new Action(unit.getAction(action), new Ref(unit))).getPathByPriority(new ListMaster<Coordinates>().getList(targetCoordinates));
if (path == null) {
// TODO preCheck if path
ai.setPathBlocked(true);
// appropriate
} else {
ai.setPathBlocked(false);
return path.getActions().get(0);
}
}
if (wait) {
action = getIdleAction(ai, type);
} else {
// if (change) {
// targetCoordinates = WanderMaster.getCoordinates(type,
// ai);
// }
// return path.getActions().getOrCreate(0);
}
}
DC_ActiveObj active = unit.getAction(action);
ref.setTarget(target);
recursion = false;
return new Action(active, ref);
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class DC_HeroSlotItem method applySpecialEffects.
public void applySpecialEffects(SPECIAL_EFFECTS_CASE case_type, DC_UnitModel target, Ref REF) {
if (specialEffects == null) {
return;
}
if (specialEffects.get(case_type) == null) {
return;
}
Ref ref = Ref.getCopy(REF);
ref.setTarget(target.getId());
ref.setSource(getOwnerObj().getId());
Effect effect = specialEffects.get(case_type);
effect.apply(ref);
}
Aggregations