58. Broadcasting Data Table Rows

This commit is contained in:
Edward R. Gonzalez 2024-04-26 20:08:08 -04:00
parent e8fb014d29
commit fe2abe1972
27 changed files with 127 additions and 26 deletions

Binary file not shown.

View File

@ -10,6 +10,7 @@ Tag_GlobalPPV=Global_PPV
Template_PlayerCamera=/Game/Actors/BP_CameraMount.BP_CameraMount_C Template_PlayerCamera=/Game/Actors/BP_CameraMount.BP_CameraMount_C
Template_HUD_HostUI=/Game/UI/UI_Host.UI_Host_C Template_HUD_HostUI=/Game/UI/UI_Host.UI_Host_C
Template_HostWidgetController=/Game/UI/BP_HostWidgetController.BP_HostWidgetController_C Template_HostWidgetController=/Game/UI/BP_HostWidgetController.BP_HostWidgetController_C
TaggedMessageTable=/Game/Core/Tables/DT_TaggedMessages.DT_TaggedMessages
[/Script/GameplayAbilities.AbilitySystemGlobals] [/Script/GameplayAbilities.AbilitySystemGlobals]
bUseDebugTargetFromHud=true bUseDebugTargetFromHud=true

View File

@ -6,11 +6,15 @@ AllowEditorTagUnloading=True
AllowGameTagUnloading=False AllowGameTagUnloading=False
FastReplication=False FastReplication=False
InvalidTagCharacters="\"\'," InvalidTagCharacters="\"\',"
+GameplayTagTableList=/Game/Core/DT_PrimaryAttributes.DT_PrimaryAttributes +GameplayTagTableList=/Game/Core/Tables/DT_PrimaryAttributes.DT_PrimaryAttributes
NumBitsForContainerSize=6 NumBitsForContainerSize=6
NetIndexFirstBitSegment=16 NetIndexFirstBitSegment=16
+GameplayTagList=(Tag="Attributes.Vital.Health",DevComment="") +GameplayTagList=(Tag="Attributes.Vital.Health",DevComment="")
+GameplayTagList=(Tag="Attributes.Vital.Mana",DevComment="") +GameplayTagList=(Tag="Attributes.Vital.Mana",DevComment="")
+GameplayTagList=(Tag="Attributes.Vital.MaxHealth",DevComment="") +GameplayTagList=(Tag="Attributes.Vital.MaxHealth",DevComment="")
+GameplayTagList=(Tag="Attributes.Vital.MaxMana",DevComment="") +GameplayTagList=(Tag="Attributes.Vital.MaxMana",DevComment="")
+GameplayTagList=(Tag="Message.Crystal.Health",DevComment="")
+GameplayTagList=(Tag="Message.Crystal.Mana",DevComment="")
+GameplayTagList=(Tag="Message.Potion.Health",DevComment="")
+GameplayTagList=(Tag="Message.Potion.Mana",DevComment="")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Project/Content/Core/CT_Potion.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Project/Content/Core/DT_TaggedMessages.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Project/Content/Core/Tables/CT_Potion.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Project/Content/Core/Tables/DT_PrimaryAttributes.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Project/Content/Core/Tables/DT_TaggedMessages.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Project/Content/Levels/StartupMap.umap (Stored with Git LFS)

Binary file not shown.

BIN
Project/Content/UI/UI_Host.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -0,0 +1,9 @@
{
"ColumnWidths":
{
"Image": 487,
"Tag": 246,
"Message": 439,
"MessageTemplate": 232
}
}

View File

@ -21,12 +21,7 @@ void UGasaAbilitySystemComp::EffectApplied(UAbilitySystemComponent* AbilitySyste
{ {
FGameplayTagContainer Tags; FGameplayTagContainer Tags;
Spec.GetAllAssetTags(Tags); Spec.GetAllAssetTags(Tags);
for (FGameplayTag const& Tag : Tags) Event_OnEffectAppliedAssetTags.Broadcast(Tags);
{
// TODO(Ed): Broadcast the tag to the widget controller
FString Msg = FString::Printf(TEXT("GE Tag: %s"), * Tag.ToString());
Log(Msg);
}
} }
void UGasaAbilitySystemComp::InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor) void UGasaAbilitySystemComp::InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor)

View File

@ -1,16 +1,22 @@
#pragma once #pragma once
#include "AbilitySystemComponent.h" #include "AbilitySystemComponent.h"
#include "GasaCommon.h" #include "GasaCommon.h"
#include "GasaAbilitySystemComponent.generated.h" #include "GasaAbilitySystemComponent.generated.h"
DECLARE_MULTICAST_DELEGATE_OneParam(FEffectAssetTagsSig, FGameplayTagContainer const& /*Tags*/);
UCLASS(BlueprintType) UCLASS(BlueprintType)
class GASA_API UGasaAbilitySystemComp : public UAbilitySystemComponent class GASA_API UGasaAbilitySystemComp : public UAbilitySystemComponent
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
FEffectAssetTagsSig Event_OnEffectAppliedAssetTags;
// TODO(Ed): If hes only using this to bind the EffectApplied to a delegate, then just use the init override instead. // TODO(Ed): If hes only using this to bind the EffectApplied to a delegate, then just use the init override instead.
void OnAbilityActorInfoSet(); void OnAbilityActorInfoSet();

