コード例 #1
0
        private void LoadAssemblies(PluginSearchMode searchMode, [CanBeNull, ItemNotNull] string[] filters, [NotNull, ItemNotNull] params string[] searchPaths)
        {
            if (_extensionContainer != null)
            {
                _extensionContainer.Dispose();
                _extensionContainer = null;
            }

            var             allAssemblies = FindAssemblies(searchMode, filters, searchPaths);
            var             configuration = new ContainerConfiguration().WithAssemblies(allAssemblies);
            CompositionHost host;

            try {
                host = configuration.CreateContainer();
            } catch (ReflectionTypeLoadException ex) {
                var loaderExceptions = ex.LoaderExceptions;
                var errorDescription = string.Join("\n", loaderExceptions.Select(le => le.Message));

                GameLog.Fatal("Failed to load plugin assemblies: {0}", ex.Message);
                GameLog.Fatal(errorDescription);

                throw;
            }

            var loadedPlugins = host.GetExports <IMilliSimPlugin>().ToArray();

            _allPlugins = loadedPlugins;

            _extensionConfiguration = configuration;
            _extensionContainer     = host;
        }
コード例 #2
0
ファイル: Monolith.cs プロジェクト: hybrasyl/server
    public void Start()
    {
        var x = 0;

        while (true)
        {
            // Ignore processing if no one is logged in, what's the point

            try
            {
                foreach (var map in _maps)
                {
                    if (map.Users.Count == 0)
                    {
                        continue;
                    }

                    foreach (var obj in map.Objects.Where(x => x is Monster).ToList())
                    {
                        if (obj is Monster mob)
                        {
                            if (mob.Active)
                            {
                                Evaluate(mob, map);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                GameLog.Fatal("Monolith thread error: {e}", e);
            }
            Thread.Sleep(1000);
            x++;
            // Refresh our list every 15 seconds in case of XML reloading
            if (x == 30)
            {
                _maps = Game.World.WorldData.Values <Map>().ToList();
                x     = 0;
            }
        }
    }