Skip to content

Commit

Permalink
1.25
Browse files Browse the repository at this point in the history
  • Loading branch information
kinsi55 committed Oct 9, 2022
1 parent c515820 commit cffc346
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 6 deletions.
1 change: 1 addition & 0 deletions Configuration/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ internal class PluginConfig {
public virtual bool RemoveHealthWarning { get; set; } = true;
public virtual bool EnableOptimizations { get; set; } = true;
public virtual bool OptimizationsAlternativeMode { get; set; } = false;
public virtual bool ExperimentalLoadTimeImprovements { get; set; } = false;
public virtual int GcSkips { get; set; } = 10;

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions GottaGoFast.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Zenject, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll</HintPath>
</Reference>
<Reference Include="Zenject-usage, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="HarmonyPatches\DefaultScenesTransitionsFromInit.cs" />
Expand All @@ -113,6 +121,8 @@
<Compile Include="HarmonyPatches\HookRestart.cs" />
<Compile Include="HarmonyPatches\LevelFailController.cs" />
<Compile Include="HarmonyPatches\MenuTransitionsHelper.cs" />
<Compile Include="HarmonyPatches\NoSliderPrefabs.cs" />
<Compile Include="HarmonyPatches\PreventMenuActivateOnRestart.cs" />
<Compile Include="Helper.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Configuration\PluginConfig.cs" />
Expand Down
14 changes: 12 additions & 2 deletions HarmonyPatches/MenuTransitionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ static class PatchLevelRestartTransition {
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
var matcher = new CodeMatcher(instructions);

matcher.MatchForward(true,
new CodeMatch(OpCodes.Ldc_R4, null, "restartdelay"),
new CodeMatch(OpCodes.Ldnull),
new CodeMatch(OpCodes.Ldnull),
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(GameScenesManager), nameof(GameScenesManager.ReplaceScenes)))
).ThrowIfInvalid("restartdelay not found");

matcher.NamedMatch("restartdelay").operand = Configuration.PluginConfig.Instance.SongRestartTransition;

matcher.End().MatchBack(
true,
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(GameScenesManager), nameof(GameScenesManager.PopScenes)))
Expand All @@ -52,14 +61,15 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
.MatchForward(
true,
new CodeMatch(x => x.opcode == OpCodes.Beq_S || x.opcode == OpCodes.Beq || x.opcode == OpCodes.Bne_Un || x.opcode == OpCodes.Bne_Un_S),
new CodeMatch(OpCodes.Ldc_R4, null, "restartdelay"),
new CodeMatch(OpCodes.Ldc_R4, null, "exitdelay"),
new CodeMatch(x => x.opcode == OpCodes.Br || x.opcode == OpCodes.Br_S),
new CodeMatch(OpCodes.Ldc_R4, null, "failpassdelay")
).ThrowIfInvalid("!");

matcher.NamedMatch("restartdelay").operand = Configuration.PluginConfig.Instance.SongRestartTransition;
matcher.NamedMatch("exitdelay").operand = Configuration.PluginConfig.Instance.SongRestartTransition;
matcher.NamedMatch("failpassdelay").operand = Configuration.PluginConfig.Instance.SongPassFailTransition;


return matcher.InstructionEnumeration();
}

Expand Down
44 changes: 44 additions & 0 deletions HarmonyPatches/NoSliderPrefabs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;

namespace GottaGoFast.HarmonyPatches {
[HarmonyPatch(typeof(BeatmapObjectsInstaller), "InstallBindings")]
static class NoSliderPrefabs {
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
var x = new CodeMatcher(instructions);
var m = new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NoSliderPrefabs), nameof(NoInitialSize)));

x.MatchForward(false,
new CodeMatch(OpCodes.Ldc_I4_S),
new CodeMatch(y => (y.operand as MethodInfo)?.Name == "WithInitialSize"),
new CodeMatch(OpCodes.Ldarg_0),
new CodeMatch(y => {
if(y.opcode != OpCodes.Ldfld)
return false;

if(!(y.operand is FieldInfo f))
return false;

return f.Name.IndexOf("slider", StringComparison.OrdinalIgnoreCase) != -1 || f.Name.IndexOf("line", StringComparison.OrdinalIgnoreCase) != -1;
})
).Repeat(y => {
y.Advance(1).InsertAndAdvance(m);
});

return x.InstructionEnumeration();
}

static int NoInitialSize(int inSize) {
if(Configuration.PluginConfig.Instance.ExperimentalLoadTimeImprovements)
return 0;

return inSize;
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// 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.2.0")]
[assembly: AssemblyFileVersion("0.2.0")]
[assembly: AssemblyVersion("0.2.1")]
[assembly: AssemblyFileVersion("0.2.1")]
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"id": "GottaGoFast",
"name": "Gotta Go Fast",
"author": "Kinsi55",
"version": "0.2.0",
"version": "0.2.1",
"description": "Significantly decreases the time it takes to (re)start songs",
"gameVersion": "1.19.0",
"gameVersion": "1.25.0",
"dependsOn": {
"BSIPA": "^4.0.5"
},
Expand Down

0 comments on commit cffc346

Please sign in to comment.