Example #1
0
        public static void InitializeTypeDictionaries(IEnumerable <Type> types)
        {
            foreach (Type type in types)
            {
                IEnumerable <ConsoleClassAttribute> attributes =
                    type.GetCustomAttributes <ConsoleClassAttribute>(false);
                if (attributes.Any())
                {
                    EngineCallbacks.RegisterType(attributes.First().ConsoleName ?? type.Name, type);
                }
                foreach (MethodInfo methodInfo in type.GetMethods())
                {
                    IEnumerable <ConsoleFunctionAttribute> functionAttributes =
                        methodInfo.GetCustomAttributes <ConsoleFunctionAttribute>(false);
                    if (functionAttributes.Any())
                    {
                        EngineCallbacks.RegisterFunction(functionAttributes.First().FunctionName ?? methodInfo.Name, methodInfo);
                    }

                    IEnumerable <ScriptEntryPoint> entryAttribute =
                        methodInfo.GetCustomAttributes <ScriptEntryPoint>(false);
                    if (entryAttribute.Any())
                    {
                        if (methodInfo.IsStatic && !methodInfo.GetParameters().Any() && methodInfo.ReturnType == typeof(void))
                        {
                            mScriptEntryPointMethodInfo = methodInfo;
                        }
                        else
                        {
                            Console.WriteLine("ScriptEntry method: " + methodInfo.Name + " did not match the necessary signature.");
                        }
                    }
                }
            }
        }
Example #2
0
        public static bool IsMethodDelegate(IntPtr className, IntPtr methodName)
        {
            string _className  = Marshal.PtrToStringAnsi(className);
            string _methodName = Marshal.PtrToStringAnsi(methodName);

            return(EngineCallbacks.IsMethod(_className, _methodName));
        }
Example #3
0
        public static string CallFunctionDelegate(IntPtr nameSpace, IntPtr name, IntPtr argv, int argc, out bool result)
        {
            string _nameSpace = Marshal.PtrToStringAnsi(nameSpace);
            string _name      = Marshal.PtrToStringAnsi(name);

            if (_name == "pushDialog")
            {
                Debugger.Break();
            }
            string[] strings = null;
            if (argv != IntPtr.Zero)
            {
                strings = StringMarshal.IntPtrToStringArray(argv, argc);
            }
            return(EngineCallbacks.CallScriptFunction(_nameSpace, _name, strings, out result));
        }
Example #4
0
        public static string CallMethodDelegate(IntPtr className, IntPtr classNamespace, uint obj, IntPtr name, IntPtr argv, int argc,
                                                out bool result)
        {
            string _className      = Marshal.PtrToStringAnsi(className);
            string _classNamespace = Marshal.PtrToStringAnsi(classNamespace);
            string _name           = Marshal.PtrToStringAnsi(name);

            if (_className == "ClientServer")
            {
                Debugger.Break();
            }

            SimObject objectWrapper = Sim.FindObjectById <SimObject>(obj);

            string[] strings = { };
            if (argv != IntPtr.Zero)
            {
                strings = StringMarshal.IntPtrToStringArray(argv, argc);
            }
            string strRes = EngineCallbacks.CallScriptMethod(_className, _classNamespace, objectWrapper, _name, strings, out result);

            return(strRes);
        }