Rework interaction system
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "ItemPickup.h"
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "Components/WidgetComponent.h"
|
||||
#include "NakedDesire/Clothing/ClothingItem.h"
|
||||
#include "NakedDesire/Clothing/ClothingItemInstance.h"
|
||||
#include "NakedDesire/Clothing/ClothingManager.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
AItemPickup::AItemPickup()
|
||||
{
|
||||
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
|
||||
SetRootComponent(Mesh);
|
||||
Mesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
||||
Collider = CreateDefaultSubobject<UBoxComponent>(TEXT("Collider"));
|
||||
Collider->SetupAttachment(RootComponent);
|
||||
Collider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
||||
|
||||
InteractionHint = CreateDefaultSubobject<UWidgetComponent>(TEXT("Interaction Hint"));
|
||||
InteractionHint->SetupAttachment(RootComponent);
|
||||
}
|
||||
|
||||
void AItemPickup::Interact_Implementation(ANakedDesireCharacter* Player)
|
||||
{
|
||||
if (ClothingItemInstance)
|
||||
{
|
||||
Player->ClothingManager->TakeClothing(ClothingItemInstance);
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
bool AItemPickup::CanInteract_Implementation(ANakedDesireCharacter* Player) const
|
||||
{
|
||||
return ClothingItemInstance != nullptr;
|
||||
}
|
||||
|
||||
void AItemPickup::HideInteractionHint_Implementation()
|
||||
{
|
||||
ApplyOutline(Mesh, false, 0);
|
||||
InteractionHint->SetVisibility(false);
|
||||
}
|
||||
|
||||
void AItemPickup::ShowInteractionFocusHint_Implementation()
|
||||
{
|
||||
ApplyOutline(Mesh, true, 2);
|
||||
InteractionHint->SetVisibility(true);
|
||||
}
|
||||
|
||||
void AItemPickup::ShowInteractionProximityHint_Implementation()
|
||||
{
|
||||
ApplyOutline(Mesh, true, 1);
|
||||
InteractionHint->SetVisibility(false);
|
||||
}
|
||||
|
||||
void AItemPickup::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
InteractionHint->SetVisibility(false);
|
||||
}
|
||||
|
||||
void AItemPickup::SetItem(UClothingItemInstance* InItem)
|
||||
{
|
||||
ClothingItemInstance = InItem;
|
||||
|
||||
Mesh->SetStaticMesh(InItem->GetClothingItem()->StaticMesh);
|
||||
}
|
||||
|
||||
void AItemPickup::ApplyOutline(UStaticMeshComponent* InMesh, bool bEnabled, int32 StencilValue)
|
||||
{
|
||||
InMesh->SetRenderCustomDepth(bEnabled);
|
||||
InMesh->SetCustomDepthStencilValue(StencilValue);
|
||||
}
|
||||
Reference in New Issue
Block a user