Move catcher base size constant to `Catcher`.

This commit is contained in:
ekrctb 2021-07-21 16:43:24 +09:00
parent 30777795ce
commit d9f9ad35be
5 changed files with 16 additions and 13 deletions

View File

@ -51,7 +51,7 @@ void moveToNext(PalpableCatchHitObject h)
bool impossibleJump = speedRequired > movement_speed * 2;
// todo: get correct catcher size, based on difficulty CS.
const float catcher_width_half = CatcherArea.CATCHER_SIZE * 0.3f * 0.5f;
const float catcher_width_half = Catcher.BASE_SIZE * 0.3f * 0.5f;
if (lastPosition - catcher_width_half < h.EffectiveX && lastPosition + catcher_width_half > h.EffectiveX)
{

View File

@ -25,6 +25,16 @@ namespace osu.Game.Rulesets.Catch.UI
{
public class Catcher : SkinReloadableDrawable
{
/// <summary>
/// The size of the catcher at 1x scale.
/// </summary>
public const float BASE_SIZE = 106.75f;
/// <summary>
/// The width of the catcher which can receive fruit. Equivalent to "catchMargin" in osu-stable.
/// </summary>
public const float ALLOWED_CATCH_RANGE = 0.8f;
/// <summary>
/// The default colour used to tint hyper-dash fruit, along with the moving catcher, its trail
/// and end glow/after-image during a hyper-dash.
@ -82,11 +92,6 @@ public CatcherAnimationState CurrentState
private set => Body.AnimationState.Value = value;
}
/// <summary>
/// The width of the catcher which can receive fruit. Equivalent to "catchMargin" in osu-stable.
/// </summary>
public const float ALLOWED_CATCH_RANGE = 0.8f;
private bool dashing;
public bool Dashing
@ -140,7 +145,7 @@ public Catcher([NotNull] Container trailsTarget, [NotNull] DroppedObjectContaine
Origin = Anchor.TopCentre;
Size = new Vector2(CatcherArea.CATCHER_SIZE);
Size = new Vector2(BASE_SIZE);
if (difficulty != null)
Scale = calculateScale(difficulty);
@ -197,7 +202,7 @@ protected override void LoadComplete()
/// Calculates the width of the area used for attempting catches in gameplay.
/// </summary>
/// <param name="scale">The scale of the catcher.</param>
public static float CalculateCatchWidth(Vector2 scale) => CatcherArea.CATCHER_SIZE * Math.Abs(scale.X) * ALLOWED_CATCH_RANGE;
public static float CalculateCatchWidth(Vector2 scale) => BASE_SIZE * Math.Abs(scale.X) * ALLOWED_CATCH_RANGE;
/// <summary>
/// Calculates the width of the area used for attempting catches in gameplay.

View File

@ -22,8 +22,6 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary>
public class CatcherArea : Container, IKeyBindingHandler<CatchAction>
{
public const float CATCHER_SIZE = 106.75f;
public Catcher Catcher
{
get => catcher;
@ -52,7 +50,7 @@ public Catcher Catcher
/// </remarks>
public CatcherArea()
{
Size = new Vector2(CatchPlayfield.WIDTH, CATCHER_SIZE);
Size = new Vector2(CatchPlayfield.WIDTH, Catcher.BASE_SIZE);
Child = comboDisplay = new CatchComboDisplay
{
RelativeSizeAxes = Axes.None,

View File

@ -23,7 +23,7 @@ public CatcherAnimationState AnimationState
public CatcherTrail()
{
Size = new Vector2(CatcherArea.CATCHER_SIZE);
Size = new Vector2(Catcher.BASE_SIZE);
Origin = Anchor.TopCentre;
Blending = BlendingParameters.Additive;
InternalChild = body = new SkinnableCatcher

View File

@ -27,7 +27,7 @@ public SkinnableCatcher()
{
Anchor = Anchor.TopCentre;
// Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling.
OriginPosition = new Vector2(0.5f, 0.06f) * CatcherArea.CATCHER_SIZE;
OriginPosition = new Vector2(0.5f, 0.06f) * Catcher.BASE_SIZE;
}
}
}