1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-19 17:12:58 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Replays/CatchFramedReplayInputHandler.cs

61 lines
1.8 KiB
C#
Raw Normal View History

2018-01-12 17:35:28 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Input;
using osu.Framework.MathUtils;
2018-01-12 17:35:28 +08:00
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Catch.Replays
{
public class CatchFramedReplayInputHandler : FramedReplayInputHandler<CatchReplayFrame>
2018-01-12 17:35:28 +08:00
{
public CatchFramedReplayInputHandler(Replay replay)
: base(replay)
{
}
2018-03-01 00:48:13 +08:00
protected override bool IsImportant(CatchReplayFrame frame) => frame.Position > 0;
2018-03-01 00:45:41 +08:00
protected float? Position
{
get
{
if (!HasFrames)
return null;
2018-03-01 00:48:13 +08:00
return Interpolation.ValueAt(CurrentTime, CurrentFrame.Position, NextFrame.Position, CurrentFrame.Time, NextFrame.Time);
}
}
public override List<InputState> GetPendingStates()
2018-01-12 17:35:28 +08:00
{
if (!Position.HasValue) return new List<InputState>();
var actions = new List<CatchAction>();
if (CurrentFrame.Dashing)
actions.Add(CatchAction.Dash);
2018-03-01 00:48:13 +08:00
if (Position.Value > CurrentFrame.Position)
actions.Add(CatchAction.MoveRight);
2018-03-01 00:48:13 +08:00
else if (Position.Value < CurrentFrame.Position)
actions.Add(CatchAction.MoveLeft);
return new List<InputState>
2018-01-12 17:35:28 +08:00
{
new CatchReplayState
{
PressedActions = actions,
CatcherX = Position.Value
},
};
}
2018-01-12 17:35:28 +08:00
public class CatchReplayState : ReplayState<CatchAction>
{
public float? CatcherX { get; set; }
}
}
}