コード例 #1
0
        public static bool HasEnoughFeedstockInStorage(ref bool __result, Building_NutrientPasteDispenser __instance)
        {
            if (!(__instance.def.GetModExtension <NPDModExtension>() is null))
            {
                bool empty = __instance.def.GetModExtension <NPDModExtension>().ingredientList is null ||
                             !__instance.def.GetModExtension <NPDModExtension>().ingredientList.Any();
                if (!empty && !(__instance.def.GetCompProperties <CompProperties_Refillable>() is null))
                {
                    __result = false;
                    List <IngredientAndCostClass> ingredientList = __instance.def.GetModExtension <NPDModExtension>().ingredientList;

                    for (int i = 0; i < ingredientList.Count; i++)
                    {
                        IngredientAndCostClass ingredient = ingredientList[i];
                        if (__instance.GetComp <CompRefillable>().items[i] < ingredient.nutritionCost)
                        {
                            __result = false;
                            return(false);
                        }
                    }
                    __result = true;
                    return(false);
                }
                Log.Error("Must include ingredient list if using CompRefillable comp class");
            }
            return(true);
        }
コード例 #2
0
 public bool HasEnoughItems()
 {
     if (!(this.parent.def.GetModExtension <NPDModExtension>().ingredientList is null) && this.parent.def.GetModExtension <NPDModExtension>().ingredientList.Count > 0)
     {
         for (int i = 0; i < this.parent.def.GetModExtension <NPDModExtension>().ingredientList.Count; i++)
         {
             IngredientAndCostClass ing = this.parent.def.GetModExtension <NPDModExtension>().ingredientList[i];
             if (this.items[i] < ing.nutritionCost)
             {
                 return(false);
             }
         }
         return(true);
     }
     Log.Error("Must have Mod Extension if using Comp Refillable CompClass");
     return(false);
 }