View File

@ -23,6 +23,7 @@
struct FInputActionValue; struct FInputActionValue;
struct FGameplayEffectContextHandle; struct FGameplayEffectContextHandle;
struct FGameplayEffectModCallbackData; struct FGameplayEffectModCallbackData;
struct FGameplayTagContainer;
struct FOnAttributeChangeData; struct FOnAttributeChangeData;
struct FReplicationFlags; struct FReplicationFlags;
@ -44,6 +45,7 @@ class UInputAction;
class UInputMappingContext; class UInputMappingContext;
class USphereComponent; class USphereComponent;
class USpringArmComponent; class USpringArmComponent;
class UTexture2D;
#pragma endregion Engine Forwards #pragma endregion Engine Forwards
#pragma region Engine Plugin Forwards #pragma region Engine Plugin Forwards
@ -72,6 +74,7 @@ class UGasaObject;
class UGasaOverlay; class UGasaOverlay;
class UGasaProgressBar; class UGasaProgressBar;
class UGasaSizeBox; class UGasaSizeBox;
class UGasaUserWidget;
class UHostWidgetController; class UHostWidgetController;
class UHUDHostWidget; class UHUDHostWidget;
class UWidgetController; class UWidgetController;

View File

@ -2,6 +2,14 @@
#include "GasaCommon.h" #include "GasaCommon.h"
template<typename RowType>
inline
RowType* GetDataTableRowByTag(UDataTable* DT, FGameplayTag& Tag)
{
RowType* Row = DT->FindRow<RowType>(Tag.GetTagName(), TEXT(""));
return Row;
}
template<typename KeyType, typename ValueType> template<typename KeyType, typename ValueType>
inline inline
void RemoveKeys(TMap<KeyType, ValueType> Map, TArray<KeyType> Keys) void RemoveKeys(TMap<KeyType, ValueType> Map, TArray<KeyType> Keys)

View File

