public void acceptWorkStrike(ActorStrikeAction actorStrikeAction) { if (actorStrikeAction.getStrikeType() == ActorStrikeAction.StrikeType.OnBlock) { ActorStrikeBlockAction strikeBlock = (ActorStrikeBlockAction)actorStrikeAction; handleStrikeEffectOnIsland(strikeBlock); jobSiteManager.acceptStrikeAt(strikeBlock.getStrikeTarget(), strikeBlock.getJobType()); } else //NEEDS DISTANCE LIMITTING { ActorStrikeAlongRayAction rayStrike = (ActorStrikeAlongRayAction)actorStrikeAction; Ray ray = new Ray(rayStrike.getStrikeOrigen(), rayStrike.getStrikeDirectionNormal()); JobSite intersectedSite = getJobSiteAlongRay(ray); Vector3?blockClicked = getNearestBlockAlongRayInAndFromWorldSpace(ray); //figuring out what to do if both a block and site are along the ray if (blockClicked != null && intersectedSite != null) { if (Math.Abs(Vector3.Distance((Vector3)blockClicked, rayStrike.getStrikeOrigen()) - (float)intersectedSite.intersects(ray)) < .01) { //block has been clicked handleRayStrikeOnIslandBlocks(rayStrike, ray); } else if (Vector3.Distance((Vector3)blockClicked, rayStrike.getStrikeOrigen()) < (float)intersectedSite.intersects(ray)) { //block has been clicked handleRayStrikeOnIslandBlocks(rayStrike, ray); } else { //siteHasBeenClicked ray = JobSiteWasHitWithJobRay(rayStrike, ray, intersectedSite); } } else if (blockClicked != null) { //block has been clicked handleRayStrikeOnIslandBlocks(rayStrike, ray); } else if (intersectedSite != null) { //site has been clicked ray = JobSiteWasHitWithJobRay(rayStrike, ray, intersectedSite); } } }
private Ray JobSiteWasHitWithJobRay(ActorStrikeAlongRayAction rayStrike, Ray ray, JobSite intersectedSite) { BlockLoc locOfWork = new BlockLoc(rayStrike.getStrikeOrigen() + rayStrike.getStrikeDirectionNormal() * ((float)intersectedSite.intersects(ray) + .001f)); jobSiteManager.acceptStrikeAt(locOfWork, rayStrike.getJobType()); return(ray); }
private Job giveCharacterJobSiteJobReturnWhetherJobFound(Character character, ref Ray rightClickRay) { Vector3?righClickedBlock = getLastSpaceAlongRay(rightClickRay); JobSite clickedJobSite = getIslandManager().getJobSiteAlongRay(rightClickRay); if (clickedJobSite != null) { if (righClickedBlock.HasValue) { if (Vector3.Distance((Vector3)righClickedBlock, rightClickRay.Position) < (float)clickedJobSite.intersects(rightClickRay) - .01f) { return(new UnemployedJob()); } } Job job = clickedJobSite.getJob(character, rightClickRay, new IslandWorkingProfile( islandManager.getClosestIslandToLocation(character.getFootLocation()).getJobSiteManager(), islandManager.getClosestIslandToLocation(character.getFootLocation()).getPathingProfile())); character.setJobAndCheckUseability(job); return(job); } return(new UnemployedJob()); }