RimWorld

RimWorld

536 ratings
Storage Refill Hysteresis
14
11
2
7
2
3
2
   
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
220 Comments
Szilreo 12 hours ago 
1.6 plz we need this
萨拉托加Ciel 21 hours ago 
1.6,求求了
鹘鸼 10 Jul @ 10:50pm 
伟大,无需多言
Travioli 3 Jul @ 3:03pm 
1.6 update?
tatakai 27 Jun @ 6:59am 
伟大,无需多言
luocha 13 Jun @ 10:59pm 
亲测1.6可用
Works in 1.6
chenpunk 11 Jun @ 10:06am 
能否加入一个存储区上限的功能?
在使用CEmod的各种炮台时需要设置存储区堆放弹药,但是CE的弹药stack上限往往很高。补货在搬运的时候往往会超出区间上限,比如我只希望最多搬5发炮弹到某个存储区,但是小人往往会一口气搬25发炮弹,即他本人的携带上限
目前这个问题我是配合本mod+stack gap一起使用的
Enrico 10 Jun @ 4:46pm 
Quarry hysteresis, anyone?
ForestSingleRank 3 Jun @ 9:15pm 
大佬,能不能在设置中加入一个默认自动打开智能补货的开关
Conyu 28 May @ 6:28am 
赞美大佬