Exemple #1
0
        public LinkedList <BlockLoc> GetBlocksBoundBy(BlockLoc loc1, BlockLoc loc2)
        {
            BlockLoc min = new BlockLoc((int)Math.Min(loc1.WSX(), loc2.WSX()), (int)Math.Min(loc1.WSY(), loc2.WSY()), (int)Math.Min(loc1.WSZ(), loc2.WSZ()));
            BlockLoc max = new BlockLoc((int)Math.Max(loc1.WSX(), loc2.WSX()), (int)Math.Max(loc1.WSY(), loc2.WSY()), (int)Math.Max(loc1.WSZ(), loc2.WSZ()));

            LinkedList <BlockLoc> result = new LinkedList <BlockLoc>();

            Island relevant  = getIslandManager().getClosestIslandToLocation(loc2.toWorldSpaceVector3());
            int    spaceSize = (max.WSY() - min.WSY());

            Console.WriteLine(spaceSize + " space size");
            for (int x = min.WSX(); x <= max.WSX(); x++)
            {
                for (int y = min.WSY(); y <= max.WSY(); y++)
                {
                    for (int z = min.WSZ(); z <= max.WSZ(); z++)
                    {
                        BlockLoc toTest = new BlockLoc(x, y, z);
                        byte?    block  = islandManager.getBlockAtOnGivenIsland(ref toTest, relevant);
                        if (block.HasValue)
                        {
                            if (PaintedCubeSpace.isSolidType((byte)block))
                            {
                                result.AddLast(new BlockLoc(x, y, z));
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #2
0
 public bool isChunkSpaceSolidAt(int x, int y, int z)
 {
     if (withinChunkSpaceInChunkSpace(x, y, z))
     {
         byte block  = getChunkSpaceBlockAtWithoutWithinCheck(x, y, z);
         bool result = PaintedCubeSpace.isSolidType(block);
         return(result);
     }
     return(false);
 }
Exemple #3
0
        public bool isSurfaceBlock(ref BlockLoc loc)
        {
            byte?    block         = islandManager.getBlockAt(ref loc);
            BlockLoc blockLocAbove = BlockLoc.AddIntVec3(loc, new IntVector3(0, 1, 0));
            byte?    aboveBlock    = islandManager.getBlockAt(ref blockLocAbove);

            if (block.HasValue && aboveBlock.HasValue)
            {
                if (PaintedCubeSpace.isOpaqueType((byte)block) && !PaintedCubeSpace.isOpaqueType((byte)aboveBlock))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #4
0
        public LinkedList <BlockLoc> getSurfaceBlocksBoundBy(BlockLoc loc1, BlockLoc loc2)
        {
            BlockLoc min = new BlockLoc((int)Math.Min(loc1.WSX(), loc2.WSX()), (int)Math.Min(loc1.WSY(), loc2.WSY()), (int)Math.Min(loc1.WSZ(), loc2.WSZ()));
            BlockLoc max = new BlockLoc((int)Math.Max(loc1.WSX(), loc2.WSX()), (int)Math.Max(loc1.WSY(), loc2.WSY()), (int)Math.Max(loc1.WSZ(), loc2.WSZ()));

            LinkedList <BlockLoc> result = new LinkedList <BlockLoc>();

            Island relevant = getIslandManager().getClosestIslandToLocation(loc2.toWorldSpaceVector3());

            BlockLoc aboveBlockLoc = new BlockLoc();
            BlockLoc blockAtLoc    = new BlockLoc();

            for (int x = min.WSX(); x <= max.WSX(); x++)
            {
                for (int y = min.WSY(); y <= max.WSY(); y++)
                {
                    for (int z = min.WSZ(); z <= max.WSZ(); z++)
                    {
                        blockAtLoc.setValuesInWorldSpace(x, y, z);
                        byte?block = islandManager.getBlockAtOnGivenIsland(ref blockAtLoc, relevant);
                        if (block.HasValue)
                        {
                            if (PaintedCubeSpace.isSolidType((byte)block))
                            {
                                aboveBlockLoc.setValuesInWorldSpace(x, y + 1, z);
                                byte?aboveBlock = islandManager.getBlockAtOnGivenIsland(ref aboveBlockLoc, relevant);
                                if (aboveBlock.HasValue)
                                {
                                    if (!PaintedCubeSpace.isOpaqueType((byte)aboveBlock))
                                    {
                                        result.AddLast(new BlockLoc(x, y, z));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemple #5
0
 public Chunk(int nChunkWidth, int nChunkHeight, int xOffset, int zOffset)
 {
     space = new PaintedCubeSpace(nChunkWidth, nChunkHeight, new Vector3(xOffset, 0, zOffset));
 }