コード例 #1
0
ファイル: ChunkData.cs プロジェクト: chrisapril/dwarfcorp
        public bool GetVoxel(VoxelChunk checkFirst, Vector3 worldLocation, ref Voxel newReference)
        {
            while (true)
            {
                if (checkFirst != null)
                {
                    if (checkFirst.IsWorldLocationValid(worldLocation))
                    {
                        if (!checkFirst.GetVoxelAtWorldLocation(worldLocation, ref newReference))
                        {
                            return(false);
                        }

                        Vector3 grid = checkFirst.WorldToGrid(worldLocation);
                        newReference.Chunk        = checkFirst;
                        newReference.GridPosition = new Vector3((int)grid.X, (int)grid.Y, (int)grid.Z);

                        return(true);
                    }

                    checkFirst = null;
                    continue;
                }

                VoxelChunk chunk = GetVoxelChunkAtWorldLocation(worldLocation);

                if (chunk == null)
                {
                    return(false);
                }


                return(chunk.GetVoxelAtWorldLocation(worldLocation, ref newReference));
            }
        }
コード例 #2
0
ファイル: ChunkData.cs プロジェクト: NakedFury/dwarfcorp
        public bool GetVoxel(VoxelChunk checkFirst, Vector3 worldLocation, ref Voxel newReference)
        {
            if (checkFirst != null)
            {
                if (checkFirst.GetVoxelAtWorldLocation(worldLocation, ref newReference))
                {
                    return(true);
                }
            }

            VoxelChunk chunk = GetVoxelChunkAtWorldLocation(worldLocation);

            if (chunk == null)
            {
                return(false);
            }

            return(chunk.GetVoxelAtValidWorldLocation(worldLocation, ref newReference));
        }
コード例 #3
0
ファイル: ChunkData.cs プロジェクト: chrisapril/dwarfcorp
        /// <summary>
        /// TODO: Get rid of the recursion
        /// Recursive function which gets all the voxels at a position in the world, assuming the voxel is in a given chunk
        /// </summary>
        /// <param Name="checkFirst">The voxel chunk to check first</param>
        /// <param Name="worldLocation">The point in the world to check</param>
        /// <param Name="toReturn">A list of voxels to get</param>
        /// <param Name="depth">The depth of the recursion</param>
        public bool GetNonNullVoxelAtWorldLocationCheckFirst(VoxelChunk checkFirst, Vector3 worldLocation, ref Voxel toReturn)
        {
            if (checkFirst != null)
            {
                if (!checkFirst.IsWorldLocationValid(worldLocation))
                {
                    return(GetNonNullVoxelAtWorldLocation(worldLocation, ref toReturn));
                }

                bool success = checkFirst.GetVoxelAtWorldLocation(worldLocation, ref toReturn);

                if (success && !toReturn.IsEmpty)
                {
                    return(true);
                }
                return(GetNonNullVoxelAtWorldLocation(worldLocation, ref toReturn));
            }

            VoxelChunk chunk = GetVoxelChunkAtWorldLocation(worldLocation);

            if (chunk == null)
            {
                return(false);
            }

            if (!chunk.IsWorldLocationValid(worldLocation))
            {
                return(false);
            }

            if (chunk.GetVoxelAtWorldLocation(worldLocation, ref toReturn) && !toReturn.IsEmpty)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: ChunkData.cs プロジェクト: maroussil/dwarfcorp
        public bool GetVoxel(VoxelChunk checkFirst, Vector3 worldLocation, ref Voxel newReference)
        {
            while(true)
            {
                if(checkFirst != null)
                {
                    if(checkFirst.IsWorldLocationValid(worldLocation))
                    {
                        if(!checkFirst.GetVoxelAtWorldLocation(worldLocation, ref newReference))
                        {
                            return false;
                        }

                        Vector3 grid = checkFirst.WorldToGrid(worldLocation);
                        newReference.Chunk = checkFirst;
                        newReference.GridPosition = new Vector3((int) grid.X, (int) grid.Y, (int) grid.Z);

                        return true;
                    }

                    checkFirst = null;
                    continue;
                }

                VoxelChunk chunk = GetVoxelChunkAtWorldLocation(worldLocation);

                if (chunk == null)
                {
                    return false;
                }

                return chunk.GetVoxelAtWorldLocation(worldLocation, ref newReference);
            }
        }
コード例 #5
0
ファイル: ChunkData.cs プロジェクト: maroussil/dwarfcorp
        /// <summary>
        /// TODO: Get rid of the recursion
        /// Recursive function which gets all the voxels at a position in the world, assuming the voxel is in a given chunk
        /// </summary>
        /// <param Name="checkFirst">The voxel chunk to check first</param>
        /// <param Name="worldLocation">The point in the world to check</param>
        /// <param Name="toReturn">A list of voxels to get</param>
        /// <param Name="depth">The depth of the recursion</param>
        public bool GetNonNullVoxelAtWorldLocationCheckFirst(VoxelChunk checkFirst, Vector3 worldLocation, ref Voxel toReturn)
        {
            if(checkFirst != null)
            {
                if(!checkFirst.IsWorldLocationValid(worldLocation))
                {
                    return GetNonNullVoxelAtWorldLocation(worldLocation, ref toReturn);
                }

                bool success = checkFirst.GetVoxelAtWorldLocation(worldLocation, ref toReturn);

                if(success && !toReturn.IsEmpty)
                {
                    return true;
                }
                return GetNonNullVoxelAtWorldLocation(worldLocation, ref toReturn);
            }

            VoxelChunk chunk = GetVoxelChunkAtWorldLocation(worldLocation);

            if(chunk == null)
            {
                return false;
            }

            if(!chunk.IsWorldLocationValid(worldLocation))
            {
                return false;
            }

            if (chunk.GetVoxelAtWorldLocation(worldLocation, ref toReturn) && !toReturn.IsEmpty)
            {
                return true;
            }
            else
            {
                return false;
            }
        }