Skip to content

Commit

Permalink
added replay height loading in case it's static
Browse files Browse the repository at this point in the history
  • Loading branch information
Hermanest committed Jul 22, 2023
1 parent 70ff27f commit 2fed561
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
20 changes: 15 additions & 5 deletions Source/2_Core/Models/AbstractReplay/GenericReplayData.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
namespace BeatLeader.Models.AbstractReplay {
public class GenericReplayData : IReplayData {
public GenericReplayData(
float failTime, string timestamp, bool leftHanded,
GameplayModifiers gameplayModifiers, float jumpDistance,
Player? player = null, PracticeSettings? practiceSettings = null) {
float failTime,
int timestamp,
bool leftHanded,
float jumpDistance,
float? fixedHeight,
GameplayModifiers gameplayModifiers,
Player? player = null,
PracticeSettings? practiceSettings = null
) {
FailTime = failTime;
Timestamp = timestamp;
LeftHanded = leftHanded;
GameplayModifiers = gameplayModifiers;
JumpDistance = jumpDistance;
Player = player;
PracticeSettings = practiceSettings;
FixedHeight = fixedHeight;
}

public bool LeftHanded { get; }
public float? FixedHeight { get; }
public float JumpDistance { get; }

public float FailTime { get; }
public string Timestamp { get; }
public bool LeftHanded { get; }
public int Timestamp { get; }

public Player? Player { get; }
public PracticeSettings? PracticeSettings { get; }
public GameplayModifiers GameplayModifiers { get; }
Expand Down
5 changes: 4 additions & 1 deletion Source/2_Core/Models/AbstractReplay/IReplayData.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
namespace BeatLeader.Models.AbstractReplay {
public interface IReplayData {
bool LeftHanded { get; }
float? FixedHeight { get; }
float JumpDistance { get; }

float FailTime { get; }
string Timestamp { get; }
int Timestamp { get; }

Player? Player { get; }
PracticeSettings? PracticeSettings { get; }
GameplayModifiers GameplayModifiers { get; }
Expand Down
5 changes: 3 additions & 2 deletions Source/7_Utils/ReplayDataUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ public static IReplay ConvertToAbstractReplay(Replay replay, Player? player) {
var replayData = replay.info;
var creplayData = new GenericReplayData(
replayData.failTime,
replayData.timestamp,
int.Parse(replayData.timestamp),
replayData.leftHanded,
replay.GetModifiersFromReplay(),
replayData.jumpDistance,
replay.heights.Count == 0 ? replayData.height : null,
replay.GetModifiersFromReplay(),
player, replay.GetPracticeSettingsFromReplay());

var frames = replay.frames.Select(static x => new PlayerMovementFrame(
Expand Down
6 changes: 3 additions & 3 deletions Source/7_Utils/StaticUtils/AbstractReplayUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public static StandardLevelScenesTransitionSetupDataSO CreateTransitionData(this
: launchData.MainReplay.ReplayData.PracticeSettings;
var beatmap = launchData.DifficultyBeatmap;

transitionData.Init("Solo", beatmap, beatmap!.level, envSettings,
transitionData.Init("Solo", beatmap, beatmap.level, envSettings,
playerData.colorSchemesSettings.GetOverrideColorScheme(),
replay.ReplayData.GameplayModifiers,
playerData.playerSpecificSettings.GetPlayerSettingsByReplay(replay),
practiceSettings, "Menu");

return transitionData!;
return transitionData;
}

public static NoteCutInfo SaturateNoteCutInfo(this NoteCutInfo cutInfo, NoteData data) {
Expand All @@ -62,7 +62,7 @@ public static NoteCutInfo SaturateNoteCutInfo(this NoteCutInfo cutInfo, NoteData
}

private static PlayerSpecificSettings GetPlayerSettingsByReplay(this PlayerSpecificSettings settings, IReplay replay) {
return settings.CopyWith(replay.ReplayData.LeftHanded, automaticPlayerHeight: true);
return settings.CopyWith(replay.ReplayData.LeftHanded, replay.ReplayData.FixedHeight, replay.ReplayData.FixedHeight is null);
}
}
}

0 comments on commit 2fed561

Please sign in to comment.