From 03d4146825ceae9f028ea5f86d67b302dad8f512 Mon Sep 17 00:00:00 2001 From: Nora Date: Sun, 28 Jul 2024 22:07:04 -0400 Subject: [PATCH] update drawable tau judgement code --- .../TestSceneDrawableJudgement.cs | 1 - .../Objects/Drawables/DrawableTauJudgement.cs | 37 +++++++++++++------ .../Drawables/Pieces/SkinnableLighting.cs | 14 +++---- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/osu.Game.Rulesets.Tau.Tests/TestSceneDrawableJudgement.cs b/osu.Game.Rulesets.Tau.Tests/TestSceneDrawableJudgement.cs index bbef36e6..791912da 100644 --- a/osu.Game.Rulesets.Tau.Tests/TestSceneDrawableJudgement.cs +++ b/osu.Game.Rulesets.Tau.Tests/TestSceneDrawableJudgement.cs @@ -88,7 +88,6 @@ private void showResult(HitResult result) ((Container)pool.Parent).Clear(false); - var container = new Container { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableTauJudgement.cs b/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableTauJudgement.cs index 71c30ae9..4581660e 100644 --- a/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableTauJudgement.cs +++ b/osu.Game.Rulesets.Tau/Objects/Drawables/DrawableTauJudgement.cs @@ -1,6 +1,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Tau.Configuration; using osu.Game.Rulesets.Tau.Objects.Drawables.Pieces; @@ -11,13 +12,15 @@ namespace osu.Game.Rulesets.Tau.Objects.Drawables { public partial class DrawableTauJudgement : DrawableJudgement { + internal Colour4 AccentColour { get; private set; } + protected SkinnableLighting Lighting { get; private set; } [Resolved] private TauRulesetConfigManager config { get; set; } - [Resolved(canBeNull: true)] - private TauCachedProperties properties { get; set; } + private float distance = 0.6f; + private float angle; public DrawableTauJudgement() { @@ -36,14 +39,23 @@ public DrawableTauJudgement() }); } - protected override void PrepareForUse() + [BackgroundDependencyLoader(true)] + private void load(TauCachedProperties properties) { - base.PrepareForUse(); + if (properties != null && properties.InverseModEnabled.Value) + distance = 0.4f; + } - Lighting.ResetAnimation(); - Lighting.SetColourFrom(JudgedObject, Result); + public override void Apply(JudgementResult result, DrawableHitObject judgedObject) + { + base.Apply(result, judgedObject); + + if (judgedObject is not { } hitObj) + return; - var angle = JudgedObject switch + AccentColour = hitObj.AccentColour.Value; + + angle = hitObj switch { DrawableAngledTauHitObject { HitObject: IHasOffsetAngle ang } => ang.GetAbsoluteAngle(), // TODO: This should NOT be here. @@ -53,11 +65,14 @@ protected override void PrepareForUse() DrawableBeat b => b.HitObject.Angle, _ => 0f }; + } - var distance = 0.6f; + protected override void PrepareForUse() + { + base.PrepareForUse(); - if (properties != null && properties.InverseModEnabled.Value) - distance = 0.4f; + Lighting.ResetAnimation(); + Lighting.SetColourFrom(this, Result); Position = Extensions.FromPolarCoordinates(distance, angle); Rotation = angle; @@ -65,7 +80,7 @@ protected override void PrepareForUse() protected override void ApplyHitAnimations() { - var hitLightingEnabled = config.Get(TauRulesetSettings.HitLighting); + bool hitLightingEnabled = config.Get(TauRulesetSettings.HitLighting); Lighting.Alpha = 0; diff --git a/osu.Game.Rulesets.Tau/Objects/Drawables/Pieces/SkinnableLighting.cs b/osu.Game.Rulesets.Tau/Objects/Drawables/Pieces/SkinnableLighting.cs index 97122446..58e22455 100644 --- a/osu.Game.Rulesets.Tau/Objects/Drawables/Pieces/SkinnableLighting.cs +++ b/osu.Game.Rulesets.Tau/Objects/Drawables/Pieces/SkinnableLighting.cs @@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Tau.Objects.Drawables.Pieces { public partial class SkinnableLighting : SkinnableSprite { - private DrawableHitObject targetObject; + private DrawableTauJudgement targetJudgement; private JudgementResult targetResult; public SkinnableLighting() @@ -24,11 +24,11 @@ protected override void SkinChanged(ISkinSource skin) /// /// Updates the lighting colour from a given hitobject and result. /// - /// The that's been judged. - /// The that was judged with. - public void SetColourFrom(DrawableHitObject targetObject, JudgementResult targetResult) + /// The that's been judged. + /// The that was judged with. + public void SetColourFrom(DrawableTauJudgement targetJudgement, JudgementResult targetResult) { - this.targetObject = targetObject; + this.targetJudgement = targetJudgement; this.targetResult = targetResult; updateColour(); @@ -36,10 +36,10 @@ public void SetColourFrom(DrawableHitObject targetObject, JudgementResult target private void updateColour() { - if (targetObject == null || targetResult == null) + if (targetJudgement == null || targetResult == null) Colour = Color4.White; else - Colour = targetResult.IsHit ? targetObject.AccentColour.Value : Color4.Transparent; + Colour = targetResult.IsHit ? targetJudgement.AccentColour : Color4.Transparent; } } }