|
|
|
|
| #include "LyraCosmeticCheats.h"
|
| #include "Cosmetics/LyraCharacterPartTypes.h"
|
| #include "LyraControllerComponent_CharacterParts.h"
|
| #include "GameFramework/CheatManagerDefines.h"
|
| #include "System/LyraDevelopmentStatics.h"
|
|
|
| #include UE_INLINE_GENERATED_CPP_BY_NAME(LyraCosmeticCheats)
|
|
|
|
|
|
|
|
|
| ULyraCosmeticCheats::ULyraCosmeticCheats()
|
| {
|
| #if UE_WITH_CHEAT_MANAGER
|
| if (HasAnyFlags(RF_ClassDefaultObject))
|
| {
|
| UCheatManager::RegisterForOnCheatManagerCreated(FOnCheatManagerCreated::FDelegate::CreateLambda(
|
| [](UCheatManager* CheatManager)
|
| {
|
| CheatManager->AddCheatManagerExtension(NewObject<ThisClass>(CheatManager));
|
| }));
|
| }
|
| #endif
|
| }
|
|
|
| void ULyraCosmeticCheats::AddCharacterPart(const FString& AssetName, bool bSuppressNaturalParts)
|
| {
|
| #if UE_WITH_CHEAT_MANAGER
|
| if (ULyraControllerComponent_CharacterParts* CosmeticComponent = GetCosmeticComponent())
|
| {
|
| TSubclassOf<AActor> PartClass = ULyraDevelopmentStatics::FindClassByShortName<AActor>(AssetName);
|
| if (PartClass != nullptr)
|
| {
|
| FLyraCharacterPart Part;
|
| Part.PartClass = PartClass;
|
|
|
| CosmeticComponent->AddCheatPart(Part, bSuppressNaturalParts);
|
| }
|
| }
|
| #endif
|
| }
|
|
|
| void ULyraCosmeticCheats::ReplaceCharacterPart(const FString& AssetName, bool bSuppressNaturalParts)
|
| {
|
| ClearCharacterPartOverrides();
|
| AddCharacterPart(AssetName, bSuppressNaturalParts);
|
| }
|
|
|
| void ULyraCosmeticCheats::ClearCharacterPartOverrides()
|
| {
|
| #if UE_WITH_CHEAT_MANAGER
|
| if (ULyraControllerComponent_CharacterParts* CosmeticComponent = GetCosmeticComponent())
|
| {
|
| CosmeticComponent->ClearCheatParts();
|
| }
|
| #endif
|
| }
|
|
|
| ULyraControllerComponent_CharacterParts* ULyraCosmeticCheats::GetCosmeticComponent() const
|
| {
|
| if (APlayerController* PC = GetPlayerController())
|
| {
|
| return PC->FindComponentByClass<ULyraControllerComponent_CharacterParts>();
|
| }
|
|
|
| return nullptr;
|
| }
|
|
|
|
|