mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 03:15:36 +08:00
Fix conversion test failing
This commit is contained in:
parent
b63e9f29d4
commit
9709a40c54
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
@ -29,33 +30,15 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
if (hitObject is JuiceStream stream)
|
if (hitObject is JuiceStream stream)
|
||||||
{
|
{
|
||||||
foreach (var nested in stream.NestedHitObjects)
|
foreach (var nested in stream.NestedHitObjects)
|
||||||
{
|
yield return new ConvertValue((CatchHitObject)nested);
|
||||||
yield return new ConvertValue
|
|
||||||
{
|
|
||||||
StartTime = nested.StartTime,
|
|
||||||
Position = ((CatchHitObject)nested).X * CatchPlayfield.BASE_WIDTH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (hitObject is BananaShower shower)
|
else if (hitObject is BananaShower shower)
|
||||||
{
|
{
|
||||||
foreach (var nested in shower.NestedHitObjects)
|
foreach (var nested in shower.NestedHitObjects)
|
||||||
{
|
yield return new ConvertValue((CatchHitObject)nested);
|
||||||
yield return new ConvertValue
|
|
||||||
{
|
|
||||||
StartTime = nested.StartTime,
|
|
||||||
Position = ((CatchHitObject)nested).X * CatchPlayfield.BASE_WIDTH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
yield return new ConvertValue((CatchHitObject)hitObject);
|
||||||
yield return new ConvertValue
|
|
||||||
{
|
|
||||||
StartTime = hitObject.StartTime,
|
|
||||||
Position = ((CatchHitObject)hitObject).X * CatchPlayfield.BASE_WIDTH
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Ruleset CreateRuleset() => new CatchRuleset();
|
protected override Ruleset CreateRuleset() => new CatchRuleset();
|
||||||
@ -68,8 +51,31 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const float conversion_lenience = 2;
|
private const float conversion_lenience = 2;
|
||||||
|
|
||||||
public double StartTime;
|
[JsonIgnore]
|
||||||
public float Position;
|
public readonly CatchHitObject HitObject;
|
||||||
|
|
||||||
|
public ConvertValue(CatchHitObject hitObject)
|
||||||
|
{
|
||||||
|
HitObject = hitObject;
|
||||||
|
startTime = 0;
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double startTime;
|
||||||
|
|
||||||
|
public double StartTime
|
||||||
|
{
|
||||||
|
get => HitObject?.StartTime ?? startTime;
|
||||||
|
set => startTime = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float position;
|
||||||
|
|
||||||
|
public float Position
|
||||||
|
{
|
||||||
|
get => HitObject?.X * CatchPlayfield.BASE_WIDTH ?? position;
|
||||||
|
set => position = value;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Equals(ConvertValue other)
|
public bool Equals(ConvertValue other)
|
||||||
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
=> Precision.AlmostEquals(StartTime, other.StartTime, conversion_lenience)
|
||||||
|
Loading…
Reference in New Issue
Block a user