Browse Source

Merge branch 'master' of https://github.com/artman41/IPA-Reloaded

pull/46/head
andruzzzhka 6 years ago
parent
commit
41dc5e5427
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()); 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 { public string Name {
get { throw new NotImplementedException(); } get { throw new NotImplementedException(); }


+ 17
- 0
IllusionInjector/PluginComponent.cs View File

@ -9,6 +9,7 @@ namespace IllusionInjector
public class PluginComponent : MonoBehaviour public class PluginComponent : MonoBehaviour
{ {
private CompositePlugin plugins; private CompositePlugin plugins;
private bool freshlyLoaded = false;
private bool quitting = false; private bool quitting = false;
public static PluginComponent Create() public static PluginComponent Create()
@ -27,9 +28,19 @@ namespace IllusionInjector
SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.sceneUnloaded += OnSceneUnloaded;
} }
void Start()
{
OnLevelWasLoaded(Application.loadedLevel);
}
void Update() void Update()
{ {
if (freshlyLoaded)
{
freshlyLoaded = false;
plugins.OnLevelWasInitialized(Application.loadedLevel);
}
plugins.OnUpdate(); plugins.OnUpdate();
} }
@ -61,6 +72,12 @@ namespace IllusionInjector
quitting = true; quitting = true;
} }
void OnLevelWasLoaded(int level)
{
plugins.OnLevelWasLoaded(level);
freshlyLoaded = true;
}
void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode) 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. /// Gets invoked on ever physics update.
/// </summary> /// </summary>
void OnFixedUpdate(); void OnFixedUpdate();
[Obsolete("Use OnSceneLoaded instead")]
void OnLevelWasLoaded(int level);
[Obsolete("Use OnSceneLoaded instead")]
void OnLevelWasInitialized(int level);
} }
} }

Loading…
Cancel
Save