From fe20d3ac3b25fbaaa904a4df84c7933abeb6d842 Mon Sep 17 00:00:00 2001 From: Provini <71570801+Provini@users.noreply.github.com> Date: Wed, 26 Feb 2025 13:46:42 -0500 Subject: [PATCH] Allow Negative Size/Duration Obstacles in Beatmap V3 --- .../CustomBeatmapData/ConvertersCustomify.cs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/CustomJSONData/HarmonyPatches/CustomBeatmapData/ConvertersCustomify.cs b/CustomJSONData/HarmonyPatches/CustomBeatmapData/ConvertersCustomify.cs index c79c05c..5e17bce 100644 --- a/CustomJSONData/HarmonyPatches/CustomBeatmapData/ConvertersCustomify.cs +++ b/CustomJSONData/HarmonyPatches/CustomBeatmapData/ConvertersCustomify.cs @@ -105,13 +105,43 @@ private static IEnumerable BombNoteConvertV3(IEnumerable ObstacleConvertV3(IEnumerable instructions) { return instructions.ReplaceCtor(_version3, _obstacleDataCtor, _customObstacleDataCtor); + }*/ + + [HarmonyPrefix] + [HarmonyPatch( + typeof(BeatmapDataLoaderVersion3.BeatmapDataLoader.ObstacleConverter), + nameof(BeatmapDataLoaderVersion3.BeatmapDataLoader.ObstacleConverter.Convert))] + private static bool ObstacleConvertV3( + BeatmapDataLoaderVersion3.BeatmapDataLoader.ObstacleConverter __instance, + BeatmapSaveDataVersion3.ObstacleData obstacleSaveData, + ref BeatmapObjectData? __result) + { + float time = __instance.BeatToTime(obstacleSaveData.beat); + float endBeat = obstacleSaveData.beat + obstacleSaveData.duration; + float duration = __instance.BeatToTime(endBeat) - time; + + __result = new CustomObstacleData( + time, +#if !PRE_V1_39_1 + obstacleSaveData.beat, + endBeat, + __instance.BeatToRotation(obstacleSaveData.beat), +#endif + obstacleSaveData.line, + BeatmapDataLoaderVersion3.BeatmapDataLoader.ObstacleConverter.GetNoteLineLayer(obstacleSaveData.layer), + duration, + obstacleSaveData.width, + obstacleSaveData.height, + obstacleSaveData.GetData(), + BeatmapSaveDataHelpers.version3); + return false; } [HarmonyTranspiler]