RimWorld

RimWorld

376 ratings
Storage Refill Hysteresis
5
7
4
2
3
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.5
File Size
Posted
Updated
522.778 KB
22 Jun, 2024 @ 9:00pm
27 Jun, 2024 @ 10:12am
9 Change Notes ( view )

Subscribe to download
Storage Refill Hysteresis

In 1 collection by pureMJ
Common Sense +
5 items
Description
Storage now has Smart Refill (hysteresis) function.
Refill if below configurable level. Stop if above another configurable level.

It avoids "single meal hauling" and maintains the balanced storage, making hauling adaptive.

Supports Stockpile Zones, Shelf, Fridges and all other storage buildings, as well as linked Storage groups.
Supports nutrient paste dispenser hoppers!

Has both automatic controlling and a manual toggle button (flickable control).



Background
In Rimworld we have storage units, such as a stockpile zone, shelf, fridges (from mods) and etc. Colonists will haul stuff into them automatically.

One common strategy most veteran players use: have some high priority shelf or fridge (or smaller stock pile zones), placed near dining table/crafting table/kitchen, so colonist can quickly grab what they need, rather than walking a long way into the messy general storage area for a single piece of material/meal.

This is a very good strategy, until another colonist walks across the map, into the messy general storage area, then walks a long way to the shelf next to the dining table, just to delivery a single meal.

Yes, this is beyond stupidity and I can't bear to see it happen all the time in my game play.

This Mod Adds
Hysteresis, a mysterious word that comes to rescue!

TL;DR: Install this mod and turn on the "Smart Refill" function on the storage of your choice, problem solved.

Details
We set a target range of storage usages.
Colonist consumes the material/items on the shelf gradually, and it will eventuall become relatively empty (the usage is below the target min usage), at which point the hauler can come to haul a whole stack (and in case you use Pickup and Haul, tens of stacks) and deliver all at once.
The refill will make the shelf almost full (the usage reaches the target max usage), then refill is paused (turned off).
Then again, next time when the shelf is below the target min usage, the refill is unpaused (turned on again).
... prepeat...

This process is called hysteresis. It is the same mechanism as the "do until" bill option with "pause until" checked.
We call the [min, max) target range the [b]hysteresis[/b] range.

Common Usage Cases
Different settings of the Smart Refill function will allow the storage to work on different logical "Mode".
Below are some examples.

6-9 Smart Refill Mode
A typical hysteresis range of [60%, 95%). (This is the default of the "default range" mod setting)
In this mode your storage will be filled up to 95%-ish, then refill after it's used up to below 60%.
This is the sweet point for small storages such as fridge (or linked fridges) near dining table. No more single meal delivery.

One Fill Mode
Hysteresis range of [0%, x%).
This storage will be filled to x% once and then stop, until you manually click the toggle button to tell it to refill again.

No Hysteresis Mode
Hysteresis range of [x%, x%).
This storage will refill if it's below x% but immediately stop when it's above.
This mode will be similar to how SatisfiedStorage works except this mod counts all cells of a storage and supports linked storages.

Monitor Mode
Hysteresis range of [100%, 100%).
Even if you do not want the Smart Refill function, it is still beneficial to turn it on.
At this mode the storage functions as if this mod does not exist, except your large storages will no long tank your performance when it's full.
And you get to have a nice monitor UI of how much your storage is filled up.

More smart ways to use this mod are waiting for you to explore.

Performance
This mod has no observable negative impact on performance. It is tested in late game scenarios with tens of thousands of storage cells.

In fact, thanks to the usage of cache this mod improves performance, by telling the game that "this big, almost full storage is paused for refill", so that vanilla game does not need to check every cell each time a haul job is made.

Compatibility
Compatible with Deep Storage, Pickup and Haul, While You Are Nearby, Rim Fridge etc.
Also compatible with Adaptive Storage Framework, RimKeeper - Storage & Filters Helper etc.


F.A.Q
Does this mod affect performance?
No. It actually improves performance, see explanation in the Performance section.

Is this mod safe to add/remove mid save?
Yes.

Why does my colonist refill my storage beyond the set upper limit?
That's normal. There is a overshoot effect which is intentional.

Detailed Explanation:
The upper limit serves two goals:
  1. When the usage is below it, if it was refilling, the refill won't stop.
  2. When usage reaches it, the refill will turn off automatically.

Note that the first goals is strict. It will never turn off refill automatically if the usage is below the upper limit.
However, the second goal is not strict. The moment when the usage hit the upper limit, it takes up to about a second (can be configured in the mod settings) for the storage to stop the refill. This is for game performance.
Also, for colonist work efficiency, this mod does not hard stop any colonist who is already on the way to delivery things to the storage. So they will finish whatever they are already hauling into the storage before the refill stop. (If you think about it, there is no point to hard stop at the upper limit, because that only wastes storage space and waste some of the ongoing work efforts)


Updates
v0.1.6 Fixed a minor bug that shelves in blueprint could not be linked.
v0.1.5 Fixed a minor bug that mod settings would only appear in dev mode.
v0.1.4 Emergent bug fix: game cannot load.
v0.1.3 Fixed a minor bug that hoppers were ignoring smart refill settings.
v0.1.2 Improved UI logic so it's now compatible with more mods.
v0.1.1 Fixed a minor bug that when this mod is added mid save, old storages couldn't gain hysteresis function.
v0.1.0 First version.

Credits & Links
Many thanks to the members of the #mod-development channel on the Rimworld Discord server!

If you enjoy this mod, please check out my other Rimworld mods on Steam Workshop!
Popular Discussions View All (1)
0
26 Jun, 2024 @ 8:45am
Bug Report
pureMJ
178 Comments
天真浪漫 23 hours ago 
无需多言
路人公 29 Dec, 2024 @ 1:04am 
伟大
Inzhy凡泽 28 Dec, 2024 @ 6:00pm 
哥你可千万要更新下去啊,1.6以后的版本如果你不更新了我怎么活啊TAT
Inzhy凡泽 28 Dec, 2024 @ 5:59pm 
伟大
sstareven 6 Dec, 2024 @ 1:01pm 
作者会不会考虑和multiplayer模组兼容,让智能补货的功能同步给主客机之间……大感谢你的模组
12138 1 Dec, 2024 @ 7:42pm 
好像没有兼容边缘工厂的存储箱,显示有问题。。。。我在炮台附件放了一格的存储箱(A点)装化合燃料,但经常会从更远处的存储点(B点)拿化合燃料去给炮台加油,但来到炮台附近手动控制加油又会从A点拿货,如果这时有人要去A点拿货,那手动控制的人加油就会去B点拿货了,这种可以怎么优化吗
Alexkittly 23 Nov, 2024 @ 5:32am 
终于有这个功能了,原版不能自定义管理物品数量真的麻烦的要死
SunKnight_Czy 19 Nov, 2024 @ 12:29am 
希望不仅可以使用比例,也可以使用具体数字
HawnHan 13 Nov, 2024 @ 5:24pm 
佬,兼容Stockpile Stack Limit吗(感觉功能上有点冲突
Device 23 Sep, 2024 @ 1:11am 
大爱这个mod,感觉比stackgap好用