コード例 #1
0
        public static void FillOrderProcessorFromPawnKindDef(ThingOrderProcessor orderProcessor, PawnKindDef pawnKind)
        {
            ThingDef       pawnThingDef = pawnKind.race;
            RaceProperties raceProps    = pawnThingDef.race;

            //Assemble all required materials for a fully grown adult.
            ThingDef meatDef = raceProps.meatDef;
            float    meatBaseNutrition = meatDef.ingestible.CachedNutrition;
            float    meatAmount = pawnThingDef.GetStatValueAbstract(StatDefOf.MeatAmount);
            int      nutritionAmount, proteinAmount;

            //protein cost = Meat * base Meat nutrition (vanilla is .05) * magic multiplier of 27
            //Minimum protein cost is 25, max is 750. Multiply by mod setting for clone ingredients
            //finally, round up to the nearest number divisible by 5
            proteinAmount = (int)(Math.Ceiling((meatAmount * meatBaseNutrition * 27f).Clamp(25, 750)
                                               * QEESettings.instance.cloneTotalResourcesFloat / 5) * 5);

            nutritionAmount = 4 * proteinAmount;

            {
                ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_ProteinMash, proteinAmount);
                orderProcessor.desiredIngredients.Add(orderRequest);
            }

            {
                ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_NutrientSolution, nutritionAmount);
                orderProcessor.desiredIngredients.Add(orderRequest);
            }
        }
コード例 #2
0
        public static void FillOrderProcessorFromPawnKindDef(ThingOrderProcessor orderProcessor, PawnKindDef pawnKind)
        {
            ThingDef pawnThingDef = pawnKind.race;

            RaceProperties raceProps = pawnThingDef.race;

            //Assemble all required materials for a fully grown adult.
            //Meat is worth the full nutritional value.
            ThingDef meatDef           = raceProps.meatDef;
            float    meatBaseNutrition = meatDef.ingestible.CachedNutrition;
            float    meatAmount        = pawnThingDef.GetStatValueAbstract(StatDefOf.MeatAmount) * raceProps.baseBodySize;

            //Leather is worth half of the meat value.
            float leatherAmount = pawnThingDef.GetStatValueAbstract(StatDefOf.LeatherAmount) * raceProps.baseBodySize;

            int proteinAmount   = (int)(meatAmount * meatBaseNutrition * 15f) + (int)(leatherAmount * meatBaseNutrition * 15f);
            int nutritionAmount = (int)(proteinAmount * 4.5f);

            {
                ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_ProteinMash, proteinAmount);
                orderProcessor.desiredIngredients.Add(orderRequest);
            }

            {
                ThingOrderRequest orderRequest = new ThingOrderRequest(QEThingDefOf.QE_NutrientSolution, nutritionAmount);
                orderProcessor.desiredIngredients.Add(orderRequest);
            }
        }
コード例 #3
0
        public static void FillOrderProcessorFromVatGrowerRecipe(ThingOrderProcessor orderProcessor, GrowerRecipeDef recipeDef)
        {
            foreach (IngredientCount ingredientCount in recipeDef.ingredients)
            {
                ThingFilter filterCopy = new ThingFilter();
                filterCopy.CopyAllowancesFrom(ingredientCount.filter);

                ThingOrderRequest copy = new ThingOrderRequest(filterCopy);
                copy.amount = (int)(ingredientCount.GetBaseCount() * QEESettings.instance.organTotalResourcesFloat);

                orderProcessor.desiredIngredients.Add(copy);
            }
        }
コード例 #4
0
        public static string FormatCachedIngredientsInThingOrderProcessor(this ThingOrderProcessor orderProcessor, string format = "{0} x {1}", char delimiter = ',')
        {
            StringBuilder builder = new StringBuilder();

            //Ingredients Requested
            foreach (ThingOrderRequest request in orderProcessor.PendingRequests)
            {
                builder.Append(string.Format(format, request.LabelCap, request.amount));
                if (orderProcessor.PendingRequests.Count() > 1 && request != orderProcessor.PendingRequests.Last())
                {
                    builder.Append(delimiter);
                    builder.Append(' ');
                }
            }

            return(builder.ToString().TrimEndNewlines());
        }
コード例 #5
0
        public static Thing FindClosestRequestForThingOrderProcessor(ThingOrderProcessor orderProcessor, Pawn finder)
        {
            Thing result = GenClosest.ClosestThingReachable(finder.Position, finder.Map, ThingRequest.ForGroup(ThingRequestGroup.HaulableEver), PathEndMode.OnCell, TraverseParms.For(finder),
                                                            validator :
                                                            delegate(Thing thing)
            {
                if (thing.IsForbidden(finder))
                {
                    return(false);
                }

                foreach (ThingOrderRequest request in orderProcessor.PendingRequests)
                {
                    if (request.ThingMatches(thing))
                    {
                        return(true);
                    }
                }

                return(false);
            });

            return(result);
        }
コード例 #6
0
 public Building_GrowerBase()
 {
     innerContainer = new ThingOwner <Thing>(this, false, LookMode.Deep);
     orderProcessor = new ThingOrderProcessor(this);
 }