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


C# MyCubeGrid.CubeExists方法代码示例

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


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

示例1: GetAffectedCubes

        /// <summary>
        /// Gets all cubes which are affected by bone.
        /// </summary>
        /// <param name="onlyExisting">Returns only cubes which were added to skeleton.</param>
        public void GetAffectedCubes(Vector3I cube, Vector3I boneOffset, List<Vector3I> resultList, MyCubeGrid grid)
        {
            Debug.Assert(BoneDensity == 2, "This algorithm requires BoneDensity to be 2");

            Vector3I dist = boneOffset - Vector3I.One;
            Vector3I sign = Vector3I.Sign(dist);
            dist *= sign;

            Vector3I offset;
            for (offset.X = 0; offset.X <= dist.X; offset.X++)
            {
                for (offset.Y = 0; offset.Y <= dist.Y; offset.Y++)
                {
                    for (offset.Z = 0; offset.Z <= dist.Z; offset.Z++)
                    {
                        var targetCube = cube + offset * sign;
                        if (grid.CubeExists(targetCube)) resultList.Add(targetCube);
                    }
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:25,代码来源:MyGridSkeleton.cs

示例2: RemoveUnusedBones

        public void RemoveUnusedBones(MyCubeGrid grid)
        {
            ProfilerShort.Begin("RemoveUnusedBones");
            if (m_tmpRemovedCubes.Count != 0)
            {
                Debug.Assert(m_testedCubes.Count == 0);
                Debug.Assert(m_usedBones.Count == 0);

                foreach (var cube in m_tmpRemovedCubes)
                {
                    if (grid.CubeExists(cube))
                    {
                        if (!m_testedCubes.Contains(cube))
                        {
                            m_testedCubes.Add(cube);
                            AddUsedBones(cube);
                        }
                        continue;
                    }

                    Vector3I centerBonePos = cube * BoneDensity + Vector3I.One;
                    Vector3I dir, neighbor;

                    // Iterate over all the neighbors of the cube and check whether they are present in the grid
                    for (int x = -1; x <= 1; ++x) 
                        for (int y = -1; y <= 1; ++y)
                            for (int z = -1; z <= 1; ++z)
                            {
                                dir.X = x;
                                dir.Y = y;
                                dir.Z = z;
                                neighbor = cube + dir;

                                if (grid.CubeExists(neighbor) && !m_testedCubes.Contains(neighbor))
                                {
                                    m_testedCubes.Add(neighbor);
                                    AddUsedBones(neighbor);
                                }
                            }
                }

                foreach (var cube in m_tmpRemovedCubes)
                {
                    Vector3I pos = cube * BoneDensity;
                    for (int x = 0; x <= BoneDensity; ++x)
                    {
                        for (int y = 0; y <= BoneDensity; ++y)
                        {
                            for (int z = 0; z <= BoneDensity; ++z)
                            {
                                if (!m_usedBones.Contains(pos)) ClearBone(ref pos);

                                pos.Z++;
                            }
                            pos.Y++;
                            pos.Z -= BoneDensity + 1;
                        }
                        pos.X++;
                        pos.Y -= BoneDensity + 1;
                    }
                }

                m_testedCubes.Clear();
                m_usedBones.Clear();
                m_tmpRemovedCubes.Clear();
            }
            ProfilerShort.End();
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:68,代码来源:MyGridSkeleton.cs

示例3: GetCubeFromBone

        private Vector3I? GetCubeFromBone(Vector3I bone, MyCubeGrid grid)
        {
            Vector3I result = Vector3I.Zero;
            result = bone / 2;

            if (grid.CubeExists(result))
            {
                return result;
            }

            for (int i = -1; i <= 1; i++)
                for (int j = -1; j <=1; j++)
                    for (int k = -1; k <= 1; k++)
                    {
                        Vector3I current = result + new Vector3I(i, j, k);
                        Vector3I test = bone - current * 2;

                        if (test.X > 2 || test.Y > 2 || test.Z > 2)
                            continue;

                        if (grid.CubeExists(current))
                        {
                            return current;
                        }
                    }

            return null;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:28,代码来源:MyGridSkeleton.cs


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