Added commissions system
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "NakedDesire/Global/Constants.h"
|
||||
#include "NakedDesire/Global/NakedDesireGameplayTags.h"
|
||||
#include "NakedDesire/Locations/LocationData.h"
|
||||
#include "NakedDesire/Locations/LocationSubsystem.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
#include "NakedDesire/Stats/StatsManager.h"
|
||||
|
||||
@@ -12,6 +15,13 @@ void USessionManagerSubsystem::OnWorldBeginPlay(UWorld& InWorld)
|
||||
{
|
||||
Super::OnWorldBeginPlay(InWorld);
|
||||
|
||||
// The apartment threshold is now a location event (Location.Apartment), not a per-trigger flag.
|
||||
if (ULocationSubsystem* Locations = InWorld.GetSubsystem<ULocationSubsystem>())
|
||||
{
|
||||
Locations->OnLocationEntered.AddDynamic(this, &USessionManagerSubsystem::HandleLocationEntered);
|
||||
Locations->OnLocationExited.AddDynamic(this, &USessionManagerSubsystem::HandleLocationExited);
|
||||
}
|
||||
|
||||
// The player pawn and its UStatsManager may not have finished BeginPlay when
|
||||
// the world begins play, so defer binding by one tick.
|
||||
InWorld.GetTimerManager().SetTimerForNextTick(this, &USessionManagerSubsystem::BindToPlayerStats);
|
||||
@@ -30,19 +40,19 @@ void USessionManagerSubsystem::BindToPlayerStats()
|
||||
Player->StatsManager->EnergyUpdate.AddDynamic(this, &USessionManagerSubsystem::HandleEnergyUpdate);
|
||||
}
|
||||
|
||||
void USessionManagerSubsystem::NotifyEnteredApartment()
|
||||
void USessionManagerSubsystem::HandleLocationEntered(ULocationData* Location)
|
||||
{
|
||||
// Returning home is the safe end of a session (§4.3).
|
||||
if (bSessionActive)
|
||||
// Returning to the apartment is the safe end of a session (§4.3).
|
||||
if (Location && Location->Tag.MatchesTag(TAG_Location_Apartment) && bSessionActive)
|
||||
{
|
||||
EndSession(ESessionLossCause::SafeReturn);
|
||||
}
|
||||
}
|
||||
|
||||
void USessionManagerSubsystem::NotifyLeftApartment()
|
||||
void USessionManagerSubsystem::HandleLocationExited(ULocationData* Location)
|
||||
{
|
||||
// Leaving the apartment is the only way to start a session (§4.1).
|
||||
if (!bSessionActive)
|
||||
if (Location && Location->Tag.MatchesTag(TAG_Location_Apartment) && !bSessionActive)
|
||||
{
|
||||
StartSession();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user