Пример #1
0
        public static void AttachBootstrap()
        {
            try {
                Hooks.CreateOrUpdateSubjects();

                System.Reflection.Assembly executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
                Type[] types = executingAssembly.GetTypes();
                for (int i = 0; i < types.Length; i++)
                {
                    object[] customAttributes = types[i].GetCustomAttributes(typeof(ConsoleSystem.Factory), false);
                    if (customAttributes != null && customAttributes.Length != 0)
                    {
                        ConsoleSystem.Factory factory = customAttributes[0] as ConsoleSystem.Factory;
                        typeof(ConsoleSystem.Index).CallStaticMethod("BuildFields", types[i], factory);
                        typeof(ConsoleSystem.Index).CallStaticMethod("BuildProperties", types[i], factory);
                        typeof(ConsoleSystem.Index).CallStaticMethod("BuildFunctions", types[i], factory);
                    }
                }

                DirectoryConfig.GetInstance();
                CoreConfig.GetInstance();
                Config.GetInstance();

                if (!pluton.enabled)
                {
                    Debug.Log("[Bootstrap] Pluton is disabled!");
                    return;
                }

                Init();

                PlutonLoaded = true;
                Console.WriteLine("Pluton Loaded!");
            } catch (Exception ex) {
                Debug.LogException(ex);
                Debug.Log("[Bootstarp] Error while loading Pluton!");
            }
        }
Пример #2
0
        public static void reload(ConsoleSystem.Arg arg)
        {
            if (PluginLoader.GetInstance().Plugins.ContainsKey(arg.ArgsStr))
            {
                PluginLoader.GetInstance().ReloadPlugin(arg.ArgsStr);
                arg.ReplyWith(String.Format("{0} plugin reloaded!", arg.ArgsStr));
            }
            else if (arg.ArgsStr == "")
            {
                DirectoryConfig.GetInstance().Reload();
                CoreConfig.GetInstance().Reload();
                Config.GetInstance().Reload();

                Server.GetInstance().LoadLoadouts();

                if (Server.GetInstance().Loaded)
                {
                    Hooks.On_ServerInit();
                }

                PluginLoader.GetInstance().ReloadPlugins();

                arg.ReplyWith("Pluton reloaded!");

                var planes = (from plane in UnityEngine.Object.FindObjectsOfType <CargoPlane>()
                              where plane.transform.position.x == 0f && plane.transform.position.z == 0f
                              select plane).ToList();
                planes.ForEach(p => p.SendMessage("KillMessage", UnityEngine.SendMessageOptions.DontRequireReceiver));
                if (planes.Count != 0)
                {
                    Pluton.Logger.LogWarning(String.Format("Destroyed {0} plane at Vector3.zero", planes.Count));
                }
            }
            else
            {
                arg.ReplyWith(String.Format("Couldn't find plugin: {0}!", arg.ArgsStr));
            }
        }
Пример #3
0
        public void InstallHooks(BasePlugin plugin)
        {
            if (plugin.State != PluginState.Loaded)
            {
                return;
            }

            foreach (string method in plugin.Globals)
            {
                if (Hooks.HookNames.Contains(method))
                {
                    plugin.Hooks.Add(
                        Hooks.Subscribe(method, plugin)
                        );
                    Logger.LogDebug($"[{plugin.Type}] Adding hook: {plugin.Name}.{method}");
                }
            }

            if (plugin.Globals.Contains("On_PluginInit"))
            {
                plugin.Invoke("On_PluginInit");
            }
        }
Пример #4
0
 private void _adstimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     Hooks.Advertise();
 }