Exemplo n.º 1
0
        /// <summary>
        /// Converts a <c>Trading.Thing</c> into a <c>Verse.Thing</c>.
        /// Used for unloading a <c>Trading.Thing</c> after transport.
        /// </summary>
        /// <param name="protoThing">Thing to convert</param>
        /// <returns>Converted thing</returns>
        /// <exception cref="InvalidOperationException">Could not find a single def that matches Trading.Thing def name</exception>
        /// <exception cref="InvalidOperationException">Could not find a single def that matches Trading.Thing stuff def name</exception>
        public static Verse.Thing ConvertThingFromProto(Trading.ProtoThing protoThing)
        {
            // Try to get the ThingDef for protoThing
            ThingDef thingDef;

            try
            {
                thingDef = DefDatabase <ThingDef> .AllDefs.Single(def => def.defName == protoThing.DefName);
            }
            catch (InvalidOperationException e)
            {
                throw new InvalidOperationException(string.Format("Could not find a single def that matches def name '{0}'", protoThing.DefName), e);
            }

            // Try to get the ThingDef for stuff inside protoThing
            ThingDef stuffDef = null;

            try
            {
                // Check if we actually have stuff inside the thing
                if (!string.IsNullOrEmpty(protoThing.StuffDefName))
                {
                    stuffDef = DefDatabase <ThingDef> .AllDefs.Single(def => def.defName == protoThing.StuffDefName);
                }
            }
            catch (InvalidOperationException e)
            {
                throw new InvalidOperationException(string.Format("Could not find a single def that matches stuff def name '{0}'", protoThing.StuffDefName), e);
            }

            // Make our base verseThing and give it protoThing's stack count and hit points
            Verse.Thing verseThing = ThingMaker.MakeThing(thingDef, stuffDef);
            verseThing.stackCount = protoThing.StackCount;
            verseThing.HitPoints  = protoThing.HitPoints;

            // Check if verseThing should have its quality set
            if (protoThing.Quality != Quality.None)
            {
                // Set verseThing's quality if it is capable of having a quality
                // Art generation should be that of an outsider given that this is a traded item
                verseThing.TryGetComp <CompQuality>()?.SetQuality((QualityCategory)protoThing.Quality, ArtGenerationContext.Outsider);
            }

            // Check if verseThing is minified
            if (verseThing is MinifiedThing minifiedVerseThing)
            {
                // Set verseThing's inner thing to protoThing's inner thing
                minifiedVerseThing.InnerThing = protoThing.InnerProtoThing != null?ConvertThingFromProto(protoThing.InnerProtoThing) : null;
            }

            // Return the constructed Verse.Thing
            return(verseThing);
        }
Exemplo n.º 2
0
        public virtual void AttachTo(Thing parent)
        {
            this.parent = parent;
            CompAttachBase compAttachBase = parent.TryGetComp <CompAttachBase>();

            if (compAttachBase == null)
            {
                Log.Error(string.Concat(new object[]
                {
                    "Cannot attach ",
                    this,
                    " to ",
                    parent,
                    ": parent has no CompAttachBase."
                }), false);
                return;
            }
            compAttachBase.AddAttachment(this);
        }
Exemplo n.º 3
0
        public bool CountValidThing(Thing thing, Bill_Production bill, ThingDef def)
        {
            ThingDef def2 = thing.def;

            if (def2 != def)
            {
                return(false);
            }
            if (!bill.includeTainted && def2.IsApparel && ((Apparel)thing).WornByCorpse)
            {
                return(false);
            }
            if (!bill.hpRange.IncludesEpsilon((float)thing.HitPoints / (float)thing.MaxHitPoints))
            {
                return(false);
            }
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            return((compQuality == null || bill.qualityRange.Includes(compQuality.Quality)) && (!bill.limitToAllowedStuff || bill.ingredientFilter.Allows(thing.Stuff)));
        }
Exemplo n.º 4
0
 public static bool TryGetFixedTemperature(IThingHolder holder, Thing forThing, out float temperature)
 {
     if (holder is Pawn_InventoryTracker && forThing.TryGetComp <CompHatcher>() != null)
     {
         temperature = 14f;
         return(true);
     }
     if (holder is CompLaunchable || holder is ActiveDropPodInfo || holder is TravelingTransportPods)
     {
         temperature = 14f;
         return(true);
     }
     if (holder is SettlementBase_TraderTracker || holder is TradeShip)
     {
         temperature = 14f;
         return(true);
     }
     temperature = 21f;
     return(false);
 }
Exemplo n.º 5
0
        public static List <DebugMenuOption> SpawnOptions(WipeMode wipeMode)
        {
            List <DebugMenuOption> list       = new List <DebugMenuOption>();
            IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs
                                                where DebugThingPlaceHelper.IsDebugSpawnable(def, true)
                                                select def;

            foreach (ThingDef current in enumerable)
            {
                ThingDef localDef = current;
                list.Add(new DebugMenuOption(localDef.LabelCap, DebugMenuOptionMode.Tool, delegate
                {
                    Thing thing             = ThingMaker.MakeThing(localDef, GenStuff.RandomStuffFor(localDef));
                    CompQuality compQuality = thing.TryGetComp <CompQuality>();
                    if (compQuality != null)
                    {
                        compQuality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                    }
                    GenSpawn.Spawn(thing, UI.MouseCell(), Find.CurrentMap, wipeMode);
                }));
            }
            return(list);
        }
Exemplo n.º 6
0
        public static void DebugSpawn(ThingDef def, IntVec3 c, int stackCount = -1, bool direct = false)
        {
            if (stackCount <= 0)
            {
                stackCount = def.stackLimit;
            }
            ThingDef stuff = GenStuff.RandomStuffFor(def);
            Thing    thing = ThingMaker.MakeThing(def, stuff);

            thing.TryGetComp <CompQuality>()?.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
            if (thing.def.Minifiable)
            {
                thing = thing.MakeMinified();
            }
            thing.stackCount = stackCount;
            if (direct)
            {
                GenPlace.TryPlaceThing(thing, c, Find.CurrentMap, ThingPlaceMode.Direct);
            }
            else
            {
                GenPlace.TryPlaceThing(thing, c, Find.CurrentMap, ThingPlaceMode.Near);
            }
        }
Exemplo n.º 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));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        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));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
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;
        }
Exemplo n.º 11
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()*/;
        }
Exemplo n.º 12
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()*/;
        }