Refactor and support BepInEx's native plugin format

This commit is contained in:
beerpsi 2024-05-23 16:13:19 +07:00
parent 6056dbcb31
commit fefc398f07
38 changed files with 497 additions and 126 deletions

View File

@ -0,0 +1,38 @@
using System.Reflection;
using Game;
using HarmonyLib;
using Manager;
using Rizu.Core;
namespace Rizu.BepInEx;
[HarmonyPatch(typeof(GameScoreList))]
public class PatchGameScoreList
{
// New field introduced in SDEZ 1.40 (maimai DX BUDDiES)
private static readonly FieldInfo UtageKanjiTextField = typeof(SessionInfo)
.GetField("utageKanjiText", BindingFlags.Instance | BindingFlags.Public);
// ReSharper disable once InconsistentNaming
[HarmonyPatch(nameof(GameScoreList.SetPlayAfterRate))]
[HarmonyPostfix]
private static void SetPlayAfterRatePostfix(GameScoreList __instance, int musicRate, int danRate, UdemaeID dan, int classValue)
{
if (!__instance.IsEnable)
{
return;
}
if (__instance.SessionInfo.isAdvDemo || __instance.SessionInfo.isTutorial)
{
return;
}
if (UtageKanjiTextField != null && !string.IsNullOrEmpty((string)UtageKanjiTextField.GetValue(__instance.SessionInfo)))
{
return;
}
RizuPlugin.Instance.StartCoroutine(Exporter.Instance.ExportScore(__instance));
}
}

View File

@ -0,0 +1,27 @@
using HarmonyLib;
using Manager.UserDatas;
using Rizu.Core;
namespace Rizu.BepInEx;
[HarmonyPatch(typeof(UserDetail))]
public class PatchUserDetail
{
// ReSharper disable once InconsistentNaming
[HarmonyPatch(nameof(UserDetail.CourseRank), MethodType.Setter)]
[HarmonyPrefix]
private static bool CourseRankPrefix(UserDetail __instance, ref uint value)
{
var previousValue = __instance.CourseRank;
// Don't send an import if it's the same rank
if (value == previousValue || value == 0)
{
return true;
}
RizuPlugin.Instance.StartCoroutine(Exporter.Instance.ExportDan(__instance));
return true;
}
}

View File

@ -4,12 +4,12 @@ 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("Rizu")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("Rizu.BepInEx")]
[assembly: AssemblyDescription("Tachi score hook for maimai DX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rizu")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyCopyright("Copyright © beerpsi 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// 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")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4DDF918E-7A74-4266-B56A-028D66ED336F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rizu.BepInEx</RootNamespace>
<AssemblyName>Rizu</AssemblyName>
<Product>Rizu</Product>
<Version>0.1.1</Version>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json;
https://nuget.bepinex.dev/v3/index.json
</RestoreAdditionalProjectSources>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
<PackageReference Include="BepInEx.BaseLib" Version="5.*" GeneratePathProperty="true" />
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
<PackageReference Include="HarmonyX" Version="2.12.0" GeneratePathProperty="true" />
<Reference Include="Assembly-CSharp">
<HintPath>..\External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\External\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\External\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PatchGameScoreList.cs" />
<Compile Include="PatchUserDetail.cs" />
<Compile Include="RizuPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rizu.Core\Rizu.Core.csproj">
<Project>{4241a369-1619-4450-8182-cb66f447985f}</Project>
<Name>Rizu.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,34 @@
using BepInEx;
using HarmonyLib;
using Rizu.Core;
namespace Rizu.BepInEx;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInProcess("Sinmai.exe")]
public class RizuPlugin : BaseUnityPlugin
{
public static RizuPlugin Instance { get; private set; }
private Harmony _harmony;
private void Awake()
{
Instance = this;
Exporter.Instance.LoadConfig();
if (!Exporter.Instance.IsEnabled)
{
return;
}
_harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
_harmony.PatchAll();
}
private void OnDestroy()
{
_harmony?.UnpatchSelf();
}
}

13
Rizu.Core/Config.cs Normal file
View File

