public override object Execute(Reasoner ts, Unifier un, ITerm[] args) { CheckArguments(args); suspendIntention = false; Circumstance C = ts.GetCircumstance(); if (args.Length == 0) { // suspend the current intention Intention i = C.GetSelectedIntention(); suspendIntention = true; i.SetSuspended(true); C.AddPendingIntention(SELF_SUSPENDED_INT + i.GetID(), i); return(true); } // use the argument to select the intention to suspend. Trigger g = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]); // ** Must test in PA/PI first since some actions (as .suspend) put intention in PI // suspending from Pending Actions foreach (ExecuteAction a in C.GetPendingActions().Values) { Intention ia = a.GetIntention(); if (ia.HasTrigger(g, un)) { ia.SetSuspended(true); C.AddPendingIntention(SUSPENDED_INT + ia.GetID(), ia); } } // suspending from Pending Intentions foreach (Intention ii in C.GetPendingIntentions().Values) { if (ii.HasTrigger(g, un)) { ii.SetSuspended(true); } } IEnumerator <Intention> itint = C.GetRunningIntentionsPlusAtomic(); while (itint.MoveNext()) { Intention i = itint.Current; if (i.HasTrigger(g, un)) { i.SetSuspended(true); C.RemoveRunningIntention(i); C.AddPendingIntention(SUSPENDED_INT + i.GetID(), i); } } // suspending the current intention? <-(Esta interrogación ya venía, lo juro) Intention ci = C.GetSelectedIntention(); if (ci != null && ci.HasTrigger(g, un)) { suspendIntention = true; ci.SetSuspended(true); C.AddPendingIntention(SELF_SUSPENDED_INT + ci.GetID(), ci); } // suspending G in Events int c = 0; IEnumerator <Event> ie = C.GetEventsPlusAtomic(); while (ie.MoveNext()) { Event e = ie.Current; ci = e.GetIntention(); if (un.Unifies(g, e.GetTrigger()) || (ci != null && ci.HasTrigger(g, un))) { C.RemoveEvent(e); C.AddPendingEvent(SUSPENDED_INT + e.GetTrigger() + (c++), e); if (ci != null) { ci.SetSuspended(true); } } } return(true); }