Rework interaction system

This commit is contained in:
koritsa
2026-05-28 21:53:34 +03:00
committed by koritsa
parent 372516c535
commit 97936ae495
26 changed files with 496 additions and 216 deletions
@@ -1,12 +1,8 @@
// © 2025 Naked People Team. All Rights Reserved.
#include "NakedDesireCharacter.h"
#include "NakedDesire/Locations/LocationTrigger.h"
#include "NakedDesire/Clothing/ClothingManager.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "NakedDesire/InteractionSystem/InteractionManager.h"
#include "NakedDesire/InteractionSystem/InteractionTarget.h"
#include "NakedDesire/MissionBuilder/MissionsManager.h"
#include "NakedDesire/Stats/StatsManager.h"
#include "EnhancedInputComponent.h"
@@ -15,22 +11,17 @@
#include "Internationalization/Text.h"
#include "NakedDesire/Clothing/ClothingItem.h"
#include "NakedDesire/Clothing/ClothingItemInstance.h"
#include "NakedDesire/Clothing/ClothingSlotsData.h"
#include "NakedDesire/Global/Constants.h"
#include "NakedDesire/Global/NakedDesireHUD.h"
#include "NakedDesire/Global/NakedDesireUserSettings.h"
#include "NakedDesire/Interaction/InteractionComponent.h"
#include "NakedDesire/UI/GameLayoutWidget.h"
#include "NakedDesire/UI/HUDWidget.h"
#include "NakedDesire/UI/RadialMenu/RadialMenuController.h"
#include "Perception/AIPerceptionStimuliSourceComponent.h"
#include "Perception/AISense_Sight.h"
ANakedDesireCharacter::ANakedDesireCharacter()
{
GetCharacterMovement()->MaxWalkSpeed = WalkSpeed;
GetCapsuleComponent()->OnComponentBeginOverlap.AddUniqueDynamic(this, &ANakedDesireCharacter::OnBeginOverlap);
GetCapsuleComponent()->OnComponentEndOverlap.AddUniqueDynamic(this, &ANakedDesireCharacter::OnEndOverlap);
bUseControllerRotationYaw = false;
@@ -40,8 +31,6 @@ ANakedDesireCharacter::ANakedDesireCharacter()
ClothingManager = CreateDefaultSubobject<UClothingManager>("Clothing Manager");
StatsManager = CreateDefaultSubobject<UStatsManager>("Stats Manager");
MissionsManager = CreateDefaultSubobject<UMissionsManager>("Missions Manager");
InteractionManager = CreateDefaultSubobject<UInteractionManager>("Interaction Manager");
RadialMenuController = CreateDefaultSubobject<URadialMenuController>(TEXT("Radial Menu Controller"));
NipplesMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>("Nipples");
NipplesMeshComponent->SetupAttachment(GetMesh());
@@ -90,6 +79,7 @@ ANakedDesireCharacter::ANakedDesireCharacter()
AnalCensorship->SetupAttachment(GetMesh(), FName(TEXT("pelvis")));
StimuliSourceComponent = CreateDefaultSubobject<UAIPerceptionStimuliSourceComponent>(TEXT("Stimuli Source Component"));
InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component"));
}
EGait ANakedDesireCharacter::GetGait() const
@@ -97,11 +87,6 @@ EGait ANakedDesireCharacter::GetGait() const
return Gait;
}
EStance ANakedDesireCharacter::GetStance() const
{
return Stance;
}
void ANakedDesireCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
@@ -138,6 +123,7 @@ void ANakedDesireCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInp
EnhancedInputComponent->BindAction(RunAction, ETriggerEvent::Completed, this, &ANakedDesireCharacter::OnRunRelease);
EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &ANakedDesireCharacter::OnCrouchToggle);
EnhancedInputComponent->BindAction(EquipmentAction, ETriggerEvent::Started, this, &ANakedDesireCharacter::OnEquipmentPress);
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &ANakedDesireCharacter::OnInteractPress);
}
}
@@ -233,36 +219,6 @@ bool ANakedDesireCharacter::CheckSight(const FVector& StartLocation, const FVect
return bHit;
}
void ANakedDesireCharacter::OnBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (OtherActor->Implements<UInteractionTarget>())
{
InteractionManager->OnTargetEnter(OtherActor);
}
if (const ALocationTrigger* AreaTrigger = Cast<ALocationTrigger>(OtherActor))
{
CurrentArea = AreaTrigger->GetLocationData();
OnAreaEnter.Broadcast(CurrentArea);
}
}
void ANakedDesireCharacter::OnEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if (OtherActor->Implements<UInteractionTarget>())
{
InteractionManager->OnTargetExit(OtherActor);
}
if (const ALocationTrigger* AreaTrigger = Cast<ALocationTrigger>(OtherActor))
{
CurrentArea = nullptr;
OnAreaExit.Broadcast(AreaTrigger->GetLocationData());
}
}
void ANakedDesireCharacter::OnClothingEquip(UClothingItemInstance* ClothingItemInstance)
{
if (ClothingItemInstance->GetClothingItem()->HiddenBodyParts.Contains(EBodyPart::Ass))
@@ -374,28 +330,9 @@ void ANakedDesireCharacter::OnEquipmentPress(const FInputActionValue& Value)
HUD->GetGameLayoutWidget()->OpenInventory();
}
void ANakedDesireCharacter::BuildRadialMenuEntries()
void ANakedDesireCharacter::OnInteractPress(const FInputActionValue& Value)
{
if (!SlotsData)
{
UE_LOG(LogTemp, Warning, TEXT("ANakedDesireCharacter::BuildRadialMenuEntries SlotsData not defined"));
return;
}
TArray<FRadialMenuEntry> Entries;
for (const auto& [Key, Value] : SlotsData->Slots)
{
FRadialMenuEntry Entry;
const UClothingItemInstance* EquippedItem = ClothingManager->GetSlotClothing(Key);
Entry.bEnabled = true;
Entry.DisplayName = Value.Name;
Entry.Icon = EquippedItem ? EquippedItem->GetClothingItem()->Icon : Value.Icon;
Entry.ItemId = FName(Value.Name.ToString());
Entries.Push(Entry);
}
RadialMenuController->Entries = Entries;
InteractionComponent->Interact();
}
void ANakedDesireCharacter::NotifyNoticed(ANPCAIController* NPCController)