mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 03:22:57 +08:00
Make flashlight scale with playfield
When the playfield is shrunk with mods such as BarrelRoll, flashlight does not account for this, making it significantly easier to play. This makes it scale along with the playfield.
This commit is contained in:
parent
f8d6b8e347
commit
75b9d0fe66
@ -1,8 +1,13 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
{
|
||||
@ -21,5 +26,26 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||
|
||||
[Test]
|
||||
public void TestComboBasedSize([Values] bool comboBasedSize) => CreateModTest(new ModTestData { Mod = new OsuModFlashlight { ComboBasedSize = { Value = comboBasedSize } }, PassCondition = () => true });
|
||||
|
||||
[Test]
|
||||
public void TestPlayfieldBasedSize()
|
||||
{
|
||||
ModFlashlight mod = new OsuModFlashlight();
|
||||
CreateModTest(new ModTestData
|
||||
{
|
||||
Mod = mod,
|
||||
PassCondition = () =>
|
||||
{
|
||||
var flashlightOverlay = Player.DrawableRuleset.Overlays
|
||||
.OfType<ModFlashlight<OsuHitObject>.Flashlight>()
|
||||
.First();
|
||||
|
||||
return Precision.AlmostEquals(mod.DefaultFlashlightSize * .5f, flashlightOverlay.GetSize());
|
||||
}
|
||||
});
|
||||
|
||||
AddStep("adjust playfield scale", () =>
|
||||
Player.DrawableRuleset.Playfield.Scale = new Vector2(.5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
flashlight.Depth = float.MinValue;
|
||||
|
||||
flashlight.Combo.BindTo(Combo);
|
||||
flashlight.GetPlayfieldScale = () => drawableRuleset.Playfield.Scale;
|
||||
|
||||
drawableRuleset.Overlays.Add(flashlight);
|
||||
}
|
||||
@ -102,6 +103,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public override bool RemoveCompletedTransforms => false;
|
||||
|
||||
internal Func<Vector2>? GetPlayfieldScale;
|
||||
|
||||
private readonly float defaultFlashlightSize;
|
||||
private readonly float sizeMultiplier;
|
||||
private readonly bool comboBasedSize;
|
||||
@ -141,10 +144,18 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
protected abstract string FragmentShader { get; }
|
||||
|
||||
protected float GetSize()
|
||||
public float GetSize()
|
||||
{
|
||||
float size = defaultFlashlightSize * sizeMultiplier;
|
||||
|
||||
if (GetPlayfieldScale != null)
|
||||
{
|
||||
Vector2 playfieldScale = GetPlayfieldScale();
|
||||
float rulesetScaleAvg = (playfieldScale.X + playfieldScale.Y) / 2f;
|
||||
|
||||
size *= rulesetScaleAvg;
|
||||
}
|
||||
|
||||
if (isBreakTime.Value)
|
||||
size *= 2.5f;
|
||||
else if (comboBasedSize)
|
||||
|
Loading…
Reference in New Issue
Block a user