|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- using IllusionPlugin;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using UnityEngine;
-
- namespace IllusionInjector
- {
- public class CompositePlugin : IPlugin
- {
- IEnumerable<IPlugin> plugins;
-
- private delegate void CompositeCall(IPlugin plugin);
-
- public CompositePlugin(IEnumerable<IPlugin> plugins)
- {
- this.plugins = plugins;
- }
-
- public void OnApplicationStart()
- {
- Debug.LogWarning($"OnApplicationStart Test Warning");
- Invoke(plugin => plugin.OnApplicationStart(), "OnApplicationStart");
- }
-
- public void OnApplicationQuit()
- {
- Invoke(plugin => plugin.OnApplicationQuit());
- }
-
-
- private void Invoke(CompositeCall callback, string name = null)
- {
- foreach (var plugin in plugins)
- {
- try
- {
- callback(plugin);
- if (!string.IsNullOrEmpty(name))
- Debug.LogWarning($"Executed {name} for plugin {plugin.Name}");
- }
- catch (Exception ex)
- {
- Console.WriteLine("{0}: {1}", plugin.Name, ex);
- }
- }
- }
-
-
- public void OnUpdate()
- {
- Invoke(plugin => plugin.OnUpdate());
- }
-
- public void OnFixedUpdate()
- {
- Invoke(plugin => plugin.OnFixedUpdate());
- }
-
- public void OnAnimatorIK(int layerIndex) { Invoke(plugin => plugin.OnAnimatorIK(layerIndex)); }
-
- public void OnAnimatorMove() { Invoke(plugin => plugin.OnAnimatorMove()); }
-
- public void OnApplicationFocus(bool hasFocus) { Invoke(plugin => plugin.OnApplicationFocus(hasFocus)); }
-
- public void OnApplicationPause(bool pauseStatus) { Invoke(plugin => plugin.OnApplicationPause(pauseStatus)); }
-
- public void OnAudioFilterRead(float[] data, int channels) { Invoke(plugin => plugin.OnAudioFilterRead(data, channels)); }
-
- public void OnBecameInvisible() { Invoke(plugin => plugin.OnBecameInvisible()); }
-
- public void OnBecameVisible() { Invoke(plugin => plugin.OnBecameVisible()); }
-
- public void OnBeforeTransformParentChanged() { Invoke(plugin => plugin.OnBeforeTransformParentChanged()); }
-
- public void OnCanvasGroupChanged() { Invoke(plugin => plugin.OnCanvasGroupChanged()); }
-
- public void OnCanvasHierarchyChanged() { Invoke(plugin => plugin.OnCanvasHierarchyChanged()); }
-
- public void OnCollisionEnter(Collision other) { Invoke(plugin => plugin.OnCollisionEnter(other)); }
-
- public void OnCollisionEnter2D(Collision2D other) { Invoke(plugin => plugin.OnCollisionEnter2D(other)); }
-
- public void OnCollisionExit(Collision other) { Invoke(plugin => plugin.OnCollisionExit(other)); }
-
- public void OnCollisionExit2D(Collision2D other) { Invoke(plugin => plugin.OnCollisionExit2D(other)); }
-
- public void OnCollisionStay(Collision other) { Invoke(plugin => plugin.OnCollisionStay(other)); }
-
- public void OnCollisionStay2D(Collision2D other) { Invoke(plugin => plugin.OnCollisionStay2D(other)); }
-
- public void OnConnectedToServer() { Invoke(plugin => plugin.OnConnectedToServer()); }
-
- public void OnControllerColliderHit(ControllerColliderHit hit) { Invoke(plugin => plugin.OnControllerColliderHit(hit)); }
-
- public void OnDidApplyAnimationProperties() { Invoke(plugin => plugin.OnDidApplyAnimationProperties()); }
-
- public void OnDisable() { Invoke(plugin => plugin.OnDisable()); }
-
- public void OnDrawGizmos() { Invoke(plugin => plugin.OnDrawGizmos()); }
-
- public void OnDrawGizmosSelected() { Invoke(plugin => plugin.OnDrawGizmosSelected()); }
-
- public void OnEnable() { Invoke(plugin => plugin.OnEnable()); }
-
- public void OnGUI() { Invoke(plugin => plugin.OnGUI()); }
-
- public void OnJointBreak(float breakForce) { Invoke(plugin => plugin.OnJointBreak(breakForce)); }
-
- public void OnMouseDown() { Invoke(plugin => plugin.OnMouseDown()); }
-
- public void OnMouseDrag() { Invoke(plugin => plugin.OnMouseDrag()); }
-
- public void OnMouseEnter() { Invoke(plugin => plugin.OnMouseEnter()); }
-
- public void OnMouseExit() { Invoke(plugin => plugin.OnMouseExit()); }
-
- public void OnMouseOver() { Invoke(plugin => plugin.OnMouseOver()); }
-
- public void OnMouseUp() { Invoke(plugin => plugin.OnMouseUp()); }
-
- public void OnMouseUpAsButton() { Invoke(plugin => plugin.OnMouseUpAsButton()); }
-
- public void OnParticleCollision(GameObject other) { Invoke(plugin => plugin.OnParticleCollision(other)); }
-
- public void OnPostRender() { Invoke(plugin => plugin.OnPostRender()); }
-
- public void OnPreCull() { Invoke(plugin => plugin.OnPreCull()); }
-
- public void OnPreRender() { Invoke(plugin => plugin.OnPreRender()); }
-
- public void OnRectTransformDimensionsChange() { Invoke(plugin => plugin.OnRectTransformDimensionsChange()); }
-
- public void OnRenderImage(RenderTexture src, RenderTexture dest) { Invoke(plugin => plugin.OnRenderImage(src, dest)); }
-
- public void OnRenderObject() { Invoke(plugin => plugin.OnRenderObject()); }
-
- public void OnServerInitialized() { Invoke(plugin => plugin.OnServerInitialized()); }
-
- public void OnTransformChildrenChanged() { Invoke(plugin => plugin.OnTransformChildrenChanged()); }
-
- public void OnTransformParentChanged() { Invoke(plugin => plugin.OnTransformParentChanged()); }
-
- public void OnTriggerEnter(Collider other) { Invoke(plugin => plugin.OnTriggerEnter(other)); }
-
- public void OnTriggerEnter2D(Collider2D other) { Invoke(plugin => plugin.OnTriggerEnter2D(other)); }
-
- public void OnTriggerExit(Collider other) { Invoke(plugin => plugin.OnTriggerExit(other)); }
-
- public void OnTriggerExit2D(Collider2D other) { Invoke(plugin => plugin.OnTriggerExit2D(other)); }
-
- public void OnTriggerStay(Collider other) { Invoke(plugin => plugin.OnTriggerStay(other)); }
-
- public void OnTriggerStay2D(Collider2D other) { Invoke(plugin => plugin.OnTriggerStay2D(other)); }
-
- public void OnValidate() { Invoke(plugin => plugin.OnValidate()); }
-
- public void OnWillRenderObject() { Invoke(plugin => plugin.OnWillRenderObject()); }
-
- public void Reset() { Invoke(plugin => plugin.Reset()); }
-
-
- public string Name
- {
- get { throw new NotImplementedException(); }
- }
-
- public string Version
- {
- get { throw new NotImplementedException(); }
- }
-
- public void OnLateUpdate()
- {
- Invoke(plugin =>
- {
- if (plugin is IEnhancedPlugin)
- ((IEnhancedPlugin)plugin).OnLateUpdate();
- });
- }
- }
- }
|