Tidy up code formatting / variable naming

This commit is contained in:
Dean Herbert 2019-08-12 15:05:27 +09:00
parent 45b4fc9201
commit 707911acac
1 changed files with 10 additions and 8 deletions

View File

@ -29,19 +29,21 @@ public class OsuModAutopilot : Mod, IApplicableFailOverride, IUpdatableByPlayfie
private OsuInputManager inputManager;
private List<OsuReplayFrame> replayFrames;
private int frameIndex;
private int currentFrame;
public void Update(Playfield playfield)
{
// If we are on the last replay frame, no need to do anything
if (frameIndex == replayFrames.Count - 1) return;
if (currentFrame == replayFrames.Count - 1) return;
// Check if we are closer to the next replay frame then the current one
if (Math.Abs(replayFrames[frameIndex].Time - playfield.Time.Current) >= Math.Abs(replayFrames[frameIndex + 1].Time - playfield.Time.Current))
double time = playfield.Time.Current;
// Very naive implementation of autopilot based on proximity to replay frames.
// TODO: this needs to be based on user interactions to better match stable (pausing until judgement is registered).
if (Math.Abs(replayFrames[currentFrame + 1].Time - time) <= Math.Abs(replayFrames[currentFrame].Time - time))
{
// If we are, move to the next frame, and update the mouse position
frameIndex++;
new MousePositionAbsoluteInput { Position = playfield.ToScreenSpace(replayFrames[frameIndex].Position) }.Apply(inputManager.CurrentState, inputManager);
currentFrame++;
new MousePositionAbsoluteInput { Position = playfield.ToScreenSpace(replayFrames[currentFrame].Position) }.Apply(inputManager.CurrentState, inputManager);
}
// TODO: Implement the functionality to automatically spin spinners