From 37e30b00bf6d6a494847565036d3538fb1f1e939 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 6 Apr 2021 16:39:02 +0900 Subject: [PATCH] Refactor to keep a consistent API --- osu.Game/Rulesets/Difficulty/Skills/Skill.cs | 32 ++++--------------- .../Rulesets/Difficulty/Skills/StrainSkill.cs | 13 -------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/osu.Game/Rulesets/Difficulty/Skills/Skill.cs b/osu.Game/Rulesets/Difficulty/Skills/Skill.cs index ebd389d823..9f0fb987a7 100644 --- a/osu.Game/Rulesets/Difficulty/Skills/Skill.cs +++ b/osu.Game/Rulesets/Difficulty/Skills/Skill.cs @@ -19,12 +19,9 @@ namespace osu.Game.Rulesets.Difficulty.Skills protected readonly ReverseQueue Previous; /// - /// Soft capacity of the queue. - /// will automatically resize if it exceeds capacity, but will do so at a very slight performance impact. - /// The actual capacity will be set to this value + 1 to allow for storage of the current object before the next can be processed. - /// Setting to zero (default) will cause to be uninstanciated. + /// Number of previous s to keep inside the queue. /// - protected virtual int PreviousCollectionSoftCapacity => 0; + protected virtual int HistoryLength => 1; /// /// Mods for use in skill calculations. @@ -36,32 +33,17 @@ namespace osu.Game.Rulesets.Difficulty.Skills protected Skill(Mod[] mods) { this.mods = mods; - - if (PreviousCollectionSoftCapacity > 0) - Previous = new ReverseQueue(PreviousCollectionSoftCapacity + 1); + Previous = new ReverseQueue(HistoryLength + 1); } internal void ProcessInternal(DifficultyHitObject current) { - RemoveExtraneousHistory(current); + while (Previous.Count > HistoryLength) + Previous.Dequeue(); + Process(current); - AddToHistory(current); - } - /// - /// Remove objects from that are no longer needed for calculations from the current object onwards. - /// - /// The to be processed. - protected virtual void RemoveExtraneousHistory(DifficultyHitObject current) - { - } - - /// - /// Add the current to the queue (if required). - /// - /// The that was just processed. - protected virtual void AddToHistory(DifficultyHitObject current) - { + Previous.Enqueue(current); } /// diff --git a/osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs b/osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs index 16816be35c..71cee36812 100644 --- a/osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs +++ b/osu.Game/Rulesets/Difficulty/Skills/StrainSkill.cs @@ -20,8 +20,6 @@ namespace osu.Game.Rulesets.Difficulty.Skills /// protected abstract double SkillMultiplier { get; } - protected override int PreviousCollectionSoftCapacity => 1; - /// /// Determines how quickly strain decays for the given skill. /// For example a value of 0.15 indicates that strain decays to 15% of its original value in one second. @@ -54,17 +52,6 @@ namespace osu.Game.Rulesets.Difficulty.Skills { } - protected override void RemoveExtraneousHistory(DifficultyHitObject current) - { - while (Previous.Count > 1) - Previous.Dequeue(); - } - - protected override void AddToHistory(DifficultyHitObject current) - { - Previous.Enqueue(current); - } - /// /// Process a and update current strain values accordingly. ///