1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-11 05:52:56 +08:00
osu-lazer/osu.Game/Screens/Edit/Commands/MoveCommand.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1017 B
C#
Raw Normal View History

2024-10-09 02:29:06 +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.
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Screens.Edit.Commands
{
2024-10-10 23:10:44 +08:00
public class MoveCommand : IMergeableCommand
2024-10-09 02:29:06 +08:00
{
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;
2024-10-10 20:05:50 +08:00
2024-10-10 23:52:57 +08:00
public IMergeableCommand? MergeWith(IEditorCommand previous)
2024-10-10 20:05:50 +08:00
{
if (previous is MoveCommand moveCommand)
2024-10-10 23:52:57 +08:00
return moveCommand.Target != Target ? null : moveCommand;
2024-10-10 20:05:50 +08:00
return null;
}
2024-10-09 02:29:06 +08:00
}
}