예제 #1
0
        private static void CacheCallouts()
        {
            foreach (var Assem in Functions.GetAllUserPlugins())
            {
                var AssemName     = Assem.GetName();
                var AssemCallouts = (from Callout in Assem.GetTypes()
                                     where Callout.IsClass && Callout.BaseType == typeof(LSPD_First_Response.Mod.Callouts.Callout)
                                     select Callout).ToList();

                if (AssemCallouts.Count() < 1)
                {
                    Logger.Log(Assem.GetName().Name + " No callouts detected.");
                }

                else
                {
                    var AddCount = 0;
                    foreach (Type Callout in AssemCallouts)
                    {
                        var CalloutAttributes = Callout.GetCustomAttributes(typeof(CalloutInfoAttribute), true);

                        if (CalloutAttributes.Count() > 0)
                        {
                            var CalloutAttribute = (CalloutInfoAttribute)(from a in CalloutAttributes select a).FirstOrDefault();

                            if (CalloutAttribute != null)
                            {
                                if (Globals.Config.CalloutProbability == false)
                                {
                                    RandomCalloutCache.Add(CalloutAttribute.Name);
                                }

                                else
                                {
                                    for (var LoopCount = 0; LoopCount < CalloutProbabilityRegistrationCount[(int)CalloutAttribute.CalloutProbability] * Globals.Config.CalloutProbabilityModifier; LoopCount++)
                                    {
                                        RandomCalloutCache.Add(CalloutAttribute.Name);
                                    }
                                }
                                AddCount++;
                            }
                        }
                    }

                    Logger.Log(Assem.GetName().Name + $" detected {AddCount} callouts and added them to the ForceACallout cache.");
                }
            }

            if (Globals.Config.CalloutProbability == true)
            {
                Logger.Log($"{RandomCalloutCache.Count} total probabilities registered in ForceACallout.");
            }
        }
예제 #2
0
        internal static void CacheCallouts()
        {
            foreach (Assembly Assem in Functions.GetAllUserPlugins())
            {
                AssemblyName AssemName     = Assem.GetName();
                List <Type>  AssemCallouts = (from Callout in Assem.GetTypes()
                                              where Callout.IsClass && Callout.BaseType == typeof(LSPD_First_Response.Mod.Callouts.Callout)
                                              select Callout).ToList();

                if (AssemCallouts.Count() < 1)
                {
                    Logger.Log(Assem.FullName + "No callouts detected.");
                }

                else
                {
                    int AddCount = 0;
                    foreach (Type Callout in AssemCallouts)
                    {
                        object[] CalloutAttributes = Callout.GetCustomAttributes(typeof(CalloutInfoAttribute), true);

                        if (CalloutAttributes.Count() > 0)
                        {
                            CalloutInfoAttribute CalloutAttribute = (CalloutInfoAttribute)(from a in CalloutAttributes select a).FirstOrDefault();

                            if (CalloutAttribute != null)
                            {
                                RandomCalloutCache.Add(CalloutAttribute.Name);
                                AddCount++;
                            }
                        }
                    }

                    Logger.Log(Assem.FullName + $" detected {AddCount} callouts and added them to the ForceACallout cache.");
                }
            }
        }