@ -0,0 +1,13 @@
using System.Collections.Generic;
namespace Rizu.Core;
public class Config
{
public bool Enabled;
public int NetworkTimeout;
public string FailedImportsFolder;
public string TachiBaseUrl;
public string TachiImportEndpoint;
public Dictionary<string, string> AccessTokens = new();
}

View File

@ -1,6 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
@ -8,19 +7,20 @@ using MAI2.Util;
using MAI2System;
using Manager;
using Manager.UserDatas;
using Rizu.Models;
using Rizu.Core.Models;
using UnityEngine;
using UnityEngine.Networking;
using Path = System.IO.Path;
namespace Rizu;
namespace Rizu.Core;
public class Exporter : SingletonMonoBehaviour<Exporter>
public class Exporter
{
protected Exporter()
{
_dontDestroyOnLoad = true;
}
public static readonly Exporter Instance = new();
private readonly Config _config = new();
public bool IsEnabled => _config.Enabled;
// ReSharper disable Unity.PerformanceAnalysis
public IEnumerator ExportScore(GameScoreList score)
@ -199,7 +199,7 @@ public class Exporter : SingletonMonoBehaviour<Exporter>
}
}
private void SaveFailedImport(string path, string import)
private static void SaveFailedImport(string path, string import)
{
var parent = Path.GetDirectoryName(path);
@ -239,16 +239,4 @@ public class Exporter : SingletonMonoBehaviour<Exporter>
Logger.Info("> Tachi import URL: {0}{1}", _config.TachiBaseUrl, _config.TachiImportEndpoint);
Logger.Info("> {0} API key{1} loaded", _config.AccessTokens.Count, _config.AccessTokens.Count != 1 ? "s" : "");
}
private readonly Config _config = new();
private class Config
{
public bool Enabled;
public int NetworkTimeout;
public string FailedImportsFolder;
public string TachiBaseUrl;
public string TachiImportEndpoint;
public Dictionary<string, string> AccessTokens = new();
}
}

View File

@ -1,6 +1,6 @@
using UnityEngine.Networking;
namespace Rizu;
namespace Rizu.Core;
public class ForceAcceptAllCertificateHandler : CertificateHandler
{

View File

@ -1,7 +1,7 @@
using System.Diagnostics;
using JetBrains.Annotations;
namespace Rizu;
namespace Rizu.Core;
// UnityEngine.Debug logs don't show up in BepInEx logs for some reason
public static class Logger
@ -54,5 +54,4 @@ public static class Logger
{
System.Console.WriteLine($"{LogPrefix} [{level}] {format}", args);
}
}

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManual

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualDan

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualMatchingClass

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualMeta

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualOptional

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualRankUp

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualResponseBody

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualScore

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class BatchManualScoreJudgements

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class ImportDocument

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class ImportErrContent

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class ImportProgress

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class ImportStatusResponseBody

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class SessionInfoReturn

View File

@ -1,6 +1,6 @@
using System;
namespace Rizu.Models;
namespace Rizu.Core.Models;
[Serializable]
public class TachiResponse<T>

View File

