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) { if (!path.isUseable()) { return(new CharacterTask.SwitchJob(new UnemployedJob())); } else if (path.length() == 0) { if (toReturnTo != null) { return(new CharacterTask.SwitchJob(toReturnTo)); } else { return(new CharacterTask.SwitchJob(new UnemployedJob())); } } else if (!currentStep.isComplete()) { return(currentStep); } else { path.removeAt(0); if (path != null && path.length() > 0) { currentStep = new CharacterTask.StepToBlock(path.getFirst()); } return(currentStep); } }
public override List <ActorAction> update(CharacterTaskTracker taskTracker) { updateSwingResetTime(); performOceanPhysics(); List <ActorAction> actions = new List <ActorAction>(); setRootPartLocation(physics.AABB.middle()); List <AnimationType> animations = UpdateJobTasks(actions, taskTracker); if (isWalkingOverride && !(job is CaptainingBoatJob)) { animations.Add(AnimationType.walking); } updateAnimations(animations); if (isDead()) { actions.Add(new ActorDieAction(this)); } setupBodyPartGroupGivenCurrentJob(); return(actions); }
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())); } }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { Actor toAttack = getNearestEnemyInAgroRange(); if (toAttack != null) { float distToTarget = Vector3.Distance(character.getLocation(), toAttack.getLocation()); if (distToTarget > loseInterestDistance || toAttack.isDead()) { return(new CharacterTask.NoTask()); } else if (distToTarget > getDesiredDistanceFromTarget()) { return(new CharacterTask.WalkTowardPoint(toAttack.getLocation())); } else if (distToTarget < 1) { Vector3 fromTargetToMe = (character.getFootLocation() - toAttack.getFootLocation()); fromTargetToMe.Normalize(); return(new CharacterTask.WalkTowardPoint(character.getFootLocation() + fromTargetToMe)); } else { // return new CharacterTask.NoTask(); if (character.canSwing()) { return(new CharacterTask.DoStrikeOfWorkAlongRay(character, character.getLocation(), character.getStrikeRange(), toAttack.getLocation() - character.getLocation())); } else { return(new CharacterTask.NoTask()); } } } if (character.getFaction() != Actor.Faction.friendly) { /* PathHandler pathHandler = new PathHandler(); * Path path = pathHandler.getPathToSingleBlock(pathingProfile, * new BlockLoc(character.getFootLocation()), pathingProfile, * BlockLoc.AddIntVec3(new BlockLoc(character.getFootLocation()), pathingProfile.getRandomMove()), 2); * TravelAlongPath currentWalkJob = new TravelAlongPath(path, new AggressiveStanceJob(pathingProfile, actorProfile, character)); * if (currentWalkJob.isUseable()) * { * // return new CharacterTask.SwitchJob(currentWalkJob); * }*/ BlockLoc toTry = BlockLoc.AddIntVec3(new BlockLoc(character.getFootLocation()), World.getPathingProfile().getRandomMove()); if (World.getPathingProfile().isStandableAtWithHeight(toTry, 2)) { List <BlockLoc> pathList = new List <BlockLoc>(); pathList.Add(toTry); Path path = new Path(pathList); return(new CharacterTask.SwitchJob(new TravelAlongPath(path, new AggressiveStanceJob(character)))); } } return(new CharacterTask.NoTask()); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { if (currentWalkJob == null || !currentWalkJob.isUseable() || !currentWalkJob.isComplete()) { setWalkJobToRandomStep(); } return(currentWalkJob.getCurrentTask(taskTracker)); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { waitSoFar++; if (waitSoFar >= waitDuration) { return(new CharacterTask.SwitchJob(toReturnTo)); } else { return(new CharacterTask.NoTask()); } }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { if (!hasDroppedLoad) { hasDroppedLoad = true; return(new CharacterTask.PlaceResource(targetBlock, carriedType)); } else { return(new CharacterTask.SwitchJob(toReturnTo)); } }
public List <ActorAction> update() { List <ActorAction> result = new List <ActorAction>(); CharacterTaskTracker taskTracker = new CharacterTaskTracker(actors); foreach (Actor test in actors) { result.AddRange(test.update(taskTracker)); } return(result); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { if (workingProfile.getPathingProfile().isProfileSolidAtWithWithinCheck(targetBlock)) { character.pickUpItem(ResourceBlock.ResourceType.standardBlock); return(new CharacterTask.DestroyBlock(targetBlock)); } else { return(new CharacterTask.SwitchJob(new CarryResourceToStockpileKickoffJob(ResourceBlock.ResourceType.standardBlock, character, new ExcavateKickoffJob(workingProfile, character), workingProfile))); } }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { float distToTarget = Vector3.Distance(character.getLocation(), target.getLocation()); if (distToTarget > loseInterestDistance || target.isDead()) { return(new CharacterTask.SwitchJob(new AggressiveStanceJob(character))); } else if (distToTarget > getDesiredDistanceFromTarget()) { return(new CharacterTask.WalkTowardPoint(target.getLocation())); } else { return(new CharacterTask.DoStrikeOfWorkAlongRay(character, character.getLocation(), character.getStrikeRange(), target.getLocation() - character.getLocation())); } //return new CharacterTask.LookTowardPoint(target.getLocation()); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { if (workingProfile.getTreeJobSite().getTreeTrunkBlocks().Count > 0) { if (workingProfile.getTreeJobSite().getTreeTrunkBlocks().Contains(targetBlock)) { return(new CharacterTask.ChopBlockForFrame(targetBlock)); } else { character.pickUpItem(ResourceBlock.ResourceType.Wood); return(new CharacterTask.SwitchJob(new CarryResourceToStockpileKickoffJob( ResourceBlock.ResourceType.Wood, character, new LoggingKickoffJob(character, workingProfile), workingProfile))); } } else { return(new CharacterTask.SwitchJob(new UnemployedJob())); } }
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()); } }
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())); } }
public abstract List <ActorAction> update(CharacterTaskTracker taskTracker);
public override List <ActorAction> update(CharacterTaskTracker taskTracker) { List <ActorAction> actions = new List <ActorAction>(); return(actions); }
public abstract CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker);
private List <AnimationType> UpdateJobTasks(List <ActorAction> actions, CharacterTaskTracker taskTracker) { CharacterTask.Task toDo = job.getCurrentTask(taskTracker); List <AnimationType> animations = new List <AnimationType>(); switch (toDo.taskType) { case CharacterTask.Type.NoTask: //runPhysics(actions); animations.Add(AnimationType.standing); break; case CharacterTask.Type.StepToBlock: updateStepTask((CharacterTask.StepToBlock)toDo, animations); setVelocity(new Vector3()); break; case CharacterTask.Type.DestoryBlock: animations.Add(AnimationType.standing); CharacterTask.DestroyBlock destroyBlock = (CharacterTask.DestroyBlock)toDo; actions.Add(new ActorStrikeBlockAction(this, destroyBlock.getBlockToDestroy(), JobType.mining)); StartHammerAnimationIfPossible(); break; case CharacterTask.Type.BuildBlock: animations.Add(AnimationType.standing); CharacterTask.BuildBlock buildBlock = (CharacterTask.BuildBlock)toDo; actions.Add(new ActorPlaceBlockAction(buildBlock.getBlockLocToBuild(), buildBlock.getBlockTypeToBuild())); StartHammerAnimationIfPossible(); dropItem(); break; case CharacterTask.Type.ChopBlockForFrame: animations.Add(AnimationType.standing); CharacterTask.ChopBlockForFrame chopBlock = (CharacterTask.ChopBlockForFrame)toDo; actions.Add(new ActorStrikeBlockAction(this, chopBlock.getBlockToChop(), JobType.logging)); StartHammerAnimationIfPossible(); break; case CharacterTask.Type.ObjectBuildForFrame: CharacterTask.ObjectBuildForFrame objectBuildTask = (CharacterTask.ObjectBuildForFrame)toDo; objectBuildTask.getSiteToWorkOn().buildForAFrame(); if (objectBuildTask.getSiteToWorkOn().isReadyToBeBuilt()) { actions.Add(new ActorPlaceBoatAction(objectBuildTask.getSiteToWorkOn().getObjectLoc())); } StartHammerAnimationIfPossible(); break; case CharacterTask.Type.CaptainBoat: //setRotationWithGivenDeltaVec(((CharacterTask.CaptainBoat)toDo).getBoat().getFootLocation() - getFootLocation()); setFootLocation(((CharacterTask.CaptainBoat)toDo).getBoat().getLocation() + new Vector3(0, .6f, 0)); setVelocity(new Vector3()); break; case CharacterTask.Type.GetInBoat: getInBoat(((CharacterTask.GetInBoat)toDo).getBoat()); break; case CharacterTask.Type.SwitchJob: setJobAndCheckUseability(((CharacterTask.SwitchJob)toDo).getNewJob()); break; case CharacterTask.Type.WalkTowardPoint: animations.Add(AnimationType.walking); if (World.getPathingProfile().isActorStanding(this)) { Vector3 move = getWalkTowardDeltaVec(((CharacterTask.WalkTowardPoint)toDo).getTargetLoc()); move.Normalize(); move *= getWalkSpeedWhilePathing(); actions.Add(getAddVelocityAction(move, false)); } setRotationWithGivenDeltaVec(((CharacterTask.WalkTowardPoint)toDo).getTargetLoc() - getLocation()); break; case CharacterTask.Type.LookTowardPoint: animations.Add(AnimationType.standing); setRotationWithGivenDeltaVec(((CharacterTask.LookTowardPoint)toDo).getTargetLoc() - getLocation()); break; case CharacterTask.Type.DoStrikeOfWorkAlongRay: animations.Add(AnimationType.standing); setRotationWithGivenDeltaVec(((CharacterTask.DoStrikeOfWorkAlongRay)toDo).getStrikeDirectionNormal()); if (canSwing()) { CharacterTask.DoStrikeOfWorkAlongRay strike = (CharacterTask.DoStrikeOfWorkAlongRay)toDo; StartStrikeAnimation(); swing(); actions.Add(new ActorStrikeAlongRayAction(this, strike.getStrikeOrigen(), strike.getStrikeDistance(), strike.getStrikeDirectionNormal(), JobType.combat, 0)); } break; case CharacterTask.Type.MakeFarmBlockGrow: actions.Add(new ActorStrikeBlockAction(this, ((CharacterTask.MakeFarmBlockGrow)toDo).getBlockToFarm(), JobType.agriculture)); StartHammerAnimationIfPossible(); break; case CharacterTask.Type.HarvestFarmBlock: CharacterTask.HarvestFarmBlock harvestTask = (CharacterTask.HarvestFarmBlock)toDo; actions.Add(new ActorStrikeBlockAction(this, ((CharacterTask.HarvestFarmBlock)toDo).getBlockToFarm(), JobType.agriculture)); setJobAndCheckUseability(new CarryResourceToStockpileKickoffJob(ResourceBlock.ResourceType.Wheat, this, new FarmingKickoffJob(harvestTask.getFarm(), this, harvestTask.getWorkingProfile()), harvestTask.getWorkingProfile())); StartHammerAnimationIfPossible(); pickUpItem(ResourceBlock.ResourceType.Wheat); break; case CharacterTask.Type.PlaceResource: CharacterTask.PlaceResource placeResource = (CharacterTask.PlaceResource)toDo; actions.Add(new ActorPlaceResourceAction(placeResource.getLocToPlaceResource(), placeResource.getTypeToPlace())); //StartHammerAnimationIfPossible(); dropLoad(); break; case CharacterTask.Type.PickUpResource: CharacterTask.PickUpResource pickUpResource = (CharacterTask.PickUpResource)toDo; actions.Add(new ActorPickUpResourceAction(pickUpResource.getLocToPlaceResource(), pickUpResource.getTypeToPlace())); load.pickUpItem(pickUpResource.getTypeToPlace()); StartHammerAnimationIfPossible(); pickUpItem(pickUpResource.getTypeToPlace()); break; default: throw new Exception("unhandled task"); } if (job.isComplete()) { job = new UnemployedJob(); } return(animations); }
public override CharacterTask.Task getCurrentTask(CharacterTaskTracker taskTracker) { return(new CharacterTask.NoTask()); }