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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NakedDesire/MissionBuilder/MissionGoal.h"
|
||||
#include "NakedDesire/Player/PrivateBodyPartType.h"
|
||||
#include "FlashGoal.generated.h"
|
||||
|
||||
class ANPCAIController;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(EditInlineNew)
|
||||
class NAKEDDESIRE_API UFlashGoal : public UMissionGoal
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, meta = (ClampMin = 1))
|
||||
int RequiredFlashCount = 1;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
EPrivateBodyPartType BodyType;
|
||||
|
||||
FDelegateHandle PlayerNoticedHandle;
|
||||
|
||||
UPROPERTY()
|
||||
TSet<AActor*> NoticedActors;
|
||||
|
||||
public:
|
||||
virtual void Init(ANakedDesireCharacter* PlayerCharacter) override;
|
||||
virtual void Complete() override;
|
||||
virtual FText GetDescription() const override;
|
||||
|
||||
private:
|
||||
void OnPlayerNoticed(ANPCAIController* NPC);
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#include "MinTimeGoal.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Missions.Goals.MinTime"
|
||||
const FText GoalsMinTimeDescription = LOCTEXT("Description", "Do following at least {MinTime} seconds");
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
|
||||
FText UMinTimeGoal::GetDescription() const
|
||||
{
|
||||
return FText::Format(GoalsMinTimeDescription,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("MinTime"), MinTime}
|
||||
});
|
||||
}
|
||||
|
||||
void UMinTimeGoal::OnRestrictionUpdated(UGoalRestriction* Restriction)
|
||||
{
|
||||
Super::OnRestrictionUpdated(Restriction);
|
||||
|
||||
if (CheckRestrictions())
|
||||
{
|
||||
if (!TimerHandle.IsValid())
|
||||
{
|
||||
GetWorld()->GetTimerManager().SetTimer(TimerHandle, this, &UMinTimeGoal::TimeIsUp, MinTime, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TimerHandle.IsValid())
|
||||
{
|
||||
GetWorld()->GetTimerManager().ClearTimer(TimerHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UMinTimeGoal::TimeIsUp()
|
||||
{
|
||||
Complete();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "../MissionGoal.h"
|
||||
#include "MinTimeGoal.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(EditInlineNew)
|
||||
class NAKEDDESIRE_API UMinTimeGoal : public UMissionGoal
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
virtual FText GetDescription() const override;
|
||||
|
||||
protected:
|
||||
virtual void OnRestrictionUpdated(UGoalRestriction* Restriction) override;
|
||||
|
||||
private:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
float MinTime = 3.f;
|
||||
|
||||
FTimerHandle TimerHandle;
|
||||
|
||||
void TimeIsUp();
|
||||
};
|
||||
Reference in New Issue
Block a user