Skip to content

Commit

Permalink
Merge pull request #16 from kinsi55/master
Browse files Browse the repository at this point in the history
Only load / parse data if there is any depending plugins
  • Loading branch information
halsafar authored Mar 17, 2022
2 parents bfd2758 + 69b59b0 commit e38ca96
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion SongDataCore/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using BS_Utils.Utilities;
using IPA.Loader;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;

namespace SongDataCore
{
Expand All @@ -21,6 +23,8 @@ public class Plugin

public bool DatabasesLoaded;

bool hasDependent = false;

[Init]
public void Init(IPA.Logging.Logger logger, PluginMetadata metadata)
{
Expand Down Expand Up @@ -55,6 +59,14 @@ private void OnMenuSceneLoadedFresh(ScenesTransitionSetupDataSO data)

// Force false, always load the database here.
DatabasesLoaded = false;

hasDependent = false;
foreach(var x in PluginManager.EnabledPlugins) {
hasDependent = IPA.Utilities.ReflectionUtil.GetProperty<HashSet<PluginMetadata>, PluginMetadata>(x, "Dependencies").Any(x => x.Id == "SongDataCore");

if(hasDependent)
break;
}
LoadDatabases();
}

Expand All @@ -74,7 +86,7 @@ private void OnGameSceneLoaded()

private void LoadDatabases()
{
if (DatabasesLoaded) return;
if (DatabasesLoaded || !hasDependent) return;

Songs.Load();

Expand Down

0 comments on commit e38ca96

Please sign in to comment.