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)); } }
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 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()); }
private void removeAllBlocksAtOrBelowWorkBlock(IEnumerable <BlockLoc> blocksToAdd, HashSet <BlockLoc> locs) { HashSet <BlockLoc> blocksToNotBeFarmed = removeAllBlocksOfWorkFrom(blocksToAdd, locs); foreach (BlockLoc alreadyOccupiedBlock in blocksToNotBeFarmed) { locs.Remove(BlockLoc.AddIntVec3(alreadyOccupiedBlock, new IntVector3(0, -1, 0))); } }
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 HashSet <BlockLoc> getBlocksAvailableForWorkFromFootLoc(BlockLoc footLoc) { HashSet <BlockLoc> result = new HashSet <BlockLoc>(); foreach (IntVector3 relativeAvailableLoc in availableBlocksFromGivenStadingLoc) { result.Add(BlockLoc.AddIntVec3(footLoc, relativeAvailableLoc)); } return(result); }
public HashSet <BlockLoc> getFootLocsThatHaveAccessToBlock(BlockLoc goalBlockLoc) { HashSet <BlockLoc> result = new HashSet <BlockLoc>(); foreach (IntVector3 relativeFootLoc in standingLocsRelativeToAvailableBlock) { result.Add(BlockLoc.AddIntVec3(goalBlockLoc, relativeFootLoc)); } return(result); }
public List <BlockLoc> getTrunkBlocks() { int numBlocksUpFromFoot = 10; List <BlockLoc> trunkBlocks = new List <BlockLoc>(numBlocksUpFromFoot); for (int i = 0; i < numBlocksUpFromFoot; i++) { trunkBlocks.Add(BlockLoc.AddIntVec3(FootLocation, new IntVector3(0, i, 0))); } return(trunkBlocks); }
public List <BlockLoc> getSpacesThatCanBeMovedToFrom(BlockLoc from, int entityHeight) { List <BlockLoc> result = new List <BlockLoc>(8); foreach (IntVector3 move in possibleMoves) { if (isStandableAtWithHeight(BlockLoc.AddIntVec3(from, move), entityHeight) || isSwimableAtWithHeightAndWithinIsland(BlockLoc.AddIntVec3(from, move), entityHeight)) { result.Add(BlockLoc.AddIntVec3(from, move)); } } return(result); }
public bool isSurfaceBlock(ref BlockLoc loc) { byte? block = islandManager.getBlockAt(ref loc); BlockLoc blockLocAbove = BlockLoc.AddIntVec3(loc, new IntVector3(0, 1, 0)); byte? aboveBlock = islandManager.getBlockAt(ref blockLocAbove); if (block.HasValue && aboveBlock.HasValue) { if (PaintedCubeSpace.isOpaqueType((byte)block) && !PaintedCubeSpace.isOpaqueType((byte)aboveBlock)) { return(true); } } return(false); }
public override void blockWasDestroyed(BlockLoc toDestroy) { plantBlocks.Remove(toDestroy); plantBlocks.Remove(BlockLoc.AddIntVec3(toDestroy, new IntVector3(0, 1, 0))); }