void UGISInventoryBaseComponent::LootOneItem(int32 ItemIndex) { if (GetOwnerRole() < ROLE_Authority) { SeverLootOneItem(ItemIndex); } else { if (CurrentPickupActor) { // UGISItemData* test = ConstructObject<UGISItemData>(CurrentPickupActor->ItemToLoot[ItemIndex]->GetClass(), this, NAME_None, RF_NoFlags, CurrentPickupActor->ItemToLoot[ItemIndex]); //if it is not valid index both arrays, then something is wrong. if (LootedItems.IsValidIndex(ItemIndex) && CurrentPickupActor->ItemToLoot.IsValidIndex(ItemIndex)) { AddItemToInventory(LootedItems[ItemIndex]); //ok we removed one item. We need to rconstruct widgets, indexes etc, to make sure arry //have proper indexes in first place. LootedItems.RemoveAt(ItemIndex, 1, true); CurrentPickupActor->ItemToLoot.RemoveAt(ItemIndex, 1, true); } //reconstruct widget. // CurrentPickupActor->ItemToLoot = LootedItems; // ClientReconstructLootWidget(); } } }
void UGISInventoryBaseComponent::LootOneItem(int32 ItemIndex) { if (GetOwnerRole() < ROLE_Authority) { //if (LootFromPickup.Loot.IsValidIndex(ItemIndex) && CurrentPickupActor->ItemToLoot.IsValidIndex(ItemIndex)) // CurrentPickupActor->ItemToLoot.RemoveAt(ItemIndex); SeverLootOneItem(ItemIndex); } else { if (CurrentPickupActor) { //if it is not valid index both arrays, then something is wrong. if (LootFromPickup.Loot.IsValidIndex(ItemIndex) && CurrentPickupActor->ItemToLoot.IsValidIndex(ItemIndex)) { AddItemToInventory(LootFromPickup.Loot[ItemIndex].SlotData); //ok we removed one item. We need to rconstruct widgets, indexes etc, to make sure arry //have proper indexes in first place. //LootFromPickup.Loot.RemoveAtSwap(ItemIndex, 1, false); LootFromPickup.Loot.RemoveAt(ItemIndex); CurrentPickupActor->ItemToLoot.RemoveAt(ItemIndex); int32 ItemNum = CurrentPickupActor->ItemToLoot.Num(); LootFromPickup.Loot.Empty(); for (int32 ItemIdx = 0; ItemIdx < ItemNum; ItemIdx++) { FGISLootSlotInfo lootInfo; UGISItemData* dataDuplicate = ConstructObject<UGISItemData>(CurrentPickupActor->ItemToLoot[ItemIdx]->GetClass(), this, NAME_None, RF_NoFlags, CurrentPickupActor->ItemToLoot[ItemIdx]); lootInfo.OwningPickupActor = CurrentPickupActor; lootInfo.SlotComponent = this; lootInfo.SlotIndex = ItemIdx; lootInfo.SlotData = dataDuplicate; LootFromPickup.Loot.Add(lootInfo); } //if there is nothing to loot, and looting widget is visible, this will hide it. if (LootFromPickup.Loot.Num() == 0) { SetComponentTickEnabled(false); ClientSwitchLootingWidget(); } LootFromPickup.ForceRep++; CurrentPickupActor->OnLooted(); } //reconstruct widget. if (GetNetMode() == ENetMode::NM_Standalone) { OnRep_LootedItems(); } } } }
void ACavemanController::Craft(FString ItemToCraft, FString Mat1, int32 Mat1Count, FString Mat2, int32 Mat2Count, FString Mat3, int32 Mat3Count, FString Mat4, int32 Mat4Count, FString Mat5, int32 Mat5Count, FString Mat6, int32 Mat6Count) { if (Mat1Count > 0) { for (int32 i = 0; i < Mat1Count; i++) { RemoveItemByName(Mat1); } } if (Mat2Count > 0) { for (int32 i = 0; i < Mat2Count; i++) { RemoveItemByName(Mat2); } } if (Mat3Count > 0) { for (int32 i = 0; i < Mat3Count; i++) { RemoveItemByName(Mat3); } } if (Mat4Count > 0) { for (int32 i = 0; i < Mat4Count; i++) { RemoveItemByName(Mat4); } } if (Mat5Count > 0) { for (int32 i = 0; i < Mat5Count; i++) { RemoveItemByName(Mat5); } } if (Mat6Count > 0) { for (int32 i = 0; i < Mat6Count; i++) { RemoveItemByName(Mat6); } } AddItemToInventory(ItemToCraft); Cast<AMyCharacter_FirstTry>(GetCharacter())->SFXManager->PlaySoundEffect(ESoundEffects::SFX_UI_ItemCrafted); }
void UGISInventoryBaseComponent::LootAllItems(class AGISPickupActor* LootContainer) { //if (GetOwnerRole() < ROLE_Authority) //{ // SeverLootOneItem //} //else //{ if (LootContainer) { for (UGISItemData* Item : LootContainer->ItemToLoot) { AddItemToInventory(Item); } } //} }
void UGISInventoryBaseComponent::LootItems(class AGISPickupActor* LootContainer) { if (GetOwnerRole() < ROLE_Authority) { ServerLootItems(LootContainer); } else { if (!LootContainer) return; LootContainer->SetOwner(GetOwner()); for (UGISItemData* Item : LootedItems) { AddItemToInventory(Item); } } }
void UGISInventoryBaseComponent::ServerAddItemToInventory_Implementation(class UGISItemData* ItemIn) { AddItemToInventory(ItemIn); }