边缘世界 RimWorld

边缘世界 RimWorld

评价数不足
Nutrient Dispenser Improvements and Fixes
   
奖励
收藏
已收藏
取消收藏
Mod, 1.5, 1.6
文件大小
发表于
更新日期
264.036 KB
2024 年 6 月 10 日 上午 6:11
7 月 18 日 下午 12:07
6 项改动说明 ( 查看 )

订阅以下载
Nutrient Dispenser Improvements and Fixes

描述
This mod corrects some bugs that nutrient paste dispensers have in vanilla Rimworld, both observable and not. For a player, using this mod will only really fix a single bug in RimWorld where if you have dispensers without hoppers or without a way to fill those hoppers, pawns can sometimes end up choosing one that isn't actually usable, and if this happens, they won't eat anything at all, despite needing to.

Most of the fixes in this mod will instead help mod creators by making it so inheriting from the vanilla nutrient paste dispenser will work as one might expect instead of using hard-coded values from the vanilla nutrient paste meal everywhere.

The full list of fixes this mod does is as follows:

  • Where the game has been hardcoded to use `ThingDefOf.MealNutrientPaste`, instead use `Building_NutrientPasteDispenser.DispensableDef`. While this doesn't directly affect vanilla, it allows subclasses of `Building_NutrientPasteDispenser` to dispense something else than the vanilla nutrient paste. This type of fix has been applies to:
    • `Building_NutrientPasteDispenser.TryDispenseFood`
    • `FoodUtility.BestFoodSourceOnMap`
    • `JobDriver_FoodDeliver.GetReport`
    • `JobDriver_FoodFeedPatient.GetReport`
  • In `FoodUtility.BestFoodSourceOnMap`, where the logic allows choosing an "empty" dispenser: also require the dispenser to have an adjacent, accessible hopper. Without this additional check, the game can pick a dispenser without a hopper, thinking it can be filled later, but since one without hoppers can't, that job can never happen, and the pawn just ends up not eating at all.
  • In `ThingListGroupHelper.Includes`, use `ThingDef.IsFoodDispenser` to decide whether a given def is a food dispenser instead of a hardcoded check against exactly `Building_NutrientPasteDispenser`. This allows inheriting from `Building_NutrientPasteDispenser` to work as expected.

Making a custom nutrient dispenser with XML only

Besides fixing things about nutrient paste dispensers, this mod also intends to make it easier to make custom dispensers using XML only. To that extent, I've created a custom `thingClass` called `ilvyion.NutrientDispenserDispensableFix.Building_NutrientPasteDispenserImproved` which, in combination with a `<modExtensions>` called `ilvyion.NutrientDispenserDispensableFix.ImprovedNutrientPasteDispenserModExtension` lets you define things that would normally require code in XML.

Currently the only supported feature of this `ImprovedNutrientPasteDispenserModExtension` is to allow you to set what is dispensed, but I'm open to adding more features if anyone needs them.

To use this XML-only nutrient dispenser, you make a `ThingDef` like the following:
<ThingDef ParentName="BuildingBase"> <thingClass>ilvyion.NutrientDispenserDispensableFix.Building_NutrientPasteDispenserImproved</thingClass> <modExtensions> <li Class="ilvyion.NutrientDispenserDispensableFix.ImprovedNutrientPasteDispenserModExtension"> <!-- This is where you set your dispensed product --> <dispensableDef>MealNutrientPaste</dispensableDef> </li> </modExtensions> <!-- ... and the rest of the owl... er, ThingDef. --> </ThingDef>

You can look at an example dispenser definition included with this mod in Defs/ImprovedNutrientPasteDispenser.xml. It does not show up in the game directly, but can be spawned in using the debug tools. It is set up to dispense simple meals.

Source code
Source code can be found on GitHub[github.com]. Report any bugs or feature suggestions/requests on the issue tracker[github.com].

Like my work?
[ko-fi.com]

Feel free to join my Discord server[discord.gg] if you want to talk to me (and other members) about my projects, or just to hang out, I guess. :)
3 条留言
Major Major Major Major 1 月 3 日 下午 12:39 
Hey, would it be possible to add a patch allowing dispensers to dispense more than 1 meal? I am playing with modded xenotypes that can eat way more than 1 meal, but are constantly on the brink of starvation because the dispenser only allows them to take 1. VE Nutrient paste has the feeder but that thing is buggy as hell and keeps dumping out my whole network.
PBSpiralGamer 2024 年 6 月 10 日 上午 10:39 
Very useful for a mod I'm making with the help of the same author has this fix mod. Amazing work!
Antharann Fireblade 2024 年 6 月 10 日 上午 10:36 
SOOO needed to add in your own nutrient paste dispensers!!!