Cardlife mod patcher
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.

66 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. public static PluginComponent Create()
  12. {
  13. return new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
  14. }
  15. void Awake()
  16. {
  17. DontDestroyOnLoad(gameObject);
  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. Create();
  46. }
  47. void OnLevelWasLoaded(int level)
  48. {
  49. plugins.OnLevelWasLoaded(level);
  50. freshlyLoaded = true;
  51. }
  52. }
  53. }