예제 #1
0
        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));
        }
예제 #2
0
        public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker)
        {
            if (currentWalkJob == null || !currentWalkJob.isUseable() || !currentWalkJob.isComplete())
            {
                setWalkJobToRandomStep();
            }


            return(currentWalkJob.getCurrentTask(taskTracker));
        }
예제 #3
0
        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());
            }
        }
예제 #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);
            }
        }