66. Initialize Attributes with Gameplay Effects
This commit is contained in:
parent
7f7a041978
commit
f1a4a44c8d
BIN
Project/Binaries/Win64/UnrealEditor-GasaEditor.dll
(Stored with Git LFS)
BIN
Project/Binaries/Win64/UnrealEditor-GasaEditor.dll
(Stored with Git LFS)
Binary file not shown.
@ -5,6 +5,7 @@
|
|||||||
"Description": 135,
|
"Description": 135,
|
||||||
"Category": 96,
|
"Category": 96,
|
||||||
"BaseValue": 106,
|
"BaseValue": 106,
|
||||||
"Name": 82
|
"Name": 82,
|
||||||
|
"MinAttribute": 327
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -103,6 +103,8 @@ void UGasaAttributeSet::PostGameplayEffectExecute( FGameplayEffectModCallbackDat
|
|||||||
{
|
{
|
||||||
SetMaxMana( FMath::Clamp( GetMaxMana(), 0, 99999.000000 ) );
|
SetMaxMana( FMath::Clamp( GetMaxMana(), 0, 99999.000000 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Props.Populate( Data );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UGasaAttributeSet::PreAttributeChange( FGameplayAttribute const& Attribute, float& NewValue )
|
void UGasaAttributeSet::PreAttributeChange( FGameplayAttribute const& Attribute, float& NewValue )
|
||||||
|
@ -115,47 +115,6 @@ public:
|
|||||||
FORCEINLINE void SetVigor( float NewVal );
|
FORCEINLINE void SetVigor( float NewVal );
|
||||||
FORCEINLINE void SetMaxHealth( float NewVal );
|
FORCEINLINE void SetMaxHealth( float NewVal );
|
||||||
FORCEINLINE void SetMaxMana( float NewVal );
|
FORCEINLINE void SetMaxMana( float NewVal );
|
||||||
|
|
||||||
FORCEINLINE void InitHealth( float NewVal )
|
|
||||||
{
|
|
||||||
Health.SetBaseValue( NewVal );
|
|
||||||
Health.SetCurrentValue( NewVal );
|
|
||||||
}
|
|
||||||
FORCEINLINE void InitMana( float NewVal )
|
|
||||||
{
|
|
||||||
Mana.SetBaseValue( NewVal );
|
|
||||||
Mana.SetCurrentValue( 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 InitMaxHealth( float NewVal )
|
|
||||||
{
|
|
||||||
MaxHealth.SetBaseValue( NewVal );
|
|
||||||
MaxHealth.SetCurrentValue( NewVal );
|
|
||||||
}
|
|
||||||
FORCEINLINE void InitMaxMana( float NewVal )
|
|
||||||
{
|
|
||||||
MaxMana.SetBaseValue( NewVal );
|
|
||||||
MaxMana.SetCurrentValue( NewVal );
|
|
||||||
}
|
|
||||||
#pragma endregion Setters
|
#pragma endregion Setters
|
||||||
|
|
||||||
#pragma region AttributeSet
|
#pragma region AttributeSet
|
||||||
|
@ -69,10 +69,16 @@ void AGasaCharacter::InitDefaultAttributes()
|
|||||||
{
|
{
|
||||||
UAbilitySystemComponent* ASC = GetAbilitySystemComponent();
|
UAbilitySystemComponent* ASC = GetAbilitySystemComponent();
|
||||||
ensure(ASC);
|
ensure(ASC);
|
||||||
ensure(DefaultAttributes);
|
ensure(DefaultVitalAttributes);
|
||||||
FGameplayEffectContextHandle Context = ASC->MakeEffectContext();
|
ensure(DefaultPrimaryAttributes);
|
||||||
FGameplayEffectSpecHandle Spec = ASC->MakeOutgoingSpec(DefaultAttributes, 1.0f, Context );
|
ensure(DefaultSecondaryAttributes);
|
||||||
ASC->ApplyGameplayEffectSpecToTarget( * Spec.Data, ASC );
|
FGameplayEffectContextHandle Context = ASC->MakeEffectContext();
|
||||||
|
FGameplayEffectSpecHandle SpecPrimary = ASC->MakeOutgoingSpec(DefaultPrimaryAttributes, 1.0f, Context );
|
||||||
|
FGameplayEffectSpecHandle SpecSecondary = ASC->MakeOutgoingSpec(DefaultSecondaryAttributes, 1.0f, Context );
|
||||||
|
FGameplayEffectSpecHandle SpecVital = ASC->MakeOutgoingSpec(DefaultVitalAttributes, 1.0f, Context );
|
||||||
|
ASC->ApplyGameplayEffectSpecToTarget( * SpecPrimary.Data, ASC );
|
||||||
|
ASC->ApplyGameplayEffectSpecToTarget( * SpecSecondary.Data, ASC );
|
||||||
|
ASC->ApplyGameplayEffectSpecToTarget( * SpecVital.Data, ASC );
|
||||||
}
|
}
|
||||||
#pragma endregion Ability System
|
#pragma endregion Ability System
|
||||||
|
|
||||||
@ -168,11 +174,15 @@ void AGasaCharacter::PossessedBy(AController* NewController)
|
|||||||
GetMesh()->bOnlyAllowAutonomousTickPose = true;
|
GetMesh()->bOnlyAllowAutonomousTickPose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
if (bAutoAbilitySystem)
|
// if (bAutoAbilitySystem)
|
||||||
{
|
// {
|
||||||
AbilitySystem->InitAbilityActorInfo(this, this);
|
// // Note(Ed): For the player character; this is manually called by the player controller in NetOwner_Ready()
|
||||||
}
|
// AbilitySystem->InitAbilityActorInfo(this, this);
|
||||||
|
// Cast<UGasaAbilitySystemComp>(AbilitySystem)->OnAbilityActorInfoSet();
|
||||||
|
//
|
||||||
|
// InitDefaultAttributes();
|
||||||
|
// }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +206,7 @@ void AGasaCharacter::BeginPlay()
|
|||||||
// There is also OnPossessed, PostInitializeComponents, etc...
|
// There is also OnPossessed, PostInitializeComponents, etc...
|
||||||
if (bAutoAbilitySystem)
|
if (bAutoAbilitySystem)
|
||||||
{
|
{
|
||||||
|
// Note(Ed): For the player character; this is manually called by the player controller in NetOwner_Ready()
|
||||||
AbilitySystem->InitAbilityActorInfo(this, this);
|
AbilitySystem->InitAbilityActorInfo(this, this);
|
||||||
Cast<UGasaAbilitySystemComp>(AbilitySystem)->OnAbilityActorInfoSet();
|
Cast<UGasaAbilitySystemComp>(AbilitySystem)->OnAbilityActorInfoSet();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ UENUM(BlueprintType)
|
|||||||
enum class EHighlight : uint8
|
enum class EHighlight : uint8
|
||||||
{
|
{
|
||||||
Disabled,
|
Disabled,
|
||||||
Enabled,
|
Enabled,ddddddd
|
||||||
};
|
};
|
||||||
|
|
||||||
UCLASS(Abstract)
|
UCLASS(Abstract)
|
||||||
@ -36,7 +36,13 @@ public:
|
|||||||
TObjectPtr<UAttributeSet> Attributes;
|
TObjectPtr<UAttributeSet> Attributes;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Ability System")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Ability System")
|
||||||
TSubclassOf<UGameplayEffect> DefaultAttributes;
|
TSubclassOf<UGameplayEffect> DefaultVitalAttributes;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Ability System")
|
||||||
|
TSubclassOf<UGameplayEffect> DefaultPrimaryAttributes;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Ability System")
|
||||||
|
TSubclassOf<UGameplayEffect> DefaultSecondaryAttributes;
|
||||||
|
|
||||||
void InitDefaultAttributes();
|
void InitDefaultAttributes();
|
||||||
#pragma endregion Ability System
|
#pragma endregion Ability System
|
||||||
|
@ -78,6 +78,8 @@ void AGasaPlayerController::NetOwner_OnReady()
|
|||||||
PlayerChar->Attributes = PS->Attributes;
|
PlayerChar->Attributes = PS->Attributes;
|
||||||
PS->AbilitySystem->InitAbilityActorInfo(PS, PlayerChar);
|
PS->AbilitySystem->InitAbilityActorInfo(PS, PlayerChar);
|
||||||
Cast<UGasaAbilitySystemComp>(PS->AbilitySystem)->OnAbilityActorInfoSet();
|
Cast<UGasaAbilitySystemComp>(PS->AbilitySystem)->OnAbilityActorInfoSet();
|
||||||
|
|
||||||
|
PlayerChar->InitDefaultAttributes();
|
||||||
}
|
}
|
||||||
Cam->AttachToActor(PlayerChar, FAttachmentTransformRules::KeepRelativeTransform);
|
Cam->AttachToActor(PlayerChar, FAttachmentTransformRules::KeepRelativeTransform);
|
||||||
}
|
}
|
||||||
|
@ -159,22 +159,6 @@ void gen_attribute_set_from_table( UDataTable* table, FString asset_name )
|
|||||||
FORCEINLINE void Set<property>(float NewVal);
|
FORCEINLINE void Set<property>(float NewVal);
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
body.append(fmt_newline);
|
|
||||||
body.append(fmt_newline);
|
|
||||||
|
|
||||||
// Generate initers
|
|
||||||
for ( TPair< FName, TArray<FAttributeSetField>>& attributes : AttributesByCategory )
|
|
||||||
for (FAttributeSetField attribute : attributes.Value)
|
|
||||||
{
|
|
||||||
body.append(code_fmt("property", (StrC)to_string(attribute.Name),
|
|
||||||
stringize(
|
|
||||||
FORCEINLINE void Init<property>(float NewVal)
|
|
||||||
{
|
|
||||||
<property>.SetBaseValue(NewVal);
|
|
||||||
<property>.SetCurrentValue(NewVal);
|
|
||||||
}
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
body.append(def_pragma(txt("endregion Setters")));
|
body.append(def_pragma(txt("endregion Setters")));
|
||||||
body.append(fmt_newline);
|
body.append(fmt_newline);
|
||||||
|
Loading…
Reference in New Issue
Block a user