Rizu/Rizu.BepInEx/PatchUserDetail.cs

27 lines
737 B
C#
Raw Permalink Normal View History

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;
}
}