mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Use common body piece
This commit is contained in:
parent
e964a555d0
commit
4fa511043e
@ -7,7 +7,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Lines;
|
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
@ -23,7 +22,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.Slider
|
|||||||
{
|
{
|
||||||
public new Objects.Slider HitObject => (Objects.Slider)base.HitObject;
|
public new Objects.Slider HitObject => (Objects.Slider)base.HitObject;
|
||||||
|
|
||||||
private Path path;
|
|
||||||
private Container<SliderControlPoint> controlPointContainer;
|
private Container<SliderControlPoint> controlPointContainer;
|
||||||
|
|
||||||
private readonly List<Segment> segments = new List<Segment>();
|
private readonly List<Segment> segments = new List<Segment>();
|
||||||
@ -43,14 +41,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.Slider
|
|||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
path = new SmoothPath { PathWidth = 3 },
|
new BodyPiece(HitObject),
|
||||||
new SliderCirclePiece(HitObject, SliderPosition.Start),
|
new SliderCirclePiece(HitObject, SliderPosition.Start),
|
||||||
new SliderCirclePiece(HitObject, SliderPosition.End),
|
new SliderCirclePiece(HitObject, SliderPosition.End),
|
||||||
controlPointContainer = new Container<SliderControlPoint> { RelativeSizeAxes = Axes.Both }
|
controlPointContainer = new Container<SliderControlPoint> { RelativeSizeAxes = Axes.Both }
|
||||||
};
|
};
|
||||||
|
|
||||||
path.Colour = colours.YellowDark;
|
|
||||||
|
|
||||||
setState(PlacementState.Initial);
|
setState(PlacementState.Initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,23 +124,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.Slider
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
segments.ForEach(s => s.Calculate());
|
for (int i = 0; i < segments.Count; i++)
|
||||||
|
segments[i].Calculate(i == segments.Count - 1 ? (Vector2?)cursor : null);
|
||||||
|
|
||||||
switch (state)
|
HitObject.ControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToList();
|
||||||
{
|
HitObject.CurveType = HitObject.ControlPoints.Count > 2 ? CurveType.Bezier : CurveType.Linear;
|
||||||
case PlacementState.Body:
|
HitObject.Distance = segments.Sum(s => s.Distance);
|
||||||
path.Position = HitObject.Position;
|
|
||||||
path.ClearVertices();
|
|
||||||
|
|
||||||
for (int i = 0; i < segments.Count; i++)
|
|
||||||
{
|
|
||||||
var segmentPath = segments[i].Calculate(i == segments.Count - 1 ? (Vector2?)cursor : null);
|
|
||||||
segmentPath.ForEach(v => path.AddVertex(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
path.OriginPosition = path.PositionInBoundingBox(Vector2.Zero);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setState(PlacementState newState)
|
private void setState(PlacementState newState)
|
||||||
|
Loading…
Reference in New Issue
Block a user