Skip to content

Commit

Permalink
Merge pull request #27977 from DavidBeh/magnetised-judgements
Browse files Browse the repository at this point in the history
Make judgements follow hitcircles and enable them in magnetised, repel and depth
  • Loading branch information
smoogipoo committed May 30, 2024
2 parents 981b69d + 8916f08 commit 3c2599c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void showResult(HitResult result)
private partial class TestDrawableOsuJudgement : DrawableOsuJudgement
{
public new SkinnableSprite Lighting => base.Lighting;
public new SkinnableDrawable JudgementBody => base.JudgementBody;
public new SkinnableDrawable? JudgementBody => base.JudgementBody;
}
}
}
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Mods/OsuModDepth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ public class OsuModDepth : ModWithVisibilityAdjustment, IUpdatableByPlayfield, I

public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
// Hide judgment displays and follow points as they won't make any sense.
// Hide follow points as they won't make any sense.
// Judgements can potentially be turned on in a future where they display at a position relative to their drawable counterpart.
drawableRuleset.Playfield.DisplayJudgements.Value = false;
(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
}

Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Mods/OsuModMagnetised.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ internal class OsuModMagnetised : Mod, IUpdatableByPlayfield, IApplicableToDrawa

public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
// Hide judgment displays and follow points as they won't make any sense.
// Hide follow points as they won't make any sense.
// Judgements can potentially be turned on in a future where they display at a position relative to their drawable counterpart.
drawableRuleset.Playfield.DisplayJudgements.Value = false;
(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
}

Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Mods/OsuModRepel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ internal class OsuModRepel : Mod, IUpdatableByPlayfield, IApplicableToDrawableRu

public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
// Hide judgment displays and follow points as they won't make any sense.
// Hide follow points as they won't make any sense.
// Judgements can potentially be turned on in a future where they display at a position relative to their drawable counterpart.
drawableRuleset.Playfield.DisplayJudgements.Value = false;
(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
}

Expand Down
23 changes: 16 additions & 7 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuJudgement.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Configuration;
Expand All @@ -14,10 +12,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
public partial class DrawableOsuJudgement : DrawableJudgement
{
internal SkinnableLighting Lighting { get; private set; }
internal SkinnableLighting Lighting { get; private set; } = null!;

[Resolved]
private OsuConfigManager config { get; set; }
private OsuConfigManager config { get; set; } = null!;

private bool positionTransferred;

[BackgroundDependencyLoader]
private void load()
Expand All @@ -39,10 +39,19 @@ protected override void PrepareForUse()
Lighting.ResetAnimation();
Lighting.SetColourFrom(JudgedObject, Result);

if (JudgedObject?.HitObject is OsuHitObject osuObject)
positionTransferred = false;
}

protected override void Update()
{
base.Update();

if (!positionTransferred && JudgedObject is DrawableOsuHitObject osuObject && JudgedObject.IsInUse)
{
Position = osuObject.StackedEndPosition;
Scale = new Vector2(osuObject.Scale);
Position = osuObject.ToSpaceOfOtherDrawable(osuObject.OriginPosition, Parent!);
Scale = new Vector2(osuObject.HitObject.Scale);

positionTransferred = true;
}
}

Expand Down
20 changes: 13 additions & 7 deletions osu.Game/Rulesets/Judgements/DrawableJudgement.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
Expand All @@ -24,13 +21,13 @@ public partial class DrawableJudgement : PoolableDrawable
{
private const float judgement_size = 128;

public JudgementResult Result { get; private set; }
public JudgementResult? Result { get; private set; }

public DrawableHitObject JudgedObject { get; private set; }
public DrawableHitObject? JudgedObject { get; private set; }

public override bool RemoveCompletedTransforms => false;

protected SkinnableDrawable JudgementBody { get; private set; }
protected SkinnableDrawable? JudgementBody { get; private set; }

private readonly Container aboveHitObjectsContent;

Expand Down Expand Up @@ -97,12 +94,19 @@ protected virtual void ApplyMissAnimations()
/// </summary>
/// <param name="result">The applicable judgement.</param>
/// <param name="judgedObject">The drawable object.</param>
public void Apply([NotNull] JudgementResult result, [CanBeNull] DrawableHitObject judgedObject)
public void Apply(JudgementResult result, DrawableHitObject? judgedObject)
{
Result = result;
JudgedObject = judgedObject;
}

protected override void FreeAfterUse()
{
base.FreeAfterUse();

JudgedObject = null;
}

protected override void PrepareForUse()
{
base.PrepareForUse();
Expand All @@ -121,6 +125,8 @@ private void runAnimation()
ApplyTransformsAt(double.MinValue, true);
ClearTransforms(true);

Debug.Assert(Result != null && JudgementBody != null);

LifetimeStart = Result.TimeAbsolute;

using (BeginAbsoluteSequence(Result.TimeAbsolute))
Expand Down

0 comments on commit 3c2599c

Please sign in to comment.