public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { List <BlockLoc> nextBlocksToBuild = workingProfile.getTreeJobSite().getTreeTrunkBlocks(); foreach (BlockLoc claimed in taskTracker.blocksCurrentlyClaimed()) { nextBlocksToBuild.Remove(claimed); } BlockLoc blockFoundToChop; PathHandler pathHadler = new PathHandler(); Path path = pathHadler.getPathToMakeTheseBlocksAvaiable( workingProfile.getTreeJobSite().getProfile(), new BlockLoc(character.getFootLocation()), workingProfile.getTreeJobSite().getProfile(), nextBlocksToBuild, 2, out blockFoundToChop); TravelAlongPath walkJob = new TravelAlongPath(path, getWaitJobWithReturn(45, new ChopTreeJob(character, workingProfile, blockFoundToChop))); if (!walkJob.isUseable()) { failedToFindATreeToChop = true; return(new CharacterTask.SwitchJob(new UnemployedJob())); } return(new CharacterTask.SwitchJob(walkJob)); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { List <BlockLoc> goalsForBlockPickup = workingProfile.getBlocksToGetThisTypeFrom(typeToFetch).ToList(); BlockLoc blockToPlaceResourceIn; PathHandler pathHandler = new PathHandler(); foreach (BlockLoc test in taskTracker.blocksCurrentlyClaimed()) { goalsForBlockPickup.Remove(test); } if (goalsForBlockPickup.Count > 0) { Path path = pathHandler. getPathToMakeTheseBlocksAvaiable(workingProfile.getPathingProfile(), new BlockLoc(character.getFootLocation()), workingProfile.getPathingProfile(), goalsForBlockPickup, 2, out blockToPlaceResourceIn); targetBlock = blockToPlaceResourceIn; TravelAlongPath travel = new TravelAlongPath(path, new PickUpResourceJob(typeToFetch, character, toReturnTo, workingProfile, blockToPlaceResourceIn)); return(new CharacterTask.SwitchJob(travel)); } else { return(new CharacterTask.SwitchJob(new UnemployedJob())); } }
private void setWalkJobToRandomStep() { PathHandler pathHandler = new PathHandler(); Path path = pathHandler.getPathToSingleBlock(pathingProfile, new BlockLoc(character.getFootLocation()), pathingProfile, BlockLoc.AddIntVec3(new BlockLoc(character.getFootLocation()), pathingProfile.getRandomMove()), 2); currentWalkJob = new TravelAlongPath(path); }
public override Job getJobWhenClicked(Character nWorker, IslandPathingProfile profile, ActorStateProfile actorState) { IslandGame.GameWorld.CharactersAndAI.CompleteTaskJob getInBoat = new IslandGame.GameWorld.CharactersAndAI.CompleteTaskJob(nWorker, new CharacterTask.GetInBoat(this)); Path path = new PathHandler(). getPathToSingleBlock(profile, new BlockLoc(nWorker.getFootLocation()), profile, new BlockLoc(getFootLocation()), 2); TravelAlongPath travel = new TravelAlongPath(path, getInBoat); return(travel); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { if (farm.getNumFarmBlocks() > 0) { List <BlockLoc> nextBlocksToTend = farm.getBlocksNeedingTending().ToList(); foreach (BlockLoc claimed in taskTracker.blocksCurrentlyClaimed()) { nextBlocksToTend.Remove(claimed); } PathHandler pathHandler = new PathHandler(); Path path = pathHandler.getPathToBlockEnumerable(farm.getProfile(), new BlockLoc(character.getFootLocation()), farm.getProfile(), nextBlocksToTend, 2); TravelAlongPath travelJob = new TravelAlongPath(path); if (travelJob.isUseable()) { BlockLoc?toTend = path.getLast(); if (toTend != null) { TravelAlongPath travelToSwitchTo = new TravelAlongPath(path, getWaitJobWithReturn(30, new TendFarmBlockJob((BlockLoc)toTend, workingProfile, farm, character))); return(new CharacterTask.SwitchJob(travelToSwitchTo)); } return(new CharacterTask.NoTask()); } else { hasFailedToFindBlock = true; return(new CharacterTask.NoTask()); } } else { return(new CharacterTask.NoTask()); } }
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); } }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { List <BlockLoc> blocksToRemove = workingProfile.getExcavationSite().getBlocksToRemove(); if (blocksToRemove.Count > 0) { BlockLoc toDestroy; foreach (BlockLoc claimed in taskTracker.blocksCurrentlyClaimed()) { blocksToRemove.Remove(claimed); } PathHandler pathHandler = new PathHandlerPreferringHigherBlocks(); Path path = pathHandler.getPathToMakeTheseBlocksAvaiable(workingProfile.getPathingProfile(), new BlockLoc(character.getFootLocation()), workingProfile.getPathingProfile(), blocksToRemove, 2, out toDestroy); TravelAlongPath toSwitchTo = new TravelAlongPath(path, getWaitJobWithReturn(45, new DestroyBlockJob(character, workingProfile, toDestroy))); return(new CharacterTask.SwitchJob(toSwitchTo)); } else { return(new CharacterTask.SwitchJob(new UnemployedJob())); } }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { //return new CharacterTask.PlaceResource(targetBlock, carriedType); List <BlockLoc> goalsForBlockPlacement = workingProfile.getResourcesJobSite().getBlocksToStoreThisTypeIn(carriedType).ToList(); foreach (BlockLoc test in taskTracker.blocksCurrentlyClaimed()) { goalsForBlockPlacement.Remove(test); } PathHandler pathHandler = new PathHandlerPreferringLowerBlocks(); if (goalsForBlockPlacement.Count > 0) { TravelAlongPath walkJob; Path path = pathHandler. getPathToMakeTheseBlocksAvaiable(workingProfile.getPathingProfile(), new BlockLoc(character.getFootLocation()), workingProfile.getPathingProfile(), goalsForBlockPlacement, 2, out targetBlock); Job toSwichToAfterWalk = new PlaceResourceJob(carriedType, character, toReturnTo, workingProfile, targetBlock); walkJob = new TravelAlongPath(path, getWaitJobWithReturn(5, toSwichToAfterWalk)); if (path.length() == 0) { return(new CharacterTask.SwitchJob(new UnemployedJob())); } return(new CharacterTask.SwitchJob(walkJob)); } else { //TODO: make it find the nearest good maybeSpace to place a resource block return(new CharacterTask.SwitchJob(new UnemployedJob())); } }