// Copyright (c) ppy Pty Ltd . 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 : IMergeableCommand { 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; public IMergeableCommand? MergeWith(IEditorCommand previous) { if (previous is MoveCommand moveCommand) return moveCommand.Target != Target ? null : moveCommand; return null; } } }