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


C# MyCubeGrid.GetBlocks方法代码示例

本文整理汇总了C#中MyCubeGrid.GetBlocks方法的典型用法代码示例。如果您正苦于以下问题:C# MyCubeGrid.GetBlocks方法的具体用法?C# MyCubeGrid.GetBlocks怎么用?C# MyCubeGrid.GetBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyCubeGrid的用法示例。


在下文中一共展示了MyCubeGrid.GetBlocks方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Disconnect

        public bool Disconnect(MyCubeGrid grid, MySlimBlock testBlock = null, bool testDisconnect = false)
        {
            ProfilerShort.Begin("Collect+IsInVoxels");
            m_largestGroupWithPhysics = default(Group);
            m_groups.Clear();
            m_sortedBlocks.Clear();
            m_disconnectHelper.Clear();
            foreach (var block in grid.GetBlocks())
            {
                if (block == testBlock)
                    continue;

                m_disconnectHelper.Add(block);
            }
            ProfilerShort.End();

            ProfilerShort.Begin("GroupBy");
            while (m_disconnectHelper.Count > 0)
            {
                Group group = default(Group);
                group.FirstBlockIndex = m_sortedBlocks.Count;
                AddNeighbours(m_disconnectHelper.FirstElement(), out group.IsValid, testBlock);
                group.BlockCount = m_sortedBlocks.Count - group.FirstBlockIndex;

                if (group.IsValid && group.BlockCount > m_largestGroupWithPhysics.BlockCount)
                {
                    if (m_largestGroupWithPhysics.BlockCount > 0) // Is valid
                    {
                        // order matters, insert in correct place
                        int i = 0;
                        for (i = 0; i < m_groups.Count; i++)
                        {
                            if (m_groups[i].FirstBlockIndex > m_largestGroupWithPhysics.FirstBlockIndex)
                            {
                                m_groups.Insert(i, m_largestGroupWithPhysics);
                                break;
                            }
                        }

                        if (i == m_groups.Count)
                        {
                            m_groups.Add(m_largestGroupWithPhysics);
                        }
                    }

                    m_largestGroupWithPhysics = group;
                }
                else
                {
                    m_groups.Add(group);
                }
            }
            ProfilerShort.End();

            ProfilerShort.Begin("RemoveLargestGroup");
            m_sortedBlocks.RemoveRange(m_largestGroupWithPhysics.FirstBlockIndex, m_largestGroupWithPhysics.BlockCount);
            for (int i = 0; i < m_groups.Count; i++)
            {
                var g = m_groups[i];
                if (g.FirstBlockIndex > m_largestGroupWithPhysics.FirstBlockIndex)
                {
                    g.FirstBlockIndex -= m_largestGroupWithPhysics.BlockCount;
                    m_groups[i] = g;
                }
            }
            ProfilerShort.End();

            ProfilerShort.Begin("CreateSplits");
            if (m_groups.Count > 0)
            {
                if (testDisconnect)
                {
                    m_groups.Clear();
                    m_sortedBlocks.Clear();
                    m_disconnectHelper.Clear();
                    return true;
                }
                MyCubeGrid.CreateSplits(grid, m_sortedBlocks, m_groups);
            }
            else
            {
                if (!MySession.Static.Settings.StationVoxelSupport)
                {
                    if (grid.IsStatic)
                        grid.TestDynamic = MyCubeGrid.MyTestDynamicReason.GridSplit;
                }
            }
            ProfilerShort.End();

            m_groups.Clear();
            m_sortedBlocks.Clear();
            m_disconnectHelper.Clear();
            return false;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:94,代码来源:MyDisconnectHelper.cs

示例2: Disconnect

        public void Disconnect(MyCubeGrid grid)
        {
            ProfilerShort.Begin("Collect+IsInVoxels");
            m_largestGroupWithPhysics = default(Group);
            m_groups.Clear();
            m_sortedBlocks.Clear();
            m_disconnectHelper.Clear();
            foreach (var block in grid.GetBlocks())
            {
                m_disconnectHelper.Add(block);
            }
            ProfilerShort.End();

            ProfilerShort.Begin("GroupBy");
            while (m_disconnectHelper.Count > 0)
            {
                Group group = default(Group);
                group.FirstBlockIndex = m_sortedBlocks.Count;
                AddNeighbours(m_disconnectHelper.FirstElement(), out group.IsValid);
                group.BlockCount = m_sortedBlocks.Count - group.FirstBlockIndex;

                if (group.IsValid && group.BlockCount > m_largestGroupWithPhysics.BlockCount)
                {
                    if (m_largestGroupWithPhysics.BlockCount > 0) // Is valid
                    {
                        // order matters, insert in correct place
                        int i = 0;
                        for (i = 0; i < m_groups.Count; i++)
                        {
                            if (m_groups[i].FirstBlockIndex > m_largestGroupWithPhysics.FirstBlockIndex)
                            {
                                m_groups.Insert(i, m_largestGroupWithPhysics);
                                break;
                            }
                        }

                        if (i == m_groups.Count)
                        {
                            m_groups.Add(m_largestGroupWithPhysics);
                        }
                    }

                    m_largestGroupWithPhysics = group;
                }
                else
                {
                    m_groups.Add(group);
                }
            }
            ProfilerShort.End();

            ProfilerShort.Begin("RemoveLargestGroup");
            m_sortedBlocks.RemoveRange(m_largestGroupWithPhysics.FirstBlockIndex, m_largestGroupWithPhysics.BlockCount);
            for (int i = 0; i < m_groups.Count; i++)
            {
                var g = m_groups[i];
                if (g.FirstBlockIndex > m_largestGroupWithPhysics.FirstBlockIndex)
                {
                    g.FirstBlockIndex -= m_largestGroupWithPhysics.BlockCount;
                    m_groups[i] = g;
                }
            }
            ProfilerShort.End();

            ProfilerShort.Begin("CreateSplits");
            if (m_groups.Count > 0)
                MyCubeGrid.CreateSplits(grid, m_sortedBlocks, m_groups);
            ProfilerShort.End();



            m_groups.Clear();
            m_sortedBlocks.Clear();
            m_disconnectHelper.Clear();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:75,代码来源:MyDisconnectHelper.cs

示例3: Collect

        public void Collect(MyCubeGrid grid, MyVoxelSegmentation segmenter, MyVoxelSegmentationType segmentationType, IDictionary<Vector3I, HkMassElement> massResults)
        {
            foreach (var block in grid.GetBlocks())
            {
                if (block.FatBlock is MyCompoundCubeBlock)
                {
                    CollectCompoundBlock((MyCompoundCubeBlock)block.FatBlock, massResults);
                    Debug.Assert(IsValid(), "Overlapping shapes detected, block shapes cannot overlap!");
                }
                else
                {
                    CollectBlock(block, block.BlockDefinition.PhysicsOption, massResults);
                    Debug.Assert(IsValid(), "Overlapping shapes detected, block shapes cannot overlap!");
                }
            }

            AddSegmentedParts(grid.GridSize, segmenter, segmentationType);
            m_tmpCubes.Clear();

            Debug.Assert(Shapes.Count > 0, "Shape count cannot be zero");
            Debug.Assert(massResults == null || massResults.Count > 0, "No mass elements, something is wrong!");
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:22,代码来源:MyCubeBlockCollector.cs

示例4: CollectMassElements

 public void CollectMassElements(MyCubeGrid grid, IDictionary<Vector3I, HkMassElement> massResults)
 {
     foreach (var block in grid.GetBlocks())
     {
         if (block.FatBlock is MyCompoundCubeBlock)
         {             
             foreach (var cmpBlock in ((MyCompoundCubeBlock)(block.FatBlock)).GetBlocks())
             {
                 if (cmpBlock.BlockDefinition.BlockTopology == MyBlockTopology.TriangleMesh)
                 {
                     AddMass(cmpBlock, massResults);
                 }
             }
         }
         else
         {
             AddMass(block, massResults);
         }
     }
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:20,代码来源:MyCubeBlockCollector.cs

示例5: CutGroup

        public void CutGroup(MyCubeGrid grid)
        {
            if (grid == null)
                return;

            CopyGroup(grid);

            if (MyFakes.ENABLE_COPY_GROUP)
            {
                var group = MyCubeGridGroups.Static.Logical.GetGroup(grid);
                foreach (var node in group.Nodes)
                {
                    foreach (var block in node.NodeData.GetBlocks())
                    {
                        var cockpit = block.FatBlock as MyCockpit;
                        if (cockpit != null && cockpit.Pilot != null)
                            cockpit.Use();
                    }
                    node.NodeData.SyncObject.SendCloseRequest();
                }
            }
            else
            {
                foreach (var block in grid.GetBlocks())
                {
                    var cockpit = block.FatBlock as MyCockpit;
                    if (cockpit != null && cockpit.Pilot != null)
                        cockpit.Use();
                }
                grid.SyncObject.SendCloseRequest();
            }
            Deactivate();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:33,代码来源:MyGridClipboard.cs

示例6: CutGrid

        public void CutGrid(MyCubeGrid grid)
        {
            if (grid == null)
                return;

            CopyGrid(grid);

            foreach (var block in grid.GetBlocks())
            {
                var cockpit = block.FatBlock as MyCockpit;
                if (cockpit != null && cockpit.Pilot != null)
                    cockpit.Use();
            }

            grid.SyncObject.SendCloseRequest();
            Deactivate();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:17,代码来源:MyGridClipboard.cs

示例7: CutGroup

        public void CutGroup(MyCubeGrid grid, GridLinkTypeEnum groupType)
        {
            if (grid == null)
                return;

            CopyGroup(grid, groupType);

            if (MyFakes.ENABLE_COPY_GROUP)
            {
                var group = MyCubeGridGroups.Static.GetGroups(groupType).GetGroupNodes(grid);
                foreach (var node in group)
                {
                    foreach (var block in node.GetBlocks())
                    {
                        block.RemoveAuthorship();
                        var cockpit = block.FatBlock as MyCockpit;
                        if (cockpit != null && cockpit.Pilot != null)
                            cockpit.Use();
                    }
                    node.SyncObject.SendCloseRequest();
                }
            }
            else
            {
                foreach (var block in grid.GetBlocks())
                {
                    block.RemoveAuthorship();
                    var cockpit = block.FatBlock as MyCockpit;
                    if (cockpit != null && cockpit.Pilot != null)
                        cockpit.Use();
                }
                grid.SyncObject.SendCloseRequest();
            }
        }
开发者ID:Rynchodon,项目名称:SpaceEngineers,代码行数:34,代码来源:MyGridClipboard.cs


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