mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Add "ghost" mod for osu
This commit is contained in:
parent
7a80ff206e
commit
6b1534f5a6
67
osu.Game.Rulesets.Osu/Mods/OsuModGhost.cs
Normal file
67
osu.Game.Rulesets.Osu/Mods/OsuModGhost.cs
Normal file
@ -0,0 +1,67 @@
|
||||
// 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 osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModGhost : Mod, IUpdatableByPlayfield, IApplicableToScoreProcessor
|
||||
{
|
||||
public override string Name => "Ghost";
|
||||
public override string Acronym => "G";
|
||||
public override ModType Type => ModType.Fun;
|
||||
public override IconUsage? Icon => FontAwesome.Solid.Ghost;
|
||||
public override string Description => "Where's the cursor?";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
private readonly BindableNumber<float> ghostAlpha = new BindableFloat(0);
|
||||
private BindableNumber<int> currentCombo;
|
||||
|
||||
[SettingSource(
|
||||
"Hidden at combo",
|
||||
"The combo count at which the cursor becomes completely hidden",
|
||||
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
|
||||
)]
|
||||
public BindableInt HiddenComboCount { get; } = new BindableInt
|
||||
{
|
||||
Default = 10,
|
||||
Value = 10,
|
||||
MinValue = 0,
|
||||
MaxValue = 50,
|
||||
};
|
||||
|
||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||
{
|
||||
currentCombo = scoreProcessor.Combo.GetBoundCopy();
|
||||
currentCombo.BindValueChanged(combo =>
|
||||
{
|
||||
float dimFactor = HiddenComboCount.Value == 0 ? 1 : (float)combo.NewValue / HiddenComboCount.Value;
|
||||
|
||||
scoreProcessor.TransformBindableTo(ghostAlpha, 1-dimFactor, 100, Easing.OutQuint);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
public virtual void Update(Playfield playfield)
|
||||
{
|
||||
playfield.Cursor.Alpha = ghostAlpha.Value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class HiddenComboSlider : OsuSliderBar<int>
|
||||
{
|
||||
public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
|
||||
}
|
||||
}
|
@ -192,6 +192,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
new OsuModBarrelRoll(),
|
||||
new OsuModApproachDifferent(),
|
||||
new OsuModMuted(),
|
||||
new OsuModGhost(),
|
||||
};
|
||||
|
||||
case ModType.System:
|
||||
|
Loading…
Reference in New Issue
Block a user