2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
2019-09-12 17:33:46 +08:00
|
|
|
using System.Collections.Generic;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2018-11-28 16:20:37 +08:00
|
|
|
using osu.Game.Replays.Legacy;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
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 17:33:46 +08:00
|
|
|
public List<CatchAction> Actions = new List<CatchAction>();
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
public float Position;
|
|
|
|
public bool Dashing;
|
|
|
|
|
|
|
|
public CatchReplayFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-09-12 17:33:46 +08:00
|
|
|
public CatchReplayFrame(double time, float? position = null, bool dashing = false, CatchReplayFrame lastFrame = null)
|
2018-04-13 17:19:50 +08:00
|
|
|
: base(time)
|
|
|
|
{
|
|
|
|
Position = position ?? -1;
|
|
|
|
Dashing = dashing;
|
2019-09-12 17:33:46 +08:00
|
|
|
|
|
|
|
if (Dashing)
|
|
|
|
Actions.Add(CatchAction.Dash);
|
|
|
|
|
|
|
|
if (lastFrame != null)
|
|
|
|
{
|
|
|
|
if (Position > lastFrame.Position)
|
2019-09-13 22:05:47 +08:00
|
|
|
lastFrame.Actions.Add(CatchAction.MoveRight);
|
2019-09-12 17:33:46 +08:00
|
|
|
else if (Position < lastFrame.Position)
|
2019-09-13 22:05:47 +08:00
|
|
|
lastFrame.Actions.Add(CatchAction.MoveLeft);
|
2019-09-12 17:33:46 +08:00
|
|
|
}
|
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)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-09-12 17:33:46 +08:00
|
|
|
Position = currentFrame.Position.X / CatchPlayfield.BASE_WIDTH;
|
|
|
|
Dashing = currentFrame.ButtonState == ReplayButtonState.Left1;
|
|
|
|
|
|
|
|
if (Dashing)
|
|
|
|
Actions.Add(CatchAction.Dash);
|
|
|
|
|
2019-09-13 22:05:47 +08:00
|
|
|
// this probably needs some cross-checking with osu-stable to ensure it is actually correct.
|
|
|
|
if (lastFrame is CatchReplayFrame lastCatchFrame)
|
2019-09-12 17:33:46 +08:00
|
|
|
{
|
2019-09-13 22:05:47 +08:00
|
|
|
if (Position > lastCatchFrame.Position)
|
|
|
|
lastCatchFrame.Actions.Add(CatchAction.MoveRight);
|
|
|
|
else if (Position < lastCatchFrame.Position)
|
2019-09-12 17:33:46 +08:00
|
|
|
Actions.Add(CatchAction.MoveLeft);
|
|
|
|
}
|
2018-04-13 17:19:50 +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 * CatchPlayfield.BASE_WIDTH, null, state);
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|