1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 21:02:54 +08:00
osu-lazer/osu.Game/Input/Handlers/ReplayInputHandler.cs

48 lines
1.7 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +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;
using System.Collections.Generic;
using osu.Framework.Input.Handlers;
2018-07-21 10:38:28 +08:00
using osu.Framework.Input.StateChanges;
using osu.Framework.Input.States;
2018-04-13 17:19:50 +08:00
using osu.Framework.Platform;
using OpenTK;
namespace osu.Game.Input.Handlers
{
public abstract class ReplayInputHandler : InputHandler
{
/// <summary>
/// A function that converts coordinates from gamefield to screen space.
/// </summary>
public Func<Vector2, Vector2> GamefieldToScreenSpace { protected get; set; }
/// <summary>
/// Update the current frame based on an incoming time value.
/// There are cases where we return a "must-use" time value that is different from the input.
/// This is to ensure accurate playback of replay data.
/// </summary>
/// <param name="time">The time which we should use for finding the current frame.</param>
/// <returns>The usable time value. If null, we should not advance time as we do not have enough data.</returns>
public abstract double? SetFrameFromTime(double time);
public override bool Initialize(GameHost host) => true;
public override bool IsActive => true;
public override int Priority => 0;
2018-06-11 22:00:26 +08:00
public class ReplayState<T> : IInput
2018-04-13 17:19:50 +08:00
where T : struct
{
public List<T> PressedActions;
2018-06-11 22:00:26 +08:00
public void Apply(InputState state, IInputStateChangeHandler handler)
2018-04-13 17:19:50 +08:00
{
2018-06-11 22:00:26 +08:00
handler.HandleCustomInput(state, this);
2018-04-13 17:19:50 +08:00
}
}
}
}