Exemplo n.º 1
0
        public ModScript(Assembly ass, string fileName)
        {
            IsInGameplay = false;
            IsInActivity = false;

            File    = fileName;
            t       = NReflec.GetTypesFromAssembly(ass);
            methods = NReflec.GetMethodsFromAssembly(ass);
            CheckMethods();
        }
Exemplo n.º 2
0
        public ModScript(string dllFile)
        {
            IsInGameplay = false;
            IsInActivity = false;

            File = dllFile;
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, File);

            t       = NReflec.GetTypesFromDLL(path);
            methods = NReflec.GetMethodsFromDLL(path);
            CheckMethods();
        }
Exemplo n.º 3
0
        public void CallModFunction(ModMethod modMethod, params object[] o)
        {
            var method = string.Empty;

            switch (modMethod)
            {
            case ModMethod.None:
                method = string.Empty;
                break;

            case ModMethod.Pre:
                method = Mod.PRE_METHOD;
                break;

            case ModMethod.Initialize:
                method = Mod.INITIALIZE_METHOD;
                break;

            case ModMethod.Main:
                method = Mod.MAIN_METHOD;
                break;

            case ModMethod.Update:
                method = Mod.UPDATE_METHOD;
                break;

            case ModMethod.OnKeyDown:
                method = Mod.ONKEYDOWN_METHOD;
                break;

            case ModMethod.OnKeyUp:
                method = Mod.ONKEYUP_METHOD;
                break;

            case ModMethod.OnGameplayStart:
                method = Mod.ONGAMEPLAYSTART_METHOD;
                break;

            case ModMethod.OnGameplayExit:
                method = Mod.ONGAMEPLAYEXIT_METHOD;
                break;

            case ModMethod.OnActivityEnter:
                method = Mod.ONACTIVITYENTER_METHOD;
                break;

            case ModMethod.OnActivityExit:
                method = Mod.ONACTIVITYEXIT_METHOD;
                break;

            case ModMethod.OnExit:
                method = Mod.ONEXIT_METHOD;
                break;
            }
            for (var i = 0; i < t.Length; i++)
            {
                if (t[i].IsSubclassOf(typeof(Mod)))
                {
                    try
                    {
                        NReflec.CallMethodFromType(t[i], method, o);
                    }
                    catch (Exception e) {
                        Log.Print("EXCEPTION", e.ToString());
                    }
                }
            }
        }