RimWorld

RimWorld

575 ratings
Storage Refill Hysteresis
15
11
2
7
2
2
3
3
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.5, 1.6
File Size
Posted
Updated
551.468 KB
22 Jun, 2024 @ 9:00pm
15 Jul @ 1:26pm
10 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.2.0 Now supports 1.6.
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
232 Comments
海胆今天吃dm53 11 hours ago 
在飞船上似乎起飞降落之后会自动关闭(
HUSboboKY 22 Jul @ 4:44am 
非常好用,萌新爱了,感谢:steamhappy:大佬
Han 20 Jul @ 6:16am 
您就是缘神!
irilis 19 Jul @ 9:13am 
Is there a way to actually enforce the upper limit? When I want only a small cache of something near some workstation, with 1%-2% smart refill mode. I don't want my pawns to carry a full stack there (especially with Stack XXL active)!
愛麗速子身上喘 19 Jul @ 2:45am 
感謝大佬
Windecho 16 Jul @ 3:49am 
Hero
johndoe123456 15 Jul @ 2:16pm 
Bless 🙏
pureMJ  [author] 15 Jul @ 1:28pm 
Updated to 1.6
zecher 15 Jul @ 4:29am 
大佬求求更新,没有这个mod我已经不会玩游戏了
501000 14 Jul @ 6:19am 
1.6 plz