init
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "FlashGoal.h"
|
||||
|
||||
#include "NakedDesire/NPC/NPCAIController.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Missions.Goals.Flash"
|
||||
const FText GoalsFlashSingle = LOCTEXT("Description.Single", "Flash someone {BodyPart} once");
|
||||
const FText GoalsFlashMultiple = LOCTEXT("Description.Multiple", "Flash {BodyPart} to {PeopleCount} people");
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
void UFlashGoal::Init(ANakedDesireCharacter* PlayerCharacter)
|
||||
{
|
||||
Super::Init(PlayerCharacter);
|
||||
|
||||
PlayerNoticedHandle = PlayerCharacter->OnNoticed.AddUObject(this, &UFlashGoal::OnPlayerNoticed);
|
||||
}
|
||||
|
||||
void UFlashGoal::Complete()
|
||||
{
|
||||
Super::Complete();
|
||||
|
||||
Player->OnNoticed.Remove(PlayerNoticedHandle);
|
||||
}
|
||||
|
||||
FText UFlashGoal::GetDescription() const
|
||||
{
|
||||
const FText BodyTypeString = UPrivateBodyPartType::GetString(BodyType);
|
||||
|
||||
if (RequiredFlashCount == 1)
|
||||
{
|
||||
return FText::Format(GoalsFlashSingle,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("BodyPart"), BodyTypeString}
|
||||
});
|
||||
}
|
||||
|
||||
return FText::Format(GoalsFlashMultiple,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("BodyPart"), BodyTypeString},
|
||||
{TEXT("PeopleCount"), RequiredFlashCount}
|
||||
});
|
||||
}
|
||||
|
||||
void UFlashGoal::OnPlayerNoticed(ANPCAIController* NPC)
|
||||
{
|
||||
if (IsCompleted || !CheckRestrictions())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NoticedActors.Contains(NPC))
|
||||
{
|
||||
NoticedActors.Add(NPC);
|
||||
}
|
||||
|
||||
if (NoticedActors.Num() >= RequiredFlashCount)
|
||||
{
|
||||
Complete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user