2024-10-21 13:10:56 -07:00
|
|
|
// Used in the GasaGen.cpp translation unit
|
2024-04-21 06:51:51 -07:00
|
|
|
#if GASA_INTELLISENSE_DIRECTIVES
|
|
|
|
#pragma once
|
|
|
|
#define GEN_EXPOSE_BACKEND
|
|
|
|
#include "gen.hpp"
|
|
|
|
#include "gen.builder.hpp"
|
|
|
|
#include "GasaGenCommon.cpp"
|
|
|
|
#endif
|
2024-04-14 18:51:14 -07:00
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
struct GAS_AttributeEntry
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
StrCached Name;
|
2024-10-21 13:10:56 -07:00
|
|
|
// StringCached Description;
|
|
|
|
// StringCached Category;
|
2024-12-14 05:46:22 -08:00
|
|
|
StrCached MinName;
|
|
|
|
StrCached MaxName;
|
2024-04-24 15:18:26 -07:00
|
|
|
float Min;
|
|
|
|
float Max;
|
|
|
|
};
|
|
|
|
|
|
|
|
void def_attribute_properties ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
|
|
|
void def_attribute_field_on_reps ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
2024-12-14 05:46:22 -08:00
|
|
|
void def_attribute_field_property_getters ( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties );
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_field_value_getters ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
|
|
|
void def_attribute_field_value_setters ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
2024-12-14 05:46:22 -08:00
|
|
|
void def_attribute_field_property_setter_inlines( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties );
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_field_initers ( CodeBody body, Array<GAS_AttributeEntry> properties );
|
2024-12-14 05:46:22 -08:00
|
|
|
void impl_attribute_fields ( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties );
|
2024-04-24 15:18:26 -07:00
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
Array<GAS_AttributeEntry> get_gasa_primary_attribute_fields()
|
|
|
|
{
|
|
|
|
local_persist
|
2024-12-14 05:46:22 -08:00
|
|
|
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, 64);
|
2024-10-21 13:10:56 -07:00
|
|
|
|
|
|
|
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
StrCached str_Strength = cache_str(txt("Strength"));
|
|
|
|
StrCached str_Intelligence = cache_str(txt("Intelligence"));
|
|
|
|
StrCached str_Resilience = cache_str(txt("Resilience"));
|
|
|
|
StrCached str_Vigor = cache_str(txt("Vigor"));
|
2024-10-21 13:10:56 -07:00
|
|
|
|
|
|
|
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<GAS_AttributeEntry> get_gasa_secondary_attribute_fields()
|
|
|
|
{
|
|
|
|
local_persist
|
2024-12-14 05:46:22 -08:00
|
|
|
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, 64);
|
2024-10-21 13:10:56 -07:00
|
|
|
|
|
|
|
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
// StrCached str_Strength = cache_str(txt("Strength"));
|
|
|
|
// StrCached str_Intelligence = cache_str(txt("Intelligence"));
|
|
|
|
// StrCached str_Resilience = cache_str(txt("Resilience"));
|
|
|
|
// StrCached str_Vigor = cache_str(txt("Vigor"));
|
2024-10-21 13:10:56 -07:00
|
|
|
//
|
|
|
|
// 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<GAS_AttributeEntry> get_gasa_vital_attribute_fields()
|
2024-04-21 21:30:29 -07:00
|
|
|
{
|
|
|
|
local_persist
|
2024-12-14 05:46:22 -08:00
|
|
|
Array<GAS_AttributeEntry> attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, 64);
|
2024-04-21 21:30:29 -07:00
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
for (local_persist s32 do_once = 0; do_once == 0; ++ do_once)
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
StrCached str_Health = cache_str(txt("Health"));
|
|
|
|
StrCached str_MaxHealth = cache_str(txt("MaxHealth"));
|
|
|
|
StrCached str_Mana = cache_str(txt("Mana"));
|
|
|
|
StrCached str_MaxMana = cache_str(txt("MaxMana"));
|
2024-04-24 15:18:26 -07:00
|
|
|
|
|
|
|
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 };
|
|
|
|
|
|
|
|
attribute_fields.append(Health);
|
|
|
|
attribute_fields.append(MaxHealth);
|
|
|
|
attribute_fields.append(Mana);
|
|
|
|
attribute_fields.append(MaxMana);
|
2024-04-21 21:30:29 -07:00
|
|
|
}
|
|
|
|
return attribute_fields;
|
|
|
|
}
|
|
|
|
|
2024-04-14 18:51:14 -07:00
|
|
|
void gen_UGasaAttributeSet()
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeTypename type_UAttributeSet = def_type( txt("UAttributeSet") );
|
|
|
|
CodeComment generation_notice = def_comment(txt("Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp"));
|
2024-04-14 18:51:14 -07:00
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
Array<GAS_AttributeEntry> primary_attribute_fields = get_gasa_primary_attribute_fields();
|
|
|
|
Array<GAS_AttributeEntry> secondary_attribute_fields = get_gasa_secondary_attribute_fields();
|
|
|
|
Array<GAS_AttributeEntry> vital_attribute_fields = get_gasa_vital_attribute_fields();
|
2024-10-22 10:07:50 -07:00
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
s32 all_attrib_count = primary_attribute_fields.num() + secondary_attribute_fields.num() + vital_attribute_fields.num();
|
2024-10-22 10:07:50 -07:00
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
Array< GAS_AttributeEntry>
|
2024-12-14 05:46:22 -08:00
|
|
|
all_attribute_fields = Array<GAS_AttributeEntry>::init_reserve(ctx.Allocator_Temp, all_attrib_count);
|
2024-10-21 13:10:56 -07:00
|
|
|
all_attribute_fields.append( primary_attribute_fields);
|
|
|
|
all_attribute_fields.append( secondary_attribute_fields);
|
|
|
|
all_attribute_fields.append( vital_attribute_fields);
|
2024-04-14 18:51:14 -07:00
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
Str class_name = txt("UGasaAttributeSet");
|
2024-04-14 18:51:14 -07:00
|
|
|
|
|
|
|
Builder header = Builder::open( path_gasa_ability_system "GasaAttributeSet.h");
|
|
|
|
{
|
|
|
|
header.print(generation_notice);
|
2024-04-21 15:56:57 -07:00
|
|
|
header.print(pragma_once);
|
2024-04-14 18:51:14 -07:00
|
|
|
header.print(fmt_newline);
|
|
|
|
{
|
|
|
|
CodeInclude Include_AttributeSet = def_include(txt("AttributeSet.h"));
|
|
|
|
CodeInclude Include_GasaAttributeSet_Generated = def_include(txt("GasaAttributeSet.generated.h"));
|
2024-10-22 10:07:50 -07:00
|
|
|
header.print( Include_AttributeSet);
|
|
|
|
header.print( Include_GasaAttributeSet_Generated);
|
|
|
|
header.print( fmt_newline);
|
2024-04-14 18:51:14 -07:00
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
CodeAttributes api_attribute = def_attributes( UModule_GASA_API->Name);
|
2024-04-14 18:51:14 -07:00
|
|
|
|
|
|
|
CodeClass GasaAttributeSet = {};
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeBody body = def_body( CT_Class_Body );
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-21 06:51:51 -07:00
|
|
|
body.append( UHT_GENERATED_BODY);
|
2024-04-14 18:51:14 -07:00
|
|
|
body.append( access_public );
|
|
|
|
|
|
|
|
body.append( def_constructor() );
|
2024-04-21 06:51:51 -07:00
|
|
|
body.append(fmt_newline);
|
2024-10-21 13:10:56 -07:00
|
|
|
|
|
|
|
body.append( def_comment(txt("Primary Attribute Fields")));
|
|
|
|
body.append(fmt_newline);
|
|
|
|
def_attribute_properties( body, primary_attribute_fields);
|
|
|
|
body.append(fmt_newline);
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append(fmt_newline);
|
2024-10-21 13:10:56 -07:00
|
|
|
|
|
|
|
// body.append( def_comment(txt("Secondary Attribute Fields")));
|
2024-10-22 10:07:50 -07:00
|
|
|
// body.append(fmt_newline);sssss// def_attribute_properties( body, secondary_attribute_fields);
|
2024-10-21 13:10:56 -07:00
|
|
|
// 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);
|
2024-04-14 18:51:14 -07:00
|
|
|
|
|
|
|
body.append(fmt_newline);
|
|
|
|
|
|
|
|
body.append( fmt_newline );
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append( def_pragma(txt( "region Getters" )));
|
2024-10-21 13:10:56 -07:00
|
|
|
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 );
|
2024-04-21 15:56:57 -07:00
|
|
|
body.append( fmt_newline );
|
2024-10-21 13:10:56 -07:00
|
|
|
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 );
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append( def_pragma(txt( "endregion Getters" )));
|
2024-04-14 18:51:14 -07:00
|
|
|
body.append( fmt_newline );
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append( def_pragma(txt( "region Setters" )));
|
2024-10-21 13:10:56 -07:00
|
|
|
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 );
|
2024-04-21 15:56:57 -07:00
|
|
|
body.append( fmt_newline );
|
|
|
|
body.append( fmt_newline );
|
2024-10-21 13:10:56 -07:00
|
|
|
def_attribute_field_initers( body, primary_attribute_fields );
|
|
|
|
def_attribute_field_initers( body, secondary_attribute_fields );
|
|
|
|
def_attribute_field_initers( body, vital_attribute_fields );
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append( def_pragma(txt( "endregion Setters" )));
|
2024-04-14 18:51:14 -07:00
|
|
|
body.append( fmt_newline );
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append( def_pragma( txt("region AttributeSet")));
|
|
|
|
body.append( code_str(
|
|
|
|
void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override;
|
2024-04-24 17:18:38 -07:00
|
|
|
void PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data) override;
|
2024-04-24 15:18:26 -07:00
|
|
|
));
|
|
|
|
body.append( def_pragma( txt("endregion AttributeSet")));
|
|
|
|
body.append(fmt_newline);
|
|
|
|
|
2024-04-14 18:51:14 -07:00
|
|
|
body.append( def_pragma( txt("region UObject")));
|
2024-04-16 14:18:06 -07:00
|
|
|
CodeFn GetLifetimeOfReplicatedProps = parse_function( code(
|
2024-04-14 18:51:14 -07:00
|
|
|
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
2024-04-16 14:18:06 -07:00
|
|
|
));
|
|
|
|
body.append( GetLifetimeOfReplicatedProps );
|
2024-04-14 18:51:14 -07:00
|
|
|
body.append( def_pragma( txt("endregion UObject")));
|
|
|
|
}
|
2024-12-14 05:46:22 -08:00
|
|
|
GasaAttributeSet = def_class( class_name, { body
|
|
|
|
, type_UAttributeSet, AccessSpec_Public
|
|
|
|
, api_attribute }
|
2024-04-14 18:51:14 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-04-21 06:51:51 -07:00
|
|
|
header.print( UHT_UCLASS );
|
2024-04-14 18:51:14 -07:00
|
|
|
header.print(GasaAttributeSet);
|
|
|
|
}
|
|
|
|
header.write();
|
2024-04-21 06:51:51 -07:00
|
|
|
format_file(path_gasa_ability_system "GasaAttributeSet.h");
|
2024-04-14 18:51:14 -07:00
|
|
|
}
|
|
|
|
|
2024-04-21 15:56:57 -07:00
|
|
|
Builder inlines = Builder::open( path_gasa_ability_system "GasaAttributeSet_Inlines.h");
|
|
|
|
{
|
|
|
|
inlines.print(generation_notice);
|
|
|
|
inlines.print(pragma_once);
|
|
|
|
inlines.print(fmt_newline);
|
|
|
|
inlines.print( def_include( txt("GasaAttributeSet.h")));
|
|
|
|
inlines.print( def_include(txt("AbilitySystemComponent.h")));
|
|
|
|
inlines.print(fmt_newline);
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeBody body = def_body(CT_Global_Body);
|
2024-04-21 15:56:57 -07:00
|
|
|
{
|
2024-10-21 13:10:56 -07:00
|
|
|
def_attribute_field_property_setter_inlines( body, class_name, all_attribute_fields );
|
2024-04-21 15:56:57 -07:00
|
|
|
}
|
|
|
|
inlines.print(body);
|
|
|
|
inlines.print(fmt_newline);
|
|
|
|
|
|
|
|
CodeNS ns_gasa = parse_namespace( code(
|
|
|
|
namespace Gasa
|
|
|
|
{
|
|
|
|
inline
|
|
|
|
UGasaAttributeSet const* GetAttributeSet( UAbilitySystemComponent* ASC )
|
|
|
|
{
|
|
|
|
return Cast<UGasaAttributeSet>(ASC->GetAttributeSet( UGasaAttributeSet::StaticClass() ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
));
|
|
|
|
|
|
|
|
inlines.print(ns_gasa);
|
|
|
|
inlines.write();
|
|
|
|
format_file(path_gasa_ability_system "GasaAttributeSet_Inlines.h");
|
|
|
|
}
|
|
|
|
|
2024-04-14 18:51:14 -07:00
|
|
|
Builder source = Builder::open( path_gasa_ability_system "GasaAttributeSet.cpp" );
|
|
|
|
{
|
|
|
|
source.print(generation_notice);
|
|
|
|
header.print(fmt_newline);
|
|
|
|
source.print( def_include( txt("GasaAttributeSet.h")));
|
2024-04-21 15:56:57 -07:00
|
|
|
source.print( def_include( txt("GasaAttributeSet_Inlines.h")));
|
2024-04-24 17:18:38 -07:00
|
|
|
source.print( def_include( txt("EffectProperties.h")));
|
2024-04-14 18:51:14 -07:00
|
|
|
source.print(fmt_newline);
|
|
|
|
source.print( def_include( txt("AbilitySystemComponent.h")));
|
|
|
|
source.print( def_include( txt("Net/UnrealNetwork.h")));
|
|
|
|
source.print( def_include( txt("Networking/GasaNetLibrary.h")));
|
2024-10-19 19:34:51 -07:00
|
|
|
source.print( def_include( txt("GameplayEffectExtension.h")));
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeBody body = def_body( CT_Global_Body );
|
2024-04-14 18:51:14 -07:00
|
|
|
body.append(fmt_newline);
|
|
|
|
|
|
|
|
CodeConstructor constructor_for_UGasaAttributeSet = parse_constructor( code(
|
|
|
|
UGasaAttributeSet::UGasaAttributeSet()
|
|
|
|
{
|
|
|
|
InitHealth( 100.f );
|
|
|
|
InitMaxHealth( 100.f );
|
2024-04-15 20:09:46 -07:00
|
|
|
InitMana( 50.f );
|
2024-04-14 18:51:14 -07:00
|
|
|
InitMaxMana( 50.f );
|
|
|
|
}
|
|
|
|
));
|
|
|
|
body.append(constructor_for_UGasaAttributeSet );
|
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
impl_attribute_fields( body, class_name, all_attribute_fields);
|
2024-04-14 18:51:14 -07:00
|
|
|
|
2024-10-19 19:34:51 -07:00
|
|
|
CodeFn PostGameplayEffectExecute;
|
2024-04-24 15:18:26 -07:00
|
|
|
CodeFn PreAttributeChange;
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeBody pre_attribute_clamps = def_body( CT_Function_Body );
|
2024-10-19 19:34:51 -07:00
|
|
|
pre_attribute_clamps.append(fmt_newline);
|
|
|
|
pre_attribute_clamps.append(fmt_newline);
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeBody post_attribute_clamps = def_body( CT_Function_Body );
|
2024-10-19 19:34:51 -07:00
|
|
|
post_attribute_clamps.append(fmt_newline);
|
|
|
|
post_attribute_clamps.append(fmt_newline);
|
|
|
|
|
2024-10-21 13:10:56 -07:00
|
|
|
for (GAS_AttributeEntry field : all_attribute_fields)
|
2024-04-24 15:18:26 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
Str clamp_min;
|
|
|
|
if (field.MinName)
|
|
|
|
clamp_min = cache_str(token_fmt( "MinName", field.MinName, "Get<MinName>()"));
|
2024-04-24 15:18:26 -07:00
|
|
|
else
|
2024-12-14 05:46:22 -08:00
|
|
|
clamp_min = StrBuilder::fmt_buf(ctx.Allocator_Temp, "%f", field.Min).to_str();
|
2024-04-24 15:18:26 -07:00
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
Str clamp_max;
|
|
|
|
if (field.MaxName)
|
|
|
|
clamp_max = cache_str(token_fmt( "MaxName", field.MaxName, "Get<MaxName>()"));
|
2024-04-24 15:18:26 -07:00
|
|
|
else
|
2024-12-14 05:46:22 -08:00
|
|
|
clamp_max = StrBuilder::fmt_buf(ctx.Allocator_Temp, "%f", field.Max).to_str();
|
2024-04-24 15:18:26 -07:00
|
|
|
|
2024-10-19 19:34:51 -07:00
|
|
|
pre_attribute_clamps.append( code_fmt(
|
2024-12-14 05:46:22 -08:00
|
|
|
"field", field.Name,
|
|
|
|
"clamp_min", clamp_min,
|
|
|
|
"clamp_max", clamp_max,
|
2024-10-21 13:10:56 -07:00
|
|
|
stringize(
|
|
|
|
if (Attribute == Get<field>Attribute())
|
|
|
|
{
|
|
|
|
NewValue = FMath::Clamp(NewValue, <clamp_min>, <clamp_max>);
|
|
|
|
}
|
2024-04-24 15:18:26 -07:00
|
|
|
)));
|
2024-10-19 19:34:51 -07:00
|
|
|
|
|
|
|
post_attribute_clamps.append( code_fmt(
|
2024-12-14 05:46:22 -08:00
|
|
|
"field", field.Name,
|
|
|
|
"clamp_min", clamp_min,
|
|
|
|
"clamp_max", clamp_max,
|
2024-10-21 13:10:56 -07:00
|
|
|
stringize(
|
|
|
|
if ( Data.EvaluatedData.Attribute == Get<field>Attribute() )
|
|
|
|
{
|
|
|
|
Set<field>(FMath::Clamp(Get<field>(), <clamp_min>, <clamp_max> ));
|
|
|
|
}
|
2024-10-19 19:34:51 -07:00
|
|
|
)));
|
2024-04-24 15:18:26 -07:00
|
|
|
}
|
2024-10-19 19:34:51 -07:00
|
|
|
|
|
|
|
pre_attribute_clamps.append(fmt_newline);
|
|
|
|
pre_attribute_clamps.append(fmt_newline);
|
2024-10-21 13:10:56 -07:00
|
|
|
post_attribute_clamps.append(fmt_newline);
|
|
|
|
post_attribute_clamps.append(fmt_newline);
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
PreAttributeChange = parse_function( token_fmt( "attribute_clamps", (Str)pre_attribute_clamps.to_strbuilder(), stringize(
|
2024-04-24 15:18:26 -07:00
|
|
|
void UGasaAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
|
|
|
|
{
|
|
|
|
Super::PreAttributeChange(Attribute, NewValue);
|
2024-10-21 13:10:56 -07:00
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
<attribute_clamps>
|
|
|
|
}
|
|
|
|
)));
|
2024-10-19 19:34:51 -07:00
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
PostGameplayEffectExecute = parse_function( token_fmt( "attribute_clamps", (Str)post_attribute_clamps.to_strbuilder(), stringize(
|
2024-10-19 19:34:51 -07:00
|
|
|
void UGasaAttributeSet::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
|
|
|
{
|
|
|
|
Super::PostGameplayEffectExecute(Data);
|
|
|
|
FEffectProperties Props;
|
|
|
|
Props.Populate(Data);
|
2024-10-21 13:10:56 -07:00
|
|
|
|
2024-10-19 19:34:51 -07:00
|
|
|
<attribute_clamps>
|
|
|
|
}
|
|
|
|
)));
|
2024-04-24 15:18:26 -07:00
|
|
|
}
|
2024-10-19 19:34:51 -07:00
|
|
|
body.append(PostGameplayEffectExecute);
|
|
|
|
body.append(fmt_newline);
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append(PreAttributeChange);
|
2024-04-24 17:18:38 -07:00
|
|
|
body.append(fmt_newline);
|
2024-04-24 15:18:26 -07:00
|
|
|
|
2024-04-14 18:51:14 -07:00
|
|
|
CodeFn GetLifetimeOfReplicatedProps;
|
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
CodeBody field_lifetimes = def_body( CT_Function_Body);
|
2024-04-21 06:51:51 -07:00
|
|
|
field_lifetimes.append(fmt_newline);
|
|
|
|
field_lifetimes.append(fmt_newline);
|
2024-10-21 13:10:56 -07:00
|
|
|
for (GAS_AttributeEntry field : all_attribute_fields)
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
field_lifetimes.append( code_fmt( "field", field.Name, stringize(
|
2024-04-14 18:51:14 -07:00
|
|
|
DOREPLIFETIME_DEFAULT_GAS(UGasaAttributeSet, <field>);
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
GetLifetimeOfReplicatedProps = parse_function( token_fmt( "field_lifetimes", (Str)(field_lifetimes.to_strbuilder()), stringize(
|
2024-04-14 18:51:14 -07:00
|
|
|
void UGasaAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
|
|
|
{
|
|
|
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
2024-04-17 09:16:22 -07:00
|
|
|
<field_lifetimes>
|
2024-04-14 18:51:14 -07:00
|
|
|
}
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
body.append(GetLifetimeOfReplicatedProps);
|
|
|
|
|
|
|
|
source.print(body);
|
|
|
|
}
|
|
|
|
source.write();
|
2024-04-21 06:51:51 -07:00
|
|
|
format_file(path_gasa_ability_system "GasaAttributeSet.cpp");
|
2024-04-14 18:51:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_properties( CodeBody body, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
Code field_uproperty = code_fmt( "property", property.Name, stringize(
|
2024-04-14 18:51:14 -07:00
|
|
|
UPROPERTY(ReplicatedUsing=Client_OnRep_<property>, EditAnywhere, BlueprintReadWrite, Category="Attributes")
|
2024-04-24 15:18:26 -07:00
|
|
|
FGameplayAttributeData <property>;
|
2024-04-14 18:51:14 -07:00
|
|
|
));
|
2024-04-24 15:18:26 -07:00
|
|
|
body.append(field_uproperty);
|
2024-04-14 18:51:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_field_on_reps( CodeBody body, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
|
|
|
Code umeta_UFUNCTION = code_str( UFUNCTION() );
|
|
|
|
|
|
|
|
body.append(fmt_newline);
|
|
|
|
body.append( umeta_UFUNCTION );
|
|
|
|
body.append(fmt_newline);
|
2024-12-14 05:46:22 -08:00
|
|
|
body.append( code_fmt( "property", property.Name, stringize(
|
2024-04-14 18:51:14 -07:00
|
|
|
void Client_OnRep_<property>(FGameplayAttributeData& Prev<property>);
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
void def_attribute_field_property_getters( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
|
|
|
CodeFn generated_get_attribute = parse_function(
|
2024-12-14 05:46:22 -08:00
|
|
|
token_fmt( "class_name", class_name, "property", property.Name,
|
2024-04-14 18:51:14 -07:00
|
|
|
stringize(
|
|
|
|
static FGameplayAttribute Get<property>Attribute()
|
|
|
|
{
|
|
|
|
static FProperty* Prop = FindFieldChecked<FProperty>(<class_name>::StaticClass(), GET_MEMBER_NAME_CHECKED(<class_name>, <property>));
|
|
|
|
return Prop;
|
|
|
|
}
|
|
|
|
)));
|
|
|
|
body.append( generated_get_attribute );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-21 06:51:51 -07:00
|
|
|
#pragma push_macro("FORCEINLINE")
|
|
|
|
#undef FORCEINLINE
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_field_value_getters( CodeBody body, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
body.append( code_fmt( "property", property.Name,
|
2024-04-14 18:51:14 -07:00
|
|
|
stringize(
|
|
|
|
FORCEINLINE float Get<property>() const
|
|
|
|
{
|
|
|
|
return <property>.GetCurrentValue();
|
|
|
|
}
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_field_value_setters( CodeBody body, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
body.append( code_fmt( "property", property.Name,
|
2024-04-14 18:51:14 -07:00
|
|
|
stringize(
|
2024-04-21 15:56:57 -07:00
|
|
|
FORCEINLINE void Set<property>(float NewVal);
|
2024-04-14 18:51:14 -07:00
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
void def_attribute_field_property_setter_inlines( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties )
|
2024-04-21 15:56:57 -07:00
|
|
|
{
|
2024-04-22 22:10:02 -07:00
|
|
|
body.append(def_pragma( txt("region Attribute Setters")));
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-21 15:56:57 -07:00
|
|
|
{
|
|
|
|
CodeFn generated_get_attribute = parse_function(
|
2024-12-14 05:46:22 -08:00
|
|
|
token_fmt( "class_name", class_name, "property", property.Name,
|
2024-04-21 15:56:57 -07:00
|
|
|
stringize(
|
|
|
|
FORCEINLINE void <class_name>::Set<property>(float NewVal)
|
|
|
|
{
|
|
|
|
UAbilitySystemComponent* AbilityComp = GetOwningAbilitySystemComponent();
|
|
|
|
if (ensure(AbilityComp))
|
|
|
|
{
|
|
|
|
AbilityComp->SetNumericAttributeBase(Get<property>Attribute(), NewVal);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
)));
|
|
|
|
body.append( generated_get_attribute );
|
|
|
|
}
|
2024-04-22 22:10:02 -07:00
|
|
|
body.append(def_pragma( txt("endregion Attribute Setters")));
|
2024-04-21 15:56:57 -07:00
|
|
|
}
|
|
|
|
|
2024-04-24 15:18:26 -07:00
|
|
|
void def_attribute_field_initers ( CodeBody body, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-12-14 05:46:22 -08:00
|
|
|
body.append( code_fmt( "property", property.Name,
|
2024-04-14 18:51:14 -07:00
|
|
|
stringize(
|
|
|
|
FORCEINLINE void Init<property>(float NewVal)
|
|
|
|
{
|
|
|
|
<property>.SetBaseValue(NewVal);
|
|
|
|
<property>.SetCurrentValue(NewVal);
|
|
|
|
}
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-14 05:46:22 -08:00
|
|
|
void impl_attribute_fields( CodeBody body, Str class_name, Array<GAS_AttributeEntry> properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-22 22:10:02 -07:00
|
|
|
body.append(fmt_newline);
|
2024-04-22 09:01:30 -07:00
|
|
|
body.append(def_pragma( txt("region Rep Notifies")));
|
2024-04-24 15:18:26 -07:00
|
|
|
for ( GAS_AttributeEntry property : properties )
|
2024-04-14 18:51:14 -07:00
|
|
|
{
|
2024-04-22 09:01:30 -07:00
|
|
|
CodeFn field_impl = parse_function( token_fmt(
|
2024-12-14 05:46:22 -08:00
|
|
|
"class_name", class_name, "property", property.Name, "from_notice", txt("\n// From GAMEPLAYATTRIBUTE_REPNOTIFY\n"),
|
2024-04-14 18:51:14 -07:00
|
|
|
stringize(
|
|
|
|
void <class_name>::Client_OnRep_<property>(FGameplayAttributeData& Prev<property>)
|
|
|
|
{
|
2024-04-22 09:01:30 -07:00
|
|
|
<from_notice>
|
|
|
|
static FProperty* <class_name>Property = FindFieldChecked<FProperty>( StaticClass(), GET_MEMBER_NAME_CHECKED(<class_name>, <property>));
|
|
|
|
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication(FGameplayAttribute(<class_name>Property), <property>, Prev<property>);
|
2024-04-14 18:51:14 -07:00
|
|
|
}
|
|
|
|
)));
|
|
|
|
|
|
|
|
body.append( field_impl );
|
|
|
|
}
|
2024-04-22 09:01:30 -07:00
|
|
|
body.append( def_pragma( txt("endregion Rep Notifies")));
|
2024-04-22 22:10:02 -07:00
|
|
|
body.append(fmt_newline);
|
2024-04-22 09:01:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2024-12-14 05:46:22 -08:00
|
|
|
Code gen_GAMEPLAYATTRIBUTE_REPNOTIFY(Str class_name, Str property_name, Str old_value)
|
2024-04-22 09:01:30 -07:00
|
|
|
{
|
|
|
|
Code rep_notify = code_fmt(
|
|
|
|
"class_name", class_name
|
|
|
|
, "property_name", property_name
|
|
|
|
, "old_value", old_value,
|
|
|
|
stringize(
|
|
|
|
static FProperty* <class_name>Property = FindFieldChecked<FProperty>(<class_name>::StaticClass(), GET_MEMBER_NAME_CHECKED(<class_name>, <property_name>));
|
|
|
|
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication(FGameplayAttribute(<class_name>Property), <property_name>, <old_value>);
|
|
|
|
));
|
2024-04-14 18:51:14 -07:00
|
|
|
}
|
2024-04-21 06:51:51 -07:00
|
|
|
#pragma pop_macro("FORCEINLINE")
|