From f99c755732c1127f98248035faf6ea8f7aa2b0b8 Mon Sep 17 00:00:00 2001 From: Arti Kearney Date: Sat, 11 Aug 2018 10:02:17 -0700 Subject: [PATCH] Plugin working --- HitScoreVisualizer.sln | 25 +++++++ ...fterCutSwingRatingCounterDidChangeEvent.cs | 29 ++++++++ HitScoreVisualizer/HitScoreVisualizer.csproj | 67 +++++++++++++++++++ HitScoreVisualizer/Plugin.cs | 61 +++++++++++++++++ HitScoreVisualizer/Properties/AssemblyInfo.cs | 36 ++++++++++ 5 files changed, 218 insertions(+) create mode 100644 HitScoreVisualizer.sln create mode 100644 HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs create mode 100644 HitScoreVisualizer/HitScoreVisualizer.csproj create mode 100644 HitScoreVisualizer/Plugin.cs create mode 100644 HitScoreVisualizer/Properties/AssemblyInfo.cs diff --git a/HitScoreVisualizer.sln b/HitScoreVisualizer.sln new file mode 100644 index 0000000..6c22596 --- /dev/null +++ b/HitScoreVisualizer.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2035 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HitScoreVisualizer", "HitScoreVisualizer\HitScoreVisualizer.csproj", "{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FCB42BAF-E3A9-4B03-B8A5-2538DB0373DF} + EndGlobalSection +EndGlobal diff --git a/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs b/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs new file mode 100644 index 0000000..25ec770 --- /dev/null +++ b/HitScoreVisualizer/Harmony Patches/FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs @@ -0,0 +1,29 @@ +using Harmony; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace HitScoreVisualizer.Harmony_Patches +{ + [HarmonyPatch(typeof(FlyingScoreTextEffect), "HandleSaberAfterCutSwingRatingCounterDidChangeEvent", + new Type[] { typeof(SaberAfterCutSwingRatingCounter), typeof(float) })] + class FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent + { + static void Postfix(SaberAfterCutSwingRatingCounter afterCutRating, FlyingScoreTextEffect __instance, + ref Color ____color, NoteCutInfo ____noteCutInfo, int ____multiplier) + { + ScoreController.ScoreWithoutMultiplier(____noteCutInfo, afterCutRating, out int before, out int after); + int total = before + after; + ____color = + ( + total < 100 ? Color.red : + total <= 105 ? new Color(1, 165f / 255f, 0) : + total < 110 ? new Color(0, 0.5f, 1) : + Color.green + ); + } + } +} diff --git a/HitScoreVisualizer/HitScoreVisualizer.csproj b/HitScoreVisualizer/HitScoreVisualizer.csproj new file mode 100644 index 0000000..1b87029 --- /dev/null +++ b/HitScoreVisualizer/HitScoreVisualizer.csproj @@ -0,0 +1,67 @@ + + + + + Debug + AnyCPU + {7D8A403B-A4EE-42AD-85EF-ACFD7F087A79} + Library + Properties + HitScoreVisualizer + HitScoreVisualizer + v4.6 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll + + + + + + + + + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll + + + ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll + + + + + + + + + + \ No newline at end of file diff --git a/HitScoreVisualizer/Plugin.cs b/HitScoreVisualizer/Plugin.cs new file mode 100644 index 0000000..1bb88c3 --- /dev/null +++ b/HitScoreVisualizer/Plugin.cs @@ -0,0 +1,61 @@ +using Harmony; +using IllusionPlugin; +using System; +using System.Reflection; +using UnityEngine.SceneManagement; + +namespace HitScoreVisualizer +{ + public class Plugin : IPlugin + { + public string Name => "HitScoreVisualizer"; + public string Version => "0.0.1"; + public void OnApplicationStart() + { + SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged; + SceneManager.sceneLoaded += SceneManager_sceneLoaded; + try + { + var harmony = HarmonyInstance.Create("com.arti.BeatSaber.HitScoreVisualizer"); + harmony.PatchAll(Assembly.GetExecutingAssembly()); + } + catch (Exception e) + { + Console.WriteLine("[HitScoreVisualizer] This plugin requires Harmony. Make sure you " + + "installed the plugin properly, as the Harmony DLL should have been installed with it."); + Console.WriteLine(e); + } + } + + private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1) + { + } + + private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) + { + } + + public void OnApplicationQuit() + { + SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged; + SceneManager.sceneLoaded -= SceneManager_sceneLoaded; + } + + public void OnLevelWasLoaded(int level) + { + + } + + public void OnLevelWasInitialized(int level) + { + } + + public void OnUpdate() + { + } + + public void OnFixedUpdate() + { + } + } +} diff --git a/HitScoreVisualizer/Properties/AssemblyInfo.cs b/HitScoreVisualizer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7dbb35b --- /dev/null +++ b/HitScoreVisualizer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HitScoreVisualizer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HitScoreVisualizer")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7d8a403b-a4ee-42ad-85ef-acfd7f087a79")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]