当前位置: 首页>>代码示例>>C#>>正文


C# BoundingBox.GetIntersection方法代码示例

本文整理汇总了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 );
        }
开发者ID:fragmer,项目名称:fCraft,代码行数:73,代码来源:BuildingCommands.cs


注:本文中的fCraft.BoundingBox.GetIntersection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。