1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 09:37:42 +08:00
osu-lazer/osu.Game/Rulesets/Objects/PathControlPoint.cs

56 lines
1.9 KiB
C#
Raw Normal View History

2019-12-06 10:53:22 +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.
2019-12-05 12:43:38 +08:00
using System;
using Newtonsoft.Json;
2019-12-05 12:43:38 +08:00
using osu.Framework.Bindables;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Objects
{
public class PathControlPoint : IEquatable<PathControlPoint>
{
2019-12-05 13:38:21 +08:00
/// <summary>
/// The position of this <see cref="PathControlPoint"/>.
/// </summary>
[JsonProperty]
2019-12-05 12:43:38 +08:00
public readonly Bindable<Vector2> Position = new Bindable<Vector2>();
2019-12-05 13:38:21 +08: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>
[JsonProperty]
2019-12-05 12:43:38 +08:00
public readonly Bindable<PathType?> Type = new Bindable<PathType?>();
/// <summary>
/// Invoked when any property of this <see cref="PathControlPoint"/> is changed.
/// </summary>
internal event Action Changed;
2019-12-09 16:45:08 +08:00
/// <summary>
/// Creates a new <see cref="PathControlPoint"/>.
/// </summary>
public PathControlPoint()
2019-12-09 16:45:08 +08:00
{
2019-12-10 12:12:54 +08:00
Position.ValueChanged += _ => Changed?.Invoke();
Type.ValueChanged += _ => Changed?.Invoke();
2019-12-09 16:45:08 +08: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 12:12:54 +08:00
: this()
{
2019-12-09 17:01:13 +08:00
Position.Value = position;
Type.Value = type;
}
2019-12-09 16:45:08 +08:00
public bool Equals(PathControlPoint other) => Position.Value == other?.Position.Value && Type.Value == other.Type.Value;
2019-12-05 12:43:38 +08:00
}
}