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); }
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); } }