Пример #1
0
        public void Add(ScriptComponent script)
        {
            script.Initialize(services);
            registeredScripts.Add(script);

            scriptsToStart.Add(script);

            if (script is SyncScript syncScript)
            {
                syncScripts.Add(syncScript);
            }
        }
Пример #2
0
        public void Remove(ScriptComponent script)
        {
            bool startWasPending = scriptsToStart.Remove(script);
            bool wasRegistered   = registeredScripts.Remove(script);

            if (!startWasPending && wasRegistered)
            {
                script.Cancel();

                if (script is AsyncScript asyncScript)
                {
                    asyncScript.CancellationTokenSource?.Cancel();
                }
            }

            if (script is SyncScript syncScript)
            {
                syncScripts.Remove(syncScript);
            }
        }