本文整理匯總了C#中fCraft.BoundingBox.GetIntersection方法的典型用法代碼示例。如果您正苦於以下問題:C# BoundingBox.GetIntersection方法的具體用法?C# BoundingBox.GetIntersection怎麽用?C# BoundingBox.GetIntersection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fCraft.BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.GetIntersection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PasteCallback
unsafe internal static void PasteCallback( Player player, Position[] marks, object tag ) {
CopyInformation info = player.CopyInformation;
PasteArgs args = (PasteArgs)tag;
byte* specialTypes = stackalloc byte[args.BlockTypes.Length];
int specialTypeCount = args.BlockTypes.Length;
for( int i = 0; i < args.BlockTypes.Length; i++ ) {
specialTypes[i] = (byte)args.BlockTypes[i];
}
Map map = player.World.Map;
BoundingBox bounds = new BoundingBox( marks[0], info.WidthX, info.WidthY, info.Height );
int pasteVolume = bounds.GetIntersection( map.Bounds ).Volume;
if( !player.CanDraw( pasteVolume ) ) {
player.MessageNow( "You are only allowed to run draw commands that affect up to {0} blocks. This one would affect {1} blocks.",
player.Info.Rank.DrawLimit,
pasteVolume );
return;
}
if( bounds.XMin < 0 || bounds.XMax > map.WidthX - 1 ) {
player.MessageNow( "Warning: Not enough room horizontally (X), paste cut off." );
}
if( bounds.YMin < 0 || bounds.YMax > map.WidthY - 1 ) {
player.MessageNow( "Warning: Not enough room horizontally (Y), paste cut off." );
}
if( bounds.HMin < 0 || bounds.HMax > map.Height - 1 ) {
player.MessageNow( "Warning: Not enough room vertically, paste cut off." );
}
player.UndoBuffer.Clear();
int blocks = 0, blocksDenied = 0;
bool cannotUndo = false;
for( int x = bounds.XMin; x <= bounds.XMax; x += DrawStride ) {
for( int y = bounds.YMin; y <= bounds.YMax; y += DrawStride ) {
for( int h = bounds.HMin; h <= bounds.HMax; h++ ) {
for( int y3 = 0; y3 < DrawStride && y + y3 <= bounds.YMax; y3++ ) {
for( int x3 = 0; x3 < DrawStride && x + x3 <= bounds.XMax; x3++ ) {
byte block = info.Buffer[x + x3 - bounds.XMin, y + y3 - bounds.YMin, h - bounds.HMin];
if( args.DoInclude ) {
bool skip = true;
for( int i = 0; i < specialTypeCount; i++ ) {
if( block == specialTypes[i] ) {
skip = false;
break;
}
}
if( skip ) continue;
} else if( args.DoExclude ) {
bool skip = false;
for( int i = 0; i < specialTypeCount; i++ ) {
if( block == specialTypes[i] ) {
skip = true;
break;
}
}
if( skip ) continue;
}
DrawOneBlock( player, block, x + x3, y + y3, h, ref blocks, ref blocksDenied, ref cannotUndo );
}
}
}
}
}
Logger.Log( "{0} pasted {1} blocks to {2}.", LogType.UserActivity,
player.Name, blocks, player.World.Name );
DrawingFinished( player, "pasted", blocks, blocksDenied );
}