2019-12-06 02:53:22 +00: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.
|
|
|
|
|
2019-12-05 04:43:38 +00:00
|
|
|
using System;
|
2020-09-14 08:08:22 +00:00
|
|
|
using Newtonsoft.Json;
|
2019-12-05 04:43:38 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Objects
|
|
|
|
{
|
|
|
|
public class PathControlPoint : IEquatable<PathControlPoint>
|
|
|
|
{
|
2021-08-25 16:42:57 +00:00
|
|
|
private Vector2 position;
|
|
|
|
|
2019-12-05 05:38:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The position of this <see cref="PathControlPoint"/>.
|
|
|
|
/// </summary>
|
2020-09-14 08:08:22 +00:00
|
|
|
[JsonProperty]
|
2021-08-25 16:42:57 +00:00
|
|
|
public Vector2 Position
|
|
|
|
{
|
|
|
|
get => position;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == position)
|
|
|
|
return;
|
|
|
|
|
|
|
|
position = value;
|
|
|
|
Changed?.Invoke();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private PathType? type;
|
2019-12-05 04:43:38 +00:00
|
|
|
|
2019-12-05 05:38:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The type of path segment starting at this <see cref="PathControlPoint"/>.
|
|
|
|
/// If null, this <see cref="PathControlPoint"/> will be a part of the previous path segment.
|
|
|
|
/// </summary>
|
2020-09-14 08:08:22 +00:00
|
|
|
[JsonProperty]
|
2021-08-25 16:42:57 +00:00
|
|
|
public PathType? Type
|
|
|
|
{
|
|
|
|
get => type;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == type)
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = value;
|
|
|
|
Changed?.Invoke();
|
|
|
|
}
|
|
|
|
}
|
2019-12-05 04:43:38 +00:00
|
|
|
|
2019-12-05 05:38:32 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Invoked when any property of this <see cref="PathControlPoint"/> is changed.
|
|
|
|
/// </summary>
|
2021-08-25 16:42:57 +00:00
|
|
|
public event Action Changed;
|
2019-12-05 05:38:32 +00:00
|
|
|
|
2019-12-09 08:45:08 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new <see cref="PathControlPoint"/>.
|
|
|
|
/// </summary>
|
2019-12-05 05:38:32 +00:00
|
|
|
public PathControlPoint()
|
2019-12-09 08:45:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a new <see cref="PathControlPoint"/> with a provided position and type.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="position">The initial position.</param>
|
|
|
|
/// <param name="type">The initial type.</param>
|
|
|
|
public PathControlPoint(Vector2 position, PathType? type = null)
|
2019-12-10 04:12:54 +00:00
|
|
|
: this()
|
2019-12-05 05:38:32 +00:00
|
|
|
{
|
2021-08-25 16:42:57 +00:00
|
|
|
Position = position;
|
|
|
|
Type = type;
|
2019-12-05 05:38:32 +00:00
|
|
|
}
|
|
|
|
|
2021-08-25 16:42:57 +00:00
|
|
|
public bool Equals(PathControlPoint other) => Position == other?.Position && Type == other.Type;
|
2019-12-05 04:43:38 +00:00
|
|
|
}
|
|
|
|
}
|