@ -0,0 +1,35 @@
using System.Reflection;
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("Rizu.Core")]
[assembly: AssemblyDescription("Tachi score hook for maimai DX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rizu.Core")]
[assembly: AssemblyCopyright("Copyright © beerpsi 2024")]
[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("4241A369-1619-4450-8182-CB66F447985F")]
// 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("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -5,20 +5,15 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{888E076C-8A77-453F-87DC-BC0186FDBB55}</ProjectGuid>
<ProjectGuid>{4241A369-1619-4450-8182-CB66F447985F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rizu</RootNamespace>
<AssemblyName>Assembly-CSharp.Rizu.mm</AssemblyName>
<TargetFramework>net46</TargetFramework>
<RootNamespace>Rizu.Core</RootNamespace>
<AssemblyName>Rizu.Core</AssemblyName>
<Version>0.1.1</Version>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
https://api.nuget.org/v3/index.json;
https://nuget.bepinex.dev/v3/index.json;
https://nuget.samboy.dev/v3/index.json
</RestoreAdditionalProjectSources>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -40,38 +35,30 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
<Reference Include="Assembly-CSharp">
<HintPath>External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod">
<HintPath>External\MonoMod.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>External\UnityEngine.dll</HintPath>
<HintPath>..\External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>External\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\External\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule">
<HintPath>External\UnityEngine.JSONSerializeModule.dll</HintPath>
<HintPath>..\External\UnityEngine.JSONSerializeModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestModule">
<HintPath>External\UnityEngine.UnityWebRequestModule.dll</HintPath>
<HintPath>..\External\UnityEngine.UnityWebRequestModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Exporter.cs" />
<Compile Include="ForceAcceptAllCertificateHandler.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Models\BatchManual.cs" />
@ -89,16 +76,9 @@
<Compile Include="Models\ImportStatusResponseBody.cs" />
<Compile Include="Models\SessionInfoReturn.cs" />
<Compile Include="Models\TachiResponse.cs" />
<Compile Include="patch_GameScoreList.cs" />
<Compile Include="patch_AmManager.cs" />
<Compile Include="patch_UserDetail.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="Exporter.cs" />
<Compile Include="ScoreConversion.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\Rizu.cfg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -2,10 +2,10 @@
using DB;
using MAI2.Util;
using Manager;
using Rizu.Models;
using Rizu.Core.Models;
using UnityEngine;
namespace Rizu;
namespace Rizu.Core;
public static class ScoreConversion
{

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- ILRepack -->
<Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\Rizu.MonoMod.dll" />
<InputAssemblies Include="$(OutputPath)\Rizu.Core.dll" />
</ItemGroup>
<ItemGroup>
<LibraryPaths Include="..\External" />
</ItemGroup>
<ILRepack
LogFile="ILRepack.log"
Parallel="true"
InputAssemblies="@(InputAssemblies)"
LibraryPath="@(LibraryPaths)"
TargetKind="Dll"
OutputFile="$(OutputPath)\Assembly-CSharp.Rizu.mm.dll" />
</Target>
<!-- /ILRepack -->
</Project>

View File

@ -0,0 +1,35 @@
using System.Reflection;
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("Rizu.MonoMod")]
[assembly: AssemblyDescription("Tachi score hook for maimai DX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rizu")]
[assembly: AssemblyCopyright("Copyright © beerpsi 2024")]
[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("888E076C-8A77-453F-87DC-BC0186FDBB55")]
// 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("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{888E076C-8A77-453F-87DC-BC0186FDBB55}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Rizu.MonoMod</RootNamespace>
<AssemblyName>Rizu.MonoMod</AssemblyName>
<Version>0.1.1</Version>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.32" PrivateAssets="all" />
<Reference Include="Assembly-CSharp">
<HintPath>..\External\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MonoMod">
<HintPath>..\External\MonoMod.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\External\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\External\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="patch_GameScoreList.cs" />
<Compile Include="patch_AmManager.cs" />
<Compile Include="patch_UserDetail.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="RizuMonoBehaviour.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ILRepack.targets" />
<Content Include="Resources\Rizu.cfg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rizu.Core\Rizu.Core.csproj">
<Project>{4241a369-1619-4450-8182-cb66f447985f}</Project>
<Name>Rizu.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,5 @@
using MAI2.Util;
namespace Rizu.MonoMod;
public class RizuMonoBehaviour : SingletonMonoBehaviour<RizuMonoBehaviour>;

View File

@ -1,7 +1,7 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using MAI2.Util;
using Rizu.Core;
using UnityEngine;
namespace Manager;
@ -13,8 +13,9 @@ public class patch_AmManager : AmManager
private void Execute_WaitAmDaemonReady()
{
var go = new GameObject { name = "Rizu" };
go.AddComponent<Rizu.Exporter>();
SingletonMonoBehaviour<Rizu.Exporter>.instance.LoadConfig();
go.AddComponent<Rizu.MonoMod.RizuMonoBehaviour>();
Exporter.Instance.LoadConfig();
orig_Execute_WaitAmDaemonReady();
}

View File

@ -0,0 +1,41 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using System.Reflection;
using Game;
using MAI2.Util;
using Rizu.Core;
using Rizu.MonoMod;
namespace Manager;
public class patch_GameScoreList(int index) : GameScoreList(index)
{
// New field introduced in SDEZ 1.40 (maimai DX BUDDiES)
private static readonly FieldInfo utageKanjiTextField = typeof(SessionInfo)
.GetField("utageKanjiText", BindingFlags.Instance | BindingFlags.Public);
private extern void orig_SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue);
public new void SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue)
{
orig_SetPlayAfterRate(musicRate, danRate, dan, classValue);
if (!IsEnable)
{
return;
}
if (SessionInfo.isAdvDemo || SessionInfo.isTutorial)
{
return;
}
if (utageKanjiTextField != null && !string.IsNullOrEmpty((string)utageKanjiTextField.GetValue(SessionInfo)))
{
return;
}
SingletonMonoBehaviour<RizuMonoBehaviour>.instance.StartCoroutine(Exporter.Instance.ExportScore(this));
}
}

