Skip to content

Commit

Permalink
Move opacity function to OsuDifficultyHitObject
Browse files Browse the repository at this point in the history
  • Loading branch information
MBmasher committed Nov 21, 2021
1 parent fe83b8f commit afbec94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,30 @@ public class OsuDifficultyHitObject : DifficultyHitObject

private readonly OsuHitObject lastLastObject;
private readonly OsuHitObject lastObject;
private readonly double clockRate;

public OsuDifficultyHitObject(HitObject hitObject, HitObject lastLastObject, HitObject lastObject, double clockRate)
: base(hitObject, lastObject, clockRate)
{
this.lastLastObject = (OsuHitObject)lastLastObject;
this.lastObject = (OsuHitObject)lastObject;
this.clockRate = clockRate;

// Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
StrainTime = Math.Max(DeltaTime, min_delta_time);

setDistances(clockRate);
}

public double opacity(double ms, bool hidden)
{
double preemptTime = BaseObject.TimePreempt / clockRate;
if (hidden)
return Math.Clamp(Math.Min((1 - ms / preemptTime) * 2.5, (ms / preemptTime) * (1.0 / 0.3)), 0.0, 1.0);
else
return Math.Clamp((1.0 - ms / preemptTime) * 1.5, 0.0, 1.0);
}

private void setDistances(double clockRate)
{
// We don't need to calculate either angle or distance when one of the last->curr objects is a spinner
Expand Down
10 changes: 1 addition & 9 deletions osu.Game.Rulesets.Osu/Difficulty/Skills/Flashlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private double strainValueOf(DifficultyHitObject current)
double stackNerf = Math.Min(1.0, (osuPrevious.JumpDistance / scalingFactor) / 25.0);

// Bonus based on how visible the object is.
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - opacity(cumulativeStrainTime, preemptTime, hidden));
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.opacity(cumulativeStrainTime, hidden));

result += Math.Pow(0.8, i) * stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
}
Expand All @@ -87,14 +87,6 @@ private double strainValueOf(DifficultyHitObject current)
return result;
}

private double opacity(double ms, double preemptTime, bool hidden)
{
if (hidden)
return Math.Clamp(Math.Min((1 - ms / preemptTime) * 2.5, (ms / preemptTime) * (1.0 / 0.3)), 0.0, 1.0);
else
return Math.Clamp((1.0 - ms / preemptTime) * 1.5, 0.0, 1.0);
}

private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);

protected override double CalculateInitialStrain(double time) => currentStrain * strainDecay(time - Previous[0].StartTime);
Expand Down

0 comments on commit afbec94

Please sign in to comment.