本文整理汇总了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();
}