1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 14:47:24 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuModFreezeFrame.cs

103 lines
3.6 KiB
C#
Raw Normal View History

// 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.
2022-09-08 06:05:48 +08:00
using System;
2022-08-19 01:00:54 +08:00
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
2022-09-08 07:21:03 +08:00
using osu.Framework.Localisation;
2022-08-19 01:00:54 +08:00
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
2022-09-08 06:05:48 +08:00
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.UI;
2022-08-19 01:00:54 +08:00
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModFreezeFrame : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset<OsuHitObject>
2022-08-19 01:00:54 +08:00
{
public override string Name => "Freeze Frame";
2022-09-08 06:05:48 +08:00
public override string Acronym => "FF";
public override double ScoreMultiplier => 1;
2022-09-08 07:21:03 +08:00
public override LocalisableString Description => "Burn the notes into your memory";
2022-09-08 06:05:48 +08:00
2022-08-19 01:00:54 +08:00
public override ModType Type => ModType.Fun;
2022-09-08 06:05:48 +08:00
2022-09-08 21:17:22 +08:00
public override IconUsage? Icon => FontAwesome.Solid.Camera;
2022-09-08 06:05:48 +08:00
[SettingSource("Measure", "How often the hit-circles should be Grouped to freeze")]
public Bindable<BeatDivisor> Divisor { get; } = new Bindable<BeatDivisor>(BeatDivisor.Single_Measure);
2022-08-19 01:00:54 +08:00
2022-09-08 17:14:56 +08:00
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
(drawableRuleset.Playfield as OsuPlayfield)?.FollowPoints.Hide();
}
2022-08-19 01:00:54 +08:00
public override void ApplyToBeatmap(IBeatmap beatmap)
{
base.ApplyToBeatmap(beatmap);
2022-09-08 07:21:03 +08:00
foreach (var obj in beatmap.HitObjects.OfType<OsuHitObject>())
2022-08-19 01:00:54 +08:00
{
// The +1s below are added due to First HitCircle in each measure not appearing appropriately without them.
var lastTimingPoint = beatmap.ControlPointInfo.TimingPointAt(obj.StartTime + 1);
double controlPointDifference = obj.StartTime + 1 - lastTimingPoint.Time;
double remainder = controlPointDifference % (lastTimingPoint.BeatLength * getMeasure(Divisor.Value)) - 1;
double finalPreempt = obj.TimePreempt + remainder;
2022-09-08 17:14:56 +08:00
applyFadeInAdjustment(obj);
2022-09-08 07:21:03 +08:00
2022-09-08 17:14:56 +08:00
void applyFadeInAdjustment(OsuHitObject osuObject)
{
osuObject.TimePreempt = finalPreempt;
2022-09-08 17:14:56 +08:00
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
applyFadeInAdjustment(nested);
}
2022-08-19 01:00:54 +08:00
}
}
2022-09-16 08:57:21 +08:00
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state) { }
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state) { }
private float getMeasure(BeatDivisor divisor)
2022-08-19 01:00:54 +08:00
{
2022-09-16 08:57:21 +08:00
switch (divisor)
{
case BeatDivisor.Quarter_Measure:
return 0.25f;
case BeatDivisor.Half_Measure:
return 0.5f;
2022-08-19 01:00:54 +08:00
case BeatDivisor.Single_Measure:
2022-09-16 08:57:21 +08:00
return 1;
case BeatDivisor.Double_Measure:
return 2;
case BeatDivisor.Quadruple_Measure:
return 4;
default:
throw new ArgumentOutOfRangeException(nameof(divisor), divisor, null);
}
}
2022-09-08 06:05:48 +08:00
//Todo: find better way to represent these Enums to the player
2022-09-16 08:57:21 +08:00
public enum BeatDivisor
2022-08-19 01:00:54 +08:00
{
2022-09-16 08:57:21 +08:00
Quarter_Measure,
Half_Measure,
Single_Measure,
2022-09-16 08:57:21 +08:00
Double_Measure,
Quadruple_Measure
2022-09-08 06:05:48 +08:00
}
2022-08-19 01:00:54 +08:00
}
}
2022-09-08 06:05:48 +08:00