2019-01-24 08:43:03 +00:00
|
|
|
// 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 09:19:50 +00:00
|
|
|
|
2019-09-12 09:33:46 +00:00
|
|
|
using System.Collections.Generic;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Beatmaps;
|
2018-11-28 08:20:37 +00:00
|
|
|
using osu.Game.Replays.Legacy;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Rulesets.Replays;
|
|
|
|
using osu.Game.Rulesets.Replays.Types;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Replays
|
|
|
|
{
|
|
|
|
public class CatchReplayFrame : ReplayFrame, IConvertibleReplayFrame
|
|
|
|
{
|
2019-09-12 09:33:46 +00:00
|
|
|
public List<CatchAction> Actions = new List<CatchAction>();
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
public float Position;
|
|
|
|
public bool Dashing;
|
|
|
|
|
|
|
|
public CatchReplayFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-09-12 09:33:46 +00:00
|
|
|
public CatchReplayFrame(double time, float? position = null, bool dashing = false, CatchReplayFrame lastFrame = null)
|
2018-04-13 09:19:50 +00:00
|
|
|
: base(time)
|
|
|
|
{
|
|
|
|
Position = position ?? -1;
|
|
|
|
Dashing = dashing;
|
2019-09-12 09:33:46 +00:00
|
|
|
|
|
|
|
if (Dashing)
|
|
|
|
Actions.Add(CatchAction.Dash);
|
|
|
|
|
|
|
|
if (lastFrame != null)
|
|
|
|
{
|
|
|
|
if (Position > lastFrame.Position)
|
2019-09-13 14:05:47 +00:00
|
|
|
lastFrame.Actions.Add(CatchAction.MoveRight);
|
2019-09-12 09:33:46 +00:00
|
|
|
else if (Position < lastFrame.Position)
|
2019-09-13 14:05:47 +00:00
|
|
|
lastFrame.Actions.Add(CatchAction.MoveLeft);
|
2019-09-12 09:33:46 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 11:21:34 +00:00
|
|
|
public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame lastFrame = null)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2020-07-01 15:21:45 +00:00
|
|
|
Position = currentFrame.Position.X;
|
2019-09-12 09:33:46 +00:00
|
|
|
Dashing = currentFrame.ButtonState == ReplayButtonState.Left1;
|
|
|
|
|
|
|
|
if (Dashing)
|
|
|
|
Actions.Add(CatchAction.Dash);
|
|
|
|
|
2019-09-13 14:05:47 +00:00
|
|
|
// this probably needs some cross-checking with osu-stable to ensure it is actually correct.
|
|
|
|
if (lastFrame is CatchReplayFrame lastCatchFrame)
|
2019-09-12 09:33:46 +00:00
|
|
|
{
|
2019-09-13 14:05:47 +00:00
|
|
|
if (Position > lastCatchFrame.Position)
|
|
|
|
lastCatchFrame.Actions.Add(CatchAction.MoveRight);
|
|
|
|
else if (Position < lastCatchFrame.Position)
|
2019-09-12 09:33:46 +00:00
|
|
|
Actions.Add(CatchAction.MoveLeft);
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
2020-03-24 05:13:46 +00:00
|
|
|
|
2020-03-25 11:21:34 +00:00
|
|
|
public LegacyReplayFrame ToLegacy(IBeatmap beatmap)
|
2020-03-24 05:13:46 +00:00
|
|
|
{
|
|
|
|
ReplayButtonState state = ReplayButtonState.None;
|
|
|
|
|
|
|
|
if (Actions.Contains(CatchAction.Dash)) state |= ReplayButtonState.Left1;
|
|
|
|
|
2020-07-01 15:21:45 +00:00
|
|
|
return new LegacyReplayFrame(Time, Position, null, state);
|
2020-03-24 05:13:46 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|