From cab1fbd9fa41b9dee65a40c6e10b44ce1700b6ab Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 22 Dec 2019 15:38:07 -0600 Subject: [PATCH] Moved some plugin interface stuff around --- IPA.Loader/IPA.Loader.csproj | 1 - .../Loader/Composite/CompositeBSPlugin.cs | 22 ++++++++++------- .../BeatSaber/IDisablablePlugin.cs | 2 +- .../BeatSaber/IEnhancedPlugin.cs | 17 ++++++++++++- .../PluginInterfaces/BeatSaber/IPlugin.cs | 12 ---------- .../IGenericEnhancedPlugin.cs | 24 ------------------- .../PluginInterfaces/IPA/IEnhancedPlugin.cs | 2 +- 7 files changed, 31 insertions(+), 49 deletions(-) delete mode 100644 IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index 49179841..bacdc995 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -128,7 +128,6 @@ - diff --git a/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs b/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs index 70bc6999..fc25db70 100644 --- a/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs +++ b/IPA.Loader/Loader/Composite/CompositeBSPlugin.cs @@ -43,21 +43,25 @@ namespace IPA.Loader.Composite } } - public void OnUpdate() { - Invoke(plugin => plugin.Plugin.OnUpdate()); + public void OnUpdate() + { + Invoke(plugin => { + if (plugin.Plugin is IEnhancedPlugin saberPlugin) + saberPlugin.OnUpdate(); + }); } - public void OnFixedUpdate() { - Invoke(plugin => plugin.Plugin.OnFixedUpdate()); + public void OnFixedUpdate() + { + Invoke(plugin => { + if (plugin.Plugin is IEnhancedPlugin saberPlugin) + saberPlugin.OnFixedUpdate(); + }); } - public string Name => throw new InvalidOperationException(); - - public string Version => throw new InvalidOperationException(); - public void OnLateUpdate() { Invoke(plugin => { - if (plugin.Plugin is IGenericEnhancedPlugin saberPlugin) + if (plugin.Plugin is IEnhancedPlugin saberPlugin) saberPlugin.OnLateUpdate(); }); } diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs index c270515c..f3be9e5a 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs @@ -3,7 +3,7 @@ /// /// Provides methods to allow runtime disabling of a plugin. /// - public interface IDisablablePlugin + public interface IDisablablePlugin : IPlugin { /// diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs index c0dcc842..960c1688 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedPlugin.cs @@ -10,7 +10,22 @@ namespace IPA /// /// An enhanced version of a standard BeatSaber plugin. /// - public interface IEnhancedPlugin : IPlugin, IGenericEnhancedPlugin + public interface IEnhancedPlugin : IPlugin { + + /// + /// Gets invoked on every graphic update. + /// + void OnUpdate(); + + /// + /// Gets invoked on ever physics update. + /// + void OnFixedUpdate(); + + /// + /// Called after Update. + /// + void OnLateUpdate(); } } diff --git a/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs index 7710e512..c298d87a 100644 --- a/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs @@ -28,18 +28,6 @@ namespace IPA /// void OnApplicationQuit(); - // TODO: move more of these out of IPlugin - - /// - /// Gets invoked on every graphic update. - /// - void OnUpdate(); - - /// - /// Gets invoked on ever physics update. - /// - void OnFixedUpdate(); - /// /// Gets invoked whenever a scene is loaded. /// diff --git a/IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs b/IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs deleted file mode 100644 index 6a853c96..00000000 --- a/IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs +++ /dev/null @@ -1,24 +0,0 @@ -// ReSharper disable CheckNamespace - -using System; - -namespace IPA -{ - /// - /// A generic interface for the modification for enhanced plugins. - /// - public interface IGenericEnhancedPlugin - { - /// - /// Gets a list of executables this plugin should be executed on (without the file ending) - /// - /// { "PlayClub", "PlayClubStudio" } - [Obsolete("Ignored.")] - string[] Filter { get; } - - /// - /// Called after Update. - /// - void OnLateUpdate(); - } -} diff --git a/IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs b/IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs index 4db7fa06..9e4420b9 100644 --- a/IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs +++ b/IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs @@ -7,7 +7,7 @@ namespace IPA.Old /// /// An enhanced version of the standard IPA plugin. /// - [Obsolete("When building plugins for Beat Saber, use IEnhancedBeatSaberPlugin")] + [Obsolete("When building plugins for Beat Saber, use IPA.IEnhancedPlugin")] public interface IEnhancedPlugin : IPlugin { ///