Example #1
0
        private static async Task OnLoadAsync()
        {
            if (OnLoad == null)
            {
                return;
            }

            foreach (var @delegate in OnLoad.GetInvocationList())
            {
                if (@delegate == null)
                {
                    return;
                }

                @delegate.DynamicInvoke(MethodBase.GetCurrentMethod().DeclaringType, EventArgs.Empty);
                if (@delegate.Target == null)
                {
                    //Console.WriteLine(@delegate.ToString());
                    continue;
                }

                if (@delegate.Target.ToString().Contains("Transitions."))
                {
                    continue;
                }

                //Console.WriteLine(@delegate.Target.ToString());
                await Task.Delay(50);
            }
        }
Example #2
0
 /// <summary>
 ///     Calls the OnLoad event.
 /// </summary>
 private static void CallOnLoad()
 {
     if (OnLoad != null)
     {
         InvocationList.AddRange(OnLoad.GetInvocationList());
         OnLoad(MethodBase.GetCurrentMethod().DeclaringType, EventArgs.Empty);
     }
 }
Example #3
0
        private static void EventLoad()
        {
            if (OnLoad == null)
            {
                return;
            }

            foreach (var invocation in OnLoad.GetInvocationList().Where(i => LoadInvocationList.All(l => l != i)))
            {
                LoadInvocationList.Add(invocation);
                try
                {
                    invocation.DynamicInvoke(MethodBase.GetCurrentMethod().DeclaringType, EventArgs.Empty);
                }
                catch (Exception e)
                {
                    Logging.Write()(LogLevel.Fatal, "Failure to invoke invocation.\n{0}", e);
                }
            }
        }
Example #4
0
        private static void EventLoad()
        {
            if (OnLoad == null)
            {
                return;
            }

            foreach (var invocation in OnLoad.GetInvocationList().Where(i => LoadInvocationList.All(l => l != i)))
            {
                LoadInvocationList.Add(invocation);
                try
                {
                    invocation.DynamicInvoke(MethodBase.GetCurrentMethod().DeclaringType, EventArgs.Empty);
                }
                catch (Exception e)
                {
                    LogManager.GetCurrentClassLogger().Error(e);
                }
            }
        }
Example #5
0
        private static async void UpdateOnLoad()
        {
            while (!loaderTask.IsCancellationRequested)
            {
                try
                {
                    await Task.Delay(250, loaderTask.Token);

                    if (OnLoad == null)
                    {
                        continue;
                    }

                    if (!IngameTrigger.Value)
                    {
                        continue;
                    }

                    var subscribers = OnLoad.GetInvocationList();

                    foreach (var subscriber in subscribers.Where(s => !NotifiedSubscribers.Contains(s)))
                    {
                        NotifiedSubscribers.Add(subscriber);

                        GameDispatcher.BeginInvoke(() => { subscriber.DynamicInvoke(Type, EventArgs.Empty); });
                    }
                }
                catch (TaskCanceledException)
                {
                    Console.WriteLine("Stopped LoaderTask");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }