Пример #1
0
        public virtual IEnumerable <Thing> SmeltProducts(float efficiency)
        {
            List <ThingDefCountClass> costListAdj = def.CostListAdjusted(Stuff);

            for (int j = 0; j < costListAdj.Count; j++)
            {
                if (!costListAdj[j].thingDef.intricate)
                {
                    int num = GenMath.RoundRandom((float)costListAdj[j].count * 0.25f);
                    if (num > 0)
                    {
                        Thing thing = ThingMaker.MakeThing(costListAdj[j].thingDef);
                        thing.stackCount = num;
                        yield return(thing);
                    }
                }
            }
            if (def.smeltProducts != null)
            {
                for (int j = 0; j < def.smeltProducts.Count; j++)
                {
                    ThingDefCountClass thingDefCountClass = def.smeltProducts[j];
                    Thing thing2 = ThingMaker.MakeThing(thingDefCountClass.thingDef);
                    thing2.stackCount = thingDefCountClass.count;
                    yield return(thing2);
                }
            }
        }
Пример #2
0
        public virtual IEnumerable <Thing> SmeltProducts(float efficiency)
        {
            List <ThingDefCountClass> costListAdj = def.CostListAdjusted(Stuff);

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

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

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
        }
Пример #3
0
        public virtual IEnumerable <Thing> SmeltProducts(float efficiency)
        {
            List <ThingDefCountClass> costListAdj = this.def.CostListAdjusted(this.Stuff, true);

            for (int i = 0; i < costListAdj.Count; i++)
            {
                if (!costListAdj[i].thingDef.intricate)
                {
                    float countF = (float)costListAdj[i].count * 0.25f;
                    int   count  = GenMath.RoundRandom(countF);
                    if (count > 0)
                    {
                        Thing t = ThingMaker.MakeThing(costListAdj[i].thingDef, null);
                        t.stackCount = count;
                        yield return(t);
                    }
                }
            }
            if (this.def.smeltProducts != null)
            {
                for (int j = 0; j < this.def.smeltProducts.Count; j++)
                {
                    ThingDefCountClass ta = this.def.smeltProducts[j];
                    Thing t2 = ThingMaker.MakeThing(ta.thingDef, null);
                    t2.stackCount = ta.count;
                    yield return(t2);
                }
            }
        }
Пример #4
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++)
         {
             ThingDefCountClass 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);
             }
         }
     }
 }
Пример #5
0
 public virtual IEnumerable <Thing> ButcherProducts(Pawn butcher, float efficiency)
 {
     if (def.butcherProducts == null)
     {
         yield break;
     }
     for (int i = 0; i < def.butcherProducts.Count; i++)
     {
         ThingDefCountClass thingDefCountClass = def.butcherProducts[i];
         int num = GenMath.RoundRandom((float)thingDefCountClass.count * efficiency);
         if (num > 0)
         {
             Thing thing = ThingMaker.MakeThing(thingDefCountClass.thingDef);
             thing.stackCount = num;
             yield return(thing);
         }
     }
 }
Пример #6
0
        public virtual int CountProducts(Bill_Production bill)
        {
            ThingDefCountClass thingDefCountClass = this.recipe.products[0];
            ThingDef           thingDef           = thingDefCountClass.thingDef;

            if (thingDefCountClass.thingDef.CountAsResource && !bill.includeEquipped && (bill.includeTainted || !thingDefCountClass.thingDef.IsApparel || !thingDefCountClass.thingDef.apparel.careIfWornByCorpse) && bill.includeFromZone == null && bill.hpRange.min == 0f && bill.hpRange.max == 1f && bill.qualityRange.min == QualityCategory.Awful && bill.qualityRange.max == QualityCategory.Legendary && !bill.limitToAllowedStuff)
            {
                return(bill.Map.resourceCounter.GetCount(thingDefCountClass.thingDef) + this.GetCarriedCount(bill, thingDef));
            }
            int num = 0;

            if (bill.includeFromZone == null)
            {
                num = this.CountValidThings(bill.Map.listerThings.ThingsOfDef(thingDefCountClass.thingDef), bill, thingDef);
                if (thingDefCountClass.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 (this.CountValidThing(minifiedThing.InnerThing, bill, thingDef))
                        {
                            num += minifiedThing.stackCount * minifiedThing.InnerThing.stackCount;
                        }
                    }
                }
                num += this.GetCarriedCount(bill, thingDef);
            }
            else
            {
                foreach (Thing current in bill.includeFromZone.AllContainedThings)
                {
                    Thing innerIfMinified = current.GetInnerIfMinified();
                    if (this.CountValidThing(innerIfMinified, bill, thingDef))
                    {
                        num += innerIfMinified.stackCount;
                    }
                }
            }
            if (bill.includeEquipped)
            {
                foreach (Pawn current2 in bill.Map.mapPawns.FreeColonistsSpawned)
                {
                    List <ThingWithComps> allEquipmentListForReading = current2.equipment.AllEquipmentListForReading;
                    for (int j = 0; j < allEquipmentListForReading.Count; j++)
                    {
                        if (this.CountValidThing(allEquipmentListForReading[j], bill, thingDef))
                        {
                            num += allEquipmentListForReading[j].stackCount;
                        }
                    }
                    List <Apparel> wornApparel = current2.apparel.WornApparel;
                    for (int k = 0; k < wornApparel.Count; k++)
                    {
                        if (this.CountValidThing(wornApparel[k], bill, thingDef))
                        {
                            num += wornApparel[k].stackCount;
                        }
                    }
                    ThingOwner directlyHeldThings = current2.inventory.GetDirectlyHeldThings();
                    for (int l = 0; l < directlyHeldThings.Count; l++)
                    {
                        if (this.CountValidThing(directlyHeldThings[l], bill, thingDef))
                        {
                            num += directlyHeldThings[l].stackCount;
                        }
                    }
                }
            }
            return(num);
        }
Пример #7
0
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient, IBillGiver billGiver)
        {
            float efficiency;

            if (recipeDef.efficiencyStat == null)
            {
                efficiency = 1f;
            }
            else
            {
                efficiency = worker.GetStatValue(recipeDef.efficiencyStat, true);
            }
            if (recipeDef.workTableEfficiencyStat != null)
            {
                Building_WorkTable building_WorkTable = billGiver as Building_WorkTable;
                if (building_WorkTable != null)
                {
                    efficiency *= building_WorkTable.GetStatValue(recipeDef.workTableEfficiencyStat, true);
                }
            }
            if (recipeDef.products != null)
            {
                for (int i = 0; i < recipeDef.products.Count; i++)
                {
                    ThingDefCountClass 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)
                    {
                        Room  room   = worker.GetRoom(RegionType.Set_Passable);
                        float chance = (room == null) ? RoomStatDefOf.FoodPoisonChance.roomlessScore : room.GetStat(RoomStatDefOf.FoodPoisonChance);
                        if (Rand.Chance(chance))
                        {
                            foodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen);
                        }
                        else
                        {
                            float statValue = worker.GetStatValue(StatDefOf.FoodPoisonChance, true);
                            if (Rand.Chance(statValue))
                            {
                                foodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook);
                            }
                        }
                    }
                    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));
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient, IBillGiver billGiver)
        {
            float efficiency = (recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat) : 1f;

            if (recipeDef.workTableEfficiencyStat != null)
            {
                Building_WorkTable building_WorkTable = billGiver as Building_WorkTable;
                if (building_WorkTable != null)
                {
                    efficiency *= building_WorkTable.GetStatValue(recipeDef.workTableEfficiencyStat);
                }
            }
            if (recipeDef.products != null)
            {
                for (int k = 0; k < recipeDef.products.Count; k++)
                {
                    ThingDefCountClass thingDefCountClass = recipeDef.products[k];
                    Thing thing = ThingMaker.MakeThing(stuff: (!thingDefCountClass.thingDef.MadeFromStuff) ? null : dominantIngredient.def, def: thingDefCountClass.thingDef);
                    thing.stackCount = Mathf.CeilToInt((float)thingDefCountClass.count * efficiency);
                    if (dominantIngredient != null)
                    {
                        thing.SetColor(dominantIngredient.DrawColor, reportFailure: false);
                    }
                    CompIngredients compIngredients = thing.TryGetComp <CompIngredients>();
                    if (compIngredients != null)
                    {
                        for (int l = 0; l < ingredients.Count; l++)
                        {
                            compIngredients.RegisterIngredient(ingredients[l].def);
                        }
                    }
                    CompFoodPoisonable compFoodPoisonable = thing.TryGetComp <CompFoodPoisonable>();
                    if (compFoodPoisonable != null)
                    {
                        if (Rand.Chance(worker.GetRoom()?.GetStat(RoomStatDefOf.FoodPoisonChance) ?? RoomStatDefOf.FoodPoisonChance.roomlessScore))
                        {
                            compFoodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen);
                        }
                        else if (Rand.Chance(worker.GetStatValue(StatDefOf.FoodPoisonChance)))
                        {
                            compFoodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook);
                        }
                    }
                    yield return(PostProcessProduct(thing, recipeDef, worker));
                }
            }
            if (recipeDef.specialProducts == null)
            {
                yield break;
            }
            for (int k = 0; k < recipeDef.specialProducts.Count; k++)
            {
                for (int i = 0; i < ingredients.Count; i++)
                {
                    Thing thing2 = ingredients[i];
                    switch (recipeDef.specialProducts[k])
                    {
                    case SpecialProductType.Butchery:
                        foreach (Thing item in thing2.ButcherProducts(worker, efficiency))
                        {
                            yield return(PostProcessProduct(item, recipeDef, worker));
                        }
                        break;

                    case SpecialProductType.Smelted:
                        foreach (Thing item2 in thing2.SmeltProducts(efficiency))
                        {
                            yield return(PostProcessProduct(item2, recipeDef, worker));
                        }
                        break;
                    }
                }
            }
        }
        // Token: 0x06000017 RID: 23 RVA: 0x00003205 File Offset: 0x00001405
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient)
        {
            Log.Message(string.Concat(new string[]
            {
                "init WPGenRecipe: recipeDef ",
                (recipeDef != null) ? recipeDef.ToString() : null,
                " worker ",
                (worker != null) ? worker.ToString() : null,
                " ingredients ",
                (ingredients != null) ? ingredients.ToString() : null,
                " dominantIngredient ",
                (dominantIngredient != null) ? dominantIngredient.ToString() : null
            }), false);
            bool  flag = recipeDef.efficiencyStat == null;
            float efficiency;

            if (flag)
            {
                efficiency = 1f;
            }
            else
            {
                efficiency = worker.GetStatValue(recipeDef.efficiencyStat, true);
            }
            bool flag2 = recipeDef.products != null;

            if (flag2)
            {
                int num2;
                for (int i = 0; i < recipeDef.products.Count; i = num2 + 1)
                {
                    ThingDefCountClass prod = recipeDef.products[i];
                    bool     madeFromStuff  = prod.thingDef.MadeFromStuff;
                    ThingDef stuffDef;
                    if (madeFromStuff)
                    {
                        stuffDef = dominantIngredient.def;
                    }
                    else
                    {
                        stuffDef = null;
                    }
                    Thing product = ThingMaker.MakeThing(prod.thingDef, stuffDef);
                    product.stackCount = Mathf.CeilToInt((float)prod.count * efficiency);
                    bool flag3 = dominantIngredient != null;
                    if (flag3)
                    {
                        product.SetColor(dominantIngredient.DrawColor, false);
                    }
                    CompIngredients ingredientsComp = product.TryGetComp <CompIngredients>();
                    bool            flag4           = ingredientsComp != null;
                    if (flag4)
                    {
                        for (int j = 0; j < ingredients.Count; j = num2 + 1)
                        {
                            ingredientsComp.RegisterIngredient(ingredients[j].def);
                            num2 = j;
                        }
                    }
                    CompFoodPoisonable foodPoisonable = product.TryGetComp <CompFoodPoisonable>();
                    bool flag5 = foodPoisonable != null;
                    if (flag5)
                    {
                        float num    = worker.GetStatValue(StatDefOf.FoodPoisonChance, true);
                        Room  room   = worker.GetRoom(RegionType.Set_Passable);
                        float chance = (room == null) ? RoomStatDefOf.FoodPoisonChance.roomlessScore : room.GetStat(RoomStatDefOf.FoodPoisonChance);
                        bool  flag6  = Rand.Chance(chance);
                        if (flag6)
                        {
                            foodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen);
                        }
                        else
                        {
                            float statValue = worker.GetStatValue(StatDefOf.FoodPoisonChance, true);
                            bool  flag7     = Rand.Chance(statValue);
                            if (flag7)
                            {
                                foodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook);
                            }
                        }
                        room = null;
                    }
                    yield return(WPGenRecipe.PostProcessProduct(product, recipeDef, worker));

                    prod            = null;
                    stuffDef        = null;
                    product         = null;
                    ingredientsComp = null;
                    foodPoisonable  = null;
                    num2            = i;
                }
            }
            bool flag8 = recipeDef.specialProducts != null;

            if (flag8)
            {
                string str = "special recipedef not null";
                List <SpecialProductType> specialProducts = recipeDef.specialProducts;
                Log.Message(str + ((specialProducts != null) ? specialProducts.ToString() : null), false);
                Log.Message("recipeDef.specialProducts.Count " + recipeDef.specialProducts.Count.ToString(), false);
                int num2;
                for (int k = 0; k < recipeDef.specialProducts.Count; k = num2 + 1)
                {
                    Log.Message("recipeDef.specialProducts[j] " + recipeDef.specialProducts[k].ToString(), false);
                    Log.Message("ingredients.Count " + ingredients.Count.ToString(), false);
                    string str2 = "recipeDef.ingredients ";
                    List <IngredientCount> ingredients2 = recipeDef.ingredients;
                    Log.Message(str2 + ((ingredients2 != null) ? ingredients2.ToString() : null), false);
                    for (int l = 0; l < ingredients.Count; l = num2 + 1)
                    {
                        Thing  ing   = ingredients[l];
                        string str3  = "ingredients[k] ";
                        Thing  thing = ingredients[l];
                        Log.Message(str3 + ((thing != null) ? thing.ToString() : null), false);
                        string str4   = "ing ";
                        Thing  thing2 = ing;
                        Log.Message(str4 + ((thing2 != null) ? thing2.ToString() : null), false);
                        SpecialProductType specialProductType = recipeDef.specialProducts[k];
                        bool flag9 = specialProductType > SpecialProductType.Butchery;
                        if (flag9)
                        {
                            Log.Message("not butchery", false);
                            bool flag10 = specialProductType == SpecialProductType.Smelted;
                            if (flag10)
                            {
                                foreach (Thing product2 in ing.SmeltProducts(efficiency))
                                {
                                    yield return(WPGenRecipe.PostProcessProduct(product2, recipeDef, worker));
                                }
                            }
                        }
                        else
                        {
                            Log.Message("butchery", false);
                            foreach (Thing product3 in ing.ButcherProducts(worker, efficiency))
                            {
                                string[] array = new string[8];
                                array[0] = "recipeDef.specialProducts[k] ";
                                array[1] = recipeDef.specialProducts[l].ToString();
                                array[2] = "product3 ";
                                int   num3   = 3;
                                Thing thing3 = product3;
                                array[num3] = ((thing3 != null) ? thing3.ToString() : null);
                                array[4]    = " recipeDef ";
                                array[5]    = ((recipeDef != null) ? recipeDef.ToString() : null);
                                array[6]    = " worker ";
                                array[7]    = ((worker != null) ? worker.ToString() : null);
                                Log.Message(string.Concat(array), false);
                                yield return(WPGenRecipe.PostProcessProduct(product3, recipeDef, worker));
                            }
                        }
                        ing  = null;
                        num2 = l;
                    }
                    num2 = k;
                }
            }
            Log.Message("yield break", false);
            yield break;
        }
