Rework interaction system
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "ClothingItemInstance.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "NakedDesire/Interactables/ItemPickup.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
#include "NakedDesire/SaveGame/GlobalSaveGameData.h"
|
||||
#include "NakedDesire/SaveGame/ItemSaveRecord.h"
|
||||
@@ -108,6 +109,24 @@ USkeletalMeshComponent* UClothingManager::GetMeshComponent(const EClothingSlotTy
|
||||
}
|
||||
}
|
||||
|
||||
void UClothingManager::SpawnClothingPickup(UClothingItemInstance* ItemInstance)
|
||||
{
|
||||
if (!ItemPickupActor)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::SpawnClothingPickup ItemPickupActor is not set"));
|
||||
return;
|
||||
}
|
||||
|
||||
AItemPickup* NewItemPickup = GetWorld()->SpawnActor<AItemPickup>(ItemPickupActor, GetOwner()->GetActorTransform());
|
||||
if (!NewItemPickup)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::SpawnClothingPickup NewItemPickup == nullptr"));
|
||||
return;
|
||||
}
|
||||
|
||||
NewItemPickup->SetItem(ItemInstance);
|
||||
}
|
||||
|
||||
void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance)
|
||||
{
|
||||
if (!ClothingItemInstance)
|
||||
@@ -220,6 +239,8 @@ void UClothingManager::DropClothing(const EClothingSlotType ClothingType)
|
||||
FItemSaveRecord ItemSaveRecord;
|
||||
ItemSaveRecord.Init(ClothingItemInstance);
|
||||
SaveSubsystem->GetCurrentSave()->DroppedItems.Push(ItemSaveRecord);
|
||||
|
||||
SpawnClothingPickup(ClothingItemInstance);
|
||||
|
||||
OnClothingDropped.Broadcast(ClothingItemInstance);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "ClothingManager.generated.h"
|
||||
|
||||
class AItemPickup;
|
||||
class UGlobalSaveGameData;
|
||||
class AClothingPickup;
|
||||
class UClothingItemInstance;
|
||||
@@ -53,7 +54,11 @@ public:
|
||||
|
||||
private:
|
||||
USkeletalMeshComponent* GetMeshComponent(EClothingSlotType SlotType) const;
|
||||
void SpawnClothingPickup(UClothingItemInstance* ItemInstance);
|
||||
|
||||
UPROPERTY()
|
||||
TMap<EClothingSlotType, TObjectPtr<UClothingItemInstance>> EquippedClothing;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Clothing")
|
||||
TSubclassOf<AItemPickup> ItemPickupActor;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user