1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 19:12:54 +08:00

Rewrote traceable mod to inherit from hidden

This commit is contained in:
MaxOhn 2019-07-01 20:11:50 +02:00
parent 845bf21f7f
commit 5496b8bc58
5 changed files with 48 additions and 74 deletions

View File

@ -1,6 +1,7 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
@ -28,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Mods
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(OsuModTraceable) };
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public void ReadFromConfig(OsuConfigManager config)

View File

@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public override string Description => @"Play with no approach circles and fading circles/sliders.";
public override double ScoreMultiplier => 1.06;
public override Type[] IncompatibleMods => new[] { typeof(OsuModTraceable) };
private const double fade_in_duration_multiplier = 0.4;
private const double fade_out_duration_multiplier = 0.3;

View File

@ -2,84 +2,64 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Osu.Mods
{
internal class OsuModTraceable : Mod, IApplicableToDrawableHitObjects
internal class OsuModTraceable : OsuModHidden, IReadFromConfig, IApplicableToDrawableHitObjects
{
public override string Name => "Traceable";
public override string ShortenedName => "TC";
public override FontAwesome Icon => FontAwesome.fa_snapchat_ghost;
public override string Acronym => "TC";
public override IconUsage Icon => FontAwesome.Brands.SnapchatGhost;
public override ModType Type => ModType.Fun;
public override string Description => "Put your faith in the approach circles...";
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(OsuModHidden), typeof(OsuModGrow) };
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
public override void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var drawable in drawables)
drawable.ApplyCustomUpdateState += ApplyTraceableState;
}
/* Similar to ApplyHiddenState, only different if drawable is DrawableHitCircle.
* If we'd use ApplyHiddenState instead but only on non-DrawableHitCircle's, then
* the nested object HeadCircle of DrawableSlider would still use ApplyHiddenState,
* thus treating the DrawableHitCircle with the hidden mod instead of the traceable mod.
*/
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
foreach (var drawable in drawables.Skip(IncreaseFirstObjectVisibility.Value ? 1 : 0))
{
if (!(drawable is DrawableOsuHitObject d))
return;
var h = d.HitObject;
var fadeOutStartTime = h.StartTime - h.TimePreempt + h.TimeFadeIn;
// new duration from completed fade in to end (before fading out)
var longFadeDuration = ((h as IHasEndTime)?.EndTime ?? h.StartTime) - fadeOutStartTime;
switch (drawable)
{
case DrawableHitCircle circle:
// we only want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
circle.HideButApproachCircle();
// approach circle fades out quickly at StartTime
using (drawable.BeginAbsoluteSequence(h.StartTime, true))
circle.ApproachCircle.FadeOut(50);
case DrawableHitCircle _:
drawable.ApplyCustomUpdateState += ApplyTraceableState;
break;
case DrawableSlider slider:
using (slider.BeginAbsoluteSequence(fadeOutStartTime, true))
slider.Body.FadeOut(longFadeDuration, Easing.Out);
slider.ApplyCustomUpdateState += ApplyHiddenState;
slider.HeadCircle.ApplyCustomUpdateState += ApplyTraceableState;
break;
case DrawableSliderTick sliderTick:
// slider ticks fade out over up to one second
var tickFadeOutDuration = Math.Min(sliderTick.HitObject.TimePreempt - DrawableSliderTick.ANIM_DURATION, 1000);
using (sliderTick.BeginAbsoluteSequence(sliderTick.HitObject.StartTime - tickFadeOutDuration, true))
sliderTick.FadeOut(tickFadeOutDuration);
break;
case DrawableSpinner spinner:
// hide elements we don't care about.
spinner.Disc.Hide();
spinner.Ticks.Hide();
spinner.Background.Hide();
using (spinner.BeginAbsoluteSequence(fadeOutStartTime + longFadeDuration, true))
spinner.FadeOut(h.TimePreempt);
default:
drawable.ApplyCustomUpdateState += ApplyHiddenState;
break;
}
}
}
protected void ApplyTraceableState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableHitCircle circle))
return;
var h = circle.HitObject;
// we only want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
{
circle.circle.Hide(); // CirclePiece
circle.circle.AlwaysPresent = true;
circle.ring.Hide();
circle.flash.Hide();
circle.explode.Hide();
circle.number.Hide();
circle.glow.Hide();
circle.ApproachCircle.Show();
}
}
}
}

View File

@ -17,12 +17,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
{
public ApproachCircle ApproachCircle;
private readonly CirclePiece circle;
private readonly RingPiece ring;
private readonly FlashPiece flash;
private readonly ExplodePiece explode;
private readonly NumberPiece number;
private readonly GlowPiece glow;
public readonly CirclePiece circle;
public readonly RingPiece ring;
public readonly FlashPiece flash;
public readonly ExplodePiece explode;
public readonly NumberPiece number;
public readonly GlowPiece glow;
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
@ -113,17 +113,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}
}
public void HideButApproachCircle()
{
circle.Hide();
circle.AlwaysPresent = true;
ring.Hide();
flash.Hide();
explode.Hide();
number.Hide();
glow.Hide();
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (!userTriggered)

View File

@ -112,7 +112,7 @@ namespace osu.Game.Overlays.Mods
if (selected == null) continue;
foreach (var type in modTypes)
if (type.IsInstanceOfType(selected))
if (type.IsInstanceOfType(selected) && !selected.GetType().IsSubclassOf(type))
{
if (immediate)
button.Deselect();
@ -130,7 +130,7 @@ namespace osu.Game.Overlays.Mods
{
foreach (var button in buttons)
{
int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t.IsInstanceOfType(m)));
int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t.IsInstanceOfType(m) && !m.GetType().IsSubclassOf(t)));
if (i >= 0)
button.SelectAt(i);