0 of 0

File information

Last updated

Original upload

Created by

Valriz

Uploaded by

valriz

Virus scan

Safe to use

Tags for this mod

About this mod

Allows containers to be set to supply and demand the same resource, allowing you to setup buffer chests for drone logistics. Includes protections for trade rockets and destructors from churning through your precious items.

Permissions and credits
Changelogs
NOTE: Requires BepinEx to be setup!

Applies some tweaks to the Drone Logistics system to allow for buffer containers.

Most importantly, containers can now be set to supply and demand the same items - this lets you create 'buffer storage' in your logistics network.

If you have multiple containers all set to 'buffer' the same item, they will be subject to a priority rule to prevent drones from getting stuck in a loop:
Buffers can only be supplied items from other buffers if they are a higher priority - eg:
Source (any priority) -> Buffer (priority 1) -> Buffer (priority 3) -> Destination (any priority)

This ONLY impacts on buffer to buffer logistics - something that's supply-only or demand-only will behave as per normal.

Buffers that are set to the same priority will ignore each other - they'll both fill independently from suppliers, and they'll both supply independently to destinations - but they'll never supply each other.

Additional rules
The following additional rules can be disabled via BepinEx configuration settings, but are on by default:

Buffer Protection
A buffer container will NOT supply items to a destructor or a trade rocket, UNLESS the destructor/rocket has a higher priority than the buffer.
eg, a trade rocket set to priority 0 will be ignored by a container that's also on priority 0. Only a priority -1 buffer would supply a priority 0 trade rocket. (Note: the trade rocket would still be supplied from other non-buffer sources like normal)

Producer Protection
Adds two special rules for trade rockets and destructors set to -1 priority, that they can ONLY be supplied by a container 1, container 2 or container 3 (the small blue chest, the large locker and the T2 storage locker) - this will prevent a -1 destructor, for example, from being supplied resources directly from your ore miners if it was set to demand Iron. It would only be automatically supplied resources from a 'drop-off' container, where the drones would try and fill any other demand inventory first, and only if there was no remaining space - would then take it to the destructor.

Note: It's a good idea to set any auto-destructors to supply-all, effectively turning them into buffers - this way if a demand opens up for a resource you were over-full of and going to destroy - the drones can pick it up and drop it somewhere better. Note that this will prevent a -1 destructor from being supplied by any buffer inventory.

Interaction with other mods:
Other logistics mods can hook into an API to check if logistics tasks should be allowed based on configuration.

API:
To use, add a dependency for StorageDisplay and resolve the public contract as follows:

If you know the WorldObject the supply and demand inventories are attached to:

var allowBufferLogisticsTask = (Func<Inventory/*supply*/, WorldObject/*supply*/, Inventory/*demand*/, WorldObject/*demand*/, WorldObject, bool>)plugin.Instance.GetType().GetField("Api_1_AllowBufferLogisticsTaskEx", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).GetValue(null);

If you only know the inventories, then instead use:

var allowBufferLogisticsTask = (Func<Inventory/*supply*/, Inventory/*demand*/, WorldObject, bool>)plugin.Instance.GetType().GetField("Api_1_AllowBufferLogisticsTask", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).GetValue(null);

This method will return true if the logistic task should be created, and false if it should be dropped.
It is intended to be called from custom overrides of the LogisticsManager::CreateNewTaskForWorldObject method or similar and is needed to prevent drones creating loops between buffer containers