Example #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);
        }
        public bool isStandableAtWithHeight(BlockLoc IslandSpace, int entityHeight)
        {
            BlockLoc underFoot = new BlockLoc(IslandSpace.WSX(), IslandSpace.WSY() - 1, IslandSpace.WSZ());//locInPath + new IntVector3(0, -1, 0);

            if (!isProfileSolidAtWithWithinCheck(IslandSpace) && isInProfileScope(IslandSpace))
            {
                if (isProfileSolidAtWithWithinCheck(underFoot))
                {
                    for (int i = 1; i < entityHeight; i++)
                    {
                        if (isProfileSolidAtWithWithinCheck(IslandSpace.getVector3WithAddedIntvec(new IntVector3(0, i, 0))))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #3
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);
        }
Example #4
0
        private void giveCharacterTravelJob(Character character, Ray rightClickRay)
        {
            Vector3?clicked = getIslandManager().getClosestIslandToLocation(character.getLocation()).getLastSpaceAlongRayConsideringResourceBlocks(rightClickRay);

            if (clicked.HasValue)
            {
                IntVector3           clickedBlock = new IntVector3((Vector3)clicked);
                IslandPathingProfile profile      = getIslandManager().getClosestIslandToLocation(character.getLocation()).getPathingProfile();

                PathHandler pathHandler = new PathHandler();

                Path path = pathHandler.getPathToSingleBlock(profile,
                                                             new BlockLoc(character.getFootLocation()), profile, new BlockLoc(clickedBlock.toVector3()), 2);

                TravelAlongPath walkTask = new TravelAlongPath(path);
                if (walkTask.isUseable())
                {
                    character.setJobAndCheckUseability(walkTask);
                }
                return;
            }

            Vector3?oceanClick = islandManager.getOceanIntersectionAtY1(rightClickRay);

            if (oceanClick.HasValue)
            {
                //List<BlockLoc> path = islandManager.getOceanPath((Vector3)oceanClick, character.getLocation());
                PathHandler pathHandler = new PathHandler();
                BlockLoc    goal        = new BlockLoc((Vector3)oceanClick);
                goal.setValuesInWorldSpace(goal.WSX(), 0, goal.WSZ());
                BlockLoc start = new BlockLoc(character.getLocation());
                start.setValuesInWorldSpace(start.WSX(), 0, start.WSZ());
                Path path = pathHandler.getPathToSingleBlock(getPathingProfile(),
                                                             start, getPathingProfile(), goal, 2);

                character.pathAlongOceanWithOceanPath(path);
            }
        }
Example #5
0
 protected virtual int approximateDistanceTo(BlockLoc endLoc)
 {
     return(Math.Abs(loc.WSX() - endLoc.WSX()) + Math.Abs(loc.WSY() - endLoc.WSY()) + Math.Abs(loc.WSZ() - endLoc.WSZ()));
 }