本文整理匯總了C#中fCraft.Player.UndoPop方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.UndoPop方法的具體用法?C# Player.UndoPop怎麽用?C# Player.UndoPop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fCraft.Player
的用法示例。
在下文中一共展示了Player.UndoPop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UndoHandler
static void UndoHandler( Player player, CommandReader cmd ) {
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
if( cmd.HasNext ) {
player.Message( "Undo command takes no parameters. Did you mean to do &H/UndoPlayer&S or &H/UndoArea&S?" );
return;
}
string msg = "Undo: ";
UndoState undoState = player.UndoPop();
if( undoState == null ) {
player.MessageNow( "There is currently nothing to undo." );
return;
}
// Cancel the last DrawOp, if still in progress
if( undoState.Op != null && !undoState.Op.IsDone && !undoState.Op.IsCancelled ) {
undoState.Op.Cancel();
msg += String.Format( "Cancelled {0} (was {1}% done). ",
undoState.Op.Description,
undoState.Op.PercentDone );
}
// Check if command was too massive.
if( undoState.IsTooLargeToUndo ) {
if( undoState.Op != null ) {
player.MessageNow( "Cannot undo {0}: too massive.", undoState.Op.Description );
} else {
player.MessageNow( "Cannot undo: too massive." );
}
return;
}
// no need to set player.drawingInProgress here because this is done on the user thread
Logger.Log( LogType.UserActivity,
"Player {0} initiated /Undo affecting {1} blocks (on world {2})",
player.Name,
undoState.Buffer.Count,
playerWorld.Name );
msg += String.Format( "Restoring {0} blocks. Type &H/Redo&S to reverse.",
undoState.Buffer.Count );
player.MessageNow( msg );
var op = new UndoDrawOperation( player, undoState, false );
op.Prepare( new Vector3I[0] );
op.Begin();
}