Skip to content

Commit

Permalink
wip clean hidden combo showing thingy implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBeh committed Nov 28, 2024
1 parent a27c51d commit 8a473d0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 20 deletions.
46 changes: 29 additions & 17 deletions osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
Expand All @@ -23,7 +24,7 @@

namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModHidden : ModHidden, IHidesApproachCircles, IApplicableToHealthProcessor, IUpdatableByPlayfield, IApplicableToScoreProcessor
public class OsuModHidden : ModHidden, IHidesApproachCircles, IUpdatableByPlayfield, IApplicableToScoreProcessor
{
[SettingSource("Only fade approach circles", "The main object body will not fade when enabled.")]
public Bindable<bool> OnlyFadeApproachCircles { get; } = new BindableBool();
Expand Down Expand Up @@ -55,6 +56,7 @@ static void applyFadeInAdjustment(OsuHitObject osuObject)

public void Update(Playfield playfield)
{
return;
foreach (var drawableHitObject in playfield.HitObjectContainer.AliveObjects)

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

Unreachable code detected

Check warning on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

Unreachable code detected

Check warning on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

Unreachable code detected

Check failure on line 60 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

Unreachable code detected
{
var target = (drawableHitObject switch
Expand All @@ -77,7 +79,7 @@ public void Update(Playfield playfield)
continue;
}

var fadeTarget = fadeDurationFactor;/*= fadeDurationFactor < 0.2
var fadeTarget = fadeDurationFactor; /*= fadeDurationFactor < 0.2
? 0
: Interpolation.ValueAt((float)target.Time.Current, 1f, 0f, fadeOutStartTime, fadeOutStartTime + fadeOutDuration, Easing.InQuart);*/
var fadeInTarget = Interpolation.ValueAt((float)target.Time.Current, 0f, 1f, fadeOutStartTime, fadeInEndTime);
Expand All @@ -100,6 +102,12 @@ protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject,
applyHiddenState(hitObject, false);
}

protected override uint GetHiddenComboInfluence(JudgementResult judgementResult) => judgementResult.HitObject switch
{
HitCircle and not SliderEndCircle => 1,
_ => 0,
};

private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVisibility)
{
if (!(drawableObject is DrawableOsuHitObject drawableOsuObject))
Expand All @@ -109,13 +117,14 @@ private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVis

(double fadeStartTime, double fadeDuration) = getFadeOutParameters(drawableOsuObject);

increaseVisibility = increaseVisibility || OverrideShowHitObjects();
// process approach circle hiding first (to allow for early return below).
if (!increaseVisibility)
{
if (drawableObject is DrawableHitCircle circle)
{
using (circle.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt))
circle.ApproachCircle.FadeOut();
circle.ApproachCircle.FadeTo(_alpha);
}
else if (drawableObject is DrawableSpinner spinner)
{
Expand Down Expand Up @@ -149,25 +158,25 @@ private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVis
case DrawableHitCircle circle:
Drawable fadeTarget = circle;

if (increaseVisibility || true)
if (increaseVisibility || true) // TODO clean this up
{
// only fade the circle piece (not the approach circle) for the increased visibility object.
fadeTarget = circle.CirclePiece;
}

using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
fadeTarget.FadeTo(alpha, fadeDuration);
fadeTarget.FadeTo(_alpha * 0.5f, fadeDuration);
break;

case DrawableSlider slider:
using (slider.BeginAbsoluteSequence(fadeStartTime))
slider.Body.FadeTo(alpha, fadeDuration, Easing.Out);
slider.Body.FadeTo(_alpha * 0.5f, fadeDuration, Easing.Out);

break;

case DrawableSliderTick sliderTick:
using (sliderTick.BeginAbsoluteSequence(fadeStartTime))
sliderTick.FadeTo(alpha, fadeDuration);
sliderTick.FadeTo(_alpha * 0.5f, fadeDuration);

break;

Expand Down Expand Up @@ -236,27 +245,30 @@ private static void hideSpinnerApproachCircle(DrawableSpinner spinner)
approachCircle.Hide();
}

private float alpha = 0;
private float _alpha => OverrideShowHitObjects() ? 1 : 0;
private float fadeDurationFactor = 0.9f;
private int combo = 0;

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check warning on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check warning on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The field 'OsuModHidden.combo' is assigned but its value is never used

Check failure on line 250 in osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The field 'OsuModHidden.combo' is assigned but its value is never used

public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
/*
public override void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
return;
healthProcessor.Health.ValueChanged += newHealth =>
scoreProcessor.NewJudgement += result =>
{
fadeDurationFactor = Math.Clamp(Interpolation.ValueAt((float)newHealth.NewValue, 1.2f, -0.1f, 0.2f, 0.8f), 0f, 1f);
if (result.HitObject is HitCircle and not SliderEndCircle)
combo++;
};
}
public override void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
scoreProcessor.JudgementReverted += result =>
{
if (result.HitObject is HitCircle and not SliderEndCircle)
combo--;
};
scoreProcessor.Combo.ValueChanged += combo =>
{
fadeDurationFactor = combo.NewValue == 0f ? 1f : 1f - (float)combo.NewValue / 25f;
fadeDurationFactor = Math.Clamp(fadeDurationFactor, 0f, 1f);
};
}


*/
}
}
43 changes: 41 additions & 2 deletions osu.Game/Rulesets/Mods/ModHidden.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;

