private void Events_OnLoad(object sender, EventArgs e)
        {
            if (this.initialized)
            {
                return;
            }

            this.initialized          = true;
            GlobalVariables.LocalHero = ObjectManager.LocalHero;
            GlobalVariables.EnemyTeam = UnitExtensions.GetEnemyTeam(GlobalVariables.LocalHero);
            GlobalVariables.Team      = GlobalVariables.LocalHero.Team;

            // An aggregate catalog that combines multiple catalogs
            catalog = new AggregateCatalog();

            // Adds all the parts found in the Ability# assembly
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(AbilityBootstrapper).Assembly));

            // foreach (var cacheAssembly in EnsageSharp.Sandbox.AssemblyResolver.AssemblyCache)
            // {
            // }
            // Environment.
            // catalog.Catalogs.Add(new AssemblyCatalog());
            container = new CompositionContainer(catalog);

            foreach (var c in catalog)
            {
                Console.WriteLine(c);
            }

            ComposeParts(this);

            var delay = Game.GameTime < 0 ? 3000 : 500;

            DelayAction.Add(
                delay,
                () =>
            {
                this.AbilityUnitManager.Value.OnLoad();
                foreach (var abilityService in this.AbilityServices)
                {
                    abilityService.Value.OnLoad();
                }

                this.MainMenuManager.Value.OnLoad();
            });

            DelayAction.Add(
                500,
                () =>
            {
                foreach (var abilityService in this.AbilityServices)
                {
                    Console.WriteLine("Service: " + abilityService.Value);
                }
            });
        }
Ejemplo n.º 2
0
        private void Events_OnLoad(object sender, EventArgs e)
        {
            if (this.initialized)
            {
                return;
            }

            GlobalVariables.LocalHero = ObjectManager.LocalHero;
            GlobalVariables.EnemyTeam = UnitExtensions.GetEnemyTeam(GlobalVariables.LocalHero);
            GlobalVariables.Team      = GlobalVariables.LocalHero.Team;

            // An aggregate catalog that combines multiple catalogs
            catalog = new AggregateCatalog();

            // Adds all the parts found in the Ability# assembly
            var count = 0f;

            //foreach (var cacheAssembly in EnsageSharp.Sandbox.Domain.PluginDomain.Assemblies)
            foreach (var cacheAssembly in AssemblyResolver.AssemblyCache)
            {
                if (cacheAssembly.IsLibrary || !cacheAssembly.IsLoaded || !cacheAssembly.Exists || !cacheAssembly.Name.StartsWith("Ability."))
                {
                    continue;
                }

                count++;
                //Console.WriteLine(cacheAssembly.AssemblyName + " " + cacheAssembly.Name);
                catalog.Catalogs.Add(new AssemblyCatalog(cacheAssembly.Assembly));
            }

            if (count == 0)
            {
                return;
            }

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(AbilityBootstrapper).Assembly));
            // Environment.
            // catalog.Catalogs.Add(new AssemblyCatalog());
            container = new CompositionContainer(catalog);

            // foreach (var c in catalog)
            // {
            // Console.WriteLine(c);
            // //foreach (var cExportDefinition in c.ExportDefinitions)
            // //{
            // //    Console.WriteLine(cExportDefinition.ToString());
            // //    foreach (var o in cExportDefinition.Metadata)
            // //    {
            // //        Console.WriteLine(o.ToString());
            // //    }
            // //}
            // }
            var delay = Game.GameTime < 0 ? 1500 : 500;

            DelayAction.Add(
                delay,
                () =>
            {
                this.initialized = true;
                ComposeParts(this);
                if (!Game.IsInGame)
                {
                    return;
                }

                this.AbilityFactory.Value.OnLoad();

                this.AbilityUnitManager.Value.OnLoad();

                this.MainMenuManager.Value.OnLoad();

                if (this.AbilityServices != null && this.AbilityServices.Any())
                {
                    foreach (var abilityService in this.AbilityServices)
                    {
                        Console.WriteLine("Service: " + abilityService.Value);
                        abilityService.Value?.OnLoad();
                    }
                }

                this.AbilityModuleManager.Value.OnLoad();

                this.AbilityDataCollector.Value.OnLoad();
            });

            // DelayAction.Add(
            // 500,
            // () =>
            // {
            // foreach (var abilityService in this.AbilityServices)
            // {
            // Console.WriteLine("Service: " + abilityService.Value);
            // }
            // });
        }