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.

64 lines
1.3KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. namespace IllusionInjector
  6. {
  7. public class PluginComponent : MonoBehaviour
  8. {
  9. private CompositePlugin plugins;
  10. private bool freshlyLoaded = false;
  11. void Awake()
  12. {
  13. DontDestroyOnLoad(gameObject);
  14. if (Environment.CommandLine.Contains("--verbose") && !Screen.fullScreen)
  15. {
  16. Windows.GuiConsole.CreateConsole();
  17. }
  18. plugins = new CompositePlugin(PluginManager.Plugins);
  19. plugins.OnApplicationStart();
  20. }
  21. void Start()
  22. {
  23. OnLevelWasLoaded(Application.loadedLevel);
  24. }
  25. void Update()
  26. {
  27. if (freshlyLoaded)
  28. {
  29. freshlyLoaded = false;
  30. plugins.OnLevelWasInitialized(Application.loadedLevel);
  31. }
  32. plugins.OnUpdate();
  33. }
  34. void LateUpdate()
  35. {
  36. plugins.OnLateUpdate();
  37. }
  38. void FixedUpdate()
  39. {
  40. plugins.OnFixedUpdate();
  41. }
  42. void OnDestroy()
  43. {
  44. plugins.OnApplicationQuit();
  45. }
  46. void OnLevelWasLoaded(int level)
  47. {
  48. plugins.OnLevelWasLoaded(level);
  49. freshlyLoaded = true;
  50. }
  51. }
  52. }