2020-12-08 19:34:08 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|
|
|
{
|
2020-12-08 22:11:22 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Represents a <see cref="PalpableCatchHitObject"/> caught by the catcher.
|
|
|
|
/// </summary>
|
2020-12-08 20:29:03 +08:00
|
|
|
[Cached(typeof(IHasCatchObjectState))]
|
|
|
|
public abstract partial class CaughtObject : SkinnableDrawable, IHasCatchObjectState
|
2020-12-08 19:34:08 +08:00
|
|
|
{
|
2023-01-15 22:21:38 +08:00
|
|
|
public PalpableCatchHitObject HitObject { get; private set; } = null!;
|
2020-12-08 20:29:03 +08:00
|
|
|
public Bindable<Color4> AccentColour { get; } = new Bindable<Color4>();
|
|
|
|
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
2021-06-07 13:49:37 +08:00
|
|
|
public Bindable<int> IndexInBeatmap { get; } = new Bindable<int>();
|
2020-12-08 19:34:08 +08:00
|
|
|
|
2020-12-10 19:43:01 +08:00
|
|
|
public Vector2 DisplaySize => Size * Scale;
|
|
|
|
|
|
|
|
public float DisplayRotation => Rotation;
|
2020-12-10 18:42:01 +08:00
|
|
|
|
2022-10-28 18:35:50 +08:00
|
|
|
public double DisplayStartTime => HitObject.StartTime;
|
|
|
|
|
2020-12-08 19:34:08 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this hit object should stay on the catcher plate when the object is caught by the catcher.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool StaysOnPlate => true;
|
|
|
|
|
|
|
|
public override bool RemoveWhenNotAlive => true;
|
|
|
|
|
2022-11-09 15:04:56 +08:00
|
|
|
protected CaughtObject(CatchSkinComponents skinComponent, Func<ISkinComponentLookup, Drawable> defaultImplementation)
|
|
|
|
: base(new CatchSkinComponentLookup(skinComponent), defaultImplementation)
|
2020-12-08 19:34:08 +08:00
|
|
|
{
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.None;
|
|
|
|
Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2);
|
|
|
|
}
|
|
|
|
|
2020-12-08 22:35:24 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Copies the hit object visual state from another <see cref="IHasCatchObjectState"/> object.
|
|
|
|
/// </summary>
|
|
|
|
public virtual void CopyStateFrom(IHasCatchObjectState objectState)
|
2020-12-08 19:34:08 +08:00
|
|
|
{
|
2020-12-08 20:29:03 +08:00
|
|
|
HitObject = objectState.HitObject;
|
2020-12-10 19:43:01 +08:00
|
|
|
Scale = Vector2.Divide(objectState.DisplaySize, Size);
|
|
|
|
Rotation = objectState.DisplayRotation;
|
2020-12-08 20:29:03 +08:00
|
|
|
AccentColour.Value = objectState.AccentColour.Value;
|
|
|
|
HyperDash.Value = objectState.HyperDash.Value;
|
2021-06-07 13:49:37 +08:00
|
|
|
IndexInBeatmap.Value = objectState.IndexInBeatmap.Value;
|
2020-12-08 21:38:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void FreeAfterUse()
|
|
|
|
{
|
|
|
|
ClearTransforms();
|
|
|
|
Alpha = 1;
|
|
|
|
|
|
|
|
base.FreeAfterUse();
|
2020-12-08 19:34:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|