Example #1
0
        private static bool TryRegisterConsoleVariables(RoR2.Console self)
        {
            const string registerConVarMethod   = "RegisterConVarInternal";
            var          registerConVarInternal = typeof(RoR2.Console).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
                                                  .FirstOrDefault(m => m.Name == registerConVarMethod);

            if (registerConVarInternal == null)
            {
                Chat.AddMessage($"Could not find {registerConVarMethod}. Unloading RoR2Pro.");
                return(false);
            }
            else
            {
                var consoleVariables = Reflection.GetImplementingTypes <RoR2Pro, BaseConVar>().ToList();

                Chat.AddMessage($"Registering console variables [{string.Join(", ", consoleVariables.Select(v => v.Name))}]");
                foreach (var conVar in consoleVariables)
                {
                    var instance = (BaseConVar)Activator.CreateInstance(conVar);

                    registerConVarInternal.Invoke(self, new object[] { instance });
                }

                Chat.AddMessage($"Registering console variables [{string.Join(", ", consoleVariables.Select(v => v.Name))}]");
            }

            return(true);
        }
Example #2
0
        public void LoadModules()
        {
            foreach (var action in _moduleCleanUpActions)
            {
                action();
            }
            _moduleCleanUpActions.Clear();

            var modules = Reflection.GetImplementingTypes <RoR2Pro, IModule>().ToList();

            Chat.AddMessage($"Loading Risk of Rain 2 Pro modules: [{string.Join(", ", modules.Select(m => m.Name))}]");

            foreach (var module in modules)
            {
                var instance = (IModule)Activator.CreateInstance(module);

                _moduleCleanUpActions.Add(instance.Initialize());
            }
        }