init
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "EquipClothingRestriction.h"
|
||||
|
||||
#include "NakedDesire/Clothing/ClothingItem.h"
|
||||
#include "NakedDesire/Clothing/ClothingItemData.h"
|
||||
#include "NakedDesire/Clothing/ClothingManager.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Missions.Restriction.EquipClothing"
|
||||
const FText RestrictionEquipClothingDescriptionSingle = LOCTEXT("Description.Single", "Equip {ItemName}");
|
||||
const FText RestrictionEquipClothingDescriptionMultiple = LOCTEXT("Description.Multiple", "Equip one of: {ItemNames}");
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
void UEquipClothingRestriction::Init(ANakedDesireCharacter* PlayerCharacter)
|
||||
{
|
||||
Super::Init(PlayerCharacter);
|
||||
|
||||
if (!ClothingEquippedDelegateHandle.IsValid())
|
||||
{
|
||||
Player->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &UEquipClothingRestriction::OnClothingEquipped);
|
||||
}
|
||||
|
||||
if (!ClothingUnequippedDelegateHandle.IsValid())
|
||||
{
|
||||
Player->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &UEquipClothingRestriction::OnClothingUnequipped);
|
||||
}
|
||||
|
||||
CheckClothing();
|
||||
}
|
||||
|
||||
void UEquipClothingRestriction::Stop()
|
||||
{
|
||||
Super::Stop();
|
||||
|
||||
Player->ClothingManager->OnClothingEquip.Remove(this, TEXT("OnClothingEquipped"));
|
||||
Player->ClothingManager->OnClothingUnequip.Remove(this, TEXT("OnClothingUnequipped"));
|
||||
}
|
||||
|
||||
FText UEquipClothingRestriction::GetDescription() const
|
||||
{
|
||||
if (ClothingItems.Num() == 1 && ClothingItems[0])
|
||||
{
|
||||
return FText::Format(RestrictionEquipClothingDescriptionSingle,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("ItemName"), ClothingItems[0]->Name}
|
||||
});
|
||||
}
|
||||
|
||||
FString Items = TEXT("");
|
||||
for (const auto& Item : ClothingItems)
|
||||
{
|
||||
if (Item)
|
||||
{
|
||||
Items += Item->Name.ToString() + ", ";
|
||||
}
|
||||
}
|
||||
return FText::Format(RestrictionEquipClothingDescriptionMultiple,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("ItemNames"), FText::FromString(Items)}
|
||||
});
|
||||
}
|
||||
|
||||
void UEquipClothingRestriction::OnClothingEquipped(const UClothingItemData* ClothingData)
|
||||
{
|
||||
const bool IsTargetClothing = ClothingItems.FindByPredicate([&ClothingData](const UClothingItem* Item)
|
||||
{
|
||||
return Item && Item->Name.EqualTo(ClothingData->Info->Name);
|
||||
}) != nullptr;
|
||||
if (IsTargetClothing)
|
||||
{
|
||||
Complete();
|
||||
}
|
||||
}
|
||||
|
||||
void UEquipClothingRestriction::OnClothingUnequipped(const UClothingItemData* ClothingData)
|
||||
{
|
||||
const bool IsTargetClothing = ClothingItems.FindByPredicate([&ClothingData](const UClothingItem* Item)
|
||||
{
|
||||
return Item && Item->Name.EqualTo(ClothingData->Info->Name);
|
||||
}) != nullptr;
|
||||
if (IsTargetClothing)
|
||||
{
|
||||
Init(Player);
|
||||
}
|
||||
}
|
||||
|
||||
void UEquipClothingRestriction::CheckClothing()
|
||||
{
|
||||
for (const FClothingSlotData& ClothingSlot : Player->ClothingManager->ClothingSlots)
|
||||
{
|
||||
if (!ClothingSlot.ClothingData)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool IsTargetClothing = ClothingItems.FindByPredicate([&ClothingSlot](const UClothingItem* Item)
|
||||
{
|
||||
return Item && Item->Name.EqualTo(ClothingSlot.ClothingData->Info->Name);
|
||||
}) != nullptr;
|
||||
if (IsTargetClothing)
|
||||
{
|
||||
Complete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NakedDesire/MissionBuilder/GoalRestriction.h"
|
||||
#include "EquipClothingRestriction.generated.h"
|
||||
|
||||
class UClothingItem;
|
||||
class UClothingItemData;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(EditInlineNew)
|
||||
class NAKEDDESIRE_API UEquipClothingRestriction : public UGoalRestriction
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, meta = (ToolTip =
|
||||
"One of provided clothing items should be equipped by player. If multiple clothing items required provide multiple restrictions"))
|
||||
TArray<UClothingItem*> ClothingItems;
|
||||
|
||||
public:
|
||||
virtual void Init(ANakedDesireCharacter* PlayerCharacter) override;
|
||||
virtual void Stop() override;
|
||||
virtual FText GetDescription() const override;
|
||||
|
||||
private:
|
||||
FDelegateHandle ClothingEquippedDelegateHandle;
|
||||
FDelegateHandle ClothingUnequippedDelegateHandle;
|
||||
|
||||
UFUNCTION()
|
||||
void OnClothingEquipped(const UClothingItemData* ClothingData);
|
||||
|
||||
UFUNCTION()
|
||||
void OnClothingUnequipped(const UClothingItemData* ClothingData);
|
||||
|
||||
void CheckClothing();
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "ExposeBodyPartRestriction.h"
|
||||
|
||||
#include "NakedDesire/Clothing/ClothingItemData.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
#include "NakedDesire/Clothing/ClothingManager.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Missions.Restrictions.ExposeBodyPart"
|
||||
const FText RestrictionsExposeBodyPartDescription = LOCTEXT("Description", "Expose {BodyPart}");
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
void UExposeBodyPartRestriction::Init(ANakedDesireCharacter* PlayerCharacter)
|
||||
{
|
||||
Super::Init(PlayerCharacter);
|
||||
|
||||
PlayerCharacter->ClothingManager->OnClothingEquip.AddUniqueDynamic(this, &UExposeBodyPartRestriction::EquipClothing);
|
||||
PlayerCharacter->ClothingManager->OnClothingUnequip.AddUniqueDynamic(this, &UExposeBodyPartRestriction::UnequipClothing);
|
||||
|
||||
CheckClothing();
|
||||
}
|
||||
|
||||
void UExposeBodyPartRestriction::Stop()
|
||||
{
|
||||
Super::Stop();
|
||||
|
||||
Player->ClothingManager->OnClothingEquip.Remove(this, TEXT("ClothingEquip"));
|
||||
Player->ClothingManager->OnClothingUnequip.Remove(this, TEXT("ClothingUnequip"));
|
||||
}
|
||||
|
||||
FText UExposeBodyPartRestriction::GetDescription() const
|
||||
{
|
||||
FText Part = UPrivateBodyPartType::GetString(BodyPart);
|
||||
|
||||
return FText::Format(RestrictionsExposeBodyPartDescription,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("BodyPart"), Part}
|
||||
});
|
||||
}
|
||||
|
||||
void UExposeBodyPartRestriction::EquipClothing(const UClothingItemData* ClothingData)
|
||||
{
|
||||
if (IsSuccess && ClothingData->Info->CoveredBodyParts.Contains(BodyPart))
|
||||
{
|
||||
Init(Player);
|
||||
}
|
||||
}
|
||||
|
||||
void UExposeBodyPartRestriction::UnequipClothing(const UClothingItemData* ClothingData)
|
||||
{
|
||||
if (IsSuccess)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckClothing();
|
||||
}
|
||||
|
||||
void UExposeBodyPartRestriction::CheckClothing()
|
||||
{
|
||||
if (!Player || !Player->ClothingManager || Player->ClothingManager->ClothingSlots.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const FClothingSlotData* TargetClothingItem = Player->ClothingManager->ClothingSlots.FindByPredicate([this](const FClothingSlotData& ClothingSlot)
|
||||
{
|
||||
if (ClothingSlot.ClothingData)
|
||||
{
|
||||
return ClothingSlot.ClothingData->Info->CoveredBodyParts.Contains(BodyPart);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
if (!TargetClothingItem)
|
||||
{
|
||||
Complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NakedDesire/Player/PrivateBodyPartType.h"
|
||||
#include "NakedDesire/MissionBuilder/GoalRestriction.h"
|
||||
#include "ExposeBodyPartRestriction.generated.h"
|
||||
|
||||
class UClothingItemData;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(EditInlineNew)
|
||||
class NAKEDDESIRE_API UExposeBodyPartRestriction : public UGoalRestriction
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FDelegateHandle EquipClothingHandle;
|
||||
FDelegateHandle UnequipClothingHandle;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
EPrivateBodyPartType BodyPart;
|
||||
|
||||
protected:
|
||||
virtual void Init(ANakedDesireCharacter* PlayerCharacter) override;
|
||||
virtual void Stop() override;
|
||||
virtual FText GetDescription() const override;
|
||||
|
||||
private:
|
||||
UFUNCTION()
|
||||
void EquipClothing(const UClothingItemData* ClothingData);
|
||||
|
||||
UFUNCTION()
|
||||
void UnequipClothing(const UClothingItemData* ClothingData);
|
||||
|
||||
void CheckClothing();
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
|
||||
#include "LocationRestriction.h"
|
||||
#include "NakedDesire/Locations/LocationData.h"
|
||||
#include "NakedDesire/Player/NakedDesireCharacter.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Missions.Restrictions.Location"
|
||||
const FText RestrictionsLocationDescription = LOCTEXT("Description", "Visit {LocationName}");
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
void ULocationRestriction::Init(ANakedDesireCharacter* PlayerCharacter)
|
||||
{
|
||||
Super::Init(PlayerCharacter);
|
||||
|
||||
AreaEnterHandle = PlayerCharacter->OnAreaEnter.AddUObject(this, &ULocationRestriction::OnAreaEnter);
|
||||
AreaExitHandle = PlayerCharacter->OnAreaExit.AddUObject(this, &ULocationRestriction::OnAreaExit);
|
||||
}
|
||||
|
||||
void ULocationRestriction::Stop()
|
||||
{
|
||||
Super::Stop();
|
||||
|
||||
Player->OnAreaEnter.Remove(AreaEnterHandle);
|
||||
Player->OnAreaExit.Remove(AreaExitHandle);
|
||||
}
|
||||
|
||||
FText ULocationRestriction::GetDescription() const
|
||||
{
|
||||
return FText::Format(RestrictionsLocationDescription,
|
||||
FFormatNamedArguments
|
||||
{
|
||||
{TEXT("LocationName"), TargetLocation->Name}
|
||||
});
|
||||
}
|
||||
|
||||
void ULocationRestriction::OnAreaEnter(ULocationData* LocationData)
|
||||
{
|
||||
if (!IsSuccess && LocationData->Tag.MatchesTag(TargetLocation->Tag))
|
||||
{
|
||||
Complete();
|
||||
}
|
||||
}
|
||||
|
||||
void ULocationRestriction::OnAreaExit(ULocationData* LocationData)
|
||||
{
|
||||
if (IsSuccess && LocationData->Tag.MatchesTag(TargetLocation->Tag))
|
||||
{
|
||||
Init(Player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// © 2025 Naked People Team. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "NakedDesire/MissionBuilder/GoalRestriction.h"
|
||||
#include "LocationRestriction.generated.h"
|
||||
|
||||
class ULocationData;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKEDDESIRE_API ULocationRestriction : public UGoalRestriction
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FDelegateHandle AreaEnterHandle;
|
||||
FDelegateHandle AreaExitHandle;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
ULocationData* TargetLocation;
|
||||
|
||||
protected:
|
||||
virtual void Init(ANakedDesireCharacter* PlayerCharacter) override;
|
||||
virtual void Stop() override;
|
||||
virtual FText GetDescription() const override;
|
||||
|
||||
private:
|
||||
void OnAreaEnter(ULocationData* LocationData);
|
||||
void OnAreaExit(ULocationData* LocationData);
|
||||
};
|
||||
Reference in New Issue
Block a user