2021-04-30 06:59:59 +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.
|
|
|
|
|
|
2021-04-30 07:49:19 +08:00
|
|
|
|
using System;
|
2021-04-30 06:59:59 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
2022-08-11 03:54:48 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-04-30 06:59:59 +08:00
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
|
{
|
|
|
|
|
public abstract class ModBarrelRoll<TObject> : Mod, IUpdatableByPlayfield, IApplicableToDrawableRuleset<TObject>
|
|
|
|
|
where TObject : HitObject
|
|
|
|
|
{
|
2021-04-30 10:25:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The current angle of rotation being applied by this mod.
|
|
|
|
|
/// Generally should be used to apply inverse rotation to elements which should not be rotated.
|
|
|
|
|
/// </summary>
|
2021-04-30 06:59:59 +08:00
|
|
|
|
protected float CurrentRotation { get; private set; }
|
|
|
|
|
|
|
|
|
|
[SettingSource("Roll speed", "Rotations per minute")]
|
|
|
|
|
public BindableNumber<double> SpinSpeed { get; } = new BindableDouble(0.5)
|
|
|
|
|
{
|
|
|
|
|
MinValue = 0.02,
|
|
|
|
|
MaxValue = 12,
|
|
|
|
|
Precision = 0.01,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[SettingSource("Direction", "The direction of rotation")]
|
2021-07-05 23:52:39 +08:00
|
|
|
|
public Bindable<RotationDirection> Direction { get; } = new Bindable<RotationDirection>();
|
2021-04-30 06:59:59 +08:00
|
|
|
|
|
|
|
|
|
public override string Name => "Barrel Roll";
|
|
|
|
|
public override string Acronym => "BR";
|
2022-08-11 03:54:48 +08:00
|
|
|
|
public override LocalisableString Description => "The whole playfield is on a wheel!";
|
2021-04-30 06:59:59 +08:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
|
2022-03-29 21:11:44 +08:00
|
|
|
|
public override string SettingDescription => $"{SpinSpeed.Value:N2} rpm {Direction.Value.GetDescription().ToLowerInvariant()}";
|
2021-04-30 06:59:59 +08:00
|
|
|
|
|
2024-09-11 21:54:30 +08:00
|
|
|
|
private PlayfieldAdjustmentContainer playfieldAdjustmentContainer = null!;
|
|
|
|
|
|
2024-10-18 02:38:13 +08:00
|
|
|
|
public virtual void Update(Playfield playfield)
|
2021-04-30 06:59:59 +08:00
|
|
|
|
{
|
2024-09-11 21:54:30 +08:00
|
|
|
|
playfieldAdjustmentContainer.Rotation = CurrentRotation = (Direction.Value == RotationDirection.Counterclockwise ? -1 : 1) * 360 * (float)(playfield.Time.Current / 60000 * SpinSpeed.Value);
|
2021-04-30 06:59:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ApplyToDrawableRuleset(DrawableRuleset<TObject> drawableRuleset)
|
|
|
|
|
{
|
2021-04-30 07:49:19 +08:00
|
|
|
|
// scale the playfield to allow all hitobjects to stay within the visible region.
|
|
|
|
|
|
|
|
|
|
var playfieldSize = drawableRuleset.Playfield.DrawSize;
|
2021-10-27 12:04:41 +08:00
|
|
|
|
float minSide = MathF.Min(playfieldSize.X, playfieldSize.Y);
|
|
|
|
|
float maxSide = MathF.Max(playfieldSize.X, playfieldSize.Y);
|
2024-09-11 21:54:30 +08:00
|
|
|
|
|
|
|
|
|
playfieldAdjustmentContainer = drawableRuleset.PlayfieldAdjustmentContainer;
|
|
|
|
|
playfieldAdjustmentContainer.Scale = new Vector2(minSide / maxSide);
|
2021-04-30 06:59:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|