-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47b8403
commit 6d46c9b
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
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.Sentakki.Objects.Drawables; | ||
using osu.Game.Screens.Edit; | ||
using osuTK.Graphics; | ||
|
||
namespace osu.Game.Rulesets.Sentakki.Mods; | ||
|
||
/// <summary> | ||
/// Mod that colours <see cref="HitObject"/>s based on the musical division they are on | ||
/// </summary> | ||
public class SentakkiModSynesthesia : 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 `LastTick`). | ||
// to work around this, look up the slider tail's parenting slider's end time instead to ensure proper snap. | ||
double snapTime = d.HitObject.StartTime + (d is DrawableSlideBody s ? s.HitObject.ShootDelay : 0); | ||
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; | ||
}; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters