コード例 #1
0
        public static bool HasVoxelAt(this IMyVoxelBase Voxel, Vector3I LocalPoint)
        {
            if (Voxel == null)
            {
                throw new ArgumentNullException(nameof(Voxel));
            }
            if (Voxel.Storage == null)
            {
                throw new ArgumentException("Voxel.Storage is null");
            }

            MyVoxelBase _Voxel = Voxel as MyVoxelBase;
            VoxelHit    hit    = new VoxelHit();

            _Voxel.Storage.ExecuteOperationFast(ref hit, MyStorageDataTypeFlags.Content, ref LocalPoint, ref LocalPoint, false);
            return(hit.HasHit);
        }
コード例 #2
0
        public static bool HasVoxelAt(this IMyVoxelBase Voxel, Vector3D Point)
        {
            if (Voxel == null)
            {
                throw new ArgumentNullException(nameof(Voxel));
            }
            if (Voxel.Storage == null)
            {
                throw new ArgumentException("Voxel.Storage is null");
            }

            MyVoxelBase _Voxel = Voxel as MyVoxelBase;
            VoxelHit    hit    = new VoxelHit();

            //The following magic is taken from Sandbox.Game.Entities.VoxelBaseExtensions
            Vector3 value;

            MyVoxelCoordSystems.WorldPositionToLocalPosition(Point, _Voxel.PositionComp.WorldMatrix, _Voxel.PositionComp.WorldMatrixInvScaled, _Voxel.SizeInMetresHalf, out value);
            Vector3I voxelCoord = new Vector3I(value / 1f) + _Voxel.StorageMin;

            _Voxel.Storage.ExecuteOperationFast(ref hit, MyStorageDataTypeFlags.Content, ref voxelCoord, ref voxelCoord, false);
            return(hit.HasHit);
        }