VoidArkMods / QoLPlus

ARK: Survival Ascended mod. Adds quality of life changes.
GNU Affero General Public License v3.0
17 stars 13 forks source link

Compatibility with Visual Storage mod #98

Open Vaperton opened 10 months ago

Vaperton commented 10 months ago

Currently wireless crafting works with visual storage mod but the pull system of qol+ doesn't seem to work with visual storage.

Is there a config option I have overlooked to allow pull to get resources from dedicated storage mods?

invTempest commented 10 months ago

To the mod creator, to add support for custom dedicated storage mods:

Use "BPIncrementItemTemplateQuantity" when adding/removing item from containers.

Dedicated storage containers have a function "BPIncrementItemCountQty" that custom dedicated storage mods override to verify if the structure can add/remove what is requested. This function is called when using BPIncrementItemTemplateQuantity on dedicated storage containers so it should be used.

VoidArkMods commented 8 months ago

Hello @invTempest ! In order to have the various transfer operation functionnal, the code needs to know the current amount inside a storage. The PrimalInventory now uses a boolean to express the intent of using an item count instead of an inventory, but the counter itself is not managed at this level, it is expected to be overridden. For the vanilla dedicated storages and the ones provided directly in the QoL+ mod, I can do a cast, but I'm wondering what would be the best approach for dedicated storages coming from other mods, like Visual Storage: do you have BP_DedicatedStorage as the parent of the new dedicated storage (and therefore use the "ResourceCount" counter)? Do you think it's a reasonable assertion for any dedicated storage mod? It feels like there's a missing interface to make the code really smooth.

invTempest commented 8 months ago

Thanks for the followup @VoidArkMods Visual storage containers are not childs of BP_DedicatedStorage. The containers allow for multiple types of resources to be stored in each (Wood container can store wood, fungal wood, corrupted wood, and any custom childs of wood) so it would not work to have them as a child. Setting the ResourceCount is not advised for tek dedicated storage and will not function for visual storage. "BP Increment Item Template Quantity" is the function you will want to use for adding or removing anything from them.

Below is a list of helpful functions and ways to get the info you will need for transfers for both vanilla dedicated and modded items:

1) To determine if a structure is a tek dedicated storage or visual storage you can do the following: cast to PrimalStructureItemContainer -> Get my inventory component of the structure and check "Use Item Count Instead of Inventory". If true, you know it is some sort of dedicated storage container. From there a cast to BP_DedicatedStorage will further filter base dedicated storage and childs and what is left will be modded dedicated storage that are not childs.

2) To get a list of what is stored in dedicated storage / modded dedicated storage: Check the "Remote Add Item Only Allow Item Classes" array on the inventory component as this will contain a list of the stored class(es). Dedicated storage has the "Selected Resource Class" on the structure that you could also use for those.

3) Get the item count of stored classes in dedicated storage / modded dedicated storage: "Get Item Template Quantity" will give you the count for a primal item class.

4) Check if an item can be added to the dedicated storage container / modded: If it can cast to BP_DedicatedStorage then you can just check if "Selected Resource Class" is a valid class or if the cast fails and "Use Item Count Instead Of Inventory" is true then you can run "BPAllow Add Inventory Item" with the primal item. Beware that tek dedicated storage will return true for most items as the function is used to determine if an item is allowed to go in the container not if it also == the stored class so you will need to filter them out first and check the Selected Resource Class.

Examples of transferring between different types of containers: 1) To transfer items from a slot storage (storagebox_large for example) to dedicated storage: You don't have to do anything special for this, just use "Transfer All Items to Inventory" on the inventory component and the containers will handle the rest (will check if they can be added, and run the increment functions that dedicated storage containers override)

2) To transfer items from dedicated storage to slot storage or from dedicated to dedicated: Get a list of stored class(es) in the dedicated storage containers by checking the "Remote Add Item Only Allow Item Classes" array on the inventory component. Run those through "Get Item Template Quantity" to get your counts, then use "BP Increment Item Template Quantity" on the Destination and the same function on the source (As a negative of course).

Let me know if you have any questions / comments / concerns.

VoidArkMods commented 8 months ago

Thanks, that has been very useful. Helped by your previous post, I have made some changes to improve the way the item-transfering scripts in QoL+ behave when dealing with structures using item count. I tested with the chitin/keratin storage from Visual Storage especially, as it was an easy way of dealing with an item-count based inventory having multiple allowed classes at the same time. For some reason, even though I loop through the allowed item classes array, the OmniTool prefers to transfer resource-by-resource instead of everything at once. The pulling UI should now also see properly what is inside the structures provided by Visual Storage, as well as pulling to them.

Thanks again for the very valuable information!

invTempest commented 6 months ago

Hello @VoidArkMods

Most things seem to be working as far as compatibility between the two mods goes. Recently, I've been getting reports of some issues with pulling wood specifically. The pull required resource button for crafts doesn't seem to see the wood from the VS wood bin or wood shed. Not sure why this single resource seems to be impacted but not others.

I can verify that manually pulling wood works but the auto pulling for a craft doesn't pull the wood.

Also, I got a report that instead of pulling wood it was randomly pulling angler gel of all things. I have not been able to reproduce this but they might be related?

If you have some time, can you look into what may be causing this? I'm free to help out with any kind of testing needed and answer any questions that you may have.