mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Initial unlocked slider implementation
This commit is contained in:
1 parent
d59cad08dc
commit
14fcc78224
4 files changed
+40
-37
No files matched your search
@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SceneDumper", "Plugins\Scen
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorCorrector", "Plugins\ColorCorrector\ColorCorrector.csproj", "{6809B5DC-358C-45C5-B04C-0B7027596A8B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SliderUnlocker", "Plugins\SliderUnlocker\SliderUnlocker.csproj", "{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
BepInEx.Common\BepInEx.Common.projitems*{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}*SharedItemsImports = 4
|
||||
@@ -54,6 +56,10 @@ Global
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -63,6 +69,7 @@ Global
|
||||
{379BA41B-9944-4B5A-8732-EEBAA7F05B04} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {55AC11EF-F568-4C79-A356-7ED9510145B1}
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="translation\translation.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace SliderUnlocker
|
||||
|
||||
public SliderUnlocker()
|
||||
{
|
||||
|
||||
|
||||
var harmony = HarmonyInstance.Create("com.bepis.bepinex.sliderunlocker");
|
||||
|
||||
MethodInfo original = AccessTools.Method(typeof(CustomBase), "ConvertTextFromRate");
|
||||
@@ -36,49 +34,33 @@ namespace SliderUnlocker
|
||||
|
||||
harmony.Patch(original, null, postfix);
|
||||
|
||||
Console.WriteLine("test");
|
||||
|
||||
//foreach (var method in typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")))
|
||||
//{typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name == "GetInfo");
|
||||
// Console.WriteLine(method.GetParameters().Select(x => x.ParameterType.FullName).Aggregate((a, b) => $"{a};{b}"));
|
||||
//}
|
||||
|
||||
|
||||
original = typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")).ToArray()[1];
|
||||
|
||||
//original = AccessTools.Method(typeof(AnimationKeyInfo), "GetInfo"); //new Type[] { typeof(string), typeof(float), typeof(Vector3[]), typeof(bool[]) }
|
||||
|
||||
postfix = new HarmonyMethod(typeof(SliderUnlocker).GetMethod("GetInfoHook"));
|
||||
original = AccessTools.Method(typeof(Mathf), "Clamp", new Type[] { typeof(float), typeof(float), typeof(float) });
|
||||
|
||||
postfix = new HarmonyMethod(typeof(SliderUnlocker).GetMethod("MathfClampHook"));
|
||||
|
||||
harmony.Patch(original, null, postfix);
|
||||
|
||||
Console.WriteLine("hooked");
|
||||
|
||||
|
||||
original = typeof(AnimationKeyInfo).GetMethods().Where(x => x.Name.Contains("GetInfo")).ToArray()[1];
|
||||
|
||||
var prefix = new HarmonyMethod(typeof(SliderUnlocker).GetMethod("GetInfoPreHook"));
|
||||
|
||||
postfix = new HarmonyMethod(typeof(SliderUnlocker).GetMethod("GetInfoPostHook"));
|
||||
|
||||
harmony.Patch(original, prefix, postfix);
|
||||
}
|
||||
|
||||
protected override void LevelFinishedLoading(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
foreach (Slider gameObject in GameObject.FindObjectsOfType<Slider>())
|
||||
{
|
||||
gameObject.maxValue = 2;
|
||||
gameObject.maxValue = 2f;
|
||||
}
|
||||
}
|
||||
|
||||
//TypeDefinition customBase = assembly.MainModule.Types.First(x => x.Name == "CustomBase");
|
||||
|
||||
//var methods = customBase.Methods;
|
||||
|
||||
//var convertTextFromRate = methods.First(x => x.Name == "ConvertTextFromRate");
|
||||
|
||||
//var IL = convertTextFromRate.Body.GetILProcessor();
|
||||
//IL.Replace(convertTextFromRate.Body.Instructions[0], IL.Create(OpCodes.Ldc_I4, -0));
|
||||
// IL.Replace(convertTextFromRate.Body.Instructions[2], IL.Create(OpCodes.Ldc_I4, 200));
|
||||
|
||||
// var convertRateFromText = methods.First(x => x.Name == "ConvertRateFromText");
|
||||
|
||||
//IL = convertRateFromText.Body.GetILProcessor();
|
||||
// IL.Replace(convertRateFromText.Body.Instructions[11], IL.Create(OpCodes.Ldc_I4, -0));
|
||||
// IL.Replace(convertRateFromText.Body.Instructions[13], IL.Create(OpCodes.Ldc_I4, 200));
|
||||
|
||||
|
||||
[HarmonyPostfix]
|
||||
public static void ConvertTextFromRateHook(ref string __result, int min, int max, float value)
|
||||
@@ -111,16 +93,30 @@ namespace SliderUnlocker
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
public static void GetInfoHook(AnimationKeyInfo __instance, bool __result, string name, float rate, ref Vector3[] value, bool[] flag)
|
||||
public static void MathfClampHook(ref float __result, float value, float min, float max)
|
||||
{
|
||||
if (min == 0f && max == 100f)
|
||||
__result = value;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
public static void GetInfoPreHook(ref float __state, string name, ref float rate, ref Vector3[] value, bool[] flag)
|
||||
{
|
||||
__state = rate;
|
||||
|
||||
if (rate > 1)
|
||||
Console.WriteLine(rate);
|
||||
|
||||
rate *= 2f;
|
||||
rate = 1f;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
public static void GetInfoPostHook(AnimationKeyInfo __instance, bool __result, float __state, string name, float rate, ref Vector3[] value, bool[] flag)
|
||||
{
|
||||
if (!__result)
|
||||
return;
|
||||
|
||||
|
||||
rate = __state;
|
||||
|
||||
var dictInfo = (Dictionary < string, List<AnimationKeyInfo.AnmKeyInfo> > )
|
||||
(typeof(AnimationKeyInfo).GetField("dictInfo", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance));
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BepInEx\BepInEx.csproj">
|
||||
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
|
||||
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
|
||||
<Name>BepInEx</Name>
|
||||
<Private>False</Private>
|
||||
|
||||
Reference in new issue
Block a user