Exemplo n.º 1
0
 public static Trigger TryToGetTrigger(ITerm t)
 {
     if (t.GetType() == typeof(Trigger))
     {
         return((Trigger)t);
     }
     if (t.IsPlanBody())
     {
         IPlanBody p = (IPlanBody)t;
         if (p.GetPlanSize() == 1)
         {
             TEOperator op = null;
             if (p.GetBodyType() == BodyType.Body_Type.addBel)
             {
                 op = TEOperator.add;
             }
             else if (p.GetBodyType() == BodyType.Body_Type.delBel)
             {
                 op = TEOperator.del;
             }
             if (op != null)
             {
                 Literal l = ((Literal)p.GetBodyTerm().Clone()).ForceFullLiteralImpl();
                 l.DelAnnot(BeliefBase.TSelf);
                 return(new Trigger(op, TEType.belief, l));
             }
         }
     }
     if (t.IsString())
     {
         return(AsSyntax.ParseTrigger(((IStringTerm)t).GetString()));
     }
     return(null);
 }