Browse Source

- Added old methods as support for old plugins

pull/46/head
artman41 6 years ago
parent
commit
366b58233e
3 changed files with 54 additions and 0 deletions
  1. +32
    -0
      IllusionInjector/CompositePlugin.cs
  2. +17
    -0
      IllusionInjector/PluginComponent.cs
  3. +5
    -0
      IllusionPlugin/IPlugin.cs

+ 32
- 0
IllusionInjector/CompositePlugin.cs View File

@ -80,6 +80,38 @@ namespace IllusionInjector {
Invoke(plugin => plugin.OnFixedUpdate());
}
[Obsolete("Use OnSceneLoaded instead")]
public void OnLevelWasLoaded(int level)
{
foreach (var plugin in plugins)
{
try
{
plugin.OnLevelWasLoaded(level);
}
catch (Exception ex)
{
Console.WriteLine("{0}: {1}", plugin.Name, ex);
}
}
}
[Obsolete("Use OnSceneLoaded instead")]
public void OnLevelWasInitialized(int level)
{
foreach (var plugin in plugins)
{
try
{
plugin.OnLevelWasInitialized(level);
}
catch (Exception ex)
{
Console.WriteLine("{0}: {1}", plugin.Name, ex);
}
}
}
public string Name {
get { throw new NotImplementedException(); }


+ 17
- 0
IllusionInjector/PluginComponent.cs View File

@ -9,6 +9,7 @@ namespace IllusionInjector
public class PluginComponent : MonoBehaviour
{
private CompositePlugin plugins;
private bool freshlyLoaded = false;
private bool quitting = false;
public static PluginComponent Create()
@ -27,9 +28,19 @@ namespace IllusionInjector
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
}
void Start()
{
OnLevelWasLoaded(Application.loadedLevel);
}
void Update()
{
if (freshlyLoaded)
{
freshlyLoaded = false;
plugins.OnLevelWasInitialized(Application.loadedLevel);
}
plugins.OnUpdate();
}
@ -61,6 +72,12 @@ namespace IllusionInjector
quitting = true;
}
void OnLevelWasLoaded(int level)
{
plugins.OnLevelWasLoaded(level);
freshlyLoaded = true;
}
void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
{


+ 5
- 0
IllusionPlugin/IPlugin.cs View File

@ -62,5 +62,10 @@ namespace IllusionPlugin
/// Gets invoked on ever physics update.
/// </summary>
void OnFixedUpdate();
[Obsolete("Use OnSceneLoaded instead")]
void OnLevelWasLoaded(int level);
[Obsolete("Use OnSceneLoaded instead")]
void OnLevelWasInitialized(int level);
}
}

Loading…
Cancel
Save