void Cmd_ListPlugins(string[] input)
        {
            int num = 0;

            foreach (IPluginInfo pluginInfo in loadedPlugins)
            {
                object[] array = new object[7];

                int num2 = 0;
                int num3 = num;

                num = num3 + 1;

                array[num2] = num3;

                array[1] = ": ";
                array[2] = pluginInfo.Name;
                array[3] = " version ";
                array[4] = pluginInfo.Version;
                array[5] = " by ";
                array[6] = pluginInfo.Author;

                PluginConsole.WriteLine(string.Concat(array), this);
            }
        }
Esempio n. 2
0
    void DisableSmoothing()
    {
        Destroy(smoothMovementGO);

        PluginConsole.WriteLine("Smooth Camera Disabled", this);
        PluginSettings.Instance.SetSetting("SmoothCameraToggle", smooth);
    }
        public void LoadAllPlugins()
        {
            PluginConsole.WriteLine("Loading Plugins", this);

            IEnumerable <Type> typesFromAssemblies = AssemblyManager.Instance.GetTypesFromAssemblies <DeadCorePlugin>(AssemblyManager.Instance.LoadAssemblies(pluginsLocation));

            PluginConsole.WriteLine("Plugin Types loaded from Assemblies", this);

            foreach (Type type in typesFromAssemblies)
            {
                try
                {
                    PluginConsole.WriteLine("Attempting to attach type " + type.Name, this);

                    DeadCorePlugin deadCorePlugin = pluginContainerObject.AddComponent(type) as DeadCorePlugin;
                    loadedPlugins.Add(deadCorePlugin);

                    PluginConsole.WriteLine(deadCorePlugin.Name + " version " + deadCorePlugin.Version + " has been attached to the container", this);
                }
                catch (Exception ex)
                {
                    PluginConsole.WriteLine("Error attaching " + type.Name + " to the plugin GameObject container", this);
                    PluginConsole.WriteLine(ex.ToString(), this);
                }
            }

            PluginConsole.WriteLine("Plugins Loaded", this);
            PluginConsole.WriteLine("Version " + this.Version + " Initialized", this);
            PluginConsole.WriteLine("Use 'listcommands' to list available console commands", this);
        }
Esempio n. 4
0
    void EnableSmoothing()
    {
        smoothMovementGO = new GameObject();

        PluginConsole.WriteLine("Smooth Camera Enabled", this);
        PluginSettings.Instance.SetSetting("SmoothCameraToggle", smooth);
    }
Esempio n. 5
0
        public IEnumerable <Assembly> LoadAssemblies(string path)
        {
            AssemblyName    assemblyName = null;
            List <Assembly> list         = new List <Assembly>();

            foreach (string assemblyFile in Directory.GetFiles(path, "*.dll"))
            {
                try
                {
                    assemblyName = AssemblyName.GetAssemblyName(assemblyFile);

                    Assembly assembly = Assembly.Load(assemblyName);

                    PluginConsole.WriteLine("Assembly loaded: " + assembly.ToString(), this);
                    list.Add(assembly);
                }
                catch (Exception ex)
                {
                    PluginConsole.WriteLine("Error loading " + assemblyName.FullName, this);
                    PluginConsole.WriteLine(ex.ToString(), this);
                }
            }

            return(list);
        }
 private async Task Plugin_LogEvent(PluginLogNotification log)
 {
     await Application.Current.Dispatcher.InvokeAsync(delegate
     {
         _pluginConsole.AddOutput(log.Message);
         PluginConsole.ScrollToBottom();
     });
 }
Esempio n. 7
0
    void Awake()
    {
        PluginConsole.RegisterConsoleCommand("sc_toggle", new PluginConsole.ConsoleCommandCallback(Cmd_Toggle), "Toggles smooth camera movement", this);

        if (bool.TryParse(PluginSettings.Instance.GetSetting("SmoothCameraToggle", smooth), out smooth))
        {
            PluginConsole.WriteLine("Smooth toggle setting loaded from file, smoothing enabled = " + smooth.ToString(), this);
        }
        else
        {
            PluginConsole.WriteLine("Could not load smooth toggle setting from file, using default: true", null);
        }
    }
Esempio n. 8
0
        public IEnumerable <Type> GetTypesFromAssemblies <T>(IEnumerable <Assembly> assemblies)
        {
            List <Type> list = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                IEnumerable <Type> types = assembly.GetTypes();
                foreach (Type type in types)
                {
                    if (type.IsAssignableFrom(typeof(T)) || type.IsSubclassOf(typeof(T)))
                    {
                        PluginConsole.WriteLine(type.Name + " is a valid type of " + typeof(T).Name + ", adding to 'returnVal'", this);
                        list.Add(type);
                    }
                }
            }

            return(list);
        }
        public void Initialize()
        {
            pluginContainerObject = new GameObject();
            UnityEngine.Object.DontDestroyOnLoad(pluginContainerObject);

            loadedPlugins = new List <DeadCorePlugin>();
            loadedPlugins.Add(this.pluginContainerObject.AddComponent <PluginConsole>());

            pluginsLocation = GlobalVars.RootFolder + "\\dcpm-plugins\\";

            if (!Directory.Exists(pluginsLocation))
            {
                Directory.CreateDirectory(pluginsLocation);
            }

            PluginConsole.RegisterConsoleCommand("plugins_list", Cmd_ListPlugins, "Lists all automatically loaded plugins", this);
            PluginConsole.RegisterConsoleCommand("plugins_info", Cmd_PluginInfo, "Display more detailed information about a loaded plugin, usage: 'plugins info <plugin id>' get the plugin id by using 'plugins list'", this);

            PluginConsole.WriteLine("Variables Initialized", this);

            LoadAllPlugins();
        }
        void Cmd_PluginInfo(string[] input)
        {
            int num;

            if (input.Length >= 1 && int.TryParse(input[0], out num) && num >= 0 && loadedPlugins.Count > num)
            {
                PluginConsole.WriteLine(string.Concat(new string[]
                {
                    loadedPlugins[num].Name,
                    " version ",
                    loadedPlugins[num].Version,
                    " by ",
                    loadedPlugins[num].Author
                }), this);

                PluginConsole.WriteLine(loadedPlugins[num].Name + " Description: " + loadedPlugins[num].Desc, this);
            }
            else
            {
                PluginConsole.WriteLine("Invalid argument", this);
            }
        }