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