2022-09-16 19:45:18 +08: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.
|
|
|
|
|
2022-10-18 19:39:40 +08:00
|
|
|
using System;
|
2022-08-19 01:00:54 +08:00
|
|
|
using System.Linq;
|
2022-10-18 19:39:40 +08:00
|
|
|
using osu.Framework.Graphics;
|
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.Rulesets.Mods;
|
2022-10-18 19:39:40 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2022-08-19 01:00:54 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2022-10-18 19:39:40 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2022-08-19 01:00:54 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2022-10-18 19:39:40 +08:00
|
|
|
public class OsuModFreezeFrame : Mod, IApplicableToDrawableHitObject, IApplicableToBeatmap
|
2022-08-19 01:00:54 +08:00
|
|
|
{
|
2022-09-16 19:45:18 +08:00
|
|
|
public override string Name => "Freeze Frame";
|
2022-09-08 06:05:48 +08:00
|
|
|
|
2022-09-19 01:35:12 +08:00
|
|
|
public override string Acronym => "FR";
|
2022-09-08 06:05:48 +08:00
|
|
|
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
2022-09-19 01:35:12 +08:00
|
|
|
public override LocalisableString Description => "Burn the notes into your memory.";
|
2022-09-08 06:05:48 +08:00
|
|
|
|
2022-10-18 19:39:40 +08:00
|
|
|
//Alters the transforms of the approach circles, breaking the effects of these mods.
|
2023-10-27 17:18:07 +08:00
|
|
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModApproachDifferent), typeof(OsuModTransform) }).ToArray();
|
2022-10-18 19:39:40 +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-10-18 19:39:40 +08:00
|
|
|
//mod breaks normal approach circle preempt
|
2022-10-25 12:26:32 +08:00
|
|
|
private double originalPreempt;
|
2022-09-08 17:14:56 +08:00
|
|
|
|
2022-10-12 18:42:26 +08:00
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
2022-08-19 01:00:54 +08:00
|
|
|
{
|
2022-10-25 12:26:32 +08:00
|
|
|
var firstHitObject = beatmap.HitObjects.OfType<OsuHitObject>().FirstOrDefault();
|
|
|
|
if (firstHitObject == null)
|
|
|
|
return;
|
|
|
|
|
2022-10-12 18:42:26 +08:00
|
|
|
double lastNewComboTime = 0;
|
2022-10-25 12:26:32 +08:00
|
|
|
|
|
|
|
originalPreempt = firstHitObject.TimePreempt;
|
2022-08-19 01:00:54 +08:00
|
|
|
|
2022-09-08 07:21:03 +08:00
|
|
|
foreach (var obj in beatmap.HitObjects.OfType<OsuHitObject>())
|
2022-08-19 01:00:54 +08:00
|
|
|
{
|
2022-10-12 18:42:26 +08:00
|
|
|
if (obj.NewCombo) { lastNewComboTime = obj.StartTime; }
|
2022-09-08 07:21:03 +08:00
|
|
|
|
2022-10-12 18:42:26 +08:00
|
|
|
applyFadeInAdjustment(obj);
|
2022-08-19 01:00:54 +08:00
|
|
|
}
|
|
|
|
|
2022-10-12 18:42:26 +08:00
|
|
|
void applyFadeInAdjustment(OsuHitObject osuObject)
|
2022-09-16 08:57:21 +08:00
|
|
|
{
|
2022-10-12 18:42:26 +08:00
|
|
|
osuObject.TimePreempt += osuObject.StartTime - lastNewComboTime;
|
2022-09-16 08:57:21 +08:00
|
|
|
|
2022-10-12 18:42:26 +08:00
|
|
|
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
|
|
|
|
{
|
|
|
|
switch (nested)
|
|
|
|
{
|
2022-11-14 23:18:36 +08:00
|
|
|
//Freezing the SliderTicks doesnt play well with snaking sliders
|
|
|
|
case SliderTick:
|
2022-10-12 18:42:26 +08:00
|
|
|
//SliderRepeat wont layer correctly if preempt is changed.
|
|
|
|
case SliderRepeat:
|
2022-10-13 01:45:08 +08:00
|
|
|
break;
|
2022-10-12 18:42:26 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
applyFadeInAdjustment(nested);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-09-16 08:57:21 +08:00
|
|
|
}
|
|
|
|
}
|
2022-10-18 19:39:40 +08:00
|
|
|
|
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject drawableObject)
|
|
|
|
{
|
|
|
|
drawableObject.ApplyCustomUpdateState += (drawableHitObject, _) =>
|
|
|
|
{
|
|
|
|
if (drawableHitObject is not DrawableHitCircle drawableHitCircle) return;
|
|
|
|
|
|
|
|
var hitCircle = drawableHitCircle.HitObject;
|
|
|
|
var approachCircle = drawableHitCircle.ApproachCircle;
|
|
|
|
|
2022-10-25 12:27:26 +08:00
|
|
|
// Reapply scale, ensuring the AR isn't changed due to the new preempt.
|
2022-10-25 12:26:32 +08:00
|
|
|
approachCircle.ClearTransforms(targetMember: nameof(approachCircle.Scale));
|
|
|
|
approachCircle.ScaleTo(4 * (float)(hitCircle.TimePreempt / originalPreempt));
|
2022-10-18 19:39:40 +08:00
|
|
|
|
2022-10-25 12:26:32 +08:00
|
|
|
using (drawableHitCircle.ApproachCircle.BeginAbsoluteSequence(hitCircle.StartTime - hitCircle.TimePreempt))
|
|
|
|
approachCircle.ScaleTo(1, hitCircle.TimePreempt).Then().Expire();
|
2022-10-18 19:39:40 +08:00
|
|
|
};
|
|
|
|
}
|
2022-08-19 01:00:54 +08:00
|
|
|
}
|
|
|
|
}
|