Skip to content

Commit

Permalink
update drawable tau judgement code
Browse files Browse the repository at this point in the history
  • Loading branch information
naoei committed Jul 29, 2024
1 parent f3aff25 commit 03d4146
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Tau.Tests/TestSceneDrawableJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ private void showResult(HitResult result)

((Container)pool.Parent).Clear(false);


var container = new Container
{
RelativeSizeAxes = Axes.Both,
Expand Down
37 changes: 26 additions & 11 deletions osu.Game.Rulesets.Tau/Objects/Drawables/DrawableTauJudgement.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()
{
Expand All @@ -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<Slider> { HitObject: IHasOffsetAngle ang } => ang.GetAbsoluteAngle(),
// TODO: This should NOT be here.
Expand All @@ -53,19 +65,22 @@ 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;
}

protected override void ApplyHitAnimations()
{
var hitLightingEnabled = config.Get<bool>(TauRulesetSettings.HitLighting);
bool hitLightingEnabled = config.Get<bool>(TauRulesetSettings.HitLighting);

Lighting.Alpha = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -24,22 +24,22 @@ protected override void SkinChanged(ISkinSource skin)
/// <summary>
/// Updates the lighting colour from a given hitobject and result.
/// </summary>
/// <param name="targetObject">The <see cref="DrawableHitObject"/> that's been judged.</param>
/// <param name="targetResult">The <see cref="JudgementResult"/> that <paramref name="targetObject"/> was judged with.</param>
public void SetColourFrom(DrawableHitObject targetObject, JudgementResult targetResult)
/// <param name="targetJudgement">The <see cref="DrawableHitObject"/> that's been judged.</param>
/// <param name="targetResult">The <see cref="JudgementResult"/> that <paramref name="targetJudgement"/> was judged with.</param>
public void SetColourFrom(DrawableTauJudgement targetJudgement, JudgementResult targetResult)
{
this.targetObject = targetObject;
this.targetJudgement = targetJudgement;
this.targetResult = targetResult;

updateColour();
}

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;
}
}
}

0 comments on commit 03d4146

Please sign in to comment.