A fork of Eusth's IPA
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PluginComponent.cs 1.5KB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using UnityEngine;
  2. namespace IllusionInjector
  3. {
  4. public class PluginComponent : MonoBehaviour
  5. {
  6. private CompositePlugin plugins;
  7. private bool freshlyLoaded = false;
  8. private bool quitting = false;
  9. public static PluginComponent Create()
  10. {
  11. return new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
  12. }
  13. private void Awake()
  14. {
  15. DontDestroyOnLoad(gameObject);
  16. plugins = new CompositePlugin(PluginManager.Plugins);
  17. plugins.OnApplicationStart();
  18. }
  19. private void Start()
  20. {
  21. OnLevelWasLoaded(Application.loadedLevel);
  22. }
  23. private void Update()
  24. {
  25. if (freshlyLoaded)
  26. {
  27. freshlyLoaded = false;
  28. plugins.OnLevelWasInitialized(Application.loadedLevel);
  29. }
  30. plugins.OnUpdate();
  31. }
  32. private void LateUpdate()
  33. {
  34. plugins.OnLateUpdate();
  35. }
  36. private void FixedUpdate()
  37. {
  38. plugins.OnFixedUpdate();
  39. }
  40. private void OnDestroy()
  41. {
  42. if (!quitting)
  43. {
  44. Create();
  45. }
  46. }
  47. private void OnApplicationQuit()
  48. {
  49. plugins.OnApplicationQuit();
  50. quitting = true;
  51. }
  52. private void OnLevelWasLoaded(int level)
  53. {
  54. plugins.OnLevelWasLoaded(level);
  55. freshlyLoaded = true;
  56. }
  57. }
  58. }