2020-11-05 13:49:15 +08:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
{
|
2023-02-17 17:22:30 +08:00
|
|
|
internal partial class SkinnableLighting : SkinnableSprite
|
2020-11-05 13:49:15 +08:00
|
|
|
{
|
2024-07-18 18:07:02 +08:00
|
|
|
private DrawableOsuJudgement? targetJudgement;
|
|
|
|
private JudgementResult? targetResult;
|
2020-11-05 13:49:15 +08:00
|
|
|
|
|
|
|
public SkinnableLighting()
|
|
|
|
: base("lighting")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:50:42 +08:00
|
|
|
protected override void SkinChanged(ISkinSource skin)
|
2020-11-05 13:49:15 +08:00
|
|
|
{
|
2021-05-27 13:50:42 +08:00
|
|
|
base.SkinChanged(skin);
|
2020-11-05 13:49:15 +08:00
|
|
|
updateColour();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Updates the lighting colour from a given hitobject and result.
|
|
|
|
/// </summary>
|
2024-07-18 18:07:02 +08:00
|
|
|
/// <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(DrawableOsuJudgement targetJudgement, JudgementResult? targetResult)
|
2020-11-05 13:49:15 +08:00
|
|
|
{
|
2024-07-18 18:07:02 +08:00
|
|
|
this.targetJudgement = targetJudgement;
|
2020-11-05 13:49:15 +08:00
|
|
|
this.targetResult = targetResult;
|
|
|
|
|
|
|
|
updateColour();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateColour()
|
|
|
|
{
|
2024-07-18 18:07:02 +08:00
|
|
|
if (targetJudgement == null || targetResult == null)
|
2020-11-05 13:49:15 +08:00
|
|
|
Colour = Color4.White;
|
|
|
|
else
|
2024-07-18 18:07:02 +08:00
|
|
|
Colour = targetResult.IsHit ? targetJudgement.AccentColour : Color4.Transparent;
|
2020-11-05 13:49:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|