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


C# MySlimBlock.ComputeWorldCenter方法代码示例

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


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

示例1: CastDDA

        /// <summary>
        /// Performs a grid raycast (is prone to aliasing effects).
        /// It can be recursive (it calls CastPhysicsRay when exiting the grid or when it hits an empty cell).
        /// </summary>
        /// <param name="cubeBlock">Starting block</param>
        /// <returns>Returns starting damage for current stack</returns>
        private MyRaycastDamageInfo CastDDA(MySlimBlock cubeBlock)
        {
            if (m_damageRemaining.ContainsKey(cubeBlock))
            {
                return m_damageRemaining[cubeBlock];
            }

            stackOverflowGuard = 0;

            m_castBlocks.Push(cubeBlock);

            Vector3D startPosition;
            cubeBlock.ComputeWorldCenter(out startPosition);

            List<Vector3I> cells = new List<Vector3I>();
            cubeBlock.CubeGrid.RayCastCells(startPosition, m_explosion.Center, cells);
            Vector3D oldCellWorldPosition = startPosition;
            foreach (var cell in cells)
            {
                Vector3D cellWorldPosition = Vector3D.Transform(new Vector3(cell.X, cell.Y, cell.Z) * cubeBlock.CubeGrid.GridSize, cubeBlock.CubeGrid.WorldMatrix);
                if (MyDebugDrawSettings.DEBUG_DRAW_EXPLOSION_DDA_RAYCASTS)
                {
                    DrawRay(oldCellWorldPosition, cellWorldPosition, Color.Red, false);
                    oldCellWorldPosition = cellWorldPosition;
                }
                var cube = cubeBlock.CubeGrid.GetCubeBlock(cell);
                if (cube == null)
                {
                    if (IsExplosionInsideCell(cell, cubeBlock.CubeGrid))
                    {
                        return new MyRaycastDamageInfo(m_explosionDamage, (float)(cellWorldPosition - m_explosion.Center).Length());
                    }
                    else
                    {
                        return CastPhysicsRay(cellWorldPosition);
                    }
                }
                if (cube != cubeBlock)
                {
                    if (m_damageRemaining.ContainsKey(cube))
                    {
                        return m_damageRemaining[cube];
                    }
                    else
                    {
                        if (!m_castBlocks.Contains(cube))
                        {
                            m_castBlocks.Push(cube);
                        }
                    }
                }
                else
                {
                    if (IsExplosionInsideCell(cell, cubeBlock.CubeGrid))
                    {
                        return new MyRaycastDamageInfo(m_explosionDamage, (float)(cellWorldPosition - m_explosion.Center).Length());
                    }
                }
            }

            return new MyRaycastDamageInfo(m_explosionDamage, (float)(startPosition - m_explosion.Center).Length());
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:68,代码来源:MyExplosionDamage.cs

示例2: PlayDestructionSound

        public static void PlayDestructionSound(MySlimBlock b)
        {
            MyPhysicalMaterialDefinition def = null;
            if (b.FatBlock is MyCompoundCubeBlock)
            {
                var compound = b.FatBlock as MyCompoundCubeBlock;
                if (compound.GetBlocksCount() > 0)
                    def = compound.GetBlocks()[0].BlockDefinition.PhysicalMaterial;
            }
            else if (b.FatBlock is MyFracturedBlock)
            {
                MyCubeBlockDefinition bDef;
                if (MyDefinitionManager.Static.TryGetDefinition<MyCubeBlockDefinition>((b.FatBlock as MyFracturedBlock).OriginalBlocks[0], out bDef))
                    def = bDef.PhysicalMaterial;
            }
            else
                def = b.BlockDefinition.PhysicalMaterial;

            if (def == null)
                return;

            MySoundPair destructionCue;
            if (def.GeneralSounds.TryGetValue(m_destructionSound, out destructionCue) && !destructionCue.SoundId.IsNull)
            {
                var emmiter = MyAudioComponent.TryGetSoundEmitter();
                if (emmiter == null)
                    return;
                Vector3D pos;
                b.ComputeWorldCenter(out pos);
                emmiter.SetPosition(pos);
                emmiter.PlaySound(destructionCue);
            }
        }
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:33,代码来源:MyAudioComponent.cs

示例3: CastDDA

        /// <summary>
        /// Performs a grid raycast (is prone to aliasing effects).
        /// It can be recursive (it calls CastPhysicsRay when exiting the grid or when it hits an empty cell).
        /// </summary>
        /// <param name="cubeBlock">Starting block</param>
        /// <returns>Returns starting damage for current stack</returns>
        private MyRaycastDamageInfo CastDDA(MySlimBlock cubeBlock)
        {
            if (m_damageRemaining.ContainsKey(cubeBlock))
            {
                return m_damageRemaining[cubeBlock];
            }

            stackOverflowGuard = 0;

            m_castBlocks.Push(cubeBlock);

            Vector3D startPosition;
            cubeBlock.ComputeWorldCenter(out startPosition);
            m_cells.Clear();
            cubeBlock.CubeGrid.RayCastCells(startPosition, m_explosion.Center, m_cells);
            var dir = (m_explosion.Center - startPosition);
            dir.Normalize();
            Vector3D oldCellWorldPosition = startPosition;
            foreach (var cell in m_cells)
            {
                Vector3D cellWorldPosition = Vector3D.Transform(cell * cubeBlock.CubeGrid.GridSize, cubeBlock.CubeGrid.WorldMatrix);
                if (MyDebugDrawSettings.DEBUG_DRAW_EXPLOSION_DDA_RAYCASTS)
                {
                    DrawRay(oldCellWorldPosition, cellWorldPosition, Color.Red, false);
                    oldCellWorldPosition = cellWorldPosition;
                }
                var cube = cubeBlock.CubeGrid.GetCubeBlock(cell);
                if (cube == null)
                {
                    if (IsExplosionInsideCell(cell, cubeBlock.CubeGrid))
                    {
                        return new MyRaycastDamageInfo(m_explosionDamage, (float)(cellWorldPosition - m_explosion.Center).Length());
                    }
                    else
                    {
                        //move to the edge of cube so we dont hit ourselves
                         //+ dir * (0.5 / dir).AbsMin()
                        //cmon cell is empty
                        return CastPhysicsRay(cellWorldPosition);
                    }
                }
                if (cube != cubeBlock)
                {
                    if (m_damageRemaining.ContainsKey(cube))
                    {
                        return m_damageRemaining[cube];
                    }
                    else
                    {
                        if (!m_castBlocks.Contains(cube))
                        {
                            m_castBlocks.Push(cube);
                        }
                    }
                }
                else
                {
                    if (IsExplosionInsideCell(cell, cubeBlock.CubeGrid))
                    {
                        return new MyRaycastDamageInfo(m_explosionDamage, (float)(cellWorldPosition - m_explosion.Center).Length());
                    }
                }
            }

            return new MyRaycastDamageInfo(m_explosionDamage, (float)(startPosition - m_explosion.Center).Length());
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:72,代码来源:MyGridExplosion.cs


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