void UGISInventoryBaseComponent::AddItemToInventory(class UGISItemData* ItemIn) { if (GetOwnerRole() < ROLE_Authority) { ServerAddItemToInventory(ItemIn); } else { //add item to first empty slot in first matching tab. for (FGISTabInfo& TabInfo : Tabs.InventoryTabs) { for (FGISSlotInfo& Slot : TabInfo.TabSlots) { if (Slot.ItemData == nullptr) { Slot.ItemData = ItemIn; //Slot.ItemData->OnItemRemovedFromSlot(); SlotUpdateInfo.TabIndex = TabInfo.TabIndex; SlotUpdateInfo.SlotIndex = Slot.SlotIndex; SlotUpdateInfo.SlotData = Slot.ItemData; SlotUpdateInfo.SlotComponent = this; if (GetNetMode() == ENetMode::NM_Standalone) OnItemAdded.Broadcast(SlotUpdateInfo); ClientUpdateInventory(SlotUpdateInfo); return; } } } } }
void UAREquipmentComponent::AddItemToInventory(FInventorySlot NewItem) { if (GetOwnerRole() < ROLE_Authority) { ServerAddItemToInventory(NewItem); } else { //if (TargetController) //{ // if (ItemSlot == EItemSlot::Item_Chest) // { // UARItemDataAsset* ItemDataAsset = Cast<UARItemDataAsset>(StaticLoadObject(UARItemDataAsset::StaticClass(), NULL, *ChestItemDataAssetPath, NULL, LOAD_None, NULL)); // if (ItemDataAsset && ItemDataAsset->Items.Num() > 0) // { // for (FARItemInfo& item : ItemDataAsset->Items) // { // if (item.ItemID == ItemID) // { // FInventorySlot it; // it.ItemID = item.ItemID; // it.ItemSlot = item.ItemSlot; // TargetController->InventorySmall.Add(it); // //TargetController->Inventory.Add(item); // break; // } // } // } // } //} } }