예제 #1
0
    public static void onBehaviorStop(BehaviorExecution be)
    {
        ProceduralBehavior proceduralBehavior = (ProceduralBehavior)(((Agent)be.Host).getBehaviorExecutingByName("ProceduralBehavior"));

        proceduralBehavior.BehaviorToNode[be].CurrentExecution.Finish = BehaviorScheduler.Instance.getCurrentVirtualTime();
        for (int iP = 0; iP < proceduralBehavior.RunningProcedures.Count; iP++)
        {
            ProcedureExecution procInfo = proceduralBehavior.runningProcedures[iP];
            procInfo.informActionDone(((Agent)(proceduralBehavior.Host)).Aid, proceduralBehavior.BehaviorToNode[be]);
            proceduralBehavior.sendActionDoneMessage(proceduralBehavior.BehaviorToNode[be], procInfo);
        }

        //restart();
        proceduralBehavior.ispause = false;
    }
예제 #2
0
    public static void executeOperation(ActionNode action, Agent agt)
    {
        PrintSingleton.Instance.log("Executing " + action.name + " by " + agt.name);
        ProceduralBehavior proceduralBehavior = (ProceduralBehavior)(agt.getBehaviorExecutingByName("ProceduralBehavior"));

        for (int iP = 0; iP < proceduralBehavior.runningProcedures.Count; iP++)
        {
            ProcedureExecution procInfo = proceduralBehavior.runningProcedures[iP];
            action.start(agt, procInfo.getAffectations(), false);
            proceduralBehavior.sendActionRealisationMessage(action, procInfo);
            procInfo.informActionRunning(agt.Aid, action);

            if (action.CurrentExecution != null)
            {
                proceduralBehavior.BehaviorToNode.Add(action.CurrentExecution, action);
                action.CurrentExecution.addCallbackOnBehaviorStop(onBehaviorStop);
            }
            else
            {
                procInfo.informActionDone(agt.Aid, action);
                proceduralBehavior.sendActionDoneMessage(action, procInfo);
            }
        }
    }