Skip to content

Commit f99c755

Browse files
Plugin working
1 parent 159595d commit f99c755

File tree

5 files changed

+218
-0
lines changed

5 files changed

+218
-0
lines changed

HitScoreVisualizer.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27703.2035
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HitScoreVisualizer", "HitScoreVisualizer\HitScoreVisualizer.csproj", "{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {FCB42BAF-E3A9-4B03-B8A5-2538DB0373DF}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Harmony;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using UnityEngine;
8+
9+
namespace HitScoreVisualizer.Harmony_Patches
10+
{
11+
[HarmonyPatch(typeof(FlyingScoreTextEffect), "HandleSaberAfterCutSwingRatingCounterDidChangeEvent",
12+
new Type[] { typeof(SaberAfterCutSwingRatingCounter), typeof(float) })]
13+
class FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent
14+
{
15+
static void Postfix(SaberAfterCutSwingRatingCounter afterCutRating, FlyingScoreTextEffect __instance,
16+
ref Color ____color, NoteCutInfo ____noteCutInfo, int ____multiplier)
17+
{
18+
ScoreController.ScoreWithoutMultiplier(____noteCutInfo, afterCutRating, out int before, out int after);
19+
int total = before + after;
20+
____color =
21+
(
22+
total < 100 ? Color.red :
23+
total <= 105 ? new Color(1, 165f / 255f, 0) :
24+
total < 110 ? new Color(0, 0.5f, 1) :
25+
Color.green
26+
);
27+
}
28+
}
29+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{7D8A403B-A4EE-42AD-85EF-ACFD7F087A79}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>HitScoreVisualizer</RootNamespace>
11+
<AssemblyName>HitScoreVisualizer</AssemblyName>
12+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="0Harmony">
34+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\0Harmony.dll</HintPath>
35+
</Reference>
36+
<Reference Include="Assembly-CSharp">
37+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Assembly-CSharp-firstpass">
40+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
41+
</Reference>
42+
<Reference Include="IllusionPlugin">
43+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IllusionPlugin.dll</HintPath>
44+
</Reference>
45+
<Reference Include="System" />
46+
<Reference Include="System.Core" />
47+
<Reference Include="System.Xml.Linq" />
48+
<Reference Include="System.Data.DataSetExtensions" />
49+
<Reference Include="Microsoft.CSharp" />
50+
<Reference Include="System.Data" />
51+
<Reference Include="System.Net.Http" />
52+
<Reference Include="System.Xml" />
53+
<Reference Include="UnityEngine">
54+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
55+
</Reference>
56+
<Reference Include="UnityEngine.CoreModule">
57+
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
58+
</Reference>
59+
</ItemGroup>
60+
<ItemGroup>
61+
<Compile Include="Harmony Patches\FlyingScoreTextEffectHandleSaberAfterCutSwingRatingCounterDidChangeEvent.cs" />
62+
<Compile Include="Plugin.cs" />
63+
<Compile Include="Properties\AssemblyInfo.cs" />
64+
</ItemGroup>
65+
<ItemGroup />
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
67+
</Project>

HitScoreVisualizer/Plugin.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using Harmony;
2+
using IllusionPlugin;
3+
using System;
4+
using System.Reflection;
5+
using UnityEngine.SceneManagement;
6+
7+
namespace HitScoreVisualizer
8+
{
9+
public class Plugin : IPlugin
10+
{
11+
public string Name => "HitScoreVisualizer";
12+
public string Version => "0.0.1";
13+
public void OnApplicationStart()
14+
{
15+
SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
16+
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
17+
try
18+
{
19+
var harmony = HarmonyInstance.Create("com.arti.BeatSaber.HitScoreVisualizer");
20+
harmony.PatchAll(Assembly.GetExecutingAssembly());
21+
}
22+
catch (Exception e)
23+
{
24+
Console.WriteLine("[HitScoreVisualizer] This plugin requires Harmony. Make sure you " +
25+
"installed the plugin properly, as the Harmony DLL should have been installed with it.");
26+
Console.WriteLine(e);
27+
}
28+
}
29+
30+
private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
31+
{
32+
}
33+
34+
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
35+
{
36+
}
37+
38+
public void OnApplicationQuit()
39+
{
40+
SceneManager.activeSceneChanged -= SceneManagerOnActiveSceneChanged;
41+
SceneManager.sceneLoaded -= SceneManager_sceneLoaded;
42+
}
43+
44+
public void OnLevelWasLoaded(int level)
45+
{
46+
47+
}
48+
49+
public void OnLevelWasInitialized(int level)
50+
{
51+
}
52+
53+
public void OnUpdate()
54+
{
55+
}
56+
57+
public void OnFixedUpdate()
58+
{
59+
}
60+
}
61+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("HitScoreVisualizer")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("HitScoreVisualizer")]
13+
[assembly: AssemblyCopyright("Copyright © 2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("7d8a403b-a4ee-42ad-85ef-acfd7f087a79")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)