Exemplo n.º 1
0
 public void makeFarmBlockGrow(BlockLoc blockLoc)
 {
     foreach (JobSite test in jobSites)
     {
         test.makeFarmBlockGrow(blockLoc);
     }
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public void placeRescourceBlock(BlockLoc loc, ResourceBlock.ResourceType type)
 {
     if (!resourceBlocks.ContainsKey(loc))
     {
         resourceBlocks.Add(loc, new ResourceBlock(type));
     }
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public void placeTree(BlockLoc loc, Tree.treeTypes type)
 {
     lock (trees)
     {
         trees.Add(new Tree(loc, type));
     }
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 public void addBlockToDestroy(BlockLoc blockLoc)
 {
     if (!blocksToBeRemoved.Contains(blockLoc))
     {
         blocksToBeRemoved.Add(blockLoc);
     }
 }
Exemplo n.º 9
0
 public override void makeFarmBlockGrow(BlockLoc toFarm)
 {
     if (plantBlocks.ContainsKey(toFarm))
     {
         plantBlocks[toFarm].getTendedAndReturnWheatHarvested();
     }
 }
Exemplo n.º 10
0
        public byte?getBlockAt(ref BlockLoc loc)
        {
            Vector3 worldSpaceVec3 = loc.toWorldSpaceVector3();
            Island  toTest         = getClosestIslandToLocation(ref worldSpaceVec3);

            return(toTest.getBlockAt(ref loc));
        }
Exemplo n.º 11
0
 public void blockWasBuilt(BlockLoc blockLoc)
 {
     foreach (JobSite site in jobSites)
     {
         site.blockWasBuilt(blockLoc);
     }
 }
Exemplo n.º 12
0
 public HarvestFarmBlock(BlockLoc nToDestory, Farm nFarm, IslandWorkingProfile nWorkingProfile)
 {
     toFarm         = nToDestory;
     farm           = nFarm;
     workingProfile = nWorkingProfile;
     taskType       = Type.HarvestFarmBlock;
 }
Exemplo n.º 13
0
 public DoStrikeOfWorkOnBlock(Actor nstriker, BlockLoc nBlockToStrike, JobType nJobType)
 {
     taskType      = Type.DoStrikeOfWorkOnBlock;
     jobType       = nJobType;
     striker       = nstriker;
     blockToStrike = nBlockToStrike;
 }
Exemplo n.º 14
0
 public void chopBlock(BlockLoc blockLoc)
 {
     foreach (JobSite test in jobSites)
     {
         test.chopBlock(blockLoc);
     }
 }
Exemplo n.º 15
0
 internal void blockWasDestroyed(BlockLoc toDestroy)
 {
     foreach (JobSite site in jobSites)
     {
         site.blockWasDestroyed(toDestroy);
     }
 }
Exemplo n.º 16
0
 public PathNode(PathNode nPrevious, BlockLoc nLoc, int nCostToGetHere, BlockLoc endLoc)
 {
     previous      = nPrevious;
     loc           = nLoc;
     costToGetHere = nCostToGetHere;
     approximateDistanceToTarget = approximateDistanceTo(endLoc);
 }
Exemplo n.º 17
0
        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;
                }
            }
        }
Exemplo n.º 18
0
        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);
            }
        }
Exemplo n.º 19
0
        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));
            }
        }
Exemplo n.º 20
0
 public bool blockIsFullGrown(BlockLoc blockToTend)
 {
     if (plantBlocks.ContainsKey(blockToTend))
     {
         return(plantBlocks[blockToTend].isFullyGrown());
     }
     return(false);
 }
Exemplo n.º 21
0
        public ChopTreeJob(Character nCharacter, IslandWorkingProfile nWorkingProfile, BlockLoc blockToChop)
        {
            targetBlock = blockToChop;

            character = nCharacter;
            setJobType(JobType.logging);
            workingProfile = nWorkingProfile;
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
 public void buildBlock(BlockLoc blockLoc, byte typeToBuild)
 {
     if (withinChunkSpaceInChunkSpace(blockLoc.toISIntVec3(getPathingProfile())))
     {
         chunkSpace.setBlockAtWithMeshUpdate(typeToBuild, blockLoc.toISIntVec3(getPathingProfile()));
         jobSiteManager.blockWasBuilt(blockLoc);
     }
 }
Exemplo n.º 24
0
        // 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;
        }
Exemplo n.º 25
0
        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)));
        }
Exemplo n.º 26
0
 public ActorStrikeBlockAction(Actor nstriker, BlockLoc ntoStrike, JobType nJobType)
 {
     type       = ActorActions.strike;
     jobType    = nJobType;
     strikeType = StrikeType.OnBlock;
     striker    = nstriker;
     toStrike   = ntoStrike;
 }
Exemplo n.º 27
0
        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);
 }
Exemplo n.º 29
0
 private void addBlockToBuildSite(BuildStie toAddToPotentially, BlockLoc newBlockToPlace, byte typeToAdd)
 {
     if (allBlocksWithJobSites().Contains(newBlockToPlace))
     {
         return;
     }
     toAddToPotentially.addBlock(newBlockToPlace, typeToAdd);
 }
Exemplo n.º 30
0
        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());
        }