Exemple #1
0
        public override void Init(ITorchBase torch)
        {
            base.Init(torch);

            Instance = this;

            SetUpConfig();

            MyMechanicalConnectionBlockBasePatch.ApplyLogging();
        }
Exemple #2
0
 public void Save()
 {
     _config.Save();
     MyMechanicalConnectionBlockBasePatch.ApplyLogging();
 }
        public static int CheckGroup(out MyCubeGrid biggestGrid, MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Group group)
        {
            biggestGrid = null;

            try {
                double num = 0.0;

                Dictionary <MyCubeGrid, List <TopPart> > connectionMap = new Dictionary <MyCubeGrid, List <TopPart> >();

                foreach (MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Node groupNodes in group.Nodes)
                {
                    MyCubeGrid cubeGrid = groupNodes.NodeData;

                    if (cubeGrid == null)
                    {
                        continue;
                    }

                    if (cubeGrid.Physics == null)
                    {
                        continue;
                    }

                    double volume = cubeGrid.PositionComp.WorldAABB.Size.Volume;
                    if (volume > num)
                    {
                        num         = volume;
                        biggestGrid = cubeGrid;
                    }

                    HashSet <MySlimBlock> blocks = new HashSet <MySlimBlock>(cubeGrid.GetBlocks());
                    foreach (MySlimBlock block in blocks)
                    {
                        if (block == null || block.CubeGrid == null || block.IsDestroyed)
                        {
                            continue;
                        }

                        MyCubeBlock cubeBlock = block.FatBlock;

                        if (cubeBlock == null)
                        {
                            continue;
                        }

                        if (cubeBlock is MyMotorStator rotor)
                        {
                            if (MyMechanicalConnectionBlockBasePatch.IsIrrelevantType(rotor))
                            {
                                continue;
                            }

                            MyCubeGrid top    = rotor.TopGrid;
                            MyCubeGrid bottom = cubeGrid;

                            List <TopPart> connections;

                            if (top != null && !connectionMap.ContainsKey(top))
                            {
                                connectionMap.Add(top, new List <TopPart>());
                            }

                            if (!connectionMap.ContainsKey(bottom))
                            {
                                connections = new List <TopPart>();
                                connectionMap.Add(bottom, connections);
                            }
                            else
                            {
                                connections = connectionMap[bottom];
                            }

                            connections.Add(new TopPart(top));
                        }
                    }
                }

                int maxCount = 0;

                foreach (MyCubeGrid grid in new List <MyCubeGrid>(connectionMap.Keys))
                {
                    maxCount = Math.Max(maxCount, GetMaxTiefe(grid, connectionMap));
                }

                return(maxCount);
            } catch (Exception e) {
                Log.Error(e, "Error while checking grid!");
                return(0);
            }
        }