Skip to content

Commit 4e7b0c4

Browse files
code cleanup
1 parent 24ef194 commit 4e7b0c4

1 file changed

Lines changed: 26 additions & 23 deletions

File tree

Code/Helpers/FrameworkBridge.cs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,46 @@ public void Load()
2727
{
2828
_handles.Add(Timing.RunCoroutine(Await(framework)));
2929
}
30-
}
3130

32-
public string StopAndGetLoadedFrameworksMessage()
33-
{
34-
Timing.KillCoroutines(_handles.ToArray());
35-
_handles.Clear();
36-
if (_found.Count == 0) return "No supported framework was found, no additional methods were added.";
37-
return $"SER has added methods for {_found.Count} supported framework(s): " +
38-
$"{_found.Select(f => f.Type.ToString()).JoinStrings(", ")}";
31+
Timing.CallDelayed(3f, () =>
32+
{
33+
Timing.KillCoroutines(_handles.ToArray());
34+
_handles.Clear();
35+
Logger.Info(_found.Count == 0
36+
? "No supported framework was found, no additional methods were added."
37+
: $"SER has added methods for {_found.Count} supported framework(s): " +
38+
$"{_found.Select(f => f.Type.ToString()).JoinStrings(", ")}"
39+
);
40+
});
3941
}
4042

4143
private IEnumerator<float> Await(Framework framework)
4244
{
43-
for (int timer = 0; timer <= 3; timer++)
45+
// handled from forever repeating when coroutines are killed
46+
while (true)
4447
{
45-
yield return Timing.WaitForSeconds(1f);
46-
47-
if (_found.Contains(framework))
48-
{
49-
continue;
50-
}
48+
yield return Timing.WaitForSeconds(.5f);
5149

52-
if (PluginLoader.EnabledPlugins.All(plg => plg.Name != framework.Name) && !IsExiledCompatFrameworkLoaded(framework))
50+
if (IsLabAPIComatibleFrameworkLoaded(framework) || IsExiledCompatibleFrameworkLoaded(framework))
5351
{
54-
continue;
52+
break;
5553
}
56-
57-
_found.Add(framework);
58-
MethodIndex.LoadMethodsOfFramework(framework.Type);
5954
}
55+
56+
Logger.Debug($"SER found supported framework '{framework.Type}'");
57+
_found.Add(framework);
58+
MethodIndex.LoadMethodsOfFramework(framework.Type);
59+
}
6060

61-
Logger.Raw(StopAndGetLoadedFrameworksMessage(), ConsoleColor.DarkYellow);
61+
private static bool IsLabAPIComatibleFrameworkLoaded(Framework framework)
62+
{
63+
return PluginLoader.EnabledPlugins.Any(plg => plg.Name == framework.Name);
6264
}
6365

64-
private bool IsExiledCompatFrameworkLoaded(Framework framework)
66+
private static bool IsExiledCompatibleFrameworkLoaded(Framework framework)
6567
{
66-
if (framework.Type == IDependOnFramework.Type.Callvote) // As of right now, Callvote-Exiled is not compatible with SER.
68+
// As of right now, Callvote-Exiled is not compatible with SER.
69+
if (framework.Type == IDependOnFramework.Type.Callvote)
6770
{
6871
return false;
6972
}

0 commit comments

Comments
 (0)