// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable disable 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 { /// /// Represents a caught by the catcher. /// [Cached(typeof(IHasCatchObjectState))] public abstract class CaughtObject : SkinnableDrawable, IHasCatchObjectState { public PalpableCatchHitObject HitObject { get; private set; } public Bindable AccentColour { get; } = new Bindable(); public Bindable HyperDash { get; } = new Bindable(); public Bindable IndexInBeatmap { get; } = new Bindable(); public Vector2 DisplaySize => Size * Scale; public float DisplayRotation => Rotation; public double DisplayStartTime => HitObject.StartTime; /// /// Whether this hit object should stay on the catcher plate when the object is caught by the catcher. /// public virtual bool StaysOnPlate => true; public override bool RemoveWhenNotAlive => true; protected CaughtObject(CatchSkinComponents skinComponent, Func defaultImplementation) : base(new CatchSkinComponent(skinComponent), defaultImplementation) { Origin = Anchor.Centre; RelativeSizeAxes = Axes.None; Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2); } /// /// Copies the hit object visual state from another object. /// public virtual void CopyStateFrom(IHasCatchObjectState objectState) { HitObject = objectState.HitObject; Scale = Vector2.Divide(objectState.DisplaySize, Size); Rotation = objectState.DisplayRotation; AccentColour.Value = objectState.AccentColour.Value; HyperDash.Value = objectState.HyperDash.Value; IndexInBeatmap.Value = objectState.IndexInBeatmap.Value; } protected override void FreeAfterUse() { ClearTransforms(); Alpha = 1; base.FreeAfterUse(); } } }