public static int CountForThingDef(ThingDef thingDef, float baseCount, RecipeDef recipe) { if (!recipe.IsIngredient(thingDef)) { return(0); } if (baseCount < 0) { foreach (var ingredientCount in recipe.ingredients) { if (ingredientCount.filter.AllowedThingDefs.Contains(thingDef)) { baseCount = ingredientCount.GetBaseCount(); break; } } } float ingredientValue = recipe.IngredientValueGetter.ValuePerUnitOf(thingDef); return(Mathf.Max(1, Mathf.CeilToInt(baseCount / ingredientValue))); }
public static int CountForThingDef( ThingDef thingDef, float baseCount, RecipeDef recipe ) { if( !recipe.IsIngredient( thingDef ) ) { return 0; } if( baseCount < 0 ) { foreach( var ingredientCount in recipe.ingredients ) { if( ingredientCount.filter.AllowedThingDefs.Contains( thingDef ) ) { baseCount = ingredientCount.GetBaseCount(); break; } } } float ingredientValue = recipe.IngredientValueGetter.ValuePerUnitOf( thingDef ); return Mathf.Max( 1, Mathf.CeilToInt( baseCount / ingredientValue ) ); }