@ -1,11 +1,12 @@
#pragma once #pragma once
#include "Engine/DataTable.h"
#include "Engine/DeveloperSettings.h" #include "Engine/DeveloperSettings.h"
#include "GasaCommon.h" #include "GasaCommon.h"
#include "GasaDevOptions.generated.h" #include "GasaDevOptions.generated.h"
UCLASS(Config=Game, DefaultConfig, meta=(DisplayName="Gasa")) UCLASS(Config=Game, DefaultConfig, meta=(DisplayName="Gasa"))
class GASA_API UGasaDevOptions : public UDeveloperSettings class GASA_API UGasaDevOptions : public UDeveloperSettings
{ {
@ -15,6 +16,9 @@ public:
// NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp // NOTE(Ed): Any Soft-References must have their includes defined in GasaDevOptions.cpp
// They are used by GasaGen for the GasaDevOptionsCache // They are used by GasaGen for the GasaDevOptionsCache
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI")
TSoftObjectPtr<UDataTable> TaggedMessageTable;
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI") UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category="UI")
TSoftClassPtr<ACameraMount> Template_PlayerCamera; TSoftClassPtr<ACameraMount> Template_PlayerCamera;

View File

@ -11,6 +11,9 @@ void FGasaDevOptionsCache::CachedDevOptions()
{ {
UGasaDevOptions* DevOpts = GetMutDevOptions(); UGasaDevOptions* DevOpts = GetMutDevOptions();
TaggedMessageTable = DevOpts->TaggedMessageTable.LoadSynchronous();
ensureMsgf( TaggedMessageTable != nullptr, TEXT( "TaggedMessageTable is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) );
Template_PlayerCamera = DevOpts->Template_PlayerCamera.LoadSynchronous(); Template_PlayerCamera = DevOpts->Template_PlayerCamera.LoadSynchronous();
ensureMsgf( ensureMsgf(
Template_PlayerCamera != nullptr, TEXT( "Template_PlayerCamera is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" ) Template_PlayerCamera != nullptr, TEXT( "Template_PlayerCamera is null, DO NOT RUN PIE or else you may get a crash if not handled in BP or C++" )

View File

@ -8,6 +8,8 @@ struct GASA_API FGasaDevOptionsCache
{ {
GENERATED_BODY() GENERATED_BODY()
UPROPERTY()
UObject* TaggedMessageTable;
UPROPERTY() UPROPERTY()
UClass* Template_PlayerCamera; UClass* Template_PlayerCamera;
UPROPERTY() UPROPERTY()

View File

@ -2,6 +2,9 @@
#include "AbilitySystem/GasaAbilitySystemComponent_Inlines.h" #include "AbilitySystem/GasaAbilitySystemComponent_Inlines.h"
#include "AbilitySystem/GasaAttributeSet.h" #include "AbilitySystem/GasaAttributeSet.h"
#include "GameplayEffectTypes.h" #include "GameplayEffectTypes.h"
#include "GasaDevOptions.h"
#include "TaggedMessageRow.h"
using namespace Gasa;
@ -30,6 +33,20 @@ void UHostWidgetController::MaxManaChanged( FOnAttributeChangeData const& Attrib
} }
#pragma endregion Attribute Changed Callbacks #pragma endregion Attribute Changed Callbacks
void UHostWidgetController::OnEffectAppliedAssetTags( FGameplayTagContainer const& AssetTags )
{
UDataTable* TaggedMessages = GetDevOptions()->TaggedMessageTable.Get();
for ( FGameplayTag const& Tag : AssetTags )
{
FGameplayTag MessageTagCategory = FGameplayTag::RequestGameplayTag( FName( "Message" ) );
if ( ! Tag.MatchesTag( MessageTagCategory ) )
continue;
FTaggedMessageRow* Row = TaggedMessages->FindRow<FTaggedMessageRow>( Tag.GetTagName(), TEXT( "" ) );
OnTaggedAssetMessage.Broadcast( *Row );
}
}
void UHostWidgetController::BroadcastInitialValues() void UHostWidgetController::BroadcastInitialValues()
{ {
// This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp // This function is managed by: GenGasa/GenGasa_HostWidgetController.cpp
@ -66,4 +83,6 @@ void UHostWidgetController::BindCallbacksToDependencies()
FOnGameplayAttributeValueChange& MaxManaAttributeChangedDelegate = FOnGameplayAttributeValueChange& MaxManaAttributeChangedDelegate =
AbilitySystem->GetGameplayAttributeValueChangeDelegate( GasaAttribs->GetMaxManaAttribute() ); AbilitySystem->GetGameplayAttributeValueChangeDelegate( GasaAttribs->GetMaxManaAttribute() );
MaxManaAttributeChangedDelegate.AddUObject( this, &ThisClass::MaxManaChanged ); MaxManaAttributeChangedDelegate.AddUObject( this, &ThisClass::MaxManaChanged );
AbilitySystem->Event_OnEffectAppliedAssetTags.AddUObject( this, &UHostWidgetController::OnEffectAppliedAssetTags );
} }

View File

@ -1,7 +1,10 @@
#pragma once #pragma once
#include "GasaCommon.h"
#include "TaggedMessageRow.h"
#include "WidgetController.h" #include "WidgetController.h"
#include "HostWidgetController.generated.h" #include "HostWidgetController.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FAttributeFloatChangedSig, float, NewValue ); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FAttributeFloatChangedSig, float, NewValue );
UCLASS( Blueprintable, BlueprintType ) UCLASS( Blueprintable, BlueprintType )
@ -30,6 +33,11 @@ public:
void MaxManaChanged( FOnAttributeChangeData const& Data ); void MaxManaChanged( FOnAttributeChangeData const& Data );
#pragma endregion Attribute Events #pragma endregion Attribute Events
UPROPERTY( BlueprintAssignable, Category = "Messages" )
FTaggedMessageRowSig OnTaggedAssetMessage;
void OnEffectAppliedAssetTags( FGameplayTagContainer const& AssetTags );
#pragma region WidgetController #pragma region WidgetController
void BroadcastInitialValues() override; void BroadcastInitialValues() override;
void BindCallbacksToDependencies() override; void BindCallbacksToDependencies() override;

View File

@ -0,0 +1,28 @@
#pragma once
#include "GameplayTagContainer.h"
#include "GasaCommon.h"
#include "Engine/DataTable.h"
#include "Templates/SubclassOf.h"
#include "TaggedMessageRow.generated.h"
USTRUCT(BlueprintType)
struct FTaggedMessageRow : public FTableRowBase
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FGameplayTag Tag;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FText Message;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TSubclassOf<UGasaUserWidget> MessageTemplate;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
UTexture2D* Image;
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTaggedMessageRowSig, FTaggedMessageRow, Message);

View File

@ -209,6 +209,8 @@ void gen_UHostWidgetController()
UGasaAttributeSet* GasaAttribs = Cast<UGasaAttributeSet>( Data.Attributes ); UGasaAttributeSet* GasaAttribs = Cast<UGasaAttributeSet>( Data.Attributes );
<bindings> <bindings>
AbilitySystem->Event_OnEffectAppliedAssetTags.AddUObject(this, & UHostWidgetController::OnEffectAppliedAssetTags);
}) })
)); ));
} }