void SimEventSubscriber.OnEvent(CogbotEvent evt)
 {
     if (taskInterperter != null && taskInterperter.IsSubscriberOf(evt.Verb))
     {
         object lispCode = lispCodeFromEvent(evt);
         taskQueue.Enqueue(new KeyValuePair <object, CogbotEvent>(lispCode, evt));
     }
 }
Ejemplo n.º 2
0
        public override bool BooleanOnEvent(string eventName, string[] paramNames, Type[] paramTypes, params object[] parameters)
        {
            if (Interpreter == null)
            {
                return(true);
            }
            eventName = eventName.ToLower();
            Cons eval;

            if (!Interpreter.IsSubscriberOf(eventName))
            {
                return(true);
            }

            if (EventArgsInDictionary)
            {
                Dictionary <String, object> eventArgs = new Dictionary <string, object>();
                for (int i = 0; i < paramNames.Length; i++)
                {
                    eventArgs.Add(paramNames[i], CoerceArg(parameters[i], paramTypes[i]));
                }
                eval = new Cons(eventName, new Cons(eventArgs, null));
            }
            else
            {
                //todo
                return(true);

                Cons invokeMe = null;
                for (int i = paramNames.Length - 1; i >= 0; i--)
                {
                    invokeMe = new Cons(CoerceArg(parameters[i], paramTypes[i]), invokeMe);
                }
                eval = new Cons(Interpreter.GetSymbol(eventName.ToLower()), invokeMe);
            }

            // right now most events are void but there is one that is boolean which means we may as well eturn true for all
            try
            {
                object o = Interpreter.Eval(eval);
            }
            catch (Exception e)
            {
                DLRConsole.DebugWriteLine(eval + " Caused");
                DLRConsole.DebugWriteLine(e);
            }
            return(true);
        }