Search in sources :

Example 1 with LookAtAction

use of com.bladecoder.engine.actions.LookAtAction 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();
}
Also used : LookAtAction(com.bladecoder.engine.actions.LookAtAction) SayAction(com.bladecoder.engine.actions.SayAction) SetCutmodeAction(com.bladecoder.engine.actions.SetCutmodeAction) Action(com.bladecoder.engine.actions.Action) LookAtAction(com.bladecoder.engine.actions.LookAtAction) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) SayAction(com.bladecoder.engine.actions.SayAction) Scene(com.bladecoder.engine.model.Scene) SetCutmodeAction(com.bladecoder.engine.actions.SetCutmodeAction) Verb(com.bladecoder.engine.model.Verb) BaseActor(com.bladecoder.engine.model.BaseActor)

Aggregations

Action (com.bladecoder.engine.actions.Action)1 LookAtAction (com.bladecoder.engine.actions.LookAtAction)1 SayAction (com.bladecoder.engine.actions.SayAction)1 SetCutmodeAction (com.bladecoder.engine.actions.SetCutmodeAction)1 BaseActor (com.bladecoder.engine.model.BaseActor)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 Scene (com.bladecoder.engine.model.Scene)1 Verb (com.bladecoder.engine.model.Verb)1