Пример #10
0
        public static IEnumerable <Thing> MakeRecipeProducts(RecipeDef recipeDef, Pawn worker, List <Thing> ingredients, Thing dominantIngredient, IBillGiver billGiver)
        {
            float efficiency = (recipeDef.efficiencyStat != null) ? worker.GetStatValue(recipeDef.efficiencyStat) : 1f;

            if (recipeDef.workTableEfficiencyStat != null)
            {
                Building_WorkTable building_WorkTable = billGiver as Building_WorkTable;
                if (building_WorkTable != null)
                {
                    efficiency *= building_WorkTable.GetStatValue(recipeDef.workTableEfficiencyStat);
                }
            }
            if (recipeDef.products != null)
            {
                int k = 0;
                if (k < recipeDef.products.Count)
                {
                    ThingDefCountClass prod = recipeDef.products[k];
                    Thing product3          = ThingMaker.MakeThing(stuff: (!prod.thingDef.MadeFromStuff) ? null : dominantIngredient.def, def: prod.thingDef);
                    product3.stackCount = Mathf.CeilToInt((float)prod.count * efficiency);
                    if (dominantIngredient != null)
                    {
                        product3.SetColor(dominantIngredient.DrawColor, reportFailure: 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 chance = worker.GetRoom()?.GetStat(RoomStatDefOf.FoodPoisonChance) ?? RoomStatDefOf.FoodPoisonChance.roomlessScore;
                        if (Rand.Chance(chance))
                        {
                            foodPoisonable.SetPoisoned(FoodPoisonCause.FilthyKitchen);
                        }
                        else
                        {
                            float statValue = worker.GetStatValue(StatDefOf.FoodPoisonChance);
                            if (Rand.Chance(statValue))
                            {
                                foodPoisonable.SetPoisoned(FoodPoisonCause.IncompetentCook);
                            }
                        }
                    }
                    yield return(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(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(PostProcessProduct(product2, recipeDef, worker));

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