use of com.bladecoder.engine.actions.SetCutmodeAction in project bladecoder-adventure-engine by bladecoder.
the class ModelTools method addCutMode.
public static final void addCutMode() {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (Scene scn : scenes.values()) {
Map<String, BaseActor> actors = scn.getActors();
for (BaseActor a : actors.values()) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
// Don't process verbs for inventory
if (v.getState() != null && v.getState().equalsIgnoreCase("INVENTORY"))
continue;
if (actions.size() == 1) {
Action act = actions.get(0);
if (act instanceof LookAtAction || act instanceof SayAction) {
actions.clear();
SetCutmodeAction cma1 = new SetCutmodeAction();
SetCutmodeAction cma2 = new SetCutmodeAction();
try {
ActionUtils.setParam(cma1, "value", "true");
ActionUtils.setParam(cma2, "value", "false");
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
EditorLogger.printStackTrace(e);
}
actions.add(cma1);
actions.add(act);
actions.add(cma2);
}
}
}
}
}
}
Ctx.project.setModified();
}
use of com.bladecoder.engine.actions.SetCutmodeAction in project bladecoder-adventure-engine by bladecoder.
the class CheckCutmodeEnd method visit.
@Override
public void visit(Scene s, InteractiveActor a, Verb v) {
ArrayList<Action> actions = v.getActions();
if (actions.size() > 0) {
Action action = actions.get(actions.size() - 1);
if (action instanceof SetCutmodeAction) {
try {
String val = ActionUtils.getStringValue(action, "value");
if ("true".equals(val)) {
StringBuilder sb = new StringBuilder("CheckCutmodeEnd: Cutmode ends with value=true! - ");
if (s != null) {
sb.append(s.getId());
sb.append(".");
}
if (a != null) {
sb.append(a.getId());
sb.append(".");
}
sb.append(v.getId());
EditorLogger.error(sb.toString());
}
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
}
}
}
}
Aggregations