2019-01-24 08:43:03 +00: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-01-09 04:41:57 +00:00
|
|
|
|
using System;
|
2020-07-14 13:06:15 +00:00
|
|
|
|
using System.Linq;
|
2024-02-15 11:07:55 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-08-10 20:09:11 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-02-24 06:05:12 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2022-12-19 23:31:28 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2024-03-07 12:10:11 +00:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2024-02-07 15:20:32 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2024-02-15 11:07:55 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Skinning;
|
2024-02-15 13:05:25 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2024-02-06 14:47:20 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2024-02-15 13:05:25 +00:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Screens.Play;
|
2024-02-15 11:07:55 +00:00
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-01-09 04:41:57 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Mania.Mods
|
|
|
|
|
{
|
2024-02-15 13:05:25 +00:00
|
|
|
|
public partial class ManiaModHidden : ManiaModWithPlayfieldCover, IApplicableToPlayer, IUpdatableByPlayfield
|
2018-01-09 04:41:57 +00:00
|
|
|
|
{
|
2024-02-06 14:47:20 +00:00
|
|
|
|
/// <summary>
|
2024-02-06 15:25:22 +00:00
|
|
|
|
/// osu!stable is referenced to 768px.
|
2024-02-06 14:47:20 +00:00
|
|
|
|
/// </summary>
|
2024-02-07 15:20:32 +00:00
|
|
|
|
private const float reference_playfield_height = 768;
|
2020-07-14 13:06:15 +00:00
|
|
|
|
|
2024-02-15 12:24:00 +00:00
|
|
|
|
public const float MIN_COVERAGE = 160f;
|
|
|
|
|
public const float MAX_COVERAGE = 400f;
|
|
|
|
|
private const float coverage_increase_per_combo = 0.5f;
|
2022-12-20 18:33:33 +00:00
|
|
|
|
|
2024-02-06 14:47:20 +00:00
|
|
|
|
public override LocalisableString Description => @"Keys fade out before you hit them!";
|
|
|
|
|
public override double ScoreMultiplier => 1;
|
2024-02-06 15:15:06 +00:00
|
|
|
|
|
|
|
|
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(ManiaModFadeIn),
|
|
|
|
|
typeof(ManiaModCover)
|
|
|
|
|
}).ToArray();
|
2021-02-24 06:05:12 +00:00
|
|
|
|
|
2024-02-15 12:24:00 +00:00
|
|
|
|
public override BindableNumber<float> Coverage { get; } = new BindableFloat(MIN_COVERAGE);
|
2021-02-24 06:05:12 +00:00
|
|
|
|
protected override CoverExpandDirection ExpandDirection => CoverExpandDirection.AgainstScroll;
|
2024-02-06 14:47:20 +00:00
|
|
|
|
|
2024-02-15 13:05:25 +00:00
|
|
|
|
private readonly IBindable<bool> isBreakTime = new Bindable<bool>();
|
2024-02-06 14:47:20 +00:00
|
|
|
|
private readonly BindableInt combo = new BindableInt();
|
|
|
|
|
|
|
|
|
|
public override void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyToScoreProcessor(scoreProcessor);
|
|
|
|
|
|
|
|
|
|
combo.UnbindAll();
|
|
|
|
|
combo.BindTo(scoreProcessor.Combo);
|
2024-02-15 13:05:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ApplyToPlayer(Player player)
|
|
|
|
|
{
|
|
|
|
|
isBreakTime.UnbindAll();
|
|
|
|
|
isBreakTime.BindTo(player.IsBreakTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(Playfield playfield)
|
|
|
|
|
{
|
|
|
|
|
Coverage.Value = isBreakTime.Value
|
|
|
|
|
? 0
|
|
|
|
|
: Math.Min(MAX_COVERAGE, MIN_COVERAGE + combo.Value * coverage_increase_per_combo) / reference_playfield_height;
|
2024-02-06 14:47:20 +00:00
|
|
|
|
}
|
2024-02-07 15:20:32 +00:00
|
|
|
|
|
|
|
|
|
protected override PlayfieldCoveringWrapper CreateCover(Drawable content) => new LegacyPlayfieldCover(content);
|
|
|
|
|
|
|
|
|
|
private partial class LegacyPlayfieldCover : PlayfieldCoveringWrapper
|
|
|
|
|
{
|
2024-02-15 11:07:55 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private ISkinSource skin { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
private IBindable<float>? hitPosition;
|
|
|
|
|
|
2024-02-07 15:20:32 +00:00
|
|
|
|
public LegacyPlayfieldCover(Drawable content)
|
|
|
|
|
: base(content)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-15 11:07:55 +00:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
skin.SourceChanged += onSkinChanged;
|
|
|
|
|
onSkinChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onSkinChanged()
|
|
|
|
|
{
|
|
|
|
|
hitPosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.HitPosition);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-07 15:20:32 +00:00
|
|
|
|
protected override float GetHeight(float coverage)
|
|
|
|
|
{
|
2024-02-15 11:07:55 +00:00
|
|
|
|
// In osu!stable, the cover is applied in absolute (x768) coordinates from the hit position.
|
|
|
|
|
float availablePlayfieldHeight = Math.Abs(reference_playfield_height - (hitPosition?.Value ?? Stage.HIT_TARGET_POSITION));
|
|
|
|
|
|
|
|
|
|
if (availablePlayfieldHeight == 0)
|
2024-02-07 15:20:32 +00:00
|
|
|
|
return base.GetHeight(coverage);
|
|
|
|
|
|
2024-02-15 11:07:55 +00:00
|
|
|
|
return base.GetHeight(coverage) * reference_playfield_height / availablePlayfieldHeight;
|
2024-02-07 15:20:32 +00:00
|
|
|
|
}
|
2024-03-07 12:10:11 +00:00
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
|
|
if (skin.IsNotNull())
|
|
|
|
|
skin.SourceChanged -= onSkinChanged;
|
|
|
|
|
}
|
2024-02-07 15:20:32 +00:00
|
|
|
|
}
|
2018-01-09 04:41:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|