Skip to content

Commit

Permalink
BS 1.40.0 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Dec 13, 2024
1 parent bd29d3b commit d49f641
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
28 changes: 24 additions & 4 deletions Source/0_Harmony/InstallersPatches/LevelDataEnhancerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ class LevelDataEnhancerPatch {
static MethodInfo TargetMethod() => AccessTools.FirstMethod(typeof(StandardLevelScenesTransitionSetupDataSO),
m => m.Name == nameof(StandardLevelScenesTransitionSetupDataSO.Init) &&
m.GetParameters().All(p => p.ParameterType != typeof(IBeatmapLevelData)));
public static void Postfix(in BeatmapKey beatmapKey, BeatmapLevel beatmapLevel, OverrideEnvironmentSettings overrideEnvironmentSettings, ColorScheme overrideColorScheme, GameplayModifiers gameplayModifiers, PlayerSpecificSettings playerSpecificSettings, PracticeSettings practiceSettings, EnvironmentsListModel environmentsListModel) {
public static void Postfix(
in BeatmapKey beatmapKey,
BeatmapLevel beatmapLevel,
OverrideEnvironmentSettings overrideEnvironmentSettings,
ColorScheme playerOverrideColorScheme,
bool playerOverrideLightshowColors,
ColorScheme beatmapOverrideColorScheme,
GameplayModifiers gameplayModifiers,
PlayerSpecificSettings playerSpecificSettings,
PracticeSettings practiceSettings,
EnvironmentsListModel environmentsListModel) {
Plugin.Log.Debug($"LevelDataEnhancerPatch.postfix {beatmapKey.levelId} {beatmapLevel.songName}");
string environmentName = beatmapLevel.GetEnvironmentName(beatmapKey.beatmapCharacteristic, beatmapKey.difficulty);
EnvironmentInfoSO? environmentInfoSO = environmentsListModel.GetEnvironmentInfoBySerializedName(environmentName);
Expand All @@ -23,7 +33,7 @@ public static void Postfix(in BeatmapKey beatmapKey, BeatmapLevel beatmapLevel,
MapEnhancer.playerSpecificSettings = playerSpecificSettings;
MapEnhancer.practiceSettings = practiceSettings;
MapEnhancer.environmentName = environmentName;
MapEnhancer.colorScheme = overrideColorScheme;
MapEnhancer.colorScheme = playerOverrideColorScheme;
}
}

Expand All @@ -33,8 +43,18 @@ class LevelDataEnhancerPatch2 {
static MethodInfo TargetMethod() => AccessTools.FirstMethod(typeof(StandardLevelScenesTransitionSetupDataSO),
m => m.Name == nameof(StandardLevelScenesTransitionSetupDataSO.Init) &&
m.GetParameters().Any(p => p.ParameterType == typeof(IBeatmapLevelData)));
static void Postfix(in BeatmapKey beatmapKey, BeatmapLevel beatmapLevel, OverrideEnvironmentSettings overrideEnvironmentSettings, ColorScheme overrideColorScheme, GameplayModifiers gameplayModifiers, PlayerSpecificSettings playerSpecificSettings, PracticeSettings practiceSettings, EnvironmentsListModel environmentsListModel) {
LevelDataEnhancerPatch.Postfix(beatmapKey, beatmapLevel, overrideEnvironmentSettings, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, environmentsListModel);
static void Postfix(
in BeatmapKey beatmapKey,
BeatmapLevel beatmapLevel,
OverrideEnvironmentSettings overrideEnvironmentSettings,
ColorScheme playerOverrideColorScheme,
bool playerOverrideLightshowColors,
ColorScheme beatmapOverrideColorScheme,
GameplayModifiers gameplayModifiers,
PlayerSpecificSettings playerSpecificSettings,
PracticeSettings practiceSettings,
EnvironmentsListModel environmentsListModel) {
LevelDataEnhancerPatch.Postfix(beatmapKey, beatmapLevel, overrideEnvironmentSettings, playerOverrideColorScheme, playerOverrideLightshowColors, beatmapOverrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, environmentsListModel);
}
}
}
7 changes: 5 additions & 2 deletions Source/2_Core/Managers/ReplayRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ List<ScoringElement> ____sortedScoringElementsWithoutMultiplier
[Inject, UsedImplicitly]
private BeatmapObjectManager _beatmapObjectManager;

[Inject, UsedImplicitly]
private VariableMovementDataProvider _movementDataProvider;

Check failure on line 78 in Source/2_Core/Managers/ReplayRecorder.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'VariableMovementDataProvider' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 78 in Source/2_Core/Managers/ReplayRecorder.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'VariableMovementDataProvider' could not be found (are you missing a using directive or an assembly reference?)

[Inject, UsedImplicitly]
private BeatmapObjectSpawnController _beatSpawnController;

Expand Down Expand Up @@ -290,7 +293,7 @@ private void TryGetSaberOffsets(Saber saber, out Vector3 localPosition, out Quat

#region Note Events

private void OnNoteWasAdded(NoteData noteData, BeatmapObjectSpawnMovementData.NoteSpawnData spawnData) {
private void OnNoteWasAdded(NoteData noteData, NoteSpawnData spawnData) {

Check failure on line 296 in Source/2_Core/Managers/ReplayRecorder.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'NoteSpawnData' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 296 in Source/2_Core/Managers/ReplayRecorder.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'NoteSpawnData' could not be found (are you missing a using directive or an assembly reference?)
if (_stopRecording) return;

var noteId = _noteId++;
Expand Down Expand Up @@ -426,7 +429,7 @@ private void OnResume() {
#region Misc. Events

private void OnBeatSpawnControllerDidInit() {
_replay.info.jumpDistance = _beatSpawnController.jumpDistance;
_replay.info.jumpDistance = _movementDataProvider.jumpDistance;
}

private void OnPlayerHeightChange(float height) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BeatLeader.Utils;
using BeatSaber.GameSettings;

Check failure on line 2 in Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'GameSettings' does not exist in the namespace 'BeatSaber' (are you missing an assembly reference?)

Check failure on line 2 in Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'GameSettings' does not exist in the namespace 'BeatSaber' (are you missing an assembly reference?)
using IPA.Utilities;
using UnityEngine;
using VRUIControls;
Expand All @@ -11,6 +12,7 @@ public class MenuControllersManager : MonoBehaviour {
[Inject] private readonly DiContainer _diContainer = null!;
[Inject] private readonly VRInputModule _vrInputModule = null!;
[Inject] private readonly SettingsManager _settingsManager = null!;
[Inject] private readonly ControllerProfilesModel _controllersProfile = null!;

Check failure on line 15 in Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ControllerProfilesModel' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 15 in Source/2_Core/Replayer/Emulation/Controllers/MenuControllersManager.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ControllerProfilesModel' could not be found (are you missing a using directive or an assembly reference?)

public Transform HandsContainer { get; private set; } = null!;
public VRController LeftHand { get; private set; } = null!;
Expand All @@ -29,9 +31,13 @@ private void Awake() {
menuHandsTransform.gameObject.GetComponent<DeactivateAnimatorOnInputFocusCapture>().TryDestroy();
LeftHand = Instantiate(menuHandsTransform.Find("ControllerLeft")).GetComponent<VRController>();
RightHand = Instantiate(menuHandsTransform.Find("ControllerRight")).GetComponent<VRController>();

((VRControllersValueSettingsOffsets)LeftHand._transformOffset).SetField("_settingsManager", _settingsManager);
((VRControllersValueSettingsOffsets)RightHand._transformOffset).SetField("_settingsManager", _settingsManager);

((VRControllersValueSettingsOffsets)LeftHand._transformOffset).SetField("_controllersProfile", _controllersProfile);
((VRControllersValueSettingsOffsets)RightHand._transformOffset).SetField("_controllersProfile", _controllersProfile);

_diContainer.InjectComponentsInChildren(LeftHand.gameObject);
_diContainer.InjectComponentsInChildren(RightHand.gameObject);

Expand Down
1 change: 1 addition & 0 deletions Source/2_Core/Replayer/ReplayerLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private void Awake() {
launchData.BeatmapLevel,
envSettings,
playerData.colorSchemesSettings.GetOverrideColorScheme(),
false,
null,
launchData.Settings.IgnoreModifiers ? CreateDisabledModifiers(replayModifiers) : replayModifiers,
playerData.playerSpecificSettings.GetPlayerSettingsByReplay(replay),
Expand Down
11 changes: 6 additions & 5 deletions Source/2_Core/Replayer/Tweaking/Tweaks/JumpDistanceTweak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal class JumpDistanceTweak : GameTweak {
public override bool CanBeInstalled => _launchData.Settings.LoadPlayerJumpDistance;

private static readonly HarmonyPatchDescriptor _movementDataInitPatchDescriptor = new(
typeof(BeatmapObjectSpawnMovementData).GetMethod(nameof(
BeatmapObjectSpawnMovementData.Init), ReflectionUtils.DefaultFlags)!,
typeof(VariableMovementDataProvider).GetMethod(nameof(
VariableMovementDataProvider.Init), ReflectionUtils.DefaultFlags)!,
typeof(JumpDistanceTweak).GetMethod(nameof(
MovementDataInitPrefix), ReflectionUtils.StaticFlags));

Expand All @@ -31,10 +31,11 @@ public override void Dispose() {
JDFixerInterop.Enabled = true;
}

private static void MovementDataInitPrefix(ref float startNoteJumpMovementSpeed, ref BeatmapObjectSpawnMovementData.NoteJumpValueType noteJumpValueType, ref float noteJumpValue) {
private static void MovementDataInitPrefix(ref float noteJumpMovementSpeed, ref BeatmapObjectSpawnMovementData.NoteJumpValueType noteJumpValueType, ref float noteJumpValue) {
if (_desiredJumpDistance == 0) return;
noteJumpValueType = BeatmapObjectSpawnMovementData.NoteJumpValueType.JumpDuration;
noteJumpValue = _desiredJumpDistance / startNoteJumpMovementSpeed / 2;
Plugin.Log.Notice($"[JumpDistanceTweak] Applied JD: {_desiredJumpDistance} | NJS: {startNoteJumpMovementSpeed} | NJV: {noteJumpValue}");
noteJumpValue = _desiredJumpDistance / noteJumpMovementSpeed / 2;
Plugin.Log.Notice($"[JumpDistanceTweak] Applied JD: {_desiredJumpDistance} | NJS: {noteJumpMovementSpeed} | NJV: {noteJumpValue}");
}
}
}

0 comments on commit d49f641

Please sign in to comment.