Added session system

This commit is contained in:
2026-05-30 00:18:14 +03:00
parent 8f132c463d
commit d53ca8e56b
8 changed files with 413 additions and 12 deletions
@@ -4,6 +4,8 @@
#include "LocationTrigger.h"
#include "Components/BoxComponent.h"
#include "NakedDesire/Global/SessionManagerSubsystem.h"
#include "NakedDesire/Player/NakedDesireCharacter.h"
ALocationTrigger::ALocationTrigger()
@@ -19,3 +21,38 @@ ULocationData* ALocationTrigger::GetLocationData() const
return LocationData;
}
void ALocationTrigger::BeginPlay()
{
Super::BeginPlay();
if (bIsApartment)
{
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 (USessionManagerSubsystem* SessionManager = GetWorld()->GetSubsystem<USessionManagerSubsystem>())
{
SessionManager->NotifyEnteredApartment();
}
}
void ALocationTrigger::OnTriggerEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if (!OtherActor || !OtherActor->IsA<ANakedDesireCharacter>())
return;
if (USessionManagerSubsystem* SessionManager = GetWorld()->GetSubsystem<USessionManagerSubsystem>())
{
SessionManager->NotifyLeftApartment();
}
}
@@ -20,8 +20,26 @@ class NAKEDDESIRE_API ALocationTrigger : public AActor
UPROPERTY(EditAnywhere)
ULocationData* LocationData;
// When set, the player crossing this trigger drives session start / end on
// USessionManagerSubsystem (GDD §4.1 / §4.3). Exactly one trigger — the
// apartment — should have this checked.
UPROPERTY(EditAnywhere, Category = "Session")
bool bIsApartment = false;
public:
ALocationTrigger();
ULocationData* GetLocationData() const;
protected:
virtual void BeginPlay() override;
private:
UFUNCTION()
void OnTriggerBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
void OnTriggerEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
};