public Thing TakeOutProduct() { // Integrity check for the food being ready if (!Finished) { Log.Warning("Survivalist's Additions:: Tried to get smoked food but it's not yet smoked."); return(null); } // Create the food Thing smokedFood; ThingCountExposable selectedFood = foodSources.RandomElement(); if (selectedFood.thingDef == SrvDefOf.SRV_Cheese) { smokedFood = ThingMaker.MakeThing(SrvDefOf.SRV_SmokedCheese, null); } else { smokedFood = ThingMaker.MakeThing(SrvDefOf.SRV_SmokedMeat, null); smokedFood.TryGetComp <CompIngredients>().RegisterIngredient(selectedFood.thingDef); } smokedFood.stackCount = selectedFood.count; // Remove this food from the list, resetting if this is the last one foodSources.Remove(selectedFood); if (foodSources.Count <= 0) { Reset(); } return(smokedFood); }
// Tending implies rotating the food, removing rotten bits, adjusting the coals, etc. public void Tend() { ticksSinceTending = 0; // Remove some of the rotting bits of the food while (RotProgressPct >= 0.05f) { int i = Rand.Range(0, foodSources.Count); int amountToTrim = (int)(FoodCount * 0.05); int trimmedAmount = amountToTrim * 1000; if (amountToTrim > 0) { ThingCountExposable rottingFood = foodSources.RandomElement(); int trimmedCount = rottingFood.count - amountToTrim; if (trimmedCount <= 0) { trimmedAmount = rottingFood.count * 1000; foodSources.Remove(rottingFood); } else { foodSources.Find((ThingCountExposable c) => c == rottingFood).count = trimmedCount; } } if (trimmedAmount > 0) { rottingTicks -= trimmedAmount; } else { rottingTicks = 0; } } }