Пример #1
0
        internal static void DebugDrawBlockGroups <TNode, TGroupData>(MyGroups <TNode, TGroupData> groups) where TNode : MySlimBlock where TGroupData : IGroupData <TNode>, new()
        {
            int num = 0;

            using (HashSet <MyGroups <TNode, TGroupData> .Group> .Enumerator enumerator = groups.Groups.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    num++;
                    Color colorFrom = new Vector3(((float)(num % 15)) / 15f, 1f, 1f).HSVtoColor();
                    HashSetReader <MyGroups <TNode, TGroupData> .Node> nodes = enumerator.Current.Nodes;
                    foreach (MyGroups <TNode, TGroupData> .Node node in nodes)
                    {
                        try
                        {
                            BoundingBoxD xd;
                            node.NodeData.GetWorldBoundingBox(out xd, false);
                            SortedDictionaryValuesReader <long, MyGroups <TNode, TGroupData> .Node> children = node.Children;
                            foreach (MyGroups <TNode, TGroupData> .Node node2 in children)
                            {
                                m_tmpBlocksDebugHelper.Add(node2);
                            }
                            foreach (object obj2 in m_tmpBlocksDebugHelper)
                            {
                                BoundingBoxD xd2;
                                MyGroups <TNode, TGroupData> .Node node3 = null;
                                int num2 = 0;
                                children = node.Children;
                                foreach (MyGroups <TNode, TGroupData> .Node node4 in children)
                                {
                                    if (obj2 == node4)
                                    {
                                        node3 = node4;
                                        num2++;
                                    }
                                }
                                node3.NodeData.GetWorldBoundingBox(out xd2, false);
                                MyRenderProxy.DebugDrawLine3D(xd.Center, xd2.Center, colorFrom, colorFrom, false, false);
                                MyRenderProxy.DebugDrawText3D((xd.Center + xd2.Center) * 0.5, num2.ToString(), colorFrom, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
                            }
                            Color color = new Color(colorFrom.ToVector3() + 0.25f);
                            MyRenderProxy.DebugDrawSphere(xd.Center, 0.2f, color.ToVector3(), 0.5f, false, true, true, false);
                            MyRenderProxy.DebugDrawText3D(xd.Center, node.LinkCount.ToString(), color, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, -1, false);
                        }
                        finally
                        {
                            m_tmpBlocksDebugHelper.Clear();
                        }
                    }
                }
            }
        }
Пример #2
0
 internal void RemoveBlockSmallToLargeConnection(MySlimBlock block)
 {
     if (m_smallToLargeCheckEnabled && block.CubeGrid.IsStatic)
     {
         MyCompoundCubeBlock fatBlock = block.FatBlock as MyCompoundCubeBlock;
         if (fatBlock != null)
         {
             foreach (MySlimBlock block3 in fatBlock.GetBlocks())
             {
                 this.RemoveBlockSmallToLargeConnection(block3);
             }
         }
         else
         {
             m_tmpGrids.Clear();
             if (GetCubeSize(block) == MyCubeSize.Large)
             {
                 this.RemoveChangedLargeBlockConnectionToSmallBlocks(block, m_tmpGrids);
                 if (Sync.IsServer)
                 {
                     foreach (MyCubeGrid grid in m_tmpGrids)
                     {
                         if (grid.TestDynamic != MyCubeGrid.MyTestDynamicReason.NoReason)
                         {
                             continue;
                         }
                         if (!this.SmallGridIsStatic(grid))
                         {
                             grid.TestDynamic = MyCubeGrid.MyTestDynamicReason.GridSplit;
                         }
                     }
                 }
                 m_tmpGrids.Clear();
             }
             else
             {
                 MyGroups <MySlimBlock, MyBlockGroupData> .Group group = MyCubeGridGroups.Static.SmallToLargeBlockConnections.GetGroup(block);
                 if (group == null)
                 {
                     if ((Sync.IsServer && ((block.CubeGrid.GetBlocks().Count > 0) && (block.CubeGrid.TestDynamic == MyCubeGrid.MyTestDynamicReason.NoReason))) && !this.SmallGridIsStatic(block.CubeGrid))
                     {
                         block.CubeGrid.TestDynamic = MyCubeGrid.MyTestDynamicReason.GridSplit;
                     }
                 }
                 else
                 {
                     HashSet <MySlimBlockPair> set;
                     m_tmpSlimBlocks.Clear();
                     foreach (MyGroups <MySlimBlock, MyBlockGroupData> .Node node in group.Nodes)
                     {
                         SortedDictionaryValuesReader <long, MyGroups <MySlimBlock, MyBlockGroupData> .Node> children = node.Children;
                         using (SortedDictionary <long, MyGroups <MySlimBlock, MyBlockGroupData> .Node> .ValueCollection.Enumerator enumerator4 = children.GetEnumerator())
                         {
                             while (enumerator4.MoveNext())
                             {
                                 if (enumerator4.Current.NodeData == block)
                                 {
                                     m_tmpSlimBlocks.Add(node.NodeData);
                                     break;
                                 }
                             }
                         }
                     }
                     foreach (MySlimBlock block4 in m_tmpSlimBlocks)
                     {
                         this.DisconnectSmallToLargeBlock(block, block4);
                     }
                     m_tmpSlimBlocks.Clear();
                     if ((Sync.IsServer && (!this.m_mapSmallGridToConnectedBlocks.TryGetValue(block.CubeGrid, out set) && ((block.CubeGrid.GetBlocks().Count > 0) && (block.CubeGrid.TestDynamic == MyCubeGrid.MyTestDynamicReason.NoReason)))) && !this.SmallGridIsStatic(block.CubeGrid))
                     {
                         block.CubeGrid.TestDynamic = MyCubeGrid.MyTestDynamicReason.GridSplit;
                     }
                 }
             }
         }
     }
 }