mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Add the file
This commit is contained in:
parent
e3cc25a96a
commit
2afcdb1451
@ -0,0 +1,69 @@
|
|||||||
|
// 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.Lists;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Timing;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.UI.Scrolling.Visualisers
|
||||||
|
{
|
||||||
|
public class ConstantSpeedChangeVisualiser : ISpeedChangeVisualiser
|
||||||
|
{
|
||||||
|
public void ComputeInitialStates(IEnumerable<DrawableHitObject> hitObjects, ScrollingDirection direction, double timeRange, Vector2 length)
|
||||||
|
{
|
||||||
|
foreach (var obj in hitObjects)
|
||||||
|
{
|
||||||
|
obj.LifetimeStart = obj.HitObject.StartTime - timeRange;
|
||||||
|
|
||||||
|
if (obj.HitObject is IHasEndTime endTime)
|
||||||
|
{
|
||||||
|
var hitObjectLength = (endTime.EndTime - obj.HitObject.StartTime) / timeRange;
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
obj.Height = (float)(hitObjectLength * length.Y);
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Left:
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
obj.Width = (float)(hitObjectLength * length.X);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComputeInitialStates(obj.NestedHitObjects, direction, timeRange, length);
|
||||||
|
|
||||||
|
// Nested hitobjects don't need to scroll, but they do need accurate positions
|
||||||
|
UpdatePositions(obj.NestedHitObjects, direction, obj.HitObject.StartTime, timeRange, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdatePositions(IEnumerable<DrawableHitObject> hitObjects, ScrollingDirection direction, double currentTime, double timeRange, Vector2 length)
|
||||||
|
{
|
||||||
|
foreach (var obj in hitObjects)
|
||||||
|
{
|
||||||
|
var position = (obj.HitObject.StartTime - currentTime) / timeRange;
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case ScrollingDirection.Up:
|
||||||
|
obj.Y = (float)(position * length.Y);
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Down:
|
||||||
|
obj.Y = (float)(-position * length.Y);
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Left:
|
||||||
|
obj.X = (float)(position * length.X);
|
||||||
|
break;
|
||||||
|
case ScrollingDirection.Right:
|
||||||
|
obj.X = (float)(-position * length.X);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.UI.Scrolling.Visualisers
|
|||||||
|
|
||||||
foreach (var obj in hitObjects)
|
foreach (var obj in hitObjects)
|
||||||
{
|
{
|
||||||
var finalPosition = (hitObjectPositions[obj] - timelinePosition);
|
var finalPosition = hitObjectPositions[obj] - timelinePosition;
|
||||||
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user