public Analyzer(ModContentPack content) : base(content)
        {
            Settings = GetSettings <PerfAnalSettings>();

            if (Settings.UnlockFramerate && Application.platform != RuntimePlatform.OSXPlayer)
            {
                QualitySettings.vSyncCount  = 0;
                Application.targetFrameRate = 999;
            }

            foreach (var mod in LoadedModManager.RunningMods)
            {
                if (mod.Name == this.Content.Name)
                {
                    continue;
                }

                foreach (var ass in mod.assemblies.loadedAssemblies)
                {
                    try
                    {
                        AnalyzerCache.AssemblyToModname.Add(ass.FullName, mod.Name);
                    }
                    catch (Exception)
                    {
                        // we do this so if there are duplicated assemblies, we don't have duplicated keys(unnecessary complexity)
                    }
                }
            }

            foreach (var dir in ModLister.AllActiveModDirs)
            {
                var count = dir.GetFiles("Analyzer.xml")?.Count();
                if (count != 0)
                {
                    var         thing = dir.GetFiles("Analyzer.xml").First();
                    XmlDocument doc   = new XmlDocument();
                    doc.Load(thing.OpenRead());
                    XmlParser.Parse(doc, ref methods);
                }
            }

            if (methods.Count != 0)
            {
                foreach (var m in methods)
                {
                    Type myType = DynamicTypeBuilder.CreateType(m.Key, m.Value);

                    foreach (var profileTab in AnalyzerState.SideTabCategories)
                    {
                        if (profileTab.UpdateMode == UpdateMode.ModderAdded)
                        {
                            ProfileMode mode = ProfileMode.Create(myType.Name, UpdateMode.ModderAdded, null, false, myType);
                            profileTab.Modes.Add(mode, null);
                            break;
                        }
                    }
                }
            }
        }
Exemple #2
0
 public Analyzer(ModContentPack content) : base(content)
 {
     Settings = GetSettings <PerfAnalSettings>();
 }