1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 07:53:38 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Replays/CatchReplayFrame.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
2.3 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using System.Collections.Generic;
using osu.Game.Beatmaps;
2018-11-28 16:20:37 +08:00
using osu.Game.Replays.Legacy;
2018-01-12 17:35:28 +08:00
using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Replays.Types;
2018-04-13 17:19:50 +08:00
2018-01-12 17:35:28 +08:00
namespace osu.Game.Rulesets.Catch.Replays
{
public class CatchReplayFrame : ReplayFrame, IConvertibleReplayFrame
2018-01-12 17:35:28 +08:00
{
public List<CatchAction> Actions = new List<CatchAction>();
2018-03-01 00:48:13 +08:00
public float Position;
public bool Dashing;
2018-04-13 17:19:50 +08:00
public CatchReplayFrame()
{
}
2018-04-13 17:19:50 +08:00
public CatchReplayFrame(double time, float? position = null, bool dashing = false, CatchReplayFrame lastFrame = null)
: base(time)
2018-01-12 17:35:28 +08:00
{
2018-03-01 00:48:13 +08:00
Position = position ?? -1;
Dashing = dashing;
if (Dashing)
Actions.Add(CatchAction.Dash);
if (lastFrame != null)
{
if (Position > lastFrame.Position)
lastFrame.Actions.Add(CatchAction.MoveRight);
else if (Position < lastFrame.Position)
lastFrame.Actions.Add(CatchAction.MoveLeft);
}
}
2018-04-13 17:19:50 +08:00
2020-03-25 19:21:34 +08:00
public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame lastFrame = null)
{
Position = currentFrame.Position.X;
Dashing = currentFrame.ButtonState == ReplayButtonState.Left1;
if (Dashing)
Actions.Add(CatchAction.Dash);
// this probably needs some cross-checking with osu-stable to ensure it is actually correct.
if (lastFrame is CatchReplayFrame lastCatchFrame)
{
if (Position > lastCatchFrame.Position)
lastCatchFrame.Actions.Add(CatchAction.MoveRight);
else if (Position < lastCatchFrame.Position)
lastCatchFrame.Actions.Add(CatchAction.MoveLeft);
}
2018-01-12 17:35:28 +08:00
}
2020-03-24 13:13:46 +08:00
2020-03-25 19:21:34 +08:00
public LegacyReplayFrame ToLegacy(IBeatmap beatmap)
2020-03-24 13:13:46 +08:00
{
ReplayButtonState state = ReplayButtonState.None;
if (Actions.Contains(CatchAction.Dash)) state |= ReplayButtonState.Left1;
return new LegacyReplayFrame(Time, Position, null, state);
2020-03-24 13:13:46 +08:00
}
2018-01-12 17:35:28 +08:00
}
}