Check failure on line 4 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
using NUnit.Framework.Internal;
using OpenTabletDriver.Plugin;
using osu.Framework.Bindables;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;

Check failure on line 12 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;

Check failure on line 14 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
using osu.Game.Scoring;
using Logger = osu.Framework.Logging.Logger;
using LogLevel = osu.Framework.Logging.LogLevel;

namespace osu.Game.Rulesets.Mods
{
Expand All @@ -16,9 +26,17 @@ public abstract class ModHidden : ModWithVisibilityAdjustment, IApplicableToScor
public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => UsesDefaultConfiguration;

public virtual void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
private bool lastShown;

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check warning on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check warning on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The field 'ModHidden.lastShown' is assigned but its value is never used

Check failure on line 29 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The field 'ModHidden.lastShown' is assigned but its value is never used
private uint _combo;

Check failure on line 30 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Naming rule violation: Prefix '_' is not expected (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide1006)
private bool Show => _combo < EnableAtCombo.Value;

Check failure on line 31 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Naming rule violation: The first word, 'Show', must begin with a lower case character (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide1006)

[SettingSource("Enable at combo", "The combo at which the hidden effect will start to take effect.")]
public BindableNumber<int> EnableAtCombo { get; } = new BindableNumber<int>(10)
{
}
MinValue = 0,
MaxValue = 100,
Precision = 1,
};

public virtual ScoreRank AdjustRank(ScoreRank rank, double accuracy)
{
Expand All @@ -34,5 +52,26 @@ public virtual ScoreRank AdjustRank(ScoreRank rank, double accuracy)
return rank;
}
}

public virtual void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
_combo = (uint)EnableAtCombo.Value;
lastShown = false;

scoreProcessor.NewJudgement += result => ScoreProcessorOnNewJudgement(result);
scoreProcessor.JudgementReverted += result => ScoreProcessorOnNewJudgement(result, true);

void ScoreProcessorOnNewJudgement(JudgementResult obj, bool revert = false)

Check failure on line 64 in osu.Game/Rulesets/Mods/ModHidden.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Naming rule violation: The first word, 'ScoreProcessorOnNewJudgement', must begin with a lower case character (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide1006)
{
if (revert) return;
uint abs = GetHiddenComboInfluence(obj);
_combo = !obj.IsHit && abs > 0 ? 0 : _combo + abs;
Logger.Log($"Combo: {_combo}", level: LogLevel.Verbose);
}
}

protected virtual bool OverrideShowHitObjects() => Show;

protected virtual uint GetHiddenComboInfluence(JudgementResult judgementResult) => 0;
}
}
5 changes: 4 additions & 1 deletion osu.Game/Rulesets/Mods/ModWithVisibilityAdjustment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements;

Check failure on line 8 in osu.Game/Rulesets/Mods/ModWithVisibilityAdjustment.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0005)
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;

Expand Down Expand Up @@ -78,13 +79,15 @@ public virtual void ApplyToDrawableHitObject(DrawableHitObject dho)
dho.ApplyCustomUpdateState += (o, state) =>
{
// Increased visibility is applied to the entire first object, including all of its nested hitobjects.
if (IncreaseFirstObjectVisibility.Value && isObjectEqualToOrNestedIn(o.HitObject, FirstObject))
// TODO Not sure if this OverrideShowHitObject() is necessary, seems not beacause of pooling
if ((IncreaseFirstObjectVisibility.Value && isObjectEqualToOrNestedIn(o.HitObject, FirstObject)))
ApplyIncreasedVisibilityState(o, state);
else
ApplyNormalVisibilityState(o, state);
};
}


/// <summary>
/// Checks whether a given object is nested within a target.
/// </summary>
Expand Down

0 comments on commit 8a473d0

Please sign in to comment.