2023-05-13 02:07:25 +00: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.
|
2023-05-13 02:43:28 +00:00
|
|
|
|
2023-05-13 02:07:25 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Mod that colours <see cref="HitObject"/>s based on the musical division they are on
|
|
|
|
/// </summary>
|
2023-06-08 07:52:28 +00:00
|
|
|
public class OsuModSynesthesia : ModSynesthesia, IApplicableToBeatmap, IApplicableToDrawableHitObject
|
2023-05-13 02:07:25 +00:00
|
|
|
{
|
2023-05-13 05:13:39 +00:00
|
|
|
private readonly OsuColour colours = new OsuColour();
|
2023-05-13 02:07:25 +00:00
|
|
|
|
2023-05-13 05:13:39 +00:00
|
|
|
private IBeatmap? currentBeatmap { get; set; }
|
2023-05-13 02:07:25 +00:00
|
|
|
|
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
|
|
|
{
|
|
|
|
//Store a reference to the current beatmap to look up the beat divisor when notes are drawn
|
2023-05-13 05:13:39 +00:00
|
|
|
if (currentBeatmap != beatmap)
|
|
|
|
currentBeatmap = beatmap;
|
2023-05-13 02:07:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
|
|
|
|
{
|
2023-06-08 07:52:28 +00:00
|
|
|
if (currentBeatmap == null) return;
|
2023-05-13 02:07:25 +00:00
|
|
|
|
2023-05-30 08:43:08 +00:00
|
|
|
drawable.OnUpdate += _ =>
|
|
|
|
drawable.AccentColour.Value = BindableBeatDivisor.GetColourFor(
|
|
|
|
currentBeatmap.ControlPointInfo.GetClosestBeatDivisor(drawable.HitObject.StartTime),
|
|
|
|
colours);
|
2023-05-13 02:07:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|