Combine Items inside the inventory.

Egnech

New member
Hello!

I’m new to UIS, and so far I’m very impressed with it.

I want to have a similar to classic Resident Evil games inventory system, where player can combine special items inside the inventory itself, and not with the special crafting screen. I think this video will explain the idea better.

I think I can take MoveItemAction as an example, and some how override “on drop” action. But this already requires more deep knowledge of the system than I have now. Maybe you can suggest me where to look next?
 
I'm convinced some one asked the same questions a few months ago and showed it working, but I can't seem to find the forum post about it anymore.

But you are right looking at the MoveItemAction and drag and drop actions is the correct way to do it. The way the Move Item Action works is by getting a component on the UI which disables the next action and instead does something else (in this case move the item).

I would suggest you copy paste the Move Item Action code and then make the necessary modifications to make it work. I'm afraid there isn't an easy way to do this. it will require you to learn how the ItemViewSlotContainer and the Crafting system works. The source code is fully commented so you should be able to follow along. and if not don't hesitate to ask.
For now I would recommend you have a look at these:

And watching the video tutorials migh help get you comfortable with the Inventory UI, make sure to watch the MoveItemAction video:
 
Thank you!
I've already watched the video tutorials, and they are super handy.
I will post my progress into this thread incase someone else will be interested in the future.
 
Ok, I think I've found the solution. I can add additional Item View Drop Action Set, specify Condition and Action and here we go, the front end for this is ready.

Only thing that is not clear for now, is how to differentiate regular Move Action from the Combine Action inside ItemViewDropCondition & ItemViewDropAction. I'm absolutely can add some global flag like IsCombineActionAndNotTheMoveAction. But this looks a bit messy for me. And from the other side there - I can override multiple classes just to add this flag somewhere inside the system, which is also not that good a solution.

Is there a way to track last triggered Item Action?
 
Not really... you could add an event and listen to it to know which action was triggered last. It's not very pretty but it works.

If you think you'll need more than just a flag in the future another solution would be to Override the ItemViewSlotMoveCursor and use a custom ItemViewSlotEventData. You can get the ItemViewSlotEventData from the ItemViewDropHandler.StreamData within the DropAction.

then within the custom ItemViewSlotEventData you can add some properties with more information about the move.

But if all you need is a simple flag, I wouldn't complicate it more than it needs to be. You can use our event system to set that flag if you want, learn more here:
 
If you think you'll need more than just a flag in the future another solution would be to Override the ItemViewSlotMoveCursor and use a custom ItemViewSlotEventData. You can get the ItemViewSlotEventData from the ItemViewDropHandler.StreamData within the DropAction.
I've checked the ItemViewDropHandler.StreamData and I can't find the ItemViewSlotEventData there. There is only Source* and Destination* fields.
 
Also as I'm got deeper into the sources I've found that the best solution will probably be to have an array of ItemViewDropActionSet's, and some how specify the desired Index where to lookup the drop actions (probably within the ItemViewSlotMoveCursor).

But this will require to override too much of the existing code. Which is not that big of a deal, but I'm afraid that when you will release some updates I will need to rework it again, and then again... You know the trick ?
 
Ah you are right I don't keep track of the ItemViewSlotEventData. Here is the updated class:
Code:
/// <summary>
/// The Item View Slot Drop Handler Stream Data goes through the conditions and actions.
/// </summary>
public class ItemViewSlotDropHandlerStreamData
{
    public ItemViewSlotEventData DragSlotEventData { get; set; }
    public ItemViewSlotsContainerBase SourceContainer { get; set; }
    public ItemViewSlot SourceItemViewSlot { get; set; }
    public ItemInfo SourceItemInfo { get; set; }
    public int SourceIndex { get; set; }
    public ItemViewSlotEventData DropSlotEventData { get; set; }
    public ItemViewSlotsContainerBase DestinationContainer { get; set; }
    public ItemViewSlot DestinationItemViewSlot { get; set; }
    public ItemInfo DestinationItemInfo { get; set; }
    public int DestinationIndex { get; set; }
    /// <summary>
    /// Default Constructor.
    /// </summary>
    public ItemViewSlotDropHandlerStreamData()
    {
    }
    /// <summary>
    /// Reset the stream data.
    /// </summary>
    /// <param name="sourceItemViewSlot">The source item view slot.</param>
    /// <param name="dragSlotEventData">The drag slot event data.</param>
    /// <param name="dropSlotEventData">The drop slot event data.</param>
    public virtual void Reset(ItemViewSlot sourceItemViewSlot, ItemViewSlotEventData dragSlotEventData, ItemViewSlotEventData dropSlotEventData)
    {
        DragSlotEventData = dragSlotEventData;
        SourceContainer = dragSlotEventData.ItemViewSlotsContainer;
        SourceItemViewSlot = sourceItemViewSlot;
        SourceItemInfo = dragSlotEventData.ItemView.CurrentValue;
        SourceIndex = dragSlotEventData.Index;
        DropSlotEventData = dropSlotEventData;
        DestinationContainer = dropSlotEventData.ItemViewSlotsContainer;
        DestinationItemViewSlot = dropSlotEventData.ItemViewSlot;
        DestinationItemInfo = dropSlotEventData.ItemView.CurrentValue;
        DestinationIndex = dropSlotEventData.Index;
    }
}

I was thinking that another potential solution would be to use a different CursorManagerID on the Drophandler. This way you could have one ItemViewSlotcursorManager/Drag/DropHandler for the move and other componentss for the combine. I think that might work well.

I also added a getter to get the Cursor ID in the ItemViewDropHandler:
Code:
public uint CursorManagerID => m_CursorManagerID;

I hope that helps somehow
 
I was thinking that another potential solution would be to use a different CursorManagerID on the Drophandler. This way you could have one ItemViewSlotcursorManager/Drag/DropHandler for the move and other componentss for the combine. I think that might work well.
I like this idea, but I'm not sure how I can handle Cursor ID in this case, I didn't get to this part yet xD
 
So, I decided to go with overriding the ItemViewSlotEventData and ItemViewSlotMoveCursor components.
It seems like more safe approach, and in the future it will be easier to apply updates, because no internal code was changed this was.
It was an easy task, because the code quality is very good... besides some naming issues, but nothing crucial.
Thank you for help!
 
Top