#pragma warning restore 414
 
 
 void Awake( )
 {
    #if !(UNITY_FLASH)
    useGUILayout = false;
    #endif
    ExposedVariables.Awake( );
    ExposedVariables.SetParent( this.gameObject );
    if ( "1.CMR" != uScript_MasterComponent.Version )
    {
       uScriptDebug.Log( "The generated code is not compatible with your current uScript Runtime " + uScript_MasterComponent.Version, uScriptDebug.Type.Error );
       ExposedVariables = null;
       UnityEngine.Debug.Break();
    }
 }
Exemplo n.º 2
0
   #pragma warning restore 414


    void Awake( )
    {
      #if !(UNITY_FLASH)
        useGUILayout = false;
      #endif
        ExposedVariables.Awake( );
        ExposedVariables.SetParent(this.gameObject);
        if ("1.CMR" != uScript_MasterComponent.Version)
        {
            uScriptDebug.Log("The generated code is not compatible with your current uScript Runtime " + uScript_MasterComponent.Version, uScriptDebug.Type.Error);
            ExposedVariables = null;
            UnityEngine.Debug.Break();
        }
    }
        internal AIMLTagHandler GetTagHandlerU(User user, SubQuery query, Request request, Result result, XmlNode node, bool liText)
        {
            AIMLTagHandler tagHandlerU   = getBespokeTags(user, query, request, result, node);
            string         nodeNameLower = StaticAIMLUtils.ToLower(node.LocalName);
            AltBot         targetBot     = query.TargetBot;

            if (Equals(null, tagHandlerU))
            {
                switch (nodeNameLower)
                {
                case "template":
                case "answer":     //CML
                    tagHandlerU = new template(targetBot, user, query, request, result, node);
                    break;

                case "aiml":
                case "cml":     //CML
                    tagHandlerU = new aiml(targetBot, user, query, request, result, node);
                    break;

                case "aimlexec":
                case "eval":
                    tagHandlerU = new aimlexec(targetBot, user, query, request, result, node);
                    break;

                case "vars":
                case "root":
                case "predicates":     //CML
                    tagHandlerU = new root(targetBot, user, query, request, result, node, (() => query.TargetSettings));
                    break;

                case "properties":
                case "bots":
                    tagHandlerU = new root(targetBot, user, query, request, result, node,
                                           (() => request.TargetBot.GlobalSettings));
                    break;

                case "substitutions":
                    tagHandlerU = new root(targetBot, user, query, request, result, node,
                                           (() => request.TargetBot.InputSubstitutions));
                    break;

                case "topic":
                case "conversation":     //CML
                    tagHandlerU = new topic(targetBot, user, query, request, result, node);
                    break;

                case "category":
                case "conv":     //CML
                    tagHandlerU = new category(targetBot, user, query, request, result, node);
                    break;

                case "and":
                    tagHandlerU = new and(targetBot, user, query, request, result, node);
                    break;

                case "or":
                    tagHandlerU = new or(targetBot, user, query, request, result, node);
                    break;

                case "optional":
                    tagHandlerU = new optional(targetBot, user, query, request, result, node);
                    break;

                case "isa":
                    tagHandlerU = new isa(targetBot, user, query, request, result, node);
                    break;

                case "bot":
                    tagHandlerU = new bot(targetBot, user, query, request, result, node);
                    break;

                case "condition":
                case "options":     //cml
                    tagHandlerU = new condition_aima(targetBot, user, query, request, result, node);
                    break;

                case "li":
                    if (liText)
                    {
                        tagHandlerU = new liif(targetBot, user, query, request, result, node);
                    }
                    break;

                case "if":
                    tagHandlerU = new liif(targetBot, user, query, request, result, node);
                    break;

                case "personf":
                    tagHandlerU = new format(targetBot, user, query, request, result, node,
                                             new Func <string, string>(HttpUtility.UrlEncode),
                                             null);
                    break;

                case "date":
                    tagHandlerU = new date(targetBot, user, query, request, result, node);
                    break;

                case "formal":
                    tagHandlerU = new formal(targetBot, user, query, request, result, node);
                    break;

                case "gender":
                    tagHandlerU = new gender(targetBot, user, query, request, result, node);
                    break;

                case "get":
                    tagHandlerU = new get(targetBot, user, query, request, result, node);
                    break;

                case "gossip":
                    tagHandlerU = new gossip(targetBot, user, query, request, result, node);
                    break;

                case "get_ip":
                case "id":
                    tagHandlerU = new id(targetBot, user, query, request, result, node);
                    break;

                case "inputreq":
                    tagHandlerU = new inputreq(targetBot, user, query, request, result, node);
                    break;

                case "request":
                    tagHandlerU = new input(targetBot, user, query, request, result, node, 1);
                    break;

                case "input":
                    tagHandlerU = new input(targetBot, user, query, request, result, node, 1);
                    break;

                case "justthat":     // <input index="2"/>
                    tagHandlerU = new input(targetBot, user, query, request, result, node, 2);
                    break;

                case "beforethat":     // <input index="3"/>
                    tagHandlerU = new input(targetBot, user, query, request, result, node, 3);
                    break;

#if !(__MonoCS__)
                case "javascript":
                    tagHandlerU = new javascript(targetBot, user, query, request, result, node);
                    break;
#endif
                case "learn":
                case "load":
                case "noload":     // the commented version of <load>
                    tagHandlerU = new learn(targetBot, user, query, request, result, node);
                    break;

                case "lowercase":
                    tagHandlerU = new lowercase(targetBot, user, query, request, result, node);
                    break;

                case "person":
                    tagHandlerU = new substitute(targetBot, user, query, request, result, node);
                    break;

                case "person2":
                    tagHandlerU = new substitute(targetBot, user, query, request, result, node);
                    break;

                case "random":
                    tagHandlerU = new random(targetBot, user, query, request, result, node);
                    break;

                case "sentence":
                    tagHandlerU = new sentence(targetBot, user, query, request, result, node);
                    break;

                case "set":
                    tagHandlerU = new set(targetBot, user, query, request, result, node);
                    break;

                case "size":
                case "getsize":
                    tagHandlerU = new size(targetBot, user, query, request, result, node);
                    break;

                case "sr":
                    tagHandlerU = new sr(targetBot, user, query, request, result, node);
                    break;

                case "srai_odd":
                    tagHandlerU = new srai_odd(targetBot, user, query, request, result, node);
                    break;

                case "star":
                    tagHandlerU = new star(targetBot, user, query, request, result, node);
                    break;

                case "system":
                    tagHandlerU = new system(targetBot, user, query, request, result, node);
                    break;

                case "that":     //default <that index="1,1"/>
                    tagHandlerU = new that(targetBot, user, query, request, result, node, 1);
                    break;

                case "justbeforethat":     //treated as <that index="2,1"/>
                    tagHandlerU = new that(targetBot, user, query, request, result, node, 2);
                    break;

                case "response":     //treated as <that index="1,1"/>
                    tagHandlerU = new that(targetBot, user, query, request, result, node, 2);
                    break;

                case "thatstar":
                    tagHandlerU = new thatstar(targetBot, user, query, request, result, node);
                    break;

                case "think":
                    tagHandlerU = new think(targetBot, user, query, request, result, node);
                    break;

                case "topicstar":
                    tagHandlerU = new topicstar(targetBot, user, query, request, result, node);
                    break;

                case "uppercase":
                    tagHandlerU = new uppercase(targetBot, user, query, request, result, node);
                    break;

                case "version":
                case "getversion":
                    tagHandlerU = new version(targetBot, user, query, request, result, node);
                    break;

                case "cycsystem":
                    tagHandlerU = new cycsystem(targetBot, user, query, request, result, node);
                    break;

                case "cycretract":
                    tagHandlerU = new cycretract(targetBot, user, query, request, result, node);
                    break;

                case "cycassert":
                    tagHandlerU = new cycassert(targetBot, user, query, request, result, node);
                    break;

                case "cycterm":
                    tagHandlerU = new cycterm(targetBot, user, query, request, result, node);
                    break;

                case "cycquery":
                    tagHandlerU = new cycquery(targetBot, user, query, request, result, node);
                    break;

                case "cyccondition":
                    tagHandlerU = new cyccondition(targetBot, user, query, request, result, node);
                    break;

                case "cycphrase":
                    tagHandlerU = new cycphrase(targetBot, user, query, request, result, node);
                    break;

                case "cycparaphrase":
                    tagHandlerU = new cycphrase(targetBot, user, query, request, result, node);
                    break;

                case "guard":
                    tagHandlerU = new guard(targetBot, user, query, request, result, node);
                    break;

                case "guardstar":
                    tagHandlerU = new guardstar(targetBot, user, query, request, result, node);
                    break;

                case "cycrandom":
                    tagHandlerU = new cycrandom(targetBot, user, query, request, result, node);
                    break;

                case "tscore":
                    tagHandlerU = new tscore(targetBot, user, query, request, result, node);
                    break;

                case "space":
                    tagHandlerU = new space(targetBot, user, query, request, result, node);
                    break;

                case "markov":
                    tagHandlerU = new markov(targetBot, user, query, request, result, node);
                    break;

                case "soundcode":
                    tagHandlerU = new soundcode(targetBot, user, query, request, result, node);
                    break;

                // MSM
                case "msm":
                    tagHandlerU = new msm(targetBot, user, query, request, result, node);
                    break;

                case "processmsm":
                    tagHandlerU = new process_msm(targetBot, user, query, request, result, node);
                    break;

                case "setstate":
                    tagHandlerU = new setstate(targetBot, user, query, request, result, node);
                    break;

                case "state":
                    tagHandlerU = new state(targetBot, user, query, request, result, node);
                    break;

                case "transition":
                    tagHandlerU = new transition(targetBot, user, query, request, result, node);
                    break;

                case "setevidence":
                    tagHandlerU = new setevidence(targetBot, user, query, request, result, node);
                    break;

                case "evidenceassoc":
                    tagHandlerU = new evidence_assoc(targetBot, user, query, request, result, node);
                    break;

                case "evidencepattern":
                    tagHandlerU = new evidence_pattern(targetBot, user, query, request, result, node);
                    break;

                case "evidencestate":
                    tagHandlerU = new evidencestate(targetBot, user, query, request, result, node);
                    break;

                case "dependentmachine":
                    tagHandlerU = new dependentmachine(targetBot, user, query, request, result, node);
                    break;

                case "responsetopic":
                    tagHandlerU = new response_topic(targetBot, user, query, request, result, node);
                    break;

                case "push":
                    tagHandlerU = new push(targetBot, user, query, request, result, node);
                    break;

                case "pop":
                    tagHandlerU = new pop(targetBot, user, query, request, result, node);
                    break;

                case "peekstack":
                    tagHandlerU = new peekstack(targetBot, user, query, request, result, node);
                    break;

                case "lex":
                    tagHandlerU = new lex(targetBot, user, query, request, result, node);
                    break;

                case "lexset":
                    tagHandlerU = new lexset(targetBot, user, query, request, result, node);
                    break;

                case "lexis":
                    tagHandlerU = new lexis(targetBot, user, query, request, result, node);
                    break;

                case "dbpush":
                    tagHandlerU = new dbpush(targetBot, user, query, request, result, node);
                    break;

                case "dbquery":
                    tagHandlerU = new dbquery(targetBot, user, query, request, result, node);
                    break;

                case "dbupdate":
                    tagHandlerU = new dbupdate(targetBot, user, query, request, result, node);
                    break;

                case "dbdelete":
                    tagHandlerU = new dbdelete(targetBot, user, query, request, result, node);
                    break;

                case "dbload":
                    tagHandlerU = new dbload(targetBot, user, query, request, result, node);
                    break;


                case "regex":
                    tagHandlerU = new regex(targetBot, user, query, request, result, node);
                    break;

                case "bind":     // <bind>#$isa</bind>
                    tagHandlerU = new bind(targetBot, user, query, request, result, node);
                    break;

                case "#text":
                    if (!liText)
                    {
                        return(null);
                    }
                    return(new verbatum(node.Value, targetBot, user, query, request, result, node));

                case "#comment":
                    return(new verbatum(node.OuterXml, targetBot, user, query, request, result, node));

                case "br":
                    return(new verbatum("\n", targetBot, user, query, request, result, node));

                case "pre":
                    return(new verbatum(StaticXMLUtils.InnerXmlText(node), targetBot, user, query, request, result, node));

                case "p":
                    return(new verbatum("\n\n", targetBot, user, query, request, result, node));

                case "meta":
                    return(new verbatum(node.OuterXml, targetBot, user, query, request, result, node));

                default:
                    break;
                }
            }
            if (tagHandlerU != null)
            {
                return(tagHandlerU);
            }
            if (StaticAIMLUtils.IsHtmlTag(node.Name))
            {
                return(new recursiveVerbatum(node, targetBot, user, query, request, result, node, true));
            }
            if (tagHandlerU == null)
            {
                // "bot", "favorite", "fav"
                foreach (KeyValuePair <string, string> prefix in new[]
                {
                    new KeyValuePair <string, string>("get_", "get"),
                    new KeyValuePair <string, string>("set_", "set"),
                    new KeyValuePair <string, string>("bot_", "bot"),
                    new KeyValuePair <string, string>("favorite_", "bot"),
                    new KeyValuePair <string, string>("favorite", "bot"),
                    new KeyValuePair <string, string>("fav_", "bot"),
                    new KeyValuePair <string, string>("fav", "bot"),

                    new KeyValuePair <string, string>("get", "get"),
                    new KeyValuePair <string, string>("set", "set"),
                    new KeyValuePair <string, string>("bot", "bot"),
                })
                {
                    if (nodeNameLower.StartsWith(prefix.Key) && node.Name.Length > prefix.Key.Length)
                    {
                        string               name    = node.Name.Substring(prefix.Key.Length);
                        XmlNode              pn      = node.ParentNode;
                        LineInfoElementImpl  newnode = StaticXMLUtils.CopyNode(prefix.Value, node, false);
                        XmlAttributeLineInfo atr     = (XmlAttributeLineInfo)newnode.OwnerDocument.CreateAttribute("name");
                        atr.ReadOnly = false;
                        atr.Value    = name;
                        newnode.Attributes.Append(atr);
                        if (node.Name.ToLower() != newnode.Name.ToLower())
                        {
                            writeToLog("AIMLLOADER: converted " + node.OuterXml + " -> " + newnode.OuterXml);
                            return(targetBot.GetTagHandler(newnode, query, request, result, user, liText));
                        }
                        writeToLog("AIMLLOADER: ! convert " + node.OuterXml + " -> " + newnode.OuterXml);
                    }
                }
            }
            if (tagHandlerU != null)
            {
                return(tagHandlerU);
            }
            if (nodeNameLower == "name")
            {
                return(new bot(targetBot, user, query, request, result, node));
            }

            tagHandlerU = new lazyClosure(targetBot, user, query, request, result, node);
            writeToLog("AIMLLOADER:  lazyClosure: " + node.OuterXml);
            return(tagHandlerU);
        }