View File

@ -2,6 +2,8 @@
// ReSharper disable InconsistentNaming
using MAI2.Util;
using Rizu.Core;
using Rizu.MonoMod;
namespace Manager.UserDatas;
@ -11,23 +13,16 @@ public class patch_UserDetail : UserDetail
public void set_CourseRank(uint value)
{
// Don't send an import if it's the same rank
if (value == CourseRank)
{
orig_set_CourseRank(value);
return;
}
var prevValue = CourseRank;
orig_set_CourseRank(value);
// Don't send an import if it's rank 0 (invalid)
if (value == 0)
// Don't send an import if it's the same rank
if (value == prevValue || value == 0)
{
return;
}
var exporter = SingletonMonoBehaviour<Rizu.Exporter>.instance;
exporter.StartCoroutine(exporter.ExportDan(this));
SingletonMonoBehaviour<RizuMonoBehaviour>.instance.StartCoroutine(Exporter.Instance.ExportDan(this));
}
}

View File

@ -1,6 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu", "Rizu\Rizu.csproj", "{888E076C-8A77-453F-87DC-BC0186FDBB55}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu.Core", "Rizu.Core\Rizu.Core.csproj", "{4241A369-1619-4450-8182-CB66F447985F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu.MonoMod", "Rizu.MonoMod\Rizu.MonoMod.csproj", "{888E076C-8A77-453F-87DC-BC0186FDBB55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rizu.BepInEx", "Rizu.BepInEx\Rizu.BepInEx.csproj", "{4DDF918E-7A74-4266-B56A-028D66ED336F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -8,9 +12,17 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4241A369-1619-4450-8182-CB66F447985F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4241A369-1619-4450-8182-CB66F447985F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4241A369-1619-4450-8182-CB66F447985F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4241A369-1619-4450-8182-CB66F447985F}.Release|Any CPU.Build.0 = Release|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{888E076C-8A77-453F-87DC-BC0186FDBB55}.Release|Any CPU.Build.0 = Release|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DDF918E-7A74-4266-B56A-028D66ED336F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

View File

@ -1,30 +0,0 @@
// ReSharper disable CheckNamespace
// ReSharper disable InconsistentNaming
using MAI2.Util;
namespace Manager;
public class patch_GameScoreList(int index) : GameScoreList(index)
{
private extern void orig_SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue);
public new void SetPlayAfterRate(int musicRate, int danRate, UdemaeID dan, int classValue)
{
orig_SetPlayAfterRate(musicRate, danRate, dan, classValue);
if (!IsEnable)
{
return;
}
if (SessionInfo.isAdvDemo || SessionInfo.isTutorial || !string.IsNullOrEmpty(SessionInfo.utageKanjiText))
{
return;
}
var exporter = SingletonMonoBehaviour<Rizu.Exporter>.instance;
exporter.StartCoroutine(exporter.ExportScore(this));
}
}