public void makeFarmBlockGrow(BlockLoc blockLoc) { foreach (JobSite test in jobSites) { test.makeFarmBlockGrow(blockLoc); } }
public virtual Path getPathToMakeTheseBlocksAvaiable( IslandPathingProfile startProfile, BlockLoc startLoc, IslandPathingProfile endProfile, List <BlockLoc> blockLocs, int heightOfEntity, out BlockLoc blockMadeAvailable) { blockMadeAvailable = new BlockLoc(); HashSet <BlockLoc> goals = new HashSet <BlockLoc>(); foreach (BlockLoc blockLocToAccess in blockLocs) { HashSet <BlockLoc> toAdd = endProfile.getFootLocsThatHaveAccessToBlock(blockLocToAccess); foreach (BlockLoc addToGoals in toAdd) { goals.Add(addToGoals); } } List <BlockLoc> path = getPathWithStartAndEndGroupValidation(startProfile, startLoc, endProfile, goals, heightOfEntity); foreach (BlockLoc blockToAcces in blockLocs) { if (path != null) { if (endProfile.getFootLocsThatHaveAccessToBlock(blockToAcces).Contains(path.Last())) { blockMadeAvailable = blockToAcces; } } } return(new Path(path)); }
internal HashSet <BlockLoc> getThisManyResourceBlocksOfType(int cost, ResourceBlock.ResourceType resourceType) { HashSet <BlockLoc> resourceBlocksToRemove = new HashSet <BlockLoc>(); int blocksRemovedSoFar = 0; for (int i = 0; i < 3; i++)//repeats so it can remove stacked blocks { foreach (BlockLoc test in resourceBlocks.Keys) { if (resourceBlocks[test].getResourceType() == resourceType) { BlockLoc blockAbove = (BlockLoc.AddIntVec3(test, new IntVector3(0, 1, 0))); if (!resourceBlocks.ContainsKey(blockAbove)) { if (!resourceBlocksToRemove.Contains(test)) { blocksRemovedSoFar++; resourceBlocksToRemove.Add(test); if (blocksRemovedSoFar == cost) { return(resourceBlocksToRemove); } } } } } } return(resourceBlocksToRemove); }
public void placeRescourceBlock(BlockLoc loc, ResourceBlock.ResourceType type) { if (!resourceBlocks.ContainsKey(loc)) { resourceBlocks.Add(loc, new ResourceBlock(type)); } }
public LinkedList <BlockLoc> GetBlocksBoundBy(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()); int spaceSize = (max.WSY() - min.WSY()); Console.WriteLine(spaceSize + " space size"); 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++) { BlockLoc toTest = new BlockLoc(x, y, z); byte? block = islandManager.getBlockAtOnGivenIsland(ref toTest, relevant); if (block.HasValue) { if (PaintedCubeSpace.isSolidType((byte)block)) { result.AddLast(new BlockLoc(x, y, z)); } } } } } return(result); }
public void placeTree(BlockLoc loc, Tree.treeTypes type) { lock (trees) { trees.Add(new Tree(loc, type)); } }
public bool isSwimableAtWithHeight(BlockLoc IslandSpace, int entityHeight) { if (!isProfileSolidAtWithWithinCheck(IslandSpace)) { if (IslandSpace.WSY() == 0) { for (int i = 1; i < entityHeight; i++) { if (isProfileSolidAtWithWithinCheck(IslandSpace.getVector3WithAddedIntvec(new IntVector3(0, i, 0)))) { return(false); } } return(true); } else { return(false); } } else { return(false); } }
public void addBlockToDestroy(BlockLoc blockLoc) { if (!blocksToBeRemoved.Contains(blockLoc)) { blocksToBeRemoved.Add(blockLoc); } }
public override void makeFarmBlockGrow(BlockLoc toFarm) { if (plantBlocks.ContainsKey(toFarm)) { plantBlocks[toFarm].getTendedAndReturnWheatHarvested(); } }
public byte?getBlockAt(ref BlockLoc loc) { Vector3 worldSpaceVec3 = loc.toWorldSpaceVector3(); Island toTest = getClosestIslandToLocation(ref worldSpaceVec3); return(toTest.getBlockAt(ref loc)); }
public void blockWasBuilt(BlockLoc blockLoc) { foreach (JobSite site in jobSites) { site.blockWasBuilt(blockLoc); } }
public HarvestFarmBlock(BlockLoc nToDestory, Farm nFarm, IslandWorkingProfile nWorkingProfile) { toFarm = nToDestory; farm = nFarm; workingProfile = nWorkingProfile; taskType = Type.HarvestFarmBlock; }
public DoStrikeOfWorkOnBlock(Actor nstriker, BlockLoc nBlockToStrike, JobType nJobType) { taskType = Type.DoStrikeOfWorkOnBlock; jobType = nJobType; striker = nstriker; blockToStrike = nBlockToStrike; }
public void chopBlock(BlockLoc blockLoc) { foreach (JobSite test in jobSites) { test.chopBlock(blockLoc); } }
internal void blockWasDestroyed(BlockLoc toDestroy) { foreach (JobSite site in jobSites) { site.blockWasDestroyed(toDestroy); } }
public PathNode(PathNode nPrevious, BlockLoc nLoc, int nCostToGetHere, BlockLoc endLoc) { previous = nPrevious; loc = nLoc; costToGetHere = nCostToGetHere; approximateDistanceToTarget = approximateDistanceTo(endLoc); }
public void removeWoodBlockPlanAlongRay(Ray removeWoodBlockClickRay, Vector3?exactBlockHitLocOnIsland, IslandPathingProfile profile) { float?intersectsJobSite = buildSite.intersects(removeWoodBlockClickRay); if (intersectsJobSite.HasValue) { Vector3 locationOfSelectedSpaceOnJobSite = removeWoodBlockClickRay.Position + removeWoodBlockClickRay.Direction * ((float)intersectsJobSite); if (exactBlockHitLocOnIsland.HasValue) { if (Vector3.Distance((Vector3)exactBlockHitLocOnIsland, removeWoodBlockClickRay.Position) > Vector3.Distance(locationOfSelectedSpaceOnJobSite, removeWoodBlockClickRay.Position)) { BlockLoc blockToRemove = new BlockLoc(locationOfSelectedSpaceOnJobSite + removeWoodBlockClickRay.Direction * .01f); buildSite.removeBlock(blockToRemove); return; } } else { BlockLoc blockToRemove = new BlockLoc(removeWoodBlockClickRay.Position + removeWoodBlockClickRay.Direction * ((float)intersectsJobSite)); buildSite.removeBlock(blockToRemove); return; } } }
public bool isStandableAtWithHeight(BlockLoc IslandSpace, int entityHeight) { BlockLoc underFoot = new BlockLoc(IslandSpace.WSX(), IslandSpace.WSY() - 1, IslandSpace.WSZ());//locInPath + new IntVector3(0, -1, 0); if (!isProfileSolidAtWithWithinCheck(IslandSpace) && isInProfileScope(IslandSpace)) { if (isProfileSolidAtWithWithinCheck(underFoot)) { for (int i = 1; i < entityHeight; i++) { if (isProfileSolidAtWithWithinCheck(IslandSpace.getVector3WithAddedIntvec(new IntVector3(0, i, 0)))) { return(false); } } return(true); } else { return(false); } } else { return(false); } }
private void placeStorageAreaWithBlocksToPlaceOn(IEnumerable <BlockLoc> blocksToPlaceSiteOn, IslandPathingProfile profile, ResourceBlock.ResourceType toStore) { List <BlockLoc> blocksForSite = new List <BlockLoc>(); HashSet <BlockLoc> alreadyOccupied = allBlocksWithJobSites(); foreach (BlockLoc inGround in blocksToPlaceSiteOn) { if (!alreadyOccupied.Contains(BlockLoc.AddIntVec3(inGround, new IntVector3(0, 1, 0)))) { blocksForSite.Add(BlockLoc.AddIntVec3(inGround, new IntVector3(0, 1, 0))); } if (!alreadyOccupied.Contains(BlockLoc.AddIntVec3(inGround, new IntVector3(0, 2, 0)))) { blocksForSite.Add(BlockLoc.AddIntVec3(inGround, new IntVector3(0, 2, 0))); } } HashSet <BlockLoc> locsNotOfWork = new HashSet <BlockLoc>(); removeAllBlocksAtOrBelowWorkBlock(blocksForSite, locsNotOfWork); if (locsNotOfWork.Count > 0) { HashSet <BlockLoc> locsNotSolid = new HashSet <BlockLoc>(); foreach (BlockLoc test in locsNotOfWork) { if (!profile.isProfileSolidAtWithWithinCheck(test)) { locsNotSolid.Add(test); } } resourceBlockJobsite.addStockpile(new Stockpile(locsNotSolid, toStore)); } }
public bool blockIsFullGrown(BlockLoc blockToTend) { if (plantBlocks.ContainsKey(blockToTend)) { return(plantBlocks[blockToTend].isFullyGrown()); } return(false); }
public ChopTreeJob(Character nCharacter, IslandWorkingProfile nWorkingProfile, BlockLoc blockToChop) { targetBlock = blockToChop; character = nCharacter; setJobType(JobType.logging); workingProfile = nWorkingProfile; }
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); }
public void buildBlock(BlockLoc blockLoc, byte typeToBuild) { if (withinChunkSpaceInChunkSpace(blockLoc.toISIntVec3(getPathingProfile()))) { chunkSpace.setBlockAtWithMeshUpdate(typeToBuild, blockLoc.toISIntVec3(getPathingProfile())); jobSiteManager.blockWasBuilt(blockLoc); } }
// new TendFarmBlockJob(path.Last,workingProfile,farm, character) public TendFarmBlockJob(BlockLoc nBlockToTend, IslandWorkingProfile nWorkingProfile, Farm nfarm, Character ncharacter) { targetBlock = nBlockToTend; workingProfile = nWorkingProfile; farm = nfarm; character = ncharacter; }
public Path getPathToSingleBlock(IslandPathingProfile startProfile, BlockLoc startLoc, IslandPathingProfile endProfile, BlockLoc endLoc, int heightOfEntity) { HashSet <BlockLoc> goals = new HashSet <BlockLoc>(); goals.Add(endLoc); return(new Path(getPathWithStartAndEndGroupValidation(startProfile, startLoc, endProfile, goals, heightOfEntity))); }
public ActorStrikeBlockAction(Actor nstriker, BlockLoc ntoStrike, JobType nJobType) { type = ActorActions.strike; jobType = nJobType; strikeType = StrikeType.OnBlock; striker = nstriker; toStrike = ntoStrike; }
public DestroyBlockJob(Character nCharacter, IslandWorkingProfile nWorkingProfile, BlockLoc blockToDestroy) { targetBlock = blockToDestroy; character = nCharacter; setJobType(JobType.mining); workingProfile = nWorkingProfile; }
public PathNodeForFindingLowGoals(PathNode nPrevious, BlockLoc nLoc, int nCostToGetHere, BlockLoc endLoc, int nStepsUntilGiveUpOnFindingBetterBlock) { stepsUntilGiveUpOnFindingBetterBlock = nStepsUntilGiveUpOnFindingBetterBlock; previous = nPrevious; loc = nLoc; costToGetHere = nCostToGetHere; approximateDistanceToTarget = approximateDistanceTo(endLoc); }
private void addBlockToBuildSite(BuildStie toAddToPotentially, BlockLoc newBlockToPlace, byte typeToAdd) { if (allBlocksWithJobSites().Contains(newBlockToPlace)) { return; } toAddToPotentially.addBlock(newBlockToPlace, typeToAdd); }
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()); }