Пример #1
0
        static bool Prefix(Building_NutrientPasteDispenser __instance, ref bool __result)
        {
            var fc = FridgeCache.GetFridgeCache(__instance.Map);

            float num = 0f;

            foreach (IntVec3 cell in __instance.AdjCellsCardinalInBounds)
            {
                Thing thing  = null;
                Thing holder = null;
                foreach (Thing t in cell.GetThingList(__instance.Map))
                {
                    if (Building_NutrientPasteDispenser.IsAcceptableFeedstock(t.def))
                    {
                        thing = t;
                    }
                    if (t.def == ThingDefOf.Hopper || fc?.HasFridgeAt(cell) == true)
                    {
                        holder = t;
                    }

                    if (thing != null && holder != null)
                    {
                        num += (float)thing.stackCount * thing.GetStatValue(StatDefOf.Nutrition, true);
                        if (num >= __instance.def.building.nutritionCostPerDispense)
                        {
                            __result = true;
                            return(false);
                        }
                        break;
                    }
                }
            }
            return(false);
        }
Пример #2
0
        static bool Prefix(Building_NutrientPasteDispenser __instance, ref Thing __result)
        {
            var fc = FridgeCache.GetFridgeCache(__instance.Map);

            foreach (IntVec3 cell in __instance.AdjCellsCardinalInBounds)
            {
                Thing thing  = null;
                Thing holder = null;
                foreach (Thing t in cell.GetThingList(__instance.Map))
                {
                    if (Building_NutrientPasteDispenser.IsAcceptableFeedstock(t.def))
                    {
                        thing = t;
                    }
                    if (t.def == ThingDefOf.Hopper || fc?.HasFridgeAt(cell) == true)
                    {
                        holder = t;
                    }
                }
                if (thing != null && holder != null)
                {
                    __result = thing;
                    return(false);
                }
            }
            return(false);
        }