From e875d8d09f0a0b4bd23ea9ba647d5d6d121e2c76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:57:54 +0000 Subject: [PATCH 1/2] Bump ppy.osu.Game from 2024.517.0 to 2024.816.0 Bumps [ppy.osu.Game](https://github.com/ppy/osu) from 2024.517.0 to 2024.816.0. - [Release notes](https://github.com/ppy/osu/releases) - [Commits](https://github.com/ppy/osu/commits/2024.816.0) --- updated-dependencies: - dependency-name: ppy.osu.Game dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- osu.Game.Rulesets.Soyokaze/osu.Game.Rulesets.Soyokaze.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Soyokaze/osu.Game.Rulesets.Soyokaze.csproj b/osu.Game.Rulesets.Soyokaze/osu.Game.Rulesets.Soyokaze.csproj index 3011eea..9b86cac 100644 --- a/osu.Game.Rulesets.Soyokaze/osu.Game.Rulesets.Soyokaze.csproj +++ b/osu.Game.Rulesets.Soyokaze/osu.Game.Rulesets.Soyokaze.csproj @@ -11,7 +11,7 @@ - + From ad691f9dcaf6a0e1eab88bb6bc87b611ff34e466 Mon Sep 17 00:00:00 2001 From: Alden Wu Date: Mon, 26 Aug 2024 01:32:34 -0700 Subject: [PATCH 2/2] Objects: Start pooling drawable judgements --- .../Extensions/PositionExtensions.cs | 8 ++-- .../Drawables/DrawableSoyokazeJudgement.cs | 20 +++++++--- .../Replays/SoyokazeReplayFrame.cs | 16 ++++---- .../UI/SoyokazePlayfield.cs | 37 +++++++++++++------ 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/osu.Game.Rulesets.Soyokaze/Extensions/PositionExtensions.cs b/osu.Game.Rulesets.Soyokaze/Extensions/PositionExtensions.cs index 82b9904..f40960a 100644 --- a/osu.Game.Rulesets.Soyokaze/Extensions/PositionExtensions.cs +++ b/osu.Game.Rulesets.Soyokaze/Extensions/PositionExtensions.cs @@ -24,14 +24,14 @@ public static Vector2[] GetPositions(int screenCenterGap, int objectGap, bool in { Vector2 offset = new Vector2(0); - if (origin.HasFlagFast(Anchor.x0)) + if (origin.HasFlag(Anchor.x0)) offset.X = SCREEN_WIDTH / 2; - else if (origin.HasFlagFast(Anchor.x2)) + else if (origin.HasFlag(Anchor.x2)) offset.X = -SCREEN_WIDTH / 2; - if (origin.HasFlagFast(Anchor.y0)) + if (origin.HasFlag(Anchor.y0)) offset.Y = SCREEN_HEIGHT / 2; - else if (origin.HasFlagFast(Anchor.y2)) + else if (origin.HasFlag(Anchor.y2)) offset.Y = -SCREEN_HEIGHT / 2; Vector2[] positions = new Vector2[] diff --git a/osu.Game.Rulesets.Soyokaze/Objects/Drawables/DrawableSoyokazeJudgement.cs b/osu.Game.Rulesets.Soyokaze/Objects/Drawables/DrawableSoyokazeJudgement.cs index 3d37442..e5d1992 100644 --- a/osu.Game.Rulesets.Soyokaze/Objects/Drawables/DrawableSoyokazeJudgement.cs +++ b/osu.Game.Rulesets.Soyokaze/Objects/Drawables/DrawableSoyokazeJudgement.cs @@ -1,6 +1,8 @@ // Copyright (c) Alden Wu . Licensed under the MIT Licence. // See the LICENSE file in the repository root for full licence text. +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -14,20 +16,28 @@ namespace osu.Game.Rulesets.Soyokaze.Objects.Drawables { public partial class DrawableSoyokazeJudgement : DrawableJudgement { - public DrawableSoyokazeJudgement(JudgementResult result, DrawableHitObject drawableObject, SoyokazeConfigManager configManager) - : base(result, drawableObject) + [Resolved] + private SoyokazeConfigManager configManager { get; set; } = null; + + public DrawableSoyokazeJudgement() + : base() { Origin = Anchor.Centre; Anchor = Anchor.Centre; + } + + protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultJudgementPiece(result); - SoyokazeAction button = (drawableObject as DrawableSoyokazeHitObject)?.ButtonBindable.Value ?? default; + public override void Apply(JudgementResult result, DrawableHitObject judgedObject) + { + base.Apply(result, judgedObject); + + SoyokazeAction button = (judgedObject as DrawableSoyokazeHitObject)?.ButtonBindable.Value ?? default; int screenCenterDistance = configManager?.Get(SoyokazeConfig.ScreenCenterGap) ?? 0; int gap = configManager?.Get(SoyokazeConfig.ObjectGap) ?? 0; Vector2[] positions = PositionExtensions.GetPositions(screenCenterDistance, gap, true, Anchor.Centre); Position = positions[(int)button]; } - - protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultJudgementPiece(result); } } diff --git a/osu.Game.Rulesets.Soyokaze/Replays/SoyokazeReplayFrame.cs b/osu.Game.Rulesets.Soyokaze/Replays/SoyokazeReplayFrame.cs index 3d462a4..f0ce3b1 100644 --- a/osu.Game.Rulesets.Soyokaze/Replays/SoyokazeReplayFrame.cs +++ b/osu.Game.Rulesets.Soyokaze/Replays/SoyokazeReplayFrame.cs @@ -46,21 +46,21 @@ public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayF Position = currentFrame.Position; SoyokazeActionFlag soyokazeButtonFlags = (SoyokazeActionFlag)currentFrame.ButtonState; - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button0)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button0)) Actions.Add(SoyokazeAction.Button0); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button1)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button1)) Actions.Add(SoyokazeAction.Button1); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button2)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button2)) Actions.Add(SoyokazeAction.Button2); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button3)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button3)) Actions.Add(SoyokazeAction.Button3); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button4)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button4)) Actions.Add(SoyokazeAction.Button4); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button5)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button5)) Actions.Add(SoyokazeAction.Button5); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button6)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button6)) Actions.Add(SoyokazeAction.Button6); - if (soyokazeButtonFlags.HasFlagFast(SoyokazeActionFlag.Button7)) + if (soyokazeButtonFlags.HasFlag(SoyokazeActionFlag.Button7)) Actions.Add(SoyokazeAction.Button7); } diff --git a/osu.Game.Rulesets.Soyokaze/UI/SoyokazePlayfield.cs b/osu.Game.Rulesets.Soyokaze/UI/SoyokazePlayfield.cs index 6900def..6266179 100644 --- a/osu.Game.Rulesets.Soyokaze/UI/SoyokazePlayfield.cs +++ b/osu.Game.Rulesets.Soyokaze/UI/SoyokazePlayfield.cs @@ -9,6 +9,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Soyokaze.Configuration; using osu.Game.Rulesets.Soyokaze.Objects; using osu.Game.Rulesets.Soyokaze.Objects.Drawables; @@ -22,6 +23,7 @@ public partial class SoyokazePlayfield : Playfield, IKeyBindingHandler judgementContainer = new JudgementContainer { RelativeSizeAxes = Axes.Both }; + private readonly JudgementPooler judgementPooler; private readonly SkinnableInputOverlay inputOverlay = new SkinnableInputOverlay { RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, Anchor = Anchor.Centre }; private readonly SkinnableKiaiVisualizer kiaiVisualizer = new SkinnableKiaiVisualizer { RelativeSizeAxes = Axes.Both, Origin = Anchor.Centre, Anchor = Anchor.Centre }; private SoyokazeConfigManager configManager; @@ -37,14 +39,6 @@ private partial class ProxyContainer : LifetimeManagementContainer public SoyokazePlayfield() { - NewResult += onNewResult; - } - - [BackgroundDependencyLoader(true)] - private void load(SoyokazeConfigManager cm) - { - configManager = cm; - AddRangeInternal(new Drawable[] { kiaiVisualizer, @@ -54,6 +48,25 @@ private void load(SoyokazeConfigManager cm) approachCircleContainer, }); + AddInternal(judgementPooler = new JudgementPooler(new[] + { + HitResult.Perfect, + HitResult.Great, + HitResult.Good, + HitResult.Ok, + HitResult.Meh, + HitResult.Miss, + HitResult.IgnoreHit, + })); + + NewResult += onNewResult; + } + + [BackgroundDependencyLoader(true)] + private void load(SoyokazeConfigManager cm) + { + configManager = cm; + RegisterPool(15, 30); RegisterPool(15, 30); @@ -75,16 +88,16 @@ private void onDrawableHitObjectLoaded(Drawable drawable) } } - private void onNewResult(DrawableHitObject drawableObject, JudgementResult result) + private void onNewResult(DrawableHitObject judgedObject, JudgementResult result) { - if (!drawableObject.DisplayResult || !DisplayJudgements.Value) + if (!judgedObject.DisplayResult || !DisplayJudgements.Value) return; - switch (drawableObject) + switch (judgedObject) { case DrawableHitCircle _: case DrawableHold _: - judgementContainer.Add(new DrawableSoyokazeJudgement(result, drawableObject, configManager)); + judgementContainer.Add(judgementPooler.Get(result.Type, dsj => dsj.Apply(result, judgedObject))); break; } }