Page MenuHomeFeedback Tracker

Expose the item that was added in an ScriptedInventoryOperationCallback
Assigned, NormalPublic

Description

Currently, there is no information inside the ScriptedInventoryOperationCallback to know about the target item the operation was about or its parent storage. One must hack this information by having a shared buffer somewhere that intercepts the information from InventoryStorageManagerComponent::OnItemAdded()

One relecant use case for this would be to know what item exactly was spawned by TrySpawnPrefabToStorage. Proposal text about this from private conversations earlier:

I have a proposal for a api change that should not break anything. Change the return type of TrySpawnPrefabToStorage to IEntity. Code that goes if(TrySpawnPrefabToStorage()) will still return true if it was created, and false if not because null == false. If that is not a thing maybe a way to get the spawned IEntity in the InventoryOperationCallback ... We can't mod the base class InventoryStorageManagerComponent to hook into OnItemAdded so I would need to override the SCR implementation that is hopefully used everywhere and make a getter of the last added item and then access that in my wrapper after tryspawn returned true. That is a very undesirable workaround where I have fears of timing issues (two spawnings before one of them was accessed or something). Or is there a different intended way to get the spawned item?
All other apis work with the concrete entity instance instead of spawn from resourcename. TrySpawnPrefabToStorage would be perfect if it gave access to the entity somehow then. Maybe if it breaks too much it could be made into a seperate function, not sure. Let me know what you think about all of this 🙂

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Geez changed the task status from New to Assigned.Sep 20 2022, 12:49 PM