Files
Naked-Desire/Source/NakedDesire/MissionBuilder/MissionGoal.cpp
T
2026-05-17 22:44:49 +03:00

71 lines
1.1 KiB
C++

// © 2025 Naked People Team. All Rights Reserved.
#include "MissionGoal.h"
#include "GoalRestriction.h"
void UMissionGoal::Init(ANakedDesireCharacter* PlayerCharacter)
{
Player = PlayerCharacter;
for (const auto& Elem : Restrictions)
{
Elem->Init(Player);
auto Handle = Elem->OnUpdate.AddUObject(this, &UMissionGoal::OnRestrictionUpdated);
RestrictionUpdateHandles.Add(Handle);
}
}
void UMissionGoal::Complete()
{
if (!CheckRestrictions())
{
return;
}
IsCompleted = true;
for (const auto& Restriction : Restrictions)
{
Restriction->Stop();
for (const auto& Handle : RestrictionUpdateHandles)
{
Restriction->OnUpdate.Remove(Handle);
}
}
OnUpdate.Broadcast(this);
}
bool UMissionGoal::CheckRestrictions()
{
if (IsCompleted)
{
return true;
}
for (const auto& Restriction : Restrictions)
{
if (!Restriction->GetIsSuccess())
{
return false;
}
}
return true;
}
FText UMissionGoal::GetDescription() const
{
return FText::GetEmpty();
}
void UMissionGoal::OnRestrictionUpdated(UGoalRestriction* Restriction)
{
if (IsCompleted)
{
return;
}
OnUpdate.Broadcast(this);
}