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


C# MyCubeGrid.GetBlocks方法代码示例

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


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

示例1: MyStructuralIntegrity

        public MyStructuralIntegrity(MyCubeGrid cubeGrid)
        {
            m_cubeGrid = cubeGrid;
            m_cubeGrid.OnBlockAdded += cubeGrid_OnBlockAdded;

            switch (1)
            {
                case 0: m_simulator = new MyJacobianConstraintSimulator(m_cubeGrid.GetBlocks().Count); break;
                case 1: m_simulator = new MyAdvancedStaticSimulator(m_cubeGrid); break;
				case 2: m_simulator = new MyOndraSimulator(m_cubeGrid); break;
                case 3: m_simulator = new MyOndraSimulator2(m_cubeGrid); break;
                case 4: m_simulator = new MyOndraSimulator3(m_cubeGrid); break;
            }

            foreach (var block in m_cubeGrid.GetBlocks())
            {
                cubeGrid_OnBlockAdded(block);
            }
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:19,代码来源:MyStructuralIntegrity.cs

示例2: GetBattlePoints

        public static ulong GetBattlePoints(MyCubeGrid grid)
        {
            ulong points = 0;

            foreach (var block in grid.GetBlocks())
            {
                MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
                if (compoundBlock != null)
                {
                    foreach (var blockInCompound in compoundBlock.GetBlocks())
                        points += GetBattlePoints(blockInCompound);
                }
                else
                {
                    points += GetBattlePoints(block);
                }
            }

            return points;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:20,代码来源:MyBattleHelper.cs

示例3: CheckMergeConnectivity

        public static bool CheckMergeConnectivity(MyCubeGrid hitGrid, MyCubeGrid gridToMerge, Vector3I gridOffset)
        {
            // CH: Beware, this funtion seems horribly inefficient! Think twice before using it (e.g. don't use it in a 10000x loop) or optimize it :-)
            MatrixI mergeTransform = hitGrid.CalculateMergeTransform(gridToMerge, gridOffset);
            Quaternion mergeOri;
            mergeTransform.GetBlockOrientation().GetQuaternion(out mergeOri);

            foreach (var block in gridToMerge.GetBlocks())
            {
                Quaternion ori;
                Vector3I pos = Vector3I.Transform(block.Position, mergeTransform);
                block.Orientation.GetQuaternion(out ori);
                //Matrix mergeGridMatrix = Matrix.CreateFromQuaternion(mergeOri);
                //Matrix oriMatrix = Matrix.CreateFromQuaternion(ori);
                //Matrix result = oriMatrix * mergeGridMatrix;
                //Quaternion quatFromMatrix = Quaternion.CreateFromRotationMatrix(result);
                // Seems that quaternion multiplication is reversed to matrix multiplication!
                ori = mergeOri * ori;
				var mountPoints = block.BlockDefinition.GetBuildProgressModelMountPoints(block.BuildLevelRatio);
                if (MyCubeGrid.CheckConnectivity(hitGrid, block.BlockDefinition, mountPoints, ref ori, ref pos))
                    return true;
            }

            return false;
        }
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:25,代码来源:MyCubeGrid.Static.cs

示例4: ShouldBeStatic

        public static bool ShouldBeStatic(MyCubeGrid grid)
        {
            if (grid.GridSizeEnum == MyCubeSize.Small && MyCubeGridSmallToLargeConnection.Static != null &&
                MyCubeGridSmallToLargeConnection.Static.TestGridSmallToLargeConnection(grid))
                return true;

            foreach (var block in grid.GetBlocks())
            {
                if (IsInVoxels(block))
                    return true;
            }
            return false;
        }
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:13,代码来源:MyCubeGrid.Static.cs

示例5: AddGrid

        public bool AddGrid(MyCubeGrid grid)
        {
            //TODO: create static list
            List<Vector3I> lst = new List<Vector3I>();

            foreach (var block in grid.GetBlocks())
            {
                if (block.FatBlock is MyCompoundCubeBlock)
                {
                    bool added = false;
                    foreach (var subb in (block.FatBlock as MyCompoundCubeBlock).GetBlocks())
                    {
                        if (AddBlock(subb))
                        {
                            if (!added)
                                lst.Add(block.Position);

                            added = true;
                        }
                    }
                }
                else
                {
                    if (AddBlock(block))
                    {
                        lst.Add(block.Position);
                    }
                }
            }

            if (lst.Count > 0)
            {
                grid.RazeBlocks(lst);
                return true;
            }

            return false;
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:38,代码来源:MyInventory.cs

示例6: GetTrashState

        static MyTrashRemovalFlags GetTrashState(MyCubeGrid grid, MyTrashRemovalSettings settings, out float metric,bool checkGroup = false)
        {
            metric = -1;

            HashSet<MySlimBlock> blocks = grid.GetBlocks();

            if (blocks != null  && blocks.Count > settings.BlockCountThreshold)
            {
                metric = settings.BlockCountThreshold;
                return MyTrashRemovalFlags.WithBlockCount;
            }

            if (!settings.HasFlag(MyTrashRemovalFlags.Fixed) && grid.IsStatic)
                return MyTrashRemovalFlags.Fixed;

            bool isAccelerating = false;
            bool isLinearMoving = false;
            bool isStationary = true;

            if (grid.Physics != null)
            {
                isAccelerating = grid.Physics.AngularAcceleration.AbsMax() > 0.05f || grid.Physics.LinearAcceleration.AbsMax() > 0.05f;
                isStationary = grid.Physics.AngularVelocity.AbsMax() < 0.05f && grid.Physics.LinearVelocity.AbsMax() < 0.05f;
                isLinearMoving = !isAccelerating && !isStationary;
            }

            if (!settings.HasFlag(MyTrashRemovalFlags.Stationary) && isStationary)
                return MyTrashRemovalFlags.Stationary;

            if (!settings.HasFlag(MyTrashRemovalFlags.Linear) && isLinearMoving)
                return MyTrashRemovalFlags.Linear;

            if (!settings.HasFlag(MyTrashRemovalFlags.Accelerating) && isAccelerating)
                return MyTrashRemovalFlags.Accelerating;


            if (grid.GridSystems != null)
            {
                bool isPowered = grid.GridSystems.ResourceDistributor.ResourceStateByType(MyResourceDistributorComponent.ElectricityId) != MyResourceStateEnum.NoPower;
                if (!settings.HasFlag(MyTrashRemovalFlags.Powered) && isPowered)
                    return MyTrashRemovalFlags.Powered;

                if (!settings.HasFlag(MyTrashRemovalFlags.Controlled) && grid.GridSystems.ControlSystem.IsControlled)
                    return MyTrashRemovalFlags.Controlled;

                if (!settings.HasFlag(MyTrashRemovalFlags.WithProduction) && grid.GridSystems.ControlSystem.IsControlled)
                    return MyTrashRemovalFlags.WithProduction;
            }

            if (!settings.HasFlag(MyTrashRemovalFlags.WithMedBay) && grid.BlocksCounters.GetValueOrDefault(typeof(MyObjectBuilder_MedicalRoom)) > 0)
                return MyTrashRemovalFlags.WithMedBay;

            if (IsCloseToPlayerOrCamera(grid, settings.PlayerDistanceThreshold))
            {
                metric = settings.PlayerDistanceThreshold;
                return MyTrashRemovalFlags.DistanceFromPlayer;
            }

            if (checkGroup && MyCubeGridGroups.Static.Physical != null)
            {
                var physicalGroup = MyCubeGridGroups.Static.Physical.GetGroup(grid);
                if (physicalGroup != null)
                {
                    foreach (var cubeGrid in physicalGroup.Nodes)
                    {
                        if (cubeGrid.NodeData == null || cubeGrid.NodeData.Physics == null || cubeGrid.NodeData.Physics.Shape == null || cubeGrid.NodeData == grid)
                            continue;


                        var subGridReason = GetTrashState(cubeGrid.NodeData, settings, out metric, false);
                        if (subGridReason != MyTrashRemovalFlags.None)
                        {
                            return subGridReason;
                        }
                    }
                }
            }

            return MyTrashRemovalFlags.None;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:80,代码来源:MyTrashRemoval.cs

示例7: MyOndraSimulator3

 public MyOndraSimulator3(MyCubeGrid grid)
 {
     m_grid = grid;
     m_selectedGrid = m_grid;
     SelectedCube = m_grid.GetBlocks().First().Position;
 }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:6,代码来源:MyOndraSimulator3.cs

示例8: MyAdvancedStaticSimulator

 public MyAdvancedStaticSimulator(MyCubeGrid grid)
 {
     m_grid = grid;
     m_selectedGrid = m_grid;
     if (m_grid.BlocksCount > 0)
         SelectedCube = m_grid.GetBlocks().First().Position;
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:7,代码来源:MyAdvancedStaticSimulator.cs

示例9: AddGrid

 public bool AddGrid(MyCubeGrid grid)
 {
     HashSet<Sandbox.Game.Entities.Cube.MySlimBlock> lst = new HashSet<Sandbox.Game.Entities.Cube.MySlimBlock>();
     foreach(var b in grid.GetBlocks())
     {
         if(b.FatBlock is MyCompoundCubeBlock)
         {
             foreach(var subb in (b.FatBlock as MyCompoundCubeBlock).GetBlocks())
             {
                 if (AddBlock(subb))
                     lst.Add(b);
             }
         }
         else
         {
             if (AddBlock(b))
                 lst.Add(b);
         }
     }
     foreach(var b in lst)
     {
         grid.RemoveBlock(b);
     }
     return lst.Count > 0;
     //grid.Close();
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:26,代码来源:MyInventory.cs

示例10: AddGrid

        public bool AddGrid(MyCubeGrid grid)
        {
            HashSet<Sandbox.Game.Entities.Cube.MySlimBlock> lst = new HashSet<Sandbox.Game.Entities.Cube.MySlimBlock>();

            foreach (var block in grid.GetBlocks())
            {
                if (block.FatBlock is MyCompoundCubeBlock)
                {
                    bool added = false;
                    foreach (var subb in (block.FatBlock as MyCompoundCubeBlock).GetBlocks())
                    {
                        if (AddBlock(subb))
                        {
                            added = true;
                        }
                    }
                    if (added)
                    {
                        lst.Add(block);
                    }
                }
                else
                {
                    if (AddBlock(block))
                    {
                        lst.Add(block);
                    }
                }
            }


            foreach (var b in lst)
            {
                Vector3I pos = b.Position;
                Vector3UByte size = new Vector3UByte(1, 1, 1);
                grid.RazeBlocks(ref pos, ref size);
                //   grid.RemoveBlock(b, true); not synced
            }

            return lst.Count > 0;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:41,代码来源:MyInventory.cs

示例11: ShouldBeStatic

        static bool ShouldBeStatic(MyCubeGrid grid, MyCubeGrid.MyTestDynamicReason testReason)
        {
            if (grid.GridSizeEnum == MyCubeSize.Small && MyCubeGridSmallToLargeConnection.Static != null &&
                MyCubeGridSmallToLargeConnection.Static.TestGridSmallToLargeConnection(grid))
                return true;

            if (testReason == MyTestDynamicReason.GridSplit)
            {
                foreach (var block in grid.GetBlocks())
                {
                    if (IsInVoxels(block))
                        return true;
                }
                return false;
            }

            return grid.IsStatic;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:18,代码来源:MyCubeGrid.Static.cs

示例12: CheckValidBlocksRotation

        public static bool CheckValidBlocksRotation(Matrix gridLocalMatrix, MyCubeGrid grid)
        {
            Matrix blockLocalMatrix;
            bool retval = true;

            foreach (var block in grid.GetBlocks())
            {
                MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock;
                if (compoundBlock != null) 
                {
                    foreach (var blockInCompound in compoundBlock.GetBlocks())
                    {
                        blockInCompound.Orientation.GetMatrix(out blockLocalMatrix);
                        blockLocalMatrix = blockLocalMatrix * gridLocalMatrix;

                        retval = retval && CheckValidBlockRotation(blockLocalMatrix, blockInCompound.BlockDefinition.Direction, blockInCompound.BlockDefinition.Rotation);
                        if (!retval)
                            break;
                    }
                }
                else 
                {
                    block.Orientation.GetMatrix(out blockLocalMatrix);
                    blockLocalMatrix = blockLocalMatrix * gridLocalMatrix;

                    retval = retval && CheckValidBlockRotation(blockLocalMatrix, block.BlockDefinition.Direction, block.BlockDefinition.Rotation);
                }

                if (!retval)
                    break;
            }

            return retval;
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:34,代码来源:MyCubeBuilder.cs


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