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.

CompositePlugin.cs 6.5KB

8 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using IllusionPlugin;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using UnityEngine;
  6. namespace IllusionInjector
  7. {
  8. public class CompositePlugin : IPlugin
  9. {
  10. IEnumerable<IPlugin> plugins;
  11. private delegate void CompositeCall(IPlugin plugin);
  12. public CompositePlugin(IEnumerable<IPlugin> plugins)
  13. {
  14. this.plugins = plugins;
  15. }
  16. public void OnApplicationStart()
  17. {
  18. Invoke(plugin => plugin.OnApplicationStart());
  19. }
  20. public void OnApplicationQuit()
  21. {
  22. Invoke(plugin => plugin.OnApplicationQuit());
  23. }
  24. private void Invoke(CompositeCall callback)
  25. {
  26. foreach (var plugin in plugins)
  27. {
  28. try
  29. {
  30. callback(plugin);
  31. }
  32. catch (Exception ex)
  33. {
  34. Console.WriteLine("{0}: {1}", plugin.Name, ex);
  35. }
  36. }
  37. }
  38. public void OnUpdate()
  39. {
  40. Invoke(plugin => plugin.OnUpdate());
  41. }
  42. public void OnFixedUpdate()
  43. {
  44. Invoke(plugin => plugin.OnFixedUpdate());
  45. }
  46. public void OnAnimatorIK(int layerIndex) { Invoke(plugin => plugin.OnAnimatorIK(layerIndex)); }
  47. public void OnAnimatorMove() { Invoke(plugin => plugin.OnAnimatorMove()); }
  48. public void OnApplicationFocus(bool hasFocus) { Invoke(plugin => plugin.OnApplicationFocus(hasFocus)); }
  49. public void OnApplicationPause(bool pauseStatus) { Invoke(plugin => plugin.OnApplicationPause(pauseStatus)); }
  50. public void OnAudioFilterRead(float[] data, int channels) { Invoke(plugin => plugin.OnAudioFilterRead(data, channels)); }
  51. public void OnBecameInvisible() { Invoke(plugin => plugin.OnBecameInvisible()); }
  52. public void OnBecameVisible() { Invoke(plugin => plugin.OnBecameVisible()); }
  53. public void OnBeforeTransformParentChanged() { Invoke(plugin => plugin.OnBeforeTransformParentChanged()); }
  54. public void OnCanvasGroupChanged() { Invoke(plugin => plugin.OnCanvasGroupChanged()); }
  55. public void OnCanvasHierarchyChanged() { Invoke(plugin => plugin.OnCanvasHierarchyChanged()); }
  56. public void OnCollisionEnter(Collision other) { Invoke(plugin => plugin.OnCollisionEnter(other)); }
  57. public void OnCollisionEnter2D(Collision2D other) { Invoke(plugin => plugin.OnCollisionEnter2D(other)); }
  58. public void OnCollisionExit(Collision other) { Invoke(plugin => plugin.OnCollisionExit(other)); }
  59. public void OnCollisionExit2D(Collision2D other) { Invoke(plugin => plugin.OnCollisionExit2D(other)); }
  60. public void OnCollisionStay(Collision other) { Invoke(plugin => plugin.OnCollisionStay(other)); }
  61. public void OnCollisionStay2D(Collision2D other) { Invoke(plugin => plugin.OnCollisionStay2D(other)); }
  62. public void OnConnectedToServer() { Invoke(plugin => plugin.OnConnectedToServer()); }
  63. public void OnControllerColliderHit(ControllerColliderHit hit) { Invoke(plugin => plugin.OnControllerColliderHit(hit)); }
  64. public void OnDidApplyAnimationProperties() { Invoke(plugin => plugin.OnDidApplyAnimationProperties()); }
  65. public void OnDisable() { Invoke(plugin => plugin.OnDisable()); }
  66. public void OnDrawGizmos() { Invoke(plugin => plugin.OnDrawGizmos()); }
  67. public void OnDrawGizmosSelected() { Invoke(plugin => plugin.OnDrawGizmosSelected()); }
  68. public void OnEnable() { Invoke(plugin => plugin.OnEnable()); }
  69. public void OnGUI() { Invoke(plugin => plugin.OnGUI()); }
  70. public void OnJointBreak(float breakForce) { Invoke(plugin => plugin.OnJointBreak(breakForce)); }
  71. public void OnMouseDown() { Invoke(plugin => plugin.OnMouseDown()); }
  72. public void OnMouseDrag() { Invoke(plugin => plugin.OnMouseDrag()); }
  73. public void OnMouseEnter() { Invoke(plugin => plugin.OnMouseEnter()); }
  74. public void OnMouseExit() { Invoke(plugin => plugin.OnMouseExit()); }
  75. public void OnMouseOver() { Invoke(plugin => plugin.OnMouseOver()); }
  76. public void OnMouseUp() { Invoke(plugin => plugin.OnMouseUp()); }
  77. public void OnMouseUpAsButton() { Invoke(plugin => plugin.OnMouseUpAsButton()); }
  78. public void OnParticleCollision(GameObject other) { Invoke(plugin => plugin.OnParticleCollision(other)); }
  79. public void OnPostRender() { Invoke(plugin => plugin.OnPostRender()); }
  80. public void OnPreCull() { Invoke(plugin => plugin.OnPreCull()); }
  81. public void OnPreRender() { Invoke(plugin => plugin.OnPreRender()); }
  82. public void OnRectTransformDimensionsChange() { Invoke(plugin => plugin.OnRectTransformDimensionsChange()); }
  83. public void OnRenderImage(RenderTexture src, RenderTexture dest) { Invoke(plugin => plugin.OnRenderImage(src, dest)); }
  84. public void OnRenderObject() { Invoke(plugin => plugin.OnRenderObject()); }
  85. public void OnServerInitialized() { Invoke(plugin => plugin.OnServerInitialized()); }
  86. public void OnTransformChildrenChanged() { Invoke(plugin => plugin.OnTransformChildrenChanged()); }
  87. public void OnTransformParentChanged() { Invoke(plugin => plugin.OnTransformParentChanged()); }
  88. public void OnTriggerEnter(Collider other) { Invoke(plugin => plugin.OnTriggerEnter(other)); }
  89. public void OnTriggerEnter2D(Collider2D other) { Invoke(plugin => plugin.OnTriggerEnter2D(other)); }
  90. public void OnTriggerExit(Collider other) { Invoke(plugin => plugin.OnTriggerExit(other)); }
  91. public void OnTriggerExit2D(Collider2D other) { Invoke(plugin => plugin.OnTriggerExit2D(other)); }
  92. public void OnTriggerStay(Collider other) { Invoke(plugin => plugin.OnTriggerStay(other)); }
  93. public void OnTriggerStay2D(Collider2D other) { Invoke(plugin => plugin.OnTriggerStay2D(other)); }
  94. public void OnValidate() { Invoke(plugin => plugin.OnValidate()); }
  95. public void OnWillRenderObject() { Invoke(plugin => plugin.OnWillRenderObject()); }
  96. public void Reset() { Invoke(plugin => plugin.Reset()); }
  97. public string Name
  98. {
  99. get { throw new NotImplementedException(); }
  100. }
  101. public string Version
  102. {
  103. get { throw new NotImplementedException(); }
  104. }
  105. public void OnLateUpdate()
  106. {
  107. Invoke(plugin =>
  108. {
  109. if (plugin is IEnhancedPlugin)
  110. ((IEnhancedPlugin)plugin).OnLateUpdate();
  111. });
  112. }
  113. }
  114. }