1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 14:07:25 +08:00

Use hopefully safer implementation of anchoring judgements to objects

This commit is contained in:
Bartłomiej Dach 2024-05-29 11:11:43 +02:00
parent 22a2adb5e6
commit a6c776dac8
No known key found for this signature in database
3 changed files with 17 additions and 19 deletions

View File

@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private partial class TestDrawableOsuJudgement : DrawableOsuJudgement
{
public new SkinnableSprite Lighting => base.Lighting;
public new SkinnableDrawable JudgementBody => base.JudgementBody;
public new SkinnableDrawable? JudgementBody => base.JudgementBody;
}
}
}

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
@ -14,10 +12,10 @@ 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!;
[BackgroundDependencyLoader]
private void load()
@ -38,19 +36,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Lighting.ResetAnimation();
Lighting.SetColourFrom(JudgedObject, Result);
if (JudgedObject is DrawableOsuHitObject osuObject)
{
Position = osuObject.ToSpaceOfOtherDrawable(osuObject.OriginPosition, Parent!);
Scale = new Vector2(osuObject.HitObject.Scale);
}
}
protected override void Update()
{
base.Update();
if (JudgedObject is DrawableOsuHitObject osuObject && Parent != null && osuObject.HitObject != null)
if (JudgedObject is DrawableOsuHitObject osuObject && JudgedObject.IsInUse)
{
Position = osuObject.ToSpaceOfOtherDrawable(osuObject.OriginPosition, Parent!);
Scale = new Vector2(osuObject.HitObject.Scale);

View File

@ -1,11 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
@ -24,13 +21,13 @@ namespace osu.Game.Rulesets.Judgements
{
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;
@ -97,12 +94,19 @@ namespace osu.Game.Rulesets.Judgements
/// </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();
@ -121,6 +125,8 @@ namespace osu.Game.Rulesets.Judgements
ApplyTransformsAt(double.MinValue, true);
ClearTransforms(true);
Debug.Assert(Result != null && JudgementBody != null);
LifetimeStart = Result.TimeAbsolute;
using (BeginAbsoluteSequence(Result.TimeAbsolute))