Ejemplo n.º 1
0
 public void placeRescourceBlock(BlockLoc loc, ResourceBlock.ResourceType type)
 {
     if (!resourceBlocks.ContainsKey(loc))
     {
         resourceBlocks.Add(loc, new ResourceBlock(type));
     }
 }
Ejemplo n.º 2
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));
            }
        }
Ejemplo 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);
        }
Ejemplo n.º 4
0
        internal void debitResource(int cost, ResourceBlock.ResourceType resourceType)
        {
            HashSet <BlockLoc> toRemove = getThisManyResourceBlocksOfType(cost, resourceType);

            foreach (BlockLoc test in toRemove)
            {
                resourceBlocks.Remove(test);
            }
        }
Ejemplo n.º 5
0
 public CarryResourceToStockpileKickoffJob(ResourceBlock.ResourceType nCarriedType,
                                           Character nCharacter, Job njobToReturnTo, IslandWorkingProfile nworkingProfile)
 {
     toReturnTo  = njobToReturnTo;
     carriedType = nCarriedType;
     character   = nCharacter;
     setJobType(JobType.CarryingSomething);
     workingProfile = nworkingProfile;
 }
Ejemplo n.º 6
0
 public Stockpile(IEnumerable <BlockLoc> blockLocsForStorage, ResourceBlock.ResourceType ntypeToStore)
 {
     storageSpace = new HashSet <BlockLoc>();
     foreach (BlockLoc toAdd in blockLocsForStorage)
     {
         storageSpace.Add(toAdd);
     }
     typeToStore = ntypeToStore;
 }
Ejemplo n.º 7
0
 public FetchResourceJob(IslandWorkingProfile nworkingProfile, ResourceBlock.ResourceType nTypeToFetch,
                         Character nCharacter, Job njobToReturnTo)
 {
     toReturnTo     = njobToReturnTo;
     workingProfile = nworkingProfile;
     typeToFetch    = nTypeToFetch;
     character      = nCharacter;
     setJobType(JobType.none);
 }
Ejemplo n.º 8
0
 public PlaceResourceJob(ResourceBlock.ResourceType nCarriedType,
                         Character nCharacter, Job njobToReturnTo, IslandWorkingProfile nworkingProfile, BlockLoc nLocToPlace)
 {
     targetBlock = nLocToPlace;
     toReturnTo  = njobToReturnTo;
     carriedType = nCarriedType;
     character   = nCharacter;
     setJobType(JobType.CarryingSomething);
     workingProfile = nworkingProfile;
 }
Ejemplo n.º 9
0
        //this class stores strike information and allows the striker to be told what the results
        //of its action are

        public ActorPlaceResourceAlongRay(Actor nstriker, Vector3 nStrikeOrigen,
                                          float nStrikeDistance, Vector3 nStrikeDirectionNormal, ResourceBlock.ResourceType nType, byte nSelectedBlockType)
        {
            type                       = ActorActions.strike;
            jobType                    = JobType.CarryingSomething;
            resourceType               = nType;
            strikeType                 = StrikeType.AlongRay;
            striker                    = nstriker;
            strikeOrigin               = nStrikeOrigen;
            strikeDistance             = nStrikeDistance;
            strikeDirectionNormal      = Vector3.Normalize(nStrikeDirectionNormal);
            currentlySelectedBlockType = nSelectedBlockType;
        }
Ejemplo n.º 10
0
        public IEnumerable <BlockLoc> getBlocksToGetThisTypeFrom(ResourceBlock.ResourceType typeToFetch)
        {
            List <BlockLoc> result = new List <BlockLoc>();

            foreach (BlockLoc storageLocation in resourceBlocks.Keys)
            {
                if (resourceBlocks[storageLocation].getResourceType() == typeToFetch)
                {
                    result.Add(storageLocation);
                }
            }

            return(result);
        }
Ejemplo n.º 11
0
        public void display3D()
        {
            if (isEmbodyingCharacter())
            {
                if (selectedCharacter.isCarryingItem())
                {
                    ResourceBlock.ResourceType type = selectedCharacter.getLoad();
                    String  blockChrPath            = ResourceBlock.getPathForResourceType(type);
                    Vector3 centerOfFloatingCube    = getPlayerAimingAtPointAtDistance(.7f, currentMouseState);

                    WorldMarkupHandler.addFlagPathWithPosition(blockChrPath, centerOfFloatingCube, 1f / 7f / 12f);
                }
            }

            if (selectedCharacter != null && !isEmbodyingCharacter())
            {
                Compositer.addFlagForThisFrame(selectedCharacter.getLocation() + new Vector3(0, 1.1f, 0), "white");
            }
        }
Ejemplo n.º 12
0
        public IEnumerable <BlockLoc> getBlocksToStoreThisTypeIn(ResourceBlock.ResourceType carriedType)
        {
            List <BlockLoc> result = new List <BlockLoc>();

            foreach (Stockpile stockpile in stockpiles)
            {
                if (stockpile.getStoredType() == carriedType)
                {
                    foreach (BlockLoc loc in stockpile.getAllBlocksInStockPile())
                    {
                        if (thereAreNoResourcesAt(loc))
                        {
                            result.Add(loc);
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 13
0
 public PickUpResource(BlockLoc nBlockToPlaceIn, ResourceBlock.ResourceType ntypeToPlace)
 {
     taskType       = Type.PickUpResource;
     typeToPlace    = ntypeToPlace;
     blockToPlaceIn = nBlockToPlaceIn;
 }
Ejemplo n.º 14
0
 public void addResourceBlock(BlockLoc loc, ResourceBlock.ResourceType type)
 {
     getClosestIslandToLocation(loc.toWorldSpaceVector3()).addResourceBlock(loc, type);
 }
Ejemplo n.º 15
0
 internal bool couldAffordResourceExpendeture(int cost, ResourceBlock.ResourceType resourceType)
 {
     return(resourceBlockJobsite.getBlocksToGetThisTypeFrom(resourceType).Count() >= cost);
 }
Ejemplo n.º 16
0
 internal void debitResource(int cost, ResourceBlock.ResourceType resourceType)
 {
     resourceBlockJobsite.debitResource(cost, resourceType);
 }
Ejemplo n.º 17
0
 public void addResourceBlock(BlockLoc loc, ResourceBlock.ResourceType type)
 {
     resourceBlockJobsite.placeRescourceBlock(loc, type);
 }
Ejemplo n.º 18
0
 internal void removeResourceBlock(BlockLoc blockLoc, ResourceBlock.ResourceType resourceType)
 {
     resourceBlockJobsite.removeRescourceBlock(blockLoc, resourceType);
 }
Ejemplo n.º 19
0
 public IEnumerable <BlockLoc> getBlocksToGetThisTypeFrom(ResourceBlock.ResourceType typeToFetch)
 {
     return(jobSiteManager.getResourceJobSite().getBlocksToGetThisTypeFrom(typeToFetch).ToList());
 }
Ejemplo n.º 20
0
 public void pickUpItem(ResourceBlock.ResourceType nItem)
 {
     load.pickUpItem(nItem);
     setupBodyPartGroupGivenCurrentJob();
 }
Ejemplo n.º 21
0
 public void debitResource(int cost, ResourceBlock.ResourceType resourceType)
 {
     jobSiteManager.debitResource(cost, resourceType);
 }
Ejemplo n.º 22
0
 public ActorPickUpResourceAction(BlockLoc nlocToPlace, ResourceBlock.ResourceType nTypeToPlace)
 {
     type        = ActorActions.PickUpResource;
     typeToPlace = nTypeToPlace;
     locToPlace  = nlocToPlace;
 }
Ejemplo n.º 23
0
 public bool couldAffordResourceExpendeture(int cost, ResourceBlock.ResourceType resourceType)
 {
     return(jobSiteManager.couldAffordResourceExpendeture(cost, resourceType));
 }
Ejemplo n.º 24
0
 public void removeResourceBlock(BlockLoc blockLoc, ResourceBlock.ResourceType resourceType)
 {
     jobSiteManager.removeResourceBlock(blockLoc, resourceType);
 }
Ejemplo n.º 25
0
 public ResourceAmount(int nAmount, ResourceBlock.ResourceType nType)
 {
     type   = nType;
     amount = nAmount;
 }
Ejemplo n.º 26
0
 public void removeResourceBlock(BlockLoc blockLoc, ResourceBlock.ResourceType resourceType)
 {
     getClosestIslandToLocation(blockLoc.toWorldSpaceVector3()).removeResourceBlock(blockLoc, resourceType);
 }
Ejemplo n.º 27
0
 internal void removeRescourceBlock(BlockLoc blockLoc, ResourceBlock.ResourceType resourceType)
 {
     Debug.Assert(resourceBlocks[blockLoc].getResourceType() == resourceType);
     resourceBlocks.Remove(blockLoc);
 }
Ejemplo n.º 28
0
 public void addResourceBlock(BlockLoc loc, ResourceBlock.ResourceType type)
 {
     jobSiteManager.addResourceBlock(loc, type);
 }
Ejemplo n.º 29
0
 public void pickUpItem(ResourceBlock.ResourceType nCarriedResource)
 {
     dropItem();
     carriedResource = nCarriedResource;
 }