use of com.bladecoder.engine.model.Verb in project bladecoder-adventure-engine by bladecoder.
the class VerbList method paste.
@Override
protected void paste() {
Verb newElement = (Verb) ElementUtils.cloneElement(clipboard);
// Check for id duplicates
String[] keys = new String[parent.getVerbs().size()];
Verb[] values = parent.getVerbs().values().toArray(new Verb[0]);
for (int i = 0; i < keys.length; i++) {
keys[i] = values[i].getId();
}
newElement.setId(ElementUtils.getCheckedId(newElement.getId(), keys));
int pos = list.getSelectedIndex() + 1;
list.getItems().insert(pos, newElement);
parent.addVerb(newElement);
if (scopePanel.getScope().equals(ScopePanel.WORLD_SCOPE))
Ctx.project.getI18N().extractStrings(null, null, newElement);
else if (scopePanel.getScope().equals(ScopePanel.SCENE_SCOPE))
Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), null, newElement);
else
Ctx.project.getI18N().extractStrings(Ctx.project.getSelectedScene().getId(), Ctx.project.getSelectedActor().getId(), newElement);
list.setSelectedIndex(pos);
list.invalidateHierarchy();
Ctx.project.setModified();
}
use of com.bladecoder.engine.model.Verb in project bladecoder-adventure-engine by bladecoder.
the class ModelWalker method walk.
public void walk(World w) {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (StartVisitor sv : startVisitors) sv.start(w);
for (Scene scn : scenes.values()) {
for (SceneVisitor sv : sceneVisitors) sv.visit(scn);
Map<String, BaseActor> actors = scn.getActors();
// SCENE VERBS
HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
for (VerbVisitor vv : verbVisitors) vv.visit(scn, null, v);
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
for (ActionVisitor av : actionVisitors) av.visit(scn, null, v, act);
}
}
for (BaseActor a : actors.values()) {
for (ActorVisitor av : actorVisitors) av.visit(a);
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
// ACTOR VERBS
verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
for (VerbVisitor vv : verbVisitors) vv.visit(scn, ia, v);
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
for (ActionVisitor av : actionVisitors) av.visit(scn, ia, v, act);
}
}
}
// DIALOGS
if (a instanceof CharacterActor) {
HashMap<String, Dialog> dialogs = ((CharacterActor) a).getDialogs();
if (dialogs != null) {
for (Dialog d : dialogs.values()) {
for (DialogVisitor dv : dialogVisitors) dv.visit((CharacterActor) a, d);
ArrayList<DialogOption> options = d.getOptions();
for (DialogOption o : options) {
for (DialogOptionVisitor ov : optionVisitors) ov.visit((CharacterActor) a, d, o);
}
}
}
}
}
}
for (EndVisitor ev : endVisitors) ev.end(w);
}
use of com.bladecoder.engine.model.Verb in project bladecoder-adventure-engine by bladecoder.
the class CheckInteractionVerbs method visit.
@Override
public void visit(BaseActor a) {
if (a instanceof InteractiveActor) {
ia = (InteractiveActor) a;
hasLookat = false;
hasPickup = false;
hasTalkto = false;
hasLeave = false;
hasEnterExit = false;
hasUse = false;
if (ia.getInteraction()) {
HashMap<String, Verb> verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) checkVerb(v);
if (hasLeave || hasEnterExit)
return;
// discard inventory actors
if (hasLookat) {
if (ia instanceof SpriteActor) {
SpriteActor sa = (SpriteActor) ia;
if (sa.getRenderer() instanceof AtlasRenderer) {
AtlasRenderer r = (AtlasRenderer) sa.getRenderer();
HashMap<String, AnimationDesc> animations = r.getAnimations();
if (animations.size() == 0) {
EditorLogger.error("CheckInteractionVerbs: Actor with no animations! - " + sa.getScene().getId() + "." + sa.getId());
}
if (animations.get(r.getInitAnimation()).source.contains("inventory")) {
if (!hasUse)
EditorLogger.msg("CheckInteractionVerbs: Inventory item should has default 'use' - " + sa.getScene().getId() + "." + sa.getId());
return;
}
}
}
}
// check for lookat and pickup/talk verbs
if (!hasLookat || (!hasPickup && !hasTalkto)) {
String msg = "CheckInteractionVerbs: " + a.getScene().getId() + "." + a.getId();
if (!hasLookat)
EditorLogger.error(msg);
else
EditorLogger.msg(msg);
}
}
}
}
use of com.bladecoder.engine.model.Verb in project bladecoder-adventure-engine by bladecoder.
the class RunVerbAction method getVerb.
private Verb getVerb() {
Verb v = null;
Scene s = World.getInstance().getCurrentScene();
if (actor != null) {
InteractiveActor a = (InteractiveActor) s.getActor(actor, true);
v = a.getVerbManager().getVerb(verb, a.getState(), target);
}
if (v == null) {
v = s.getVerbManager().getVerb(verb, s.getState(), target);
}
if (v == null) {
v = World.getInstance().getVerbManager().getVerb(verb, null, target);
}
if (v == null)
EngineLogger.error("Cannot find VERB: " + verb + " for ACTOR: " + actor);
return v;
}
use of com.bladecoder.engine.model.Verb in project bladecoder-adventure-engine by bladecoder.
the class ModelTools method fixSaySubtitleActor.
public static final void fixSaySubtitleActor() {
Map<String, Scene> scenes = World.getInstance().getScenes();
for (Scene scn : scenes.values()) {
Map<String, BaseActor> actors = scn.getActors();
HashMap<String, Verb> verbs = scn.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
if (act instanceof SayAction) {
try {
String stringValue = ActionUtils.getStringValue(act, "type");
if (stringValue.equals("SUBTITLE"))
ActionUtils.setParam(act, "actor", "$PLAYER");
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
EditorLogger.printStackTrace(e);
return;
}
}
}
}
for (BaseActor a : actors.values()) {
if (a instanceof InteractiveActor) {
InteractiveActor ia = (InteractiveActor) a;
verbs = ia.getVerbManager().getVerbs();
for (Verb v : verbs.values()) {
ArrayList<Action> actions = v.getActions();
for (Action act : actions) {
if (act instanceof SayAction) {
try {
String stringValue = ActionUtils.getStringValue(act, "type");
if (stringValue.equals("SUBTITLE"))
ActionUtils.setParam(act, "actor", "$PLAYER");
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
EditorLogger.printStackTrace(e);
return;
}
}
}
}
}
}
}
Ctx.project.setModified();
}
Aggregations