コード例 #1
0
        public virtual IEnumerable <Thing> SmeltProducts(float efficiency)
        {
            List <ThingCountClass> costListAdj = this.def.CostListAdjusted(this.Stuff, true);

            for (int j = 0; j < costListAdj.Count; j++)
            {
                if (!costListAdj[j].thingDef.intricate)
                {
                    float countF = (float)((float)costListAdj[j].count * 0.25);
                    int   count  = GenMath.RoundRandom(countF);
                    if (count > 0)
                    {
                        Thing t = ThingMaker.MakeThing(costListAdj[j].thingDef, null);
                        t.stackCount = count;
                        yield return(t);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
            }
            if (this.def.smeltProducts != null)
            {
                int i = 0;
                if (i < this.def.smeltProducts.Count)
                {
                    ThingCountClass ta = this.def.smeltProducts[i];
                    Thing           t2 = ThingMaker.MakeThing(ta.thingDef, null);
                    t2.stackCount = ta.count;
                    yield return(t2);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
        }
コード例 #2
0
 public virtual IEnumerable <Thing> ButcherProducts(Pawn butcher, float efficiency)
 {
     if (this.def.butcherProducts != null)
     {
         for (int i = 0; i < this.def.butcherProducts.Count; i++)
         {
             ThingCountClass ta    = this.def.butcherProducts[i];
             int             count = GenMath.RoundRandom((float)ta.count * efficiency);
             if (count > 0)
             {
                 Thing t = ThingMaker.MakeThing(ta.thingDef, null);
                 t.stackCount = count;
                 yield return(t);
             }
         }
     }
 }
コード例 #3
0
        public virtual int CountProducts(Bill_Production bill)
        {
            ThingCountClass thingCountClass = this.recipe.products[0];

            if (thingCountClass.thingDef.CountAsResource)
            {
                return(bill.Map.resourceCounter.GetCount(thingCountClass.thingDef));
            }
            int num = bill.Map.listerThings.ThingsOfDef(thingCountClass.thingDef).Count;

            if (thingCountClass.thingDef.Minifiable)
            {
                List <Thing> list = bill.Map.listerThings.ThingsInGroup(ThingRequestGroup.MinifiedThing);
                for (int i = 0; i < list.Count; i++)
                {
                    MinifiedThing minifiedThing = (MinifiedThing)list[i];
                    if (minifiedThing.InnerThing.def == thingCountClass.thingDef)
                    {
                        num++;
                    }
                }
            }
            return(num);
        }
コード例 #4
0
ファイル: GenRecipe.cs プロジェクト: sachdevs/RW-Decompile
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient)
        {
            float efficiency;

            if (recipeDef.efficiencyStat == null)
            {
                efficiency = 1f;
            }
            else
            {
                efficiency = worker.GetStatValue(recipeDef.efficiencyStat, true);
            }
            if (recipeDef.products != null)
            {
                for (int i = 0; i < recipeDef.products.Count; i++)
                {
                    ThingCountClass prod = recipeDef.products[i];
                    ThingDef        stuffDef;
                    if (prod.thingDef.MadeFromStuff)
                    {
                        stuffDef = dominantIngredient.def;
                    }
                    else
                    {
                        stuffDef = null;
                    }
                    Thing product = ThingMaker.MakeThing(prod.thingDef, stuffDef);
                    product.stackCount = Mathf.CeilToInt((float)prod.count * efficiency);
                    if (dominantIngredient != null)
                    {
                        product.SetColor(dominantIngredient.DrawColor, false);
                    }
                    CompIngredients ingredientsComp = product.TryGetComp <CompIngredients>();
                    if (ingredientsComp != null)
                    {
                        for (int l = 0; l < ingredients.Count; l++)
                        {
                            ingredientsComp.RegisterIngredient(ingredients[l].def);
                        }
                    }
                    CompFoodPoisonable foodPoisonable = product.TryGetComp <CompFoodPoisonable>();
                    if (foodPoisonable != null)
                    {
                        float num  = worker.GetStatValue(StatDefOf.FoodPoisonChance, true);
                        Room  room = worker.GetRoom(RegionType.Set_Passable);
                        if (room != null)
                        {
                            num *= room.GetStat(RoomStatDefOf.FoodPoisonChanceFactor);
                        }
                        if (Rand.Value < num)
                        {
                            foodPoisonable.PoisonPercent = 1f;
                        }
                    }
                    yield return(GenRecipe.PostProcessProduct(product, recipeDef, worker));
                }
            }
            if (recipeDef.specialProducts != null)
            {
                for (int j = 0; j < recipeDef.specialProducts.Count; j++)
                {
                    for (int k = 0; k < ingredients.Count; k++)
                    {
                        Thing ing = ingredients[k];
                        SpecialProductType specialProductType = recipeDef.specialProducts[j];
                        if (specialProductType != SpecialProductType.Butchery)
                        {
                            if (specialProductType == SpecialProductType.Smelted)
                            {
                                foreach (Thing product2 in ing.SmeltProducts(efficiency))
                                {
                                    yield return(GenRecipe.PostProcessProduct(product2, recipeDef, worker));
                                }
                            }
                        }
                        else
                        {
                            foreach (Thing product3 in ing.ButcherProducts(worker, efficiency))
                            {
                                yield return(GenRecipe.PostProcessProduct(product3, recipeDef, worker));
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient)
        {
            float efficiency = (float)((recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat, true) : 1.0);

            if (recipeDef.products != null)
            {
                int k = 0;
                if (k < recipeDef.products.Count)
                {
                    ThingCountClass prod     = recipeDef.products[k];
                    ThingDef        stuffDef = (!prod.thingDef.MadeFromStuff) ? null : dominantIngredient.def;
                    Thing           product3 = ThingMaker.MakeThing(prod.thingDef, stuffDef);
                    product3.stackCount = Mathf.CeilToInt((float)prod.count * efficiency);
                    if (dominantIngredient != null)
                    {
                        product3.SetColor(dominantIngredient.DrawColor, false);
                    }
                    CompIngredients ingredientsComp = product3.TryGetComp <CompIngredients>();
                    if (ingredientsComp != null)
                    {
                        for (int l = 0; l < ingredients.Count; l++)
                        {
                            ingredientsComp.RegisterIngredient(ingredients[l].def);
                        }
                    }
                    CompFoodPoisonable foodPoisonable = product3.TryGetComp <CompFoodPoisonable>();
                    if (foodPoisonable != null)
                    {
                        float num  = worker.GetStatValue(StatDefOf.FoodPoisonChance, true);
                        Room  room = worker.GetRoom(RegionType.Set_Passable);
                        if (room != null)
                        {
                            num *= room.GetStat(RoomStatDefOf.FoodPoisonChanceFactor);
                        }
                        if (Rand.Value < num)
                        {
                            foodPoisonable.PoisonPercent = 1f;
                        }
                    }
                    yield return(GenRecipe.PostProcessProduct(product3, recipeDef, worker));

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (recipeDef.specialProducts != null)
            {
                for (int j = 0; j < recipeDef.specialProducts.Count; j++)
                {
                    for (int i = 0; i < ingredients.Count; i++)
                    {
                        Thing ing = ingredients[i];
                        switch (recipeDef.specialProducts[j])
                        {
                        case SpecialProductType.Butchery:
                            using (IEnumerator <Thing> enumerator2 = ing.ButcherProducts(worker, efficiency).GetEnumerator())
                            {
                                if (enumerator2.MoveNext())
                                {
                                    Thing product = enumerator2.Current;
                                    yield return(GenRecipe.PostProcessProduct(product, recipeDef, worker));

                                    /*Error: Unable to find new state assignment for yield return*/;
                                }
                            }
                            break;

                        case SpecialProductType.Smelted:
                            using (IEnumerator <Thing> enumerator = ing.SmeltProducts(efficiency).GetEnumerator())
                            {
                                if (enumerator.MoveNext())
                                {
                                    Thing product2 = enumerator.Current;
                                    yield return(GenRecipe.PostProcessProduct(product2, recipeDef, worker));

                                    /*Error: Unable to find new state assignment for yield return*/;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            yield break;
IL_0473:
            /*Error near IL_0474: Unexpected return in MoveNext()*/;
        }