Example #1
0
        internal static BaseStruct FindScriptRoute(ActionGetter actionGetter, int actionID)
        {
            string scriptTypeName = string.Format(GameEnvironment.Setting.ScriptTypeName, actionID);
            string scriptCode     = "";

            if (!ScriptEngines.SettupInfo.DisablePython) //By Seamoon 在Python禁用的情况下,就没有必要再加载了
            {
                scriptCode = string.Format("action.action{0}", actionID);
                dynamic scriptScope = ScriptEngines.ExecutePython(scriptCode);
                if (scriptScope != null)
                {
                    bool ignoreAuthorize = _ignoreAuthorizeSet.Contains(actionID);
                    return(new ScriptAction(ScriptType.Python, actionID, actionGetter, scriptScope, ignoreAuthorize));
                }
            }
            if (!ScriptEngines.SettupInfo.DisableLua)
            {
                scriptCode = string.Format("Action{0}", actionID);
                dynamic scriptScope = ScriptEngines.ExecuteLua("GetTable", scriptCode, actionID);
                if (scriptScope != null)
                {
                    bool ignoreAuthorize = _ignoreAuthorizeSet.Contains(actionID);
                    return(new LuaAction(actionID, actionGetter, scriptScope, ignoreAuthorize));
                }
            }

            scriptCode = string.Format("action.action{0}", actionID);
            BaseStruct baseStruct = ScriptEngines.Execute(scriptCode, scriptTypeName, actionGetter);

            if (baseStruct != null)
            {
                return(baseStruct);
            }
            return(null);
        }