mirror of
https://github.com/ppy/osu
synced 2025-01-19 04:20:59 +00:00
Merge branch 'master' into fix-distance-snap-grid-centering
This commit is contained in:
commit
ecc5915ab3
55
osu.Game.Rulesets.Osu/Mods/OsuModSynesthesia.cs
Normal file
55
osu.Game.Rulesets.Osu/Mods/OsuModSynesthesia.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// 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.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Screens.Edit;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Mod that colours <see cref="HitObject"/>s based on the musical division they are on
|
||||||
|
/// </summary>
|
||||||
|
public class OsuModSynesthesia : 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 += _ =>
|
||||||
|
{
|
||||||
|
// slider tails are a painful edge case, as their start time is offset 36ms back (see `LegacyLastTick`).
|
||||||
|
// to work around this, look up the slider tail's parenting slider's end time instead to ensure proper snap.
|
||||||
|
double snapTime = d is DrawableSliderTail tail
|
||||||
|
? tail.Slider.GetEndTime()
|
||||||
|
: d.HitObject.StartTime;
|
||||||
|
timingBasedColour = BindableBeatDivisor.GetColourFor(currentBeatmap.ControlPointInfo.GetClosestBeatDivisor(snapTime), colours);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -204,7 +204,8 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
new MultiMod(new OsuModMagnetised(), new OsuModRepel()),
|
new MultiMod(new OsuModMagnetised(), new OsuModRepel()),
|
||||||
new ModAdaptiveSpeed(),
|
new ModAdaptiveSpeed(),
|
||||||
new OsuModFreezeFrame(),
|
new OsuModFreezeFrame(),
|
||||||
new OsuModBubbles()
|
new OsuModBubbles(),
|
||||||
|
new OsuModSynesthesia()
|
||||||
};
|
};
|
||||||
|
|
||||||
case ModType.System:
|
case ModType.System:
|
||||||
|
19
osu.Game/Rulesets/Mods/ModSynesthesia.cs
Normal file
19
osu.Game/Rulesets/Mods/ModSynesthesia.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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.Framework.Localisation;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Mod that colours hitobjects based on the musical division they are on
|
||||||
|
/// </summary>
|
||||||
|
public class ModSynesthesia : Mod
|
||||||
|
{
|
||||||
|
public override string Name => "Synesthesia";
|
||||||
|
public override string Acronym => "SY";
|
||||||
|
public override LocalisableString Description => "Colours hit objects based on the rhythm.";
|
||||||
|
public override double ScoreMultiplier => 1;
|
||||||
|
public override ModType Type => ModType.Fun;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user