From 2522f4df6c16348b5a2b67c3496b8430a2cee08b Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 21 Oct 2024 16:10:56 -0400 Subject: [PATCH] Starting to figure out attribute set more (Part of 65. 65. Initialize Attributes from a Data Table) Going to move gasagen code to editor module. --- GASATHON.10x | 31 +++- .../Gasa/AbilitySystem/GasaAttributeSet.cpp | 68 ++++++++ .../Gasa/AbilitySystem/GasaAttributeSet.h | 71 ++++++++- .../AbilitySystem/GasaAttributeSet_Inlines.h | 36 +++++ .../Source/Gasa/Characters/GasaCharacter.cpp | 15 ++ .../Source/Gasa/Characters/GasaCharacter.h | 5 + Project/Source/GasaGen/GasaGen.cpp | 2 +- .../GasaGen/GasaGen_HostWidgetController.cpp | 2 +- .../GasaGen/GasaGen_UGasaAttributeSet.cpp | 146 ++++++++++++++---- Project/Source/GasaGen/gen.dep.hpp | 5 + 10 files changed, 343 insertions(+), 38 deletions(-) diff --git a/GASATHON.10x b/GASATHON.10x index 2bfdc56..0d6379e 100644 --- a/GASATHON.10x +++ b/GASATHON.10x @@ -1,8 +1,8 @@ - *.* - *.obj,*.lib,*.pch,*.dll,*.pdb,.vs,Debug,Release,x64,obj,*.user,Intermediate + *.*, + *.obj,*.lib,*.pch,*.dll,*.pdb,.vs,Debug,Release,x64,obj,*.user,Intermediate, true true true @@ -15,12 +15,13 @@ - - + + + - false + false Debug Release @@ -39,8 +40,24 @@ C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um - - + + GASA_INTELLISENSE_DIRECTIVES + + + + Debug:x64 + + + + + Debug + + + + x64 + + + diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp index 609dd86..1b61d03 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.cpp @@ -17,6 +17,34 @@ UGasaAttributeSet::UGasaAttributeSet() } #pragma region Rep Notifies +void UGasaAttributeSet::Client_OnRep_Strength( FGameplayAttributeData& PrevStrength ) +{ + // From GAMEPLAYATTRIBUTE_REPNOTIFY + static FProperty* UGasaAttributeSetProperty = FindFieldChecked( StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Strength ) ); + GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication( FGameplayAttribute( UGasaAttributeSetProperty ), Strength, PrevStrength ); +} +void UGasaAttributeSet::Client_OnRep_Intelligence( FGameplayAttributeData& PrevIntelligence ) +{ + // From GAMEPLAYATTRIBUTE_REPNOTIFY + static FProperty* UGasaAttributeSetProperty = FindFieldChecked( StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Intelligence ) ); + GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication( + FGameplayAttribute( UGasaAttributeSetProperty ), Intelligence, PrevIntelligence + ); +} +void UGasaAttributeSet::Client_OnRep_Resilience( FGameplayAttributeData& PrevResilience ) +{ + // From GAMEPLAYATTRIBUTE_REPNOTIFY + static FProperty* UGasaAttributeSetProperty = FindFieldChecked( StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Resilience ) ); + GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication( + FGameplayAttribute( UGasaAttributeSetProperty ), Resilience, PrevResilience + ); +} +void UGasaAttributeSet::Client_OnRep_Vigor( FGameplayAttributeData& PrevVigor ) +{ + // From GAMEPLAYATTRIBUTE_REPNOTIFY + static FProperty* UGasaAttributeSetProperty = FindFieldChecked( StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Vigor ) ); + GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication( FGameplayAttribute( UGasaAttributeSetProperty ), Vigor, PrevVigor ); +} void UGasaAttributeSet::Client_OnRep_Health( FGameplayAttributeData& PrevHealth ) { // From GAMEPLAYATTRIBUTE_REPNOTIFY @@ -49,6 +77,22 @@ void UGasaAttributeSet::PostGameplayEffectExecute( FGameplayEffectModCallbackDat FEffectProperties Props; Props.Populate( Data ); + if ( Data.EvaluatedData.Attribute == GetStrengthAttribute() ) + { + SetStrength( FMath::Clamp( GetStrength(), 0, 999.000000 ) ); + } + if ( Data.EvaluatedData.Attribute == GetIntelligenceAttribute() ) + { + SetIntelligence( FMath::Clamp( GetIntelligence(), 0, 999.000000 ) ); + } + if ( Data.EvaluatedData.Attribute == GetResilienceAttribute() ) + { + SetResilience( FMath::Clamp( GetResilience(), 0, 999.000000 ) ); + } + if ( Data.EvaluatedData.Attribute == GetVigorAttribute() ) + { + SetVigor( FMath::Clamp( GetVigor(), 0, 999.000000 ) ); + } if ( Data.EvaluatedData.Attribute == GetHealthAttribute() ) { SetHealth( FMath::Clamp( GetHealth(), 0, GetMaxHealth() ) ); @@ -65,12 +109,30 @@ void UGasaAttributeSet::PostGameplayEffectExecute( FGameplayEffectModCallbackDat { SetMaxMana( FMath::Clamp( GetMaxMana(), 0, 99999.000000 ) ); } + + PostAttributeChange_Custom(); } void UGasaAttributeSet::PreAttributeChange( FGameplayAttribute const& Attribute, float& NewValue ) { Super::PreAttributeChange( Attribute, NewValue ); + if ( Attribute == GetStrengthAttribute() ) + { + NewValue = FMath::Clamp( NewValue, 0, 999.000000 ); + } + if ( Attribute == GetIntelligenceAttribute() ) + { + NewValue = FMath::Clamp( NewValue, 0, 999.000000 ); + } + if ( Attribute == GetResilienceAttribute() ) + { + NewValue = FMath::Clamp( NewValue, 0, 999.000000 ); + } + if ( Attribute == GetVigorAttribute() ) + { + NewValue = FMath::Clamp( NewValue, 0, 999.000000 ); + } if ( Attribute == GetHealthAttribute() ) { NewValue = FMath::Clamp( NewValue, 0, GetMaxHealth() ); @@ -87,12 +149,18 @@ void UGasaAttributeSet::PreAttributeChange( FGameplayAttribute const& Attribute, { NewValue = FMath::Clamp( NewValue, 0, 99999.000000 ); } + + PreAttributeChange_Custom(); } void UGasaAttributeSet::GetLifetimeReplicatedProps( TArray& OutLifetimeProps ) const { Super::GetLifetimeReplicatedProps( OutLifetimeProps ); + DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Strength ); + DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Intelligence ); + DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Resilience ); + DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Vigor ); DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Health ); DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, MaxHealth ); DOREPLIFETIME_DEFAULT_GAS( UGasaAttributeSet, Mana ); diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h index 729b6e7..e12ead4 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet.h @@ -11,6 +11,19 @@ class GASA_API UGasaAttributeSet : public UAttributeSet public: UGasaAttributeSet(); + // Primary Attribute Fields + + UPROPERTY( ReplicatedUsing = Client_OnRep_Strength, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) + FGameplayAttributeData Strength; + UPROPERTY( ReplicatedUsing = Client_OnRep_Intelligence, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) + FGameplayAttributeData Intelligence; + UPROPERTY( ReplicatedUsing = Client_OnRep_Resilience, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) + FGameplayAttributeData Resilience; + UPROPERTY( ReplicatedUsing = Client_OnRep_Vigor, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) + FGameplayAttributeData Vigor; + + // Vital Attribute Fields + UPROPERTY( ReplicatedUsing = Client_OnRep_Health, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) FGameplayAttributeData Health; UPROPERTY( ReplicatedUsing = Client_OnRep_MaxHealth, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) @@ -20,6 +33,14 @@ public: UPROPERTY( ReplicatedUsing = Client_OnRep_MaxMana, EditAnywhere, BlueprintReadWrite, Category = "Attributes" ) FGameplayAttributeData MaxMana; + UFUNCTION() + void Client_OnRep_Strength( FGameplayAttributeData& PrevStrength ); + UFUNCTION() + void Client_OnRep_Intelligence( FGameplayAttributeData& PrevIntelligence ); + UFUNCTION() + void Client_OnRep_Resilience( FGameplayAttributeData& PrevResilience ); + UFUNCTION() + void Client_OnRep_Vigor( FGameplayAttributeData& PrevVigor ); UFUNCTION() void Client_OnRep_Health( FGameplayAttributeData& PrevHealth ); UFUNCTION() @@ -30,6 +51,26 @@ public: void Client_OnRep_MaxMana( FGameplayAttributeData& PrevMaxMana ); #pragma region Getters + static FGameplayAttribute GetStrengthAttribute() + { + static FProperty* Prop = FindFieldChecked( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Strength ) ); + return Prop; + } + static FGameplayAttribute GetIntelligenceAttribute() + { + static FProperty* Prop = FindFieldChecked( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Intelligence ) ); + return Prop; + } + static FGameplayAttribute GetResilienceAttribute() + { + static FProperty* Prop = FindFieldChecked( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Resilience ) ); + return Prop; + } + static FGameplayAttribute GetVigorAttribute() + { + static FProperty* Prop = FindFieldChecked( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Vigor ) ); + return Prop; + } static FGameplayAttribute GetHealthAttribute() { static FProperty* Prop = FindFieldChecked( UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED( UGasaAttributeSet, Health ) ); @@ -51,6 +92,10 @@ public: return Prop; } + FORCEINLINE float GetStrength() const { return Strength.GetCurrentValue(); } + FORCEINLINE float GetIntelligence() const { return Intelligence.GetCurrentValue(); } + FORCEINLINE float GetResilience() const { return Resilience.GetCurrentValue(); } + FORCEINLINE float GetVigor() const { return Vigor.GetCurrentValue(); } FORCEINLINE float GetHealth() const { return Health.GetCurrentValue(); } FORCEINLINE float GetMaxHealth() const { return MaxHealth.GetCurrentValue(); } FORCEINLINE float GetMana() const { return Mana.GetCurrentValue(); } @@ -59,11 +104,35 @@ public: #pragma region Setters FORCEINLINE void - SetHealth( float NewVal ); + SetStrength( float NewVal ); + FORCEINLINE void SetIntelligence( float NewVal ); + FORCEINLINE void SetResilience( float NewVal ); + FORCEINLINE void SetVigor( float NewVal ); + FORCEINLINE void SetHealth( float NewVal ); FORCEINLINE void SetMaxHealth( float NewVal ); FORCEINLINE void SetMana( float NewVal ); FORCEINLINE void SetMaxMana( float NewVal ); + FORCEINLINE void InitStrength( float NewVal ) + { + Strength.SetBaseValue( NewVal ); + Strength.SetCurrentValue( NewVal ); + } + FORCEINLINE void InitIntelligence( float NewVal ) + { + Intelligence.SetBaseValue( NewVal ); + Intelligence.SetCurrentValue( NewVal ); + } + FORCEINLINE void InitResilience( float NewVal ) + { + Resilience.SetBaseValue( NewVal ); + Resilience.SetCurrentValue( NewVal ); + } + FORCEINLINE void InitVigor( float NewVal ) + { + Vigor.SetBaseValue( NewVal ); + Vigor.SetCurrentValue( NewVal ); + } FORCEINLINE void InitHealth( float NewVal ) { Health.SetBaseValue( NewVal ); diff --git a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h index 3f49d74..0ceb739 100644 --- a/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h +++ b/Project/Source/Gasa/AbilitySystem/GasaAttributeSet_Inlines.h @@ -6,6 +6,42 @@ #pragma region Attribute Setters FORCEINLINE +void UGasaAttributeSet::SetStrength( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetStrengthAttribute(), NewVal ); + }; +} +FORCEINLINE +void UGasaAttributeSet::SetIntelligence( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetIntelligenceAttribute(), NewVal ); + }; +} +FORCEINLINE +void UGasaAttributeSet::SetResilience( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetResilienceAttribute(), NewVal ); + }; +} +FORCEINLINE +void UGasaAttributeSet::SetVigor( float NewVal ) +{ + UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); + if ( ensure( AbilityComp ) ) + { + AbilityComp->SetNumericAttributeBase( GetVigorAttribute(), NewVal ); + }; +} +FORCEINLINE void UGasaAttributeSet::SetHealth( float NewVal ) { UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent(); diff --git a/Project/Source/Gasa/Characters/GasaCharacter.cpp b/Project/Source/Gasa/Characters/GasaCharacter.cpp index d0cd676..508239c 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.cpp +++ b/Project/Source/Gasa/Characters/GasaCharacter.cpp @@ -64,6 +64,18 @@ AGasaCharacter::AGasaCharacter() ACharacter::SetReplicateMovement(true); } +#pragma region Ability System +void AGasaCharacter::InitDefaultAttributes() +{ + UAbilitySystemComponent* ASC = GetAbilitySystemComponent(); + ensure(ASC); + ensure(DefaultAttributes); + FGameplayEffectContextHandle Context = ASC->MakeEffectContext(); + FGameplayEffectSpecHandle Spec = ASC->MakeOutgoingSpec(DefaultAttributes, 1.0f, Context ); + ASC->ApplyGameplayEffectSpecToTarget( * Spec.Data, ASC ); +} +#pragma endregion Ability System + #pragma region GameFramework void AGasaCharacter::Controller_OnPawnPossessed() { @@ -186,6 +198,8 @@ void AGasaCharacter::BeginPlay() { AbilitySystem->InitAbilityActorInfo(this, this); Cast(AbilitySystem)->OnAbilityActorInfoSet(); + + InitDefaultAttributes(); } } @@ -233,3 +247,4 @@ void AGasaCharacter::Tick(float DeltaSeconds) } } #pragma endregion Actor + diff --git a/Project/Source/Gasa/Characters/GasaCharacter.h b/Project/Source/Gasa/Characters/GasaCharacter.h index 72f7d0a..7babd28 100644 --- a/Project/Source/Gasa/Characters/GasaCharacter.h +++ b/Project/Source/Gasa/Characters/GasaCharacter.h @@ -34,6 +34,11 @@ public: UPROPERTY(EditAnywhere, Category="Ability System") TObjectPtr Attributes; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Ability System") + TSubclassOf DefaultAttributes; + + void InitDefaultAttributes(); #pragma endregion Ability System #pragma region Combat diff --git a/Project/Source/GasaGen/GasaGen.cpp b/Project/Source/GasaGen/GasaGen.cpp index b20adc1..c8bafaa 100644 --- a/Project/Source/GasaGen/GasaGen.cpp +++ b/Project/Source/GasaGen/GasaGen.cpp @@ -88,7 +88,7 @@ int gen_main() // gen_netslime_interfaces(); // One offs - if (1) + if (0) { // ue_parse_testing(); swap_SBlueprintActionMenu_Construct(); diff --git a/Project/Source/GasaGen/GasaGen_HostWidgetController.cpp b/Project/Source/GasaGen/GasaGen_HostWidgetController.cpp index 872618e..e9e67db 100644 --- a/Project/Source/GasaGen/GasaGen_HostWidgetController.cpp +++ b/Project/Source/GasaGen/GasaGen_HostWidgetController.cpp @@ -9,7 +9,7 @@ void gen_UHostWidgetController() { - Array attribute_fields = get_gasa_attribute_fields(); + Array attribute_fields = get_gasa_vital_attribute_fields(); CodeBody ori_HostWidgetController_header = parse_file(path_gasa_ui "HostWidgetController.h"); { diff --git a/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp b/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp index 2c6ebad..e0400e4 100644 --- a/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp +++ b/Project/Source/GasaGen/GasaGen_UGasaAttributeSet.cpp @@ -1,4 +1,4 @@ -// Used in the GasaGen.cpp translation unit +// Used in the GasaGen.cpp translation unit #if GASA_INTELLISENSE_DIRECTIVES #pragma once #define GEN_EXPOSE_BACKEND @@ -10,6 +10,8 @@ struct GAS_AttributeEntry { StringCached Name; +// StringCached Description; +// StringCached Category; StringCached MinName; StringCached MaxName; float Min; @@ -25,12 +27,58 @@ void def_attribute_field_property_setter_inlines( CodeBody body, StrC class_name void def_attribute_field_initers ( CodeBody body, Array properties ); void impl_attribute_fields ( CodeBody body, StrC class_name, Array properties ); -Array get_gasa_attribute_fields() +Array get_gasa_primary_attribute_fields() +{ + local_persist + Array attribute_fields = Array::init_reserve(GlobalAllocator, 64); + + for (local_persist s32 do_once = 0; do_once == 0; ++ do_once) + { + StringCached str_Strength = get_cached_string(txt("Strength")); + StringCached str_Intelligence = get_cached_string(txt("Intelligence")); + StringCached str_Resilience = get_cached_string(txt("Resilience")); + StringCached str_Vigor = get_cached_string(txt("Vigor")); + + GAS_AttributeEntry Strength = { str_Strength, {nullptr}, {nullptr}, 0, 999.f }; + GAS_AttributeEntry Intelligence = { str_Intelligence, {nullptr}, {nullptr}, 0, 999.f }; + GAS_AttributeEntry Resilience = { str_Resilience, {nullptr}, {nullptr}, 0, 999.f }; + GAS_AttributeEntry Vigor = { str_Vigor, {nullptr}, {nullptr}, 0, 999.f }; + + attribute_fields.append(Strength); + attribute_fields.append(Intelligence); + attribute_fields.append(Resilience); + attribute_fields.append(Vigor); + } + return attribute_fields; +} + +Array get_gasa_secondary_attribute_fields() +{ + local_persist + Array attribute_fields = Array::init_reserve(GlobalAllocator, 64); + + for (local_persist s32 do_once = 0; do_once == 0; ++ do_once) + { +// StringCached str_Strength = get_cached_string(txt("Strength")); +// StringCached str_Intelligence = get_cached_string(txt("Intelligence")); +// StringCached str_Resilience = get_cached_string(txt("Resilience")); +// StringCached str_Vigor = get_cached_string(txt("Vigor")); +// +// GAS_AttributeEntry Health = { str_Health, {nullptr}, str_MaxHealth, 0, 100.f }; +// GAS_AttributeEntry MaxHealth = { str_MaxHealth, {nullptr}, {nullptr}, 0, 99999.f }; +// GAS_AttributeEntry Mana = { str_Mana, {nullptr}, str_MaxMana, 0, 50.f }; +// GAS_AttributeEntry MaxMana = { str_MaxMana, {nullptr}, {nullptr}, 0, 99999.f }; + } + return attribute_fields; +} + +Array get_gasa_vital_attribute_fields() { local_persist Array attribute_fields = Array::init_reserve(GlobalAllocator, 64); - for (local_persist s32 do_once = 0; do_once == 0; ++ do_once) { + for (local_persist s32 do_once = 0; do_once == 0; ++ do_once) + { StringCached str_Health = get_cached_string(txt("Health")); StringCached str_MaxHealth = get_cached_string(txt("MaxHealth")); StringCached str_Mana = get_cached_string(txt("Mana")); @@ -54,7 +102,17 @@ void gen_UGasaAttributeSet() CodeType type_UAttributeSet = def_type( txt("UAttributeSet") ); CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp")); - Array attribute_fields = get_gasa_attribute_fields(); + Array primary_attribute_fields = get_gasa_primary_attribute_fields(); + Array secondary_attribute_fields = get_gasa_secondary_attribute_fields(); + Array vital_attribute_fields = get_gasa_vital_attribute_fields(); + + s32 all_attrib_count = primary_attribute_fields.num() + secondary_attribute_fields.num() + vital_attribute_fields.num(); + + Array< GAS_AttributeEntry> + all_attribute_fields = Array::init_reserve(GlobalAllocator, all_attrib_count); + all_attribute_fields.append( primary_attribute_fields); + all_attribute_fields.append( secondary_attribute_fields); + all_attribute_fields.append( vital_attribute_fields); StrC class_name = txt("UGasaAttributeSet"); @@ -67,7 +125,7 @@ void gen_UGasaAttributeSet() CodeInclude Include_AttributeSet = def_include(txt("AttributeSet.h")); CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h")); - CodeAttributes api_attribute= def_attributes( UModule_GASA_API->Name); + CodeAttributes api_attribute = def_attributes( UModule_GASA_API->Name); CodeClass GasaAttributeSet = {}; { @@ -78,26 +136,51 @@ void gen_UGasaAttributeSet() body.append( def_constructor() ); body.append(fmt_newline); - - def_attribute_properties( body, attribute_fields); + + body.append( def_comment(txt("Primary Attribute Fields"))); body.append(fmt_newline); - def_attribute_field_on_reps( body, attribute_fields); + def_attribute_properties( body, primary_attribute_fields); + body.append(fmt_newline); + body.append(fmt_newline); + +// body.append( def_comment(txt("Secondary Attribute Fields"))); +// body.append(fmt_newline); +// def_attribute_properties( body, secondary_attribute_fields); +// body.append(fmt_newline); +// body.append(fmt_newline); + + body.append( def_comment(txt("Vital Attribute Fields"))); + body.append(fmt_newline); + def_attribute_properties( body, vital_attribute_fields); + + body.append(fmt_newline); + def_attribute_field_on_reps( body, primary_attribute_fields); + def_attribute_field_on_reps( body, secondary_attribute_fields); + def_attribute_field_on_reps( body, vital_attribute_fields); body.append(fmt_newline); body.append( fmt_newline ); body.append( def_pragma(txt( "region Getters" ))); - def_attribute_field_property_getters( body, class_name, attribute_fields ); + def_attribute_field_property_getters( body, class_name, primary_attribute_fields ); + def_attribute_field_property_getters( body, class_name, secondary_attribute_fields ); + def_attribute_field_property_getters( body, class_name, vital_attribute_fields ); body.append( fmt_newline ); - def_attribute_field_value_getters( body, attribute_fields ); + def_attribute_field_value_getters( body, primary_attribute_fields ); + def_attribute_field_value_getters( body, secondary_attribute_fields ); + def_attribute_field_value_getters( body, vital_attribute_fields ); body.append( def_pragma(txt( "endregion Getters" ))); body.append( fmt_newline ); body.append( def_pragma(txt( "region Setters" ))); - def_attribute_field_value_setters( body, attribute_fields ); + def_attribute_field_value_setters( body, primary_attribute_fields ); + def_attribute_field_value_setters( body, secondary_attribute_fields ); + def_attribute_field_value_setters( body, vital_attribute_fields ); body.append( fmt_newline ); body.append( fmt_newline ); - def_attribute_field_initers( body, attribute_fields ); + def_attribute_field_initers( body, primary_attribute_fields ); + def_attribute_field_initers( body, secondary_attribute_fields ); + def_attribute_field_initers( body, vital_attribute_fields ); body.append( def_pragma(txt( "endregion Setters" ))); body.append( fmt_newline ); @@ -143,7 +226,7 @@ void gen_UGasaAttributeSet() CodeBody body = def_body(CodeT::Global_Body); { - def_attribute_field_property_setter_inlines( body, class_name, attribute_fields ); + def_attribute_field_property_setter_inlines( body, class_name, all_attribute_fields ); } inlines.print(body); inlines.print(fmt_newline); @@ -191,7 +274,7 @@ void gen_UGasaAttributeSet() )); body.append(constructor_for_UGasaAttributeSet ); - impl_attribute_fields( body, class_name, attribute_fields); + impl_attribute_fields( body, class_name, all_attribute_fields); CodeFn PostGameplayEffectExecute; CodeFn PreAttributeChange; @@ -204,7 +287,7 @@ void gen_UGasaAttributeSet() post_attribute_clamps.append(fmt_newline); post_attribute_clamps.append(fmt_newline); - for (GAS_AttributeEntry field : attribute_fields) + for (GAS_AttributeEntry field : all_attribute_fields) { String clamp_min; if (field.MinName.Data) @@ -222,44 +305,51 @@ void gen_UGasaAttributeSet() "field", (StrC)field.Name, "clamp_min", (StrC)clamp_min, "clamp_max", (StrC)clamp_max, - stringize( - if (Attribute == GetAttribute()) - { - NewValue = FMath::Clamp(NewValue, , ); - } + stringize( + if (Attribute == GetAttribute()) + { + NewValue = FMath::Clamp(NewValue, , ); + } ))); post_attribute_clamps.append( code_fmt( "field", (StrC)field.Name, "clamp_min", (StrC)clamp_min, "clamp_max", (StrC)clamp_max, - stringize( - if ( Data.EvaluatedData.Attribute == GetAttribute() ) - { - Set(FMath::Clamp(Get(), , )); - } + stringize( + if ( Data.EvaluatedData.Attribute == GetAttribute() ) + { + Set(FMath::Clamp(Get(), , )); + } ))); } pre_attribute_clamps.append(fmt_newline); pre_attribute_clamps.append(fmt_newline); + post_attribute_clamps.append(fmt_newline); + post_attribute_clamps.append(fmt_newline); + PreAttributeChange = parse_function( token_fmt( "attribute_clamps", (StrC)pre_attribute_clamps.to_string(), stringize( void UGasaAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) { Super::PreAttributeChange(Attribute, NewValue); + + + PreAttributeChange_Custom(); } ))); - post_attribute_clamps.append(fmt_newline); - post_attribute_clamps.append(fmt_newline); PostGameplayEffectExecute = parse_function( token_fmt( "attribute_clamps", (StrC)post_attribute_clamps.to_string(), stringize( void UGasaAttributeSet::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data) { Super::PostGameplayEffectExecute(Data); FEffectProperties Props; Props.Populate(Data); + + + PostAttributeChange_Custom(); } ))); } @@ -274,7 +364,7 @@ void gen_UGasaAttributeSet() CodeBody field_lifetimes = def_body( CodeT::Function_Body); field_lifetimes.append(fmt_newline); field_lifetimes.append(fmt_newline); - for (GAS_AttributeEntry field : attribute_fields) + for (GAS_AttributeEntry field : all_attribute_fields) { field_lifetimes.append( code_fmt( "field", (StrC)field.Name, stringize( DOREPLIFETIME_DEFAULT_GAS(UGasaAttributeSet, ); diff --git a/Project/Source/GasaGen/gen.dep.hpp b/Project/Source/GasaGen/gen.dep.hpp index cf2d6d5..d4238a5 100644 --- a/Project/Source/GasaGen/gen.dep.hpp +++ b/Project/Source/GasaGen/gen.dep.hpp @@ -1557,6 +1557,11 @@ struct Array { return 2 * value + 8; } + + bool append( Array other ) + { + return append( other, other.num() ); + } bool append( Type value ) {