|
|
|
|
| #pragma once
|
|
|
| #include "Components/PawnComponent.h"
|
| #include "Cosmetics/LyraCosmeticAnimationTypes.h"
|
| #include "LyraCharacterPartTypes.h"
|
| #include "Net/Serialization/FastArraySerializer.h"
|
|
|
| #include "LyraPawnComponent_CharacterParts.generated.h"
|
|
|
| class ULyraPawnComponent_CharacterParts;
|
| namespace EEndPlayReason { enum Type : int; }
|
| struct FGameplayTag;
|
| struct FLyraCharacterPartList;
|
|
|
| class AActor;
|
| class UChildActorComponent;
|
| class UObject;
|
| class USceneComponent;
|
| class USkeletalMeshComponent;
|
| struct FFrame;
|
| struct FNetDeltaSerializeInfo;
|
|
|
| DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLyraSpawnedCharacterPartsChanged, ULyraPawnComponent_CharacterParts*, ComponentWithChangedParts);
|
|
|
|
|
|
|
|
|
| USTRUCT()
|
| struct FLyraAppliedCharacterPartEntry : public FFastArraySerializerItem
|
| {
|
| GENERATED_BODY()
|
|
|
| FLyraAppliedCharacterPartEntry()
|
| {}
|
|
|
| FString GetDebugString() const;
|
|
|
| private:
|
| friend FLyraCharacterPartList;
|
| friend ULyraPawnComponent_CharacterParts;
|
|
|
| private:
|
|
|
| UPROPERTY()
|
| FLyraCharacterPart Part;
|
|
|
|
|
| UPROPERTY(NotReplicated)
|
| int32 PartHandle = INDEX_NONE;
|
|
|
|
|
| UPROPERTY(NotReplicated)
|
| TObjectPtr<UChildActorComponent> SpawnedComponent = nullptr;
|
| };
|
|
|
|
|
|
|
|
|
| USTRUCT(BlueprintType)
|
| struct FLyraCharacterPartList : public FFastArraySerializer
|
| {
|
| GENERATED_BODY()
|
|
|
| FLyraCharacterPartList()
|
| : OwnerComponent(nullptr)
|
| {
|
| }
|
|
|
| public:
|
|
|
| void PreReplicatedRemove(const TArrayView<int32> RemovedIndices, int32 FinalSize);
|
| void PostReplicatedAdd(const TArrayView<int32> AddedIndices, int32 FinalSize);
|
| void PostReplicatedChange(const TArrayView<int32> ChangedIndices, int32 FinalSize);
|
|
|
|
|
| bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms)
|
| {
|
| return FFastArraySerializer::FastArrayDeltaSerialize<FLyraAppliedCharacterPartEntry, FLyraCharacterPartList>(Entries, DeltaParms, *this);
|
| }
|
|
|
| FLyraCharacterPartHandle AddEntry(FLyraCharacterPart NewPart);
|
| void RemoveEntry(FLyraCharacterPartHandle Handle);
|
| void ClearAllEntries(bool bBroadcastChangeDelegate);
|
|
|
| FGameplayTagContainer CollectCombinedTags() const;
|
|
|
| void SetOwnerComponent(ULyraPawnComponent_CharacterParts* InOwnerComponent)
|
| {
|
| OwnerComponent = InOwnerComponent;
|
| }
|
|
|
| private:
|
| friend ULyraPawnComponent_CharacterParts;
|
|
|
| bool SpawnActorForEntry(FLyraAppliedCharacterPartEntry& Entry);
|
| bool DestroyActorForEntry(FLyraAppliedCharacterPartEntry& Entry);
|
|
|
| private:
|
|
|
| UPROPERTY()
|
| TArray<FLyraAppliedCharacterPartEntry> Entries;
|
|
|
|
|
| UPROPERTY(NotReplicated)
|
| TObjectPtr<ULyraPawnComponent_CharacterParts> OwnerComponent;
|
|
|
|
|
| int32 PartHandleCounter = 0;
|
| };
|
|
|
| template<>
|
| struct TStructOpsTypeTraits<FLyraCharacterPartList> : public TStructOpsTypeTraitsBase2<FLyraCharacterPartList>
|
| {
|
| enum { WithNetDeltaSerializer = true };
|
| };
|
|
|
|
|
|
|
|
|
| UCLASS(meta=(BlueprintSpawnableComponent))
|
| class ULyraPawnComponent_CharacterParts : public UPawnComponent
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
| ULyraPawnComponent_CharacterParts(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
|
|
|
|
| virtual void BeginPlay() override;
|
| virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
| virtual void OnRegister() override;
|
|
|
|
|
|
|
| UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Cosmetics)
|
| FLyraCharacterPartHandle AddCharacterPart(const FLyraCharacterPart& NewPart);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Cosmetics)
|
| void RemoveCharacterPart(FLyraCharacterPartHandle Handle);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Cosmetics)
|
| void RemoveAllCharacterParts();
|
|
|
|
|
| UFUNCTION(BlueprintCallable, BlueprintPure=false, BlueprintCosmetic, Category=Cosmetics)
|
| TArray<AActor*> GetCharacterPartActors() const;
|
|
|
|
|
| USkeletalMeshComponent* GetParentMeshComponent() const;
|
|
|
|
|
|
|
| USceneComponent* GetSceneComponentToAttachTo() const;
|
|
|
|
|
| UFUNCTION(BlueprintCallable, BlueprintPure=false, BlueprintCosmetic, Category=Cosmetics)
|
| FGameplayTagContainer GetCombinedTags(FGameplayTag RequiredPrefix) const;
|
|
|
| void BroadcastChanged();
|
|
|
| public:
|
|
|
| UPROPERTY(BlueprintAssignable, Category=Cosmetics, BlueprintCallable)
|
| FLyraSpawnedCharacterPartsChanged OnCharacterPartsChanged;
|
|
|
| private:
|
|
|
| UPROPERTY(Replicated, Transient)
|
| FLyraCharacterPartList CharacterPartList;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category=Cosmetics)
|
| FLyraAnimBodyStyleSelectionSet BodyMeshes;
|
| };
|
|
|