50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
// © 2025 Naked People Team. All Rights Reserved.
|
|
|
|
|
|
#include "LocationTrigger.h"
|
|
|
|
#include "Components/BoxComponent.h"
|
|
#include "LocationSubsystem.h"
|
|
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
|
|
|
|
|
ALocationTrigger::ALocationTrigger()
|
|
{
|
|
PrimaryActorTick.bCanEverTick = false;
|
|
|
|
BoxTrigger = CreateDefaultSubobject<UBoxComponent>("Box Trigger");
|
|
RootComponent = BoxTrigger;
|
|
}
|
|
|
|
ULocationData* ALocationTrigger::GetLocationData() const
|
|
{
|
|
return LocationData;
|
|
}
|
|
|
|
void ALocationTrigger::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
BoxTrigger->OnComponentBeginOverlap.AddDynamic(this, &ALocationTrigger::OnTriggerBeginOverlap);
|
|
BoxTrigger->OnComponentEndOverlap.AddDynamic(this, &ALocationTrigger::OnTriggerEndOverlap);
|
|
}
|
|
|
|
void ALocationTrigger::OnTriggerBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
|
{
|
|
if (!OtherActor || !OtherActor->IsA<ANakedDesireCharacter>())
|
|
return;
|
|
|
|
if (ULocationSubsystem* Locations = GetWorld()->GetSubsystem<ULocationSubsystem>())
|
|
Locations->EnterLocation(LocationData);
|
|
}
|
|
|
|
void ALocationTrigger::OnTriggerEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
|
|
{
|
|
if (!OtherActor || !OtherActor->IsA<ANakedDesireCharacter>())
|
|
return;
|
|
|
|
if (ULocationSubsystem* Locations = GetWorld()->GetSubsystem<ULocationSubsystem>())
|
|
Locations->ExitLocation(LocationData);
|
|
} |