mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:33:20 +08:00
Use var, rework dim application logic
This commit is contained in:
parent
037e23247f
commit
3c252d79ea
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -27,9 +28,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
||||||
{
|
{
|
||||||
foreach (DrawableSlider drawable in drawables.OfType<DrawableSlider>())
|
foreach (var s in drawables.OfType<DrawableSlider>())
|
||||||
{
|
{
|
||||||
drawable.Tracking.ValueChanged += flashlight.OnSliderTrackingChange;
|
s.Tracking.ValueChanged += flashlight.OnSliderTrackingChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,13 +45,28 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
public void OnSliderTrackingChange(ValueChangedEvent<bool> e)
|
public void OnSliderTrackingChange(ValueChangedEvent<bool> e)
|
||||||
{
|
{
|
||||||
|
// If any sliders are in a tracking state, apply a dim to the entire playfield over a brief duration.
|
||||||
if (e.NewValue)
|
if (e.NewValue)
|
||||||
|
{
|
||||||
trackingSliders++;
|
trackingSliders++;
|
||||||
|
// This check being here ensures we're only applying a dim if and only if a slider begins tracking.
|
||||||
|
if (trackingSliders == 1)
|
||||||
|
{
|
||||||
|
this.TransformTo(nameof(FlashlightDim), 0.8f, 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
trackingSliders--;
|
trackingSliders--;
|
||||||
|
|
||||||
// If there are any sliders in a tracking state, apply a dim to the entire playfield over a brief duration.
|
if (trackingSliders == 0)
|
||||||
this.TransformTo(nameof(FlashlightDim), trackingSliders > 0 ? 0.8f : 0.0f, 50);
|
{
|
||||||
|
this.TransformTo(nameof(FlashlightDim), 0.0f, 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trackingSliders < 0)
|
||||||
|
throw new InvalidOperationException($"The number of {nameof(trackingSliders)} cannot be below 0.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
|
Loading…
Reference in New Issue
Block a user