This release represents a major architectural refactor of the nutrition tracking system. Here are the key changes:
Core Architecture Overhaul
Replaced the component system:
- Removed
CompPartialNutrition(stored single nutrition value) - Introduced
CompFoodTracker(dual-mode nutrition tracking system) - Singleton state (
PartialNutrition): Tracks individual meal nutrition when stack size = 1 - Stack state (
NutritionEntries list): Tracks individual nutrition values for multi-item stacks - Automatically initializes based on stack count during
PostSpawnSetup()
Enhanced State Tracking
New IngestionState properties:
TraceID: Internal ID to track each ingestion event (for debugging/logging)TotalNutrition: Total nutrition of entire stack being consumedNutritionEntriesBefore: Captures nutritional state before eatingIngredientsBefore: Captures ingredients before eatingFoodToDestroy&DestroyFoodAfterIngestion: Deferred destruction handlingFoodDef,BaseDef: Better food definition tracking
Improved Nutrition Calculation
- Replaced simple linear nutrition calculations with granular meal-by-meal tracking
- Eating duration now based on
TotalNutrition / 0.9f(scaled with newNutritionConsumptionRateMultiplier) - Adjusted
MealCompletionThresholdfrom 0.995f to 0.99f (less strict) - Added
MealQualifierThreshold(0.225f) to classify batch vs. partial foods
Unified Nutrition Application
ApplyNutritionToPawn()now takesIngestionStateinstead of justPawn- Better encapsulation of nutrition correction logic
- Removed deprecated
GetRemainingNutrition()andSetRemainingNutrition()methods
New Features
1.Stack merging & splitting (MergeAndSplitPatches.cs):
- Handles
Thing.SplitOff()to properly distribute nutrition entries - Handles
Thing.TryAbsorbStack()to merge nutrition lists - Converts between singleton/stack states automatically
2.Nutrition tooltip display (GetExplanationPatch.cs):
- Inspect screen now shows multiple partial nutrition values for stacked meals
- Lists individual meal nutrition values for single meals
3.Enhanced destruction handling (DeferredFoodDestruction.cs):
- Defers food destruction until after ingestion completes
- Prevents conflicts with vanilla's Thing lifecycle
4.FoodTracker meal detection:
- New method to handle destroyed FT meals separately (
HandleDestroyedFoodTrackerMeal()) - Better distinction between vanilla foods and FT-tracked foods
Code Quality Improvements
- Comprehensive logging with TraceID for easier debugging
- Better validation and error messages
- Improved handling of edge cases (partial eating, stack disruptions)
- Cleaner separation of batch food vs. partial-creating meal logic
Removed Components
InspectStatOverride.cs(replaced byGetExplanationPatch.cs)CompPartialNutrition.cs(replaced byCompFoodTracker.cs)- Project file excludes for unused/replaced files
This release focuses on robustness and precision in nutrition tracking, especially for edge cases like interrupted meals, stack operations, and merging of partial meals.
Full Changelog: v1.2.3...v1.3.0