Example #1
0
        /// <summary>
        /// Gets all pending requests that need to be processed using ideal requests as a base.
        /// </summary>
        /// <returns>Pending requests or none.</returns>
        public IEnumerable <ThingOrderRequest> PendingRequests()
        {
            foreach (ThingOrderRequest idealRequest in requestedItems)
            {
                if (idealRequest.nutrition)
                {
                    //Food
                    float totalNutrition = CountNutrition();
                    if (totalNutrition < idealRequest.amount)
                    {
                        ThingOrderRequest request = new ThingOrderRequest();
                        request.nutrition   = true;
                        request.amount      = idealRequest.amount - totalNutrition;
                        request.thingFilter = storageSettings.filter;

                        yield return(request);
                    }
                }
                else
                {
                    //Item
                    float totalItemCount = thingHolder.TotalStackCountOfDef(idealRequest.thingDef);
                    if (totalItemCount < idealRequest.amount)
                    {
                        ThingOrderRequest request = new ThingOrderRequest();
                        request.thingDef = idealRequest.thingDef;
                        request.amount   = idealRequest.amount - totalItemCount;

                        yield return(request);
                    }
                }
            }
        }
        public void MakePawnAndInitCrafting(DroidCraftingDef def)
        {
            //Update costs.
            orderProcessor.requestedItems.Clear();

            foreach (ThingOrderRequest cost in def.costList)
            {
                ThingOrderRequest costCopy = new ThingOrderRequest();
                costCopy.nutrition = cost.nutrition;
                costCopy.thingDef  = cost.thingDef;
                costCopy.amount    = cost.amount;

                orderProcessor.requestedItems.Add(costCopy);
            }

            craftingTime = def.timeCost;

            //Apply template.
            if (def.useDroidCreator)
            {
                pawnBeingCrafted = DroidUtility.MakeDroidTemplate(def.pawnKind, Faction, Map.Tile);
            }
            else
            {
                pawnBeingCrafted = PawnGenerator.GeneratePawn(def.pawnKind, Faction);
            }

            crafterStatus = CrafterStatus.Filling;
        }
        /// <summary>
        /// Tries to find a appropiate ingredient.
        /// </summary>
        /// <param name="pawn">Pawn to search for.</param>
        /// <param name="androidPrinter">Printer to fill.</param>
        /// <param name="request">Thing order request to fulfill.</param>
        /// <returns>Valid thing if found, otherwise null.</returns>
        private Thing FindIngredient(Pawn pawn, Building_PawnCrafter androidPrinter, ThingOrderRequest request)
        {
            if (request != null)
            {
                Predicate <Thing> extraPredicate = request.ExtraPredicate();
                Predicate <Thing> predicate      = (Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1, -1, null, false) && extraPredicate(x);
                Predicate <Thing> validator      = predicate;

                return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, request.Request(), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, null, 0, -1, false, RegionType.Set_Passable, false));
            }

            return(null);
        }
        // Token: 0x0600006F RID: 111 RVA: 0x00004D39 File Offset: 0x00002F39
        public IEnumerable <ThingOrderRequest> PendingRequests()
        {
            foreach (ThingOrderRequest idealRequest in this.requestedItems)
            {
                bool nutrition = idealRequest.nutrition;
                if (nutrition)
                {
                    float totalNutrition = this.CountNutrition();
                    bool  flag           = totalNutrition < idealRequest.amount;
                    if (flag)
                    {
                        ThingOrderRequest request = new ThingOrderRequest();
                        request.nutrition   = true;
                        request.amount      = idealRequest.amount - totalNutrition;
                        request.thingFilter = this.storageSettings.filter;
                        yield return(request);

                        request = null;
                    }
                }
                else
                {
                    float totalItemCount = (float)this.thingHolder.TotalStackCountOfDef(idealRequest.thingDef);
                    bool  flag2          = totalItemCount < idealRequest.amount;
                    if (flag2)
                    {
                        ThingOrderRequest request2 = new ThingOrderRequest();
                        request2.thingDef = idealRequest.thingDef;
                        request2.amount   = idealRequest.amount - totalItemCount;
                        yield return(request2);

                        request2 = null;
                    }
                }
                idealRequest = null;
            }
            List <ThingOrderRequest> .Enumerator enumerator = default(List <ThingOrderRequest> .Enumerator);
            yield break;
            yield break;
        }