Added commision objectives
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "DroppedClothingSubsystem.h"
|
||||
|
||||
#include "NakedDesire/Interactables/ItemPickup.h"
|
||||
|
||||
void UDroppedClothingSubsystem::RegisterPickup(AItemPickup* Pickup)
|
||||
{
|
||||
if (Pickup)
|
||||
Pickups.AddUnique(Pickup);
|
||||
}
|
||||
|
||||
void UDroppedClothingSubsystem::UnregisterPickup(AItemPickup* Pickup)
|
||||
{
|
||||
Pickups.RemoveSingleSwap(Pickup);
|
||||
}
|
||||
|
||||
bool UDroppedClothingSubsystem::HasDroppedClothing() const
|
||||
{
|
||||
for (const TObjectPtr<AItemPickup>& Pickup : Pickups)
|
||||
{
|
||||
if (Pickup)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UDroppedClothingSubsystem::GetDistanceToNearestDroppedClothing(const FVector& From, float& OutDistance) const
|
||||
{
|
||||
float NearestSq = TNumericLimits<float>::Max();
|
||||
bool bFound = false;
|
||||
|
||||
for (const TObjectPtr<AItemPickup>& Pickup : Pickups)
|
||||
{
|
||||
if (!Pickup)
|
||||
continue;
|
||||
|
||||
const float DistSq = FVector::DistSquared(From, Pickup->GetActorLocation());
|
||||
if (DistSq < NearestSq)
|
||||
{
|
||||
NearestSq = DistSq;
|
||||
bFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFound)
|
||||
OutDistance = FMath::Sqrt(NearestSq);
|
||||
|
||||
return bFound;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
#include "DroppedClothingSubsystem.generated.h"
|
||||
|
||||
class AItemPickup;
|
||||
|
||||
/**
|
||||
* Single source of truth for which clothing is currently lying in the world (GDD §6.3.4 / §13.4).
|
||||
* Every AItemPickup self-registers on BeginPlay and unregisters on EndPlay (pickup destroys the actor),
|
||||
* so the tracked set always matches what is on the ground without per-query actor iteration.
|
||||
*
|
||||
* Backs the "move away from your clothing" objective family — distance is measured to the nearest tracked
|
||||
* pickup. World-scoped and transient; the pickups themselves are persisted via the save's world items.
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKEDDESIRE_API UDroppedClothingSubsystem : public UWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Called by AItemPickup as it spawns / is destroyed.
|
||||
void RegisterPickup(AItemPickup* Pickup);
|
||||
void UnregisterPickup(AItemPickup* Pickup);
|
||||
|
||||
// True while at least one clothing pickup exists in the world.
|
||||
UFUNCTION(BlueprintPure, Category = "Clothing")
|
||||
bool HasDroppedClothing() const;
|
||||
|
||||
// Distance in cm from From to the nearest tracked pickup. Returns false (and leaves OutDistance
|
||||
// untouched) when nothing is on the ground — callers decide what "no clothing to move from" means.
|
||||
bool GetDistanceToNearestDroppedClothing(const FVector& From, float& OutDistance) const;
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<AItemPickup>> Pickups;
|
||||
};
|
||||
Reference in New Issue
Block a user