Skip to content

Commit

Permalink
Introduce abstractions for pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Oct 1, 2022
1 parent 9d77592 commit 0195ed6
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 30 deletions.
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override void UpdateInitialTransforms()
double animTime = AdjustedAnimationDuration / 2;
NoteBody.FadeInFromZero(animTime).ScaleTo(1, animTime);

((HoldBody)NoteBody.Drawable).FadeColour(AccentColour.Value);
NoteBody.Drawable.FadeColour(AccentColour.Value);

using (BeginDelayedSequence(animTime, true))
{
Expand All @@ -99,7 +99,7 @@ protected override void UpdateInitialTransforms()
.ResizeHeightTo(0, stretchTime);

if (HoldStartTime == null && !Auto)
((HoldBody)NoteBody.Drawable).Delay(animTime).FadeColour(Color4.Gray, 100);
NoteBody.Drawable.Delay(animTime).FadeColour(Color4.Gray, 100);
}
}

Expand Down Expand Up @@ -142,7 +142,7 @@ protected override void UpdateHitStateTransforms(ArmedState state)
break;

case ArmedState.Miss:
((HoldBody)NoteBody.Drawable).ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
NoteBody.Drawable.ScaleTo(0.5f, time_fade_miss, Easing.InCubic)
.FadeColour(Color4.Red, time_fade_miss, Easing.OutQuint)
.MoveToOffset(new Vector2(0, -100), time_fade_miss, Easing.OutCubic)
.FadeOut(time_fade_miss);
Expand Down
20 changes: 13 additions & 7 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideTap.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
using System;
using System.Linq;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default.Slides;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableSlideTap : DrawableTap
{
protected override SentakkiSkinComponents TapPieceComponent => SentakkiSkinComponents.SlideStar;
protected override Type fallbackPieceType => typeof(SlideTapPiece);
protected override Drawable CreateTapVisual() => new SlideTapPiece()
{
Scale = new Vector2(0f),
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};

public DrawableSlideTap() : this(null) { }
public DrawableSlideTap(SlideTap? hitObject)
Expand All @@ -19,17 +25,17 @@ protected override void UpdateInitialTransforms()
{
base.UpdateInitialTransforms();

var note = (SlideTapPiece)TapVisual.Drawable;
var note = (ISlideTapPiece)TapVisual;

double spinDuration = 0;

if (ParentHitObject is DrawableSlide slide)
{
spinDuration = ((Slide)slide.HitObject).SlideInfoList.FirstOrDefault().Duration;
if (slide.SlideBodies.Count > 1)
note.SecondStar.Alpha = 1;
note.Stars[1].Alpha = 1;
else
note.SecondStar.Alpha = 0;
note.Stars[1].Alpha = 0;
}

note.Stars.Spin(spinDuration, RotationDirection.Counterclockwise, 0).Loop();
Expand Down
22 changes: 10 additions & 12 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;

using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
Expand All @@ -9,16 +9,20 @@
using osu.Game.Rulesets.Sentakki.Skinning;
using osu.Game.Rulesets.Sentakki.Skinning.Default;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
public class DrawableTap : DrawableSentakkiLanedHitObject, IKeyBindingHandler<SentakkiAction>
{
protected virtual SentakkiSkinComponents TapPieceComponent => SentakkiSkinComponents.Tap;
protected virtual Type fallbackPieceType => typeof(TapPiece);
protected virtual Drawable CreateTapVisual() => new ProxyableSkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.Tap), _ => new TapPiece())
{
Scale = new Vector2(0f),
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};

public override double LifetimeStart
{
Expand All @@ -39,7 +43,7 @@ public override double LifetimeEnd
}
}

public SkinnableDrawable TapVisual = null!;
public Drawable TapVisual = null!;

public DrawableTap() : this(null) { }

Expand All @@ -52,13 +56,7 @@ private void load()
Origin = Anchor.Centre;
Anchor = Anchor.Centre;
AddRangeInternal(new Drawable[] {
TapVisual = new ProxyableSkinnableDrawable(new SentakkiSkinComponent(TapPieceComponent), _ => (Drawable)Activator.CreateInstance(fallbackPieceType))
{
Scale = new Vector2(0f),
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
TapVisual = CreateTapVisual()
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override void UpdateInitialTransforms()
using (BeginDelayedSequence(AdjustedAnimationDuration, true))
{
TouchBody.ResizeTo(90, moveTo, Easing.InCirc);
((TouchBody)TouchBody.Drawable).BorderContainer.Delay(moveTo).FadeIn();
((ITouchPiece)TouchBody.Drawable).TouchBorder.Delay(moveTo).FadeIn();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected override void UpdateInitialTransforms()
TouchHoldBody.FadeInFromZero(fadeIn).ScaleTo(1, fadeIn);
using (BeginDelayedSequence(fadeIn, true))
{
((TouchHoldBody)TouchHoldBody.Drawable).ProgressPiece.TransformBindableTo(((TouchHoldBody)TouchHoldBody.Drawable).ProgressPiece.ProgressBindable, 1, ((IHasDuration)HitObject).Duration);
((ITouchHoldPiece)TouchHoldBody.Drawable).TransformTo(nameof(ITouchHoldPiece.Progress), 1.0, ((IHasDuration)HitObject).Duration);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@

namespace osu.Game.Rulesets.Sentakki.Skinning.Default.Slides
{
public class SlideTapPiece : CompositeDrawable
public class SlideTapPiece : CompositeDrawable, ISlideTapPiece
{
public readonly Container Stars;
public readonly SkinnableDrawable SecondStar;
public override bool RemoveWhenNotAlive => false;
private readonly SkinnableDrawable secondStar;

public Container Stars { get; private set; }

public Drawable SecondStar => secondStar;

public SlideTapPiece()
{
Expand All @@ -34,7 +38,7 @@ public SlideTapPiece()
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.None,
},
SecondStar = new SkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.SlideStar), _ => new StarPiece())
secondStar = new SkinnableDrawable(new SentakkiSkinComponent(SentakkiSkinComponents.SlideStar), _ => new StarPiece())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

namespace osu.Game.Rulesets.Sentakki.Skinning.Default.TouchHolds
{
public class TouchHoldBody : CircularContainer
public class TouchHoldBody : CircularContainer, ITouchHoldPiece
{
public double Progress
{
get => ProgressPiece.ProgressBindable.Value;
set => ProgressPiece.ProgressBindable.Value = value;
}

public readonly TouchHoldProgressPiece ProgressPiece;
private readonly TouchHoldCentrePiece centrePiece;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

namespace osu.Game.Rulesets.Sentakki.Skinning.Default.Touches
{
public class TouchBody : Container
public class TouchBody : Container, ITouchPiece
{
public Drawable TouchBorder => BorderContainer;

public Container BorderContainer;
public Container PieceContainer;
public TouchBody()
Expand Down
11 changes: 11 additions & 0 deletions osu.Game.Rulesets.Sentakki/Skinning/ISlideTapPiece.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;

namespace osu.Game.Rulesets.Sentakki.Skinning
{
public interface ISlideTapPiece : IDrawable
{
public Container Stars { get; }
public Drawable SecondStar { get; }
}
}
10 changes: 10 additions & 0 deletions osu.Game.Rulesets.Sentakki/Skinning/ITouchHoldPiece.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using osu.Framework.Graphics;

namespace osu.Game.Rulesets.Sentakki.Skinning
{
public interface ITouchHoldPiece : IDrawable
{
// Used to fill the progress bar after HitObject start time
double Progress { get; set; }
}
}
10 changes: 10 additions & 0 deletions osu.Game.Rulesets.Sentakki/Skinning/ITouchPiece.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using osu.Framework.Graphics;

namespace osu.Game.Rulesets.Sentakki.Skinning
{
public interface ITouchPiece : IDrawable
{
// Shows as soon as Time >= StartTime
Drawable TouchBorder { get; }
}
}

0 comments on commit 0195ed6

Please sign in to comment.