mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Calculate playfield scale locally
This commit is contained in:
parent
25e0fb1cf9
commit
7bf3498e2a
@ -6,15 +6,11 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public class OsuModBarrelRoll : ModBarrelRoll<OsuHitObject>, IApplicableToDrawableHitObjects
|
||||
{
|
||||
protected override Vector2 PlayfieldScale => new Vector2(OsuPlayfield.BASE_SIZE.Y / OsuPlayfield.BASE_SIZE.X);
|
||||
|
||||
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
||||
{
|
||||
foreach (var d in drawables)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -34,11 +35,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public override string SettingDescription => $"{SpinSpeed.Value} rpm {Direction.Value.GetDescription().ToLowerInvariant()}";
|
||||
|
||||
/// <summary>
|
||||
/// Used to allow all hitobjects to stay within the visible region.
|
||||
/// </summary>
|
||||
protected abstract Vector2 PlayfieldScale { get; }
|
||||
|
||||
public void Update(Playfield playfield)
|
||||
{
|
||||
playfield.Rotation = CurrentRotation = (Direction.Value == RotationDirection.Counterclockwise ? -1 : 1) * 360 * (float)(playfield.Time.Current / 60000 * SpinSpeed.Value);
|
||||
@ -46,7 +42,12 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public void ApplyToDrawableRuleset(DrawableRuleset<TObject> drawableRuleset)
|
||||
{
|
||||
drawableRuleset.Playfield.Scale = PlayfieldScale;
|
||||
// scale the playfield to allow all hitobjects to stay within the visible region.
|
||||
|
||||
var playfieldSize = drawableRuleset.Playfield.DrawSize;
|
||||
var minSide = MathF.Min(playfieldSize.X, playfieldSize.Y);
|
||||
var maxSide = MathF.Max(playfieldSize.X, playfieldSize.Y);
|
||||
drawableRuleset.Playfield.Scale = new Vector2(minSide / maxSide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user