Пример #1
0
        public void Tick()
        {
            if (RechargeCooldown > 0)
            {
                RechargeCooldown--;
            }
            if (RechargeCooldown <= 0)
            {
                RechargeCooldown = RechargeCooldownSpeed;
                Power           += RechargePower;
            }

            if (Cooldown > 0)
            {
                Cooldown--;
            }

            ActOnPower(1, () =>
            {
                if (scriptExecution == null)
                {
                    StartScript();
                }
                if (!scriptExecution.Step())
                {
                    scriptExecution = null;
                }
                Power--;
            });
        }
Пример #2
0
        internal static void DeinitializeInternal(bool reset)
        {
            m_loadedFilesManager.UnloadAllFilesWithoutDependants();

            TaskContextDummy taskContext = new TaskContextDummy();

            m_serviceManagerAdmin.StopServices(taskContext, reset);

            if (reset)
            {
                m_serviceManagerAdmin    = null;
                m_mainLogger             = null;
                m_loadedFilesManager     = null;
                m_addonManager           = null;
                m_logSinkManager         = null;
                m_scriptExecutionManager = null;
                m_dynamicObjectManager   = null;
                m_uiCalculator           = null;

                m_serviceManagerAdmin = ServiceManager.Create();
            }
        }
Пример #3
0
 public void StartScript()
 {
     scriptExecution           = scriptDelegate.CreateExecutionManager();
     scriptExecution.KeepAsync = true;
 }
Пример #4
0
        public static void Initialize(IEnumerable <IService> hostServices = null)
        {
            IService service;

            m_mainLogger = new MainLogger(out service);
            m_rootLogger = m_mainLogger.Logger.RootLogger;
            m_serviceManagerAdmin.Manager.Register(service);

            m_loadedFilesManager = new LoadedFilesManager(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_addonManager = new AddonManager(
                (IAddonManager m) =>
            {
                // **** LOAD THE ADDON MODULES ****

                m.AddAssembly(typeof(DateTime).Assembly, false);
                m.AddAssembly(typeof(Enumerable).Assembly, false);
                m.AddAssembly(typeof(Math).Assembly, false);
                m.AddAssembly(AddonManager.StepBroCoreAssembly, true);

                var modulesFolder = Path.Combine(Path.GetDirectoryName(typeof(AddonManager).Assembly.Location), "Modules");
                foreach (var f in Directory.GetFiles(modulesFolder, "*.dll"))
                {
                    m.LoadAssembly(f, false);
                }
            },
                out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_logSinkManager = new LogSinkManager(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_taskManager = new TaskManager(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_hostActions = new HostApplicationActionQueue(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_scriptExecutionManager = new ScriptExecutionManager(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_dynamicObjectManager = new DynamicObjectManager(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            m_uiCalculator = new UICalculator(out service);
            m_serviceManagerAdmin.Manager.Register(service);

            if (hostServices != null)
            {
                foreach (var hs in hostServices)
                {
                    m_serviceManagerAdmin.Manager.Register(hs);
                }
            }

            TaskContextDummy taskContext = new TaskContextDummy();

            try
            {
                m_serviceManagerAdmin.StartServices(taskContext);
            }
            catch (Exception ex)
            {
                // Roll back (stop) the services that actually did start.
                try
                {
                    m_serviceManagerAdmin.StopServices(taskContext);
                }
                catch { /* Ignore exceptions during stop */ }
                throw new Exception("Failed to start all services. " + ex.GetType().Name + ", " + ex.ToString());
            }

            m_initialized = true;
            m_initIndex++;
        }
Пример #5
0
        public void Tick()
        {
            if (RechargeCooldown > 0)
            {
                RechargeCooldown--;
            }
            if (RechargeCooldown <= 0)
            {
                RechargeCooldown = RechargeCooldownSpeed;
                Power += RechargePower;
            }

            if(Cooldown > 0)
            {
                Cooldown--;
            }

            ActOnPower(1, () =>
            {
                if (scriptExecution == null)
                {
                    StartScript();
                }
                if (!scriptExecution.Step())
                {
                    scriptExecution = null;
                }
                Power--;
            });
        }
Пример #6
0
 public void StartScript()
 {
     scriptExecution = scriptDelegate.CreateExecutionManager();
     scriptExecution.KeepAsync = true;
 }