Exemple #1
0
        private bool TestPlacement()
        {
            if (MySession.Static.ControlledEntity != null &&
                (MySession.Static.GetCameraControllerEnum() == MyCameraControllerEnum.Entity || MySession.Static.GetCameraControllerEnum() == MyCameraControllerEnum.ThirdPersonSpectator || MySession.Static.GetCameraControllerEnum() == MyCameraControllerEnum.Spectator))
            {
                for (int i = 0; i < m_previewVoxelMaps.Count; ++i)
                {
                    var aabb = m_previewVoxelMaps[i].PositionComp.WorldAABB;

                    using (m_tmpResultList.GetClearToken())
                    {
                        MyGamePruningStructure.GetTopMostEntitiesInBox(ref aabb, m_tmpResultList);
                        if (TestPlacement(m_tmpResultList) == false)
                        {
                            return(false);
                        }
                    }
                }

                if (m_planetMode)
                {
                    for (int i = 0; i < m_copiedVoxelMaps.Count; ++i)
                    {
                        MyObjectBuilder_Planet builder = m_copiedVoxelMaps[i] as MyObjectBuilder_Planet;
                        if (builder != null)
                        {
                            using (m_tmpResultList.GetClearToken())
                            {
                                BoundingSphereD sphere = new BoundingSphereD(m_pastePosition, builder.Radius * 1.1f);
                                MyGamePruningStructure.GetAllTopMostEntitiesInSphere(ref sphere, m_tmpResultList);

                                if (TestPlacement(m_tmpResultList) == false)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }