/** The body method. */ public void body() { // Make sure other plan is executed first. waitFor(10); // Set result of listener. SyncResultListener listener = (SyncResultListener) getBeliefbase().getBelief("listener").getFact(); listener.resultAvailable(this, "success"); }
/** The plan body. */ public void body() { Grid2D env = (Grid2D) getBeliefbase().getBelief("env").getFact(); ISpaceObject myself = (ISpaceObject) getBeliefbase().getBelief("myself").getFact(); ISpaceObject[] hunters = (ISpaceObject[]) getBeliefbase().getBeliefSet("seen_hunters").getFacts(); String move = MoveAction.getAvoidanceDirection( env, (IVector2) myself.getProperty(Space2D.PROPERTY_POSITION), hunters); SyncResultListener srl = new SyncResultListener(); Map params = new HashMap(); params.put(ISpaceAction.ACTOR_ID, getComponentIdentifier()); params.put(MoveAction.PARAMETER_DIRECTION, move); env.performSpaceAction("move", params, srl); try { srl.waitForResult(); } catch (RuntimeException e) { // When move fails ignore exception. fail(); } }
/** The plan body. */ public void body() { ISpaceObject waste = (ISpaceObject) getParameter("waste").getValue(); // Move to the waste position when necessary // getLogger().info("Moving to waste!"); IGoal moveto = createGoal("achievemoveto"); IVector2 location = (IVector2) waste.getProperty(Space2D.PROPERTY_POSITION); moveto.getParameter("location").setValue(location); dispatchSubgoalAndWait(moveto); IEnvironmentSpace env = (IEnvironmentSpace) getBeliefbase().getBelief("environment").getFact(); Map params = new HashMap(); params.put(ISpaceAction.ACTOR_ID, getComponentIdentifier()); params.put(ISpaceAction.OBJECT_ID, getParameter("waste").getValue()); SyncResultListener srl = new SyncResultListener(); env.performSpaceAction("pickup_waste", params, srl); try { srl.waitForResult(); } catch (RuntimeException e) { fail(); } }