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;
|
2018-02-28 15:34:47 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2018-01-12 17:35:28 +08:00
|
|
|
|
using osu.Game.Rulesets.Replays;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Replays
|
|
|
|
|
{
|
2018-02-28 15:34:47 +08:00
|
|
|
|
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
|
|
|
|
|
2018-02-28 15:34:47 +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);
|
2018-02-28 15:34:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 17:46:59 +08:00
|
|
|
|
public override List<InputState> GetPendingStates()
|
2018-01-12 17:35:28 +08:00
|
|
|
|
{
|
2018-01-22 17:46:59 +08:00
|
|
|
|
if (!Position.HasValue) return new List<InputState>();
|
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
|
var actions = new List<CatchAction>();
|
2018-01-22 17:46:59 +08:00
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
|
if (CurrentFrame.Dashing)
|
|
|
|
|
actions.Add(CatchAction.Dash);
|
2018-01-22 17:46:59 +08:00
|
|
|
|
|
2018-03-01 00:48:13 +08:00
|
|
|
|
if (Position.Value > CurrentFrame.Position)
|
2018-02-28 15:34:47 +08:00
|
|
|
|
actions.Add(CatchAction.MoveRight);
|
2018-03-01 00:48:13 +08:00
|
|
|
|
else if (Position.Value < CurrentFrame.Position)
|
2018-02-28 15:34:47 +08:00
|
|
|
|
actions.Add(CatchAction.MoveLeft);
|
2018-01-22 17:46:59 +08:00
|
|
|
|
|
|
|
|
|
return new List<InputState>
|
2018-01-12 17:35:28 +08:00
|
|
|
|
{
|
2018-01-22 17:46:59 +08:00
|
|
|
|
new CatchReplayState
|
|
|
|
|
{
|
2018-02-28 15:34:47 +08:00
|
|
|
|
PressedActions = actions,
|
|
|
|
|
CatcherX = Position.Value
|
2018-01-22 17:46:59 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-01-12 17:35:28 +08:00
|
|
|
|
|
|
|
|
|
public class CatchReplayState : ReplayState<CatchAction>
|
|
|
|
|
{
|
|
|
|
|
public float? CatcherX { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|