mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 12:00:22 +08:00
77ef450883
Mod that colours HitObjects based on the musical division they are on, now in osu!catch https://github.com/user-attachments/assets/2dda493d-dc8b-4ea4-ba47-7d04e2062b42 For now *bananas are not coloured by the mod and keep their yellow colour*, since I think its better for the sake of readabilty (also it just looks kinda ugly?). Do leave your thoughts on that. Droplets are always coloured to `LightGreen`, setting their colour to closest timeline ticks is wrong and looks incorrect since droplets aren't generated with them in mind. --------- Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com> Co-authored-by: Shavix <54279284+Shavixinio@users.noreply.github.com>
61 lines
2.1 KiB
C#
61 lines
2.1 KiB
C#
// 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.Beatmaps;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
using osu.Game.Rulesets.Mods;
|
|
using osu.Game.Rulesets.Objects;
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
using osu.Game.Screens.Edit;
|
|
using osuTK.Graphics;
|
|
|
|
namespace osu.Game.Rulesets.Catch.Mods
|
|
{
|
|
/// <summary>
|
|
/// Mod that colours <see cref="HitObject"/>s based on the musical division they are on
|
|
/// </summary>
|
|
public class CatchModSynesthesia : ModSynesthesia, IApplicableToBeatmap, IApplicableToDrawableHitObject
|
|
{
|
|
private readonly OsuColour colours = new OsuColour();
|
|
|
|
private IBeatmap? currentBeatmap { get; set; }
|
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
|
{
|
|
//Store a reference to the current beatmap to look up the beat divisor when notes are drawn
|
|
if (currentBeatmap != beatmap)
|
|
currentBeatmap = beatmap;
|
|
}
|
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject d)
|
|
{
|
|
if (currentBeatmap == null) return;
|
|
|
|
Color4? timingBasedColour = null;
|
|
|
|
d.HitObjectApplied += _ =>
|
|
{
|
|
// Block bananas from getting coloured.
|
|
if (d.HitObject is not Banana)
|
|
{
|
|
timingBasedColour = BindableBeatDivisor.GetColourFor(currentBeatmap.ControlPointInfo.GetClosestBeatDivisor(d.HitObject.StartTime), colours);
|
|
}
|
|
|
|
// Colour droplets into a solid colour, as droplets aren't generated snapped to timeline ticks.
|
|
if (d.HitObject is Droplet)
|
|
{
|
|
timingBasedColour = Color4.LightGreen;
|
|
}
|
|
};
|
|
|
|
// Need to set this every update to ensure it doesn't get overwritten by DrawableHitObject.OnApply() -> UpdateComboColour().
|
|
d.OnUpdate += _ =>
|
|
{
|
|
if (timingBasedColour != null)
|
|
d.AccentColour.Value = timingBasedColour.Value;
|
|
};
|
|
}
|
|
}
|
|
}
|