/// <summary>Returns true if this command can be aggregated with another command.</summary> /// <param name="otherCommand">The other command to aggregate.</param> /// <returns>True if both commands can be aggregated.</returns> public override bool CanAggregateWith(AggregableCommand otherCommand) { RotateTopOfStackCommand otherRotateCommand = otherCommand as RotateTopOfStackCommand; if (otherRotateCommand == null) { return(false); } if (pieces.Length != otherRotateCommand.pieces.Length) { return(false); } else { for (int i = 0; i < pieces.Length; ++i) { if (pieces[i] != otherRotateCommand.pieces[i]) { return(false); } } } return(true); }
/// <summary>Aggregate two commands and store the result in this command.</summary> /// <param name="otherCommand">Another command to aggregate.</param> public override void AggregateWith(AggregableCommand otherCommand) { Debug.Assert(CanAggregateWith(otherCommand)); rotationIncrements += ((RotatePieceCommand)otherCommand).rotationIncrements; }
/// <summary>Returns true if this command can be aggregated with another command.</summary> /// <param name="otherCommand">The other command to aggregate.</param> /// <returns>True if both commands can be aggregated.</returns> public override bool CanAggregateWith(AggregableCommand otherCommand) { RotatePieceCommand otherRotateCommand = otherCommand as RotatePieceCommand; return(otherRotateCommand != null && otherRotateCommand.piece == piece); }
/// <summary>Aggregate two commands and store the result in this command.</summary> /// <param name="otherCommand">Another command to aggregate.</param> public abstract void AggregateWith(AggregableCommand otherCommand);
/// <summary>Returns true if this command can be aggregated with another command.</summary> /// <param name="otherCommand">The other command to aggregate.</param> /// <returns>True if both commands can be aggregated.</returns> public abstract bool CanAggregateWith(AggregableCommand otherCommand);