2021-04-14 07:52:29 +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.
|
|
|
|
|
2021-04-20 09:36:11 +00:00
|
|
|
using System.Collections.Generic;
|
2021-04-14 07:52:29 +00:00
|
|
|
using osu.Framework.Bindables;
|
2021-04-17 00:32:47 +00:00
|
|
|
using osu.Framework.Extensions;
|
2021-04-15 05:40:03 +00:00
|
|
|
using osu.Framework.Graphics;
|
2021-04-14 07:52:29 +00:00
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2021-04-20 09:36:11 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2021-04-15 04:06:52 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2021-04-20 09:36:11 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2021-04-15 04:06:52 +00:00
|
|
|
using osu.Game.Rulesets.Osu.UI;
|
2021-04-14 07:52:29 +00:00
|
|
|
using osu.Game.Rulesets.UI;
|
2021-04-15 04:06:52 +00:00
|
|
|
using osuTK;
|
2021-04-14 07:52:29 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2021-04-20 09:36:11 +00:00
|
|
|
public class OsuModBarrelRoll : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<OsuHitObject>, IApplicableToDrawableHitObjects
|
2021-04-14 07:52:29 +00:00
|
|
|
{
|
2021-04-20 09:36:11 +00:00
|
|
|
private float currentRotation;
|
|
|
|
|
2021-04-15 04:15:52 +00:00
|
|
|
[SettingSource("Roll speed", "Rotations per minute")]
|
|
|
|
public BindableNumber<double> SpinSpeed { get; } = new BindableDouble(0.5)
|
2021-04-14 07:52:29 +00:00
|
|
|
{
|
2021-04-15 04:15:52 +00:00
|
|
|
MinValue = 0.02,
|
2021-04-20 09:22:58 +00:00
|
|
|
MaxValue = 12,
|
2021-04-15 04:15:52 +00:00
|
|
|
Precision = 0.01,
|
2021-04-14 07:52:29 +00:00
|
|
|
};
|
|
|
|
|
2021-04-15 05:40:03 +00:00
|
|
|
[SettingSource("Direction", "The direction of rotation")]
|
|
|
|
public Bindable<RotationDirection> Direction { get; } = new Bindable<RotationDirection>(RotationDirection.Clockwise);
|
|
|
|
|
2021-04-14 07:52:29 +00:00
|
|
|
public override string Name => "Barrel Roll";
|
|
|
|
public override string Acronym => "BR";
|
2021-04-15 05:37:47 +00:00
|
|
|
public override string Description => "The whole playfield is on a wheel!";
|
2021-04-14 07:52:29 +00:00
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
2021-04-17 03:28:07 +00:00
|
|
|
public override string SettingDescription => $"{SpinSpeed.Value} rpm {Direction.Value.GetDescription().ToLowerInvariant()}";
|
2021-04-17 00:32:47 +00:00
|
|
|
|
2021-04-14 07:52:29 +00:00
|
|
|
public void Update(Playfield playfield)
|
|
|
|
{
|
2021-04-20 09:36:11 +00:00
|
|
|
playfield.Rotation = currentRotation = (Direction.Value == RotationDirection.Counterclockwise ? -1 : 1) * 360 * (float)(playfield.Time.Current / 60000 * SpinSpeed.Value);
|
2021-04-14 07:52:29 +00:00
|
|
|
}
|
2021-04-15 04:06:52 +00:00
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
|
|
|
{
|
|
|
|
// scale the playfield to allow all hitobjects to stay within the visible region.
|
|
|
|
drawableRuleset.Playfield.Scale = new Vector2(OsuPlayfield.BASE_SIZE.Y / OsuPlayfield.BASE_SIZE.X);
|
|
|
|
}
|
2021-04-20 09:36:11 +00:00
|
|
|
|
|
|
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
{
|
|
|
|
foreach (var d in drawables)
|
|
|
|
{
|
|
|
|
d.OnUpdate += _ =>
|
|
|
|
{
|
|
|
|
switch (d)
|
|
|
|
{
|
|
|
|
case DrawableHitCircle circle:
|
|
|
|
circle.CirclePiece.Rotation = -currentRotation;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 07:52:29 +00:00
|
|
|
}
|
|
|
|
}
|