@@ -346,21 +346,22 @@ void UIFInventoryComponent::RemoveItem(uint8 InIndex)
346346 return ;
347347 }
348348 // remove from backend
349+ OnItemRemoved (InventoryItems[InIndex].Item , InIndex);
349350 if (InventoryItems[InIndex].Item )
350351 InventoryItems[InIndex].Item ->MarkPendingKill ();
351352
352353 InventoryItems[InIndex].Item = nullptr ;
353- OnServerItemRemoved (InIndex);
354354 ClientRemoveItem (InIndex);
355355}
356356void UIFInventoryComponent::ServerRemoveItem_Implementation (uint8 InIndex)
357357{
358+ OnServerItemRemoved (InventoryItems[InIndex].Item , InIndex);
358359 InventoryItems[InIndex].Item ->OnServerItemRemoved (InIndex);
359360 if (InventoryItems[InIndex].Item )
360361 InventoryItems[InIndex].Item ->MarkPendingKill ();
361362
362363 InventoryItems[InIndex].Item = nullptr ;
363- OnServerItemRemoved (InIndex);
364+
364365 ClientRemoveItem (InIndex);
365366}
366367bool UIFInventoryComponent::ServerRemoveItem_Validate (uint8 InIndex)
@@ -370,11 +371,12 @@ bool UIFInventoryComponent::ServerRemoveItem_Validate(uint8 InIndex)
370371void UIFInventoryComponent::ClientRemoveItem_Implementation (uint8 InIndex)
371372{
372373 InventoryItems[InIndex].Item ->OnItemRemoved (InIndex);
374+ OnItemRemoved (InventoryItems[InIndex].Item , InIndex);
373375 if (InventoryItems[InIndex].Item )
374376 InventoryItems[InIndex].Item ->MarkPendingKill ();
375377
376378 InventoryItems[InIndex].Item = nullptr ;
377- OnItemRemoved (InIndex);
379+
378380}
379381void UIFInventoryComponent::OnItemLoadedFreeSlot (TSoftClassPtr<class UIFItemBase > InItem)
380382{
@@ -399,9 +401,9 @@ void UIFInventoryComponent::OnItemLoaded(TSoftClassPtr<class UIFItemBase> InItem
399401void UIFInventoryComponent::ClientSendJsonData_Implementation (const FString& Data)
400402{
401403 FIFItemData Item = JsonToItem (Data);
404+ Item.Item ->ClientPostItemDeserializeFromJson ();
402405 if (Item.Item )
403406 {
404- Item.Item ->PostItemLoad ();
405407 Item.Item ->OnItemAdded (Item.Index );
406408
407409 InventoryItems[Item.Index ] = Item;
@@ -445,6 +447,7 @@ TSharedPtr<FJsonObject> UIFInventoryComponent::ItemToJson(FIFItemData* Item)
445447 TSharedPtr<FJsonObject> UObj = MakeShareable (new FJsonObject ());
446448 if (Item->Item )
447449 {
450+ Item->Item ->PreItemSerializeToJson ();
448451 FJsonUOSerialize::UObjectToJsonObject (Item->Item ->GetClass (), Item->Item , UObj.ToSharedRef ());
449452 // UObj = Item->Item->SaveToJson();
450453 }
@@ -490,6 +493,6 @@ FIFItemData UIFInventoryComponent::JsonToItem(const FString& JsonString)
490493 FIFItemData Item;
491494 Item.Index = idx;
492495 Item.Item = Cast<UIFItemBase>(OutObj);
493-
496+
494497 return Item;
495498}
0 commit comments