osu/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs

53 lines
1.9 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.
2018-04-13 09:19:50 +00:00
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
2018-04-13 09:19:50 +00:00
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
2020-07-16 08:26:18 +00:00
using osuTK;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Mania.Mods
{
public class ManiaModHidden : ModHidden, IApplicableToDrawableRuleset<ManiaHitObject>
2018-04-13 09:19:50 +00:00
{
public override string Description => @"Keys fade out before you hit them!";
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight<ManiaHitObject>) };
public virtual void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawableRuleset)
{
ManiaPlayfield maniaPlayfield = (ManiaPlayfield)drawableRuleset.Playfield;
foreach (Column column in maniaPlayfield.Stages.SelectMany(stage => stage.Columns))
{
HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer;
Container hocParent = (Container)hoc.Parent;
hocParent.Remove(hoc);
2020-07-16 12:17:51 +00:00
hocParent.Add(CreateCover(hoc).With(c =>
{
2020-07-16 08:26:18 +00:00
c.RelativeSizeAxes = Axes.Both;
c.Coverage = 0.5f;
}));
}
}
2020-07-16 12:17:51 +00:00
protected virtual PlayfieldCoveringContainer CreateCover(Drawable content) => new ModHiddenCoveringContainer(content);
2020-07-16 08:26:18 +00:00
private class ModHiddenCoveringContainer : PlayfieldCoveringContainer
{
2020-07-16 12:17:51 +00:00
public ModHiddenCoveringContainer(Drawable content)
: base(content)
2020-07-16 08:26:18 +00:00
{
2020-07-16 08:47:00 +00:00
// This cover extends outwards from the hit position.
2020-07-16 08:26:18 +00:00
Cover.Scale = new Vector2(1, -1);
}
}
2018-04-13 09:19:50 +00:00
}
}