RealtimeStyleTransferRuntime/Source/LyraGame/Cosmetics/LyraControllerComponent_Cha...

102 lines
3.1 KiB
C
Raw Permalink Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/ControllerComponent.h"
2022-09-13 07:18:28 +00:00
#include "Containers/Array.h"
#include "Engine/EngineTypes.h"
#include "HAL/Platform.h"
2022-05-23 18:41:30 +00:00
#include "LyraCharacterPartTypes.h"
2022-09-13 07:18:28 +00:00
#include "UObject/UObjectGlobals.h"
2022-05-23 18:41:30 +00:00
#include "LyraControllerComponent_CharacterParts.generated.h"
2022-09-13 07:18:28 +00:00
class APawn;
2022-05-23 18:41:30 +00:00
class ULyraPawnComponent_CharacterParts;
2022-09-13 07:18:28 +00:00
class UObject;
struct FFrame;
2022-05-23 18:41:30 +00:00
enum class ECharacterPartSource : uint8
{
Natural,
NaturalSuppressedViaCheat,
AppliedViaDeveloperSettingsCheat,
AppliedViaCheatManager
};
//////////////////////////////////////////////////////////////////////
// A character part requested on a controller component
USTRUCT()
struct FLyraControllerCharacterPartEntry
{
GENERATED_BODY()
FLyraControllerCharacterPartEntry()
{}
public:
// The character part being represented
UPROPERTY(EditAnywhere, meta=(ShowOnlyInnerProperties))
FLyraCharacterPart Part;
// The handle if already applied to a pawn
FLyraCharacterPartHandle Handle;
// The source of this part
ECharacterPartSource Source = ECharacterPartSource::Natural;
};
//////////////////////////////////////////////////////////////////////
// A component that configure what cosmetic actors to spawn for the owning controller when it possesses a pawn
UCLASS(meta = (BlueprintSpawnableComponent))
class ULyraControllerComponent_CharacterParts : public UControllerComponent
{
GENERATED_BODY()
public:
ULyraControllerComponent_CharacterParts(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
//~UActorComponent interface
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
//~End of UActorComponent interface
// Adds a character part to the actor that owns this customization component, should be called on the authority only
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Cosmetics)
void AddCharacterPart(const FLyraCharacterPart& NewPart);
// Removes a previously added character part from the actor that owns this customization component, should be called on the authority only
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Cosmetics)
void RemoveCharacterPart(const FLyraCharacterPart& PartToRemove);
// Removes all added character parts, should be called on the authority only
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Cosmetics)
void RemoveAllCharacterParts();
// Applies relevant developer settings if in PIE
void ApplyDeveloperSettings();
protected:
UPROPERTY(EditAnywhere, Category=Cosmetics)
TArray<FLyraControllerCharacterPartEntry> CharacterParts;
private:
ULyraPawnComponent_CharacterParts* GetPawnCustomizer() const;
UFUNCTION()
void OnPossessedPawnChanged(APawn* OldPawn, APawn* NewPawn);
void AddCharacterPartInternal(const FLyraCharacterPart& NewPart, ECharacterPartSource Source);
void AddCheatPart(const FLyraCharacterPart& NewPart, bool bSuppressNaturalParts);
void ClearCheatParts();
void SetSuppressionOnNaturalParts(bool bSuppressed);
friend class ULyraCosmeticCheats;
};