mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Add MoveCommand
This commit is contained in:
parent
18f7321ac6
commit
867e986240
@ -14,7 +14,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects
|
||||
{
|
||||
public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasPosition, IHasTimePreempt
|
||||
public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasMutablePosition, IHasTimePreempt
|
||||
{
|
||||
/// <summary>
|
||||
/// The radius of hit objects (ie. the radius of a <see cref="HitCircle"/>).
|
||||
|
18
osu.Game/Rulesets/Objects/Types/IHasMutablePosition.cs
Normal file
18
osu.Game/Rulesets/Objects/Types/IHasMutablePosition.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.
|
||||
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that has a starting position that can be mutated.
|
||||
/// </summary>
|
||||
public interface IHasMutablePosition : IHasPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting position of the HitObject.
|
||||
/// </summary>
|
||||
new Vector2 Position { get; set; }
|
||||
}
|
||||
}
|
27
osu.Game/Screens/Edit/Commands/MoveCommand.cs
Normal file
27
osu.Game/Screens/Edit/Commands/MoveCommand.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.
|
||||
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Commands
|
||||
{
|
||||
public class MoveCommand : IEditorCommand
|
||||
{
|
||||
public readonly IHasMutablePosition Target;
|
||||
|
||||
public readonly Vector2 Position;
|
||||
|
||||
public MoveCommand(IHasMutablePosition target, Vector2 position)
|
||||
{
|
||||
Target = target;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public void Apply() => Target.Position = Position;
|
||||
|
||||
public IEditorCommand CreateUndo() => new MoveCommand(Target, Target.Position);
|
||||
|
||||
public bool IsRedundant => Position == Target.Position;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user