added session loss sequence, added energy and stamina to HUD, added home location trigger
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "LocationData.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKEDDESIRE_API ULocationData : public UPrimaryDataAsset
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "LocationTrigger.h"
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Components/BoxComponent.h"
|
||||
#include "LocationSubsystem.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
#include "TimerManager.h"
|
||||
|
||||
|
||||
ALocationTrigger::ALocationTrigger()
|
||||
@@ -27,16 +28,26 @@ void ALocationTrigger::BeginPlay()
|
||||
|
||||
BoxTrigger->OnComponentBeginOverlap.AddDynamic(this, &ALocationTrigger::OnTriggerBeginOverlap);
|
||||
BoxTrigger->OnComponentEndOverlap.AddDynamic(this, &ALocationTrigger::OnTriggerEndOverlap);
|
||||
|
||||
// Defer to next tick so the player pawn is spawned and positioned and physics overlaps
|
||||
// have been computed before we check whether it started out inside this volume.
|
||||
GetWorld()->GetTimerManager().SetTimerForNextTick(this, &ALocationTrigger::SeedInitialPlayerOverlap);
|
||||
}
|
||||
|
||||
void ALocationTrigger::OnConstruction(const FTransform& Transform)
|
||||
{
|
||||
Super::OnConstruction(Transform);
|
||||
|
||||
BoxTrigger->SetBoxExtent(TriggerSize);
|
||||
}
|
||||
|
||||
void ALocationTrigger::OnTriggerBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
{
|
||||
if (!OtherActor || !OtherActor->IsA<ANakedDesireCharacter>())
|
||||
return;
|
||||
|
||||
if (ULocationSubsystem* Locations = GetWorld()->GetSubsystem<ULocationSubsystem>())
|
||||
Locations->EnterLocation(LocationData);
|
||||
SetPlayerInside(true);
|
||||
}
|
||||
|
||||
void ALocationTrigger::OnTriggerEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
@@ -45,6 +56,39 @@ void ALocationTrigger::OnTriggerEndOverlap(UPrimitiveComponent* OverlappedCompon
|
||||
if (!OtherActor || !OtherActor->IsA<ANakedDesireCharacter>())
|
||||
return;
|
||||
|
||||
// Another of the player's components may still overlap the box (capsule vs. mesh); only
|
||||
// report the exit once the player has fully left, so we fire exactly one Exit per Enter.
|
||||
if (IsPlayerOverlapping())
|
||||
return;
|
||||
|
||||
SetPlayerInside(false);
|
||||
}
|
||||
|
||||
void ALocationTrigger::SeedInitialPlayerOverlap()
|
||||
{
|
||||
if (IsPlayerOverlapping())
|
||||
SetPlayerInside(true);
|
||||
}
|
||||
|
||||
void ALocationTrigger::SetPlayerInside(const bool bInside)
|
||||
{
|
||||
if (bInside == bPlayerInside)
|
||||
return;
|
||||
|
||||
bPlayerInside = bInside;
|
||||
|
||||
if (ULocationSubsystem* Locations = GetWorld()->GetSubsystem<ULocationSubsystem>())
|
||||
Locations->ExitLocation(LocationData);
|
||||
{
|
||||
if (bInside)
|
||||
Locations->EnterLocation(LocationData);
|
||||
else
|
||||
Locations->ExitLocation(LocationData);
|
||||
}
|
||||
}
|
||||
|
||||
bool ALocationTrigger::IsPlayerOverlapping() const
|
||||
{
|
||||
TArray<AActor*> Overlapping;
|
||||
BoxTrigger->GetOverlappingActors(Overlapping, ANakedDesireCharacter::StaticClass());
|
||||
return Overlapping.Num() > 0;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -22,10 +22,15 @@ class NAKEDDESIRE_API ALocationTrigger : public AActor
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
ULocationData* LocationData;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector TriggerSize;
|
||||
|
||||
public:
|
||||
ALocationTrigger();
|
||||
|
||||
virtual void OnConstruction(const FTransform& Transform) override;
|
||||
|
||||
ULocationData* GetLocationData() const;
|
||||
|
||||
protected:
|
||||
@@ -39,4 +44,16 @@ private:
|
||||
UFUNCTION()
|
||||
void OnTriggerEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
|
||||
|
||||
// A pawn that spawns already inside this volume (e.g. the apartment at game start) gets no
|
||||
// begin-overlap event, so seed the state one tick after BeginPlay once the world settles.
|
||||
void SeedInitialPlayerOverlap();
|
||||
|
||||
// Forwards a single enter/exit to ULocationSubsystem on a real transition. Idempotent so the
|
||||
// seed above can't double-count against a begin-overlap the engine does deliver.
|
||||
void SetPlayerInside(bool bInside);
|
||||
|
||||
bool IsPlayerOverlapping() const;
|
||||
|
||||
bool bPlayerInside = false;
|
||||
};
|
||||
Reference in New Issue
Block a user