/** * Searches for the ActionCallback represented by the id string. * * @param id */ public static ActionCallback find(String id) { if (id == null) return null; Scene s = World.getInstance().getCurrentScene(); String[] split = id.split(SEPARATION_SYMBOL); if (split.length < 2) return null; String actorId = split[0]; String verbId = split[1]; int actionPos = -1; if (split.length > 2) actionPos = Integer.parseInt(split[2]); Verb v = null; if (actorId.equals("DEFAULT_VERB")) { v = World.getInstance().getVerbManager().getVerb(verbId, null, null); } else { InteractiveActor a; if (actorId.equals(s.getId())) { v = s.getVerbManager().getVerbs().get(verbId); } else { a = (InteractiveActor) s.getActor(actorId, true); if (a == null) return null; v = a.getVerbManager().getVerbs().get(verbId); } } if (v == null) return null; if (split.length == 2) return v; Action action = v.getActions().get(actionPos); if (action instanceof ActionCallback) return (ActionCallback) action; return null; }
private static String find(ActionCallback cb, Scene s) { if (s == null) return null; String id = s.getId(); for (Verb v : s.getVerbManager().getVerbs().values()) { String result = find(cb, v); if (result != null) { StringBuilder stringBuilder = new StringBuilder(id); stringBuilder.append(SEPARATION_SYMBOL).append(result); return stringBuilder.toString(); } } return null; }