Added commissions system
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "DayPhaseConstraint.h"
|
||||
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Commissions.Constraints.DayPhase"
|
||||
|
||||
void UDayPhaseConstraint::OnActivate()
|
||||
{
|
||||
if (UTimeOfDaySubsystem* Time = GetTime())
|
||||
Time->OnPhaseChanged.AddUniqueDynamic(this, &UDayPhaseConstraint::HandlePhaseChanged);
|
||||
}
|
||||
|
||||
void UDayPhaseConstraint::OnDeactivate()
|
||||
{
|
||||
if (UTimeOfDaySubsystem* Time = GetTime())
|
||||
Time->OnPhaseChanged.RemoveDynamic(this, &UDayPhaseConstraint::HandlePhaseChanged);
|
||||
}
|
||||
|
||||
bool UDayPhaseConstraint::IsMet() const
|
||||
{
|
||||
const UTimeOfDaySubsystem* Time = GetTime();
|
||||
return Time && Time->GetPhase() == RequiredPhase;
|
||||
}
|
||||
|
||||
void UDayPhaseConstraint::HandlePhaseChanged(EDayPhase NewPhase)
|
||||
{
|
||||
NotifyChanged();
|
||||
}
|
||||
|
||||
UTimeOfDaySubsystem* UDayPhaseConstraint::GetTime() const
|
||||
{
|
||||
UWorld* World = Player ? Player->GetWorld() : nullptr;
|
||||
return World ? World->GetSubsystem<UTimeOfDaySubsystem>() : nullptr;
|
||||
}
|
||||
|
||||
FText UDayPhaseConstraint::GetDescription() const
|
||||
{
|
||||
return (RequiredPhase == EDayPhase::Night)
|
||||
? LOCTEXT("Night", "at night")
|
||||
: LOCTEXT("Day", "during the day");
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
Reference in New Issue
Block a user