Sec 04 について
概要
- Setup Attributes
- Do NOT let one ability system component have multiple SAME Attributes. This may lead to ambiguity. Having multiple SEPARATE Attributes is allowed.
- Create a FGameplayAttributeData Health, MaxHealth, Mana, MaxMana;
- In uproperty refer ReplicatedUsing = Function: OnRep_BluBlu
- override GetLifetimeReplicatedProps and use DOREPLIFETIME_CONDITION_NOTIFY macro
- About GetLifetimeReplicatedProps: Returns the properties used for network replication, this needs to be overridden by all actor classes with native replicated properties
- Setup variables accessable by macro
- Detail about ATTRIBUTE_ACCESSORS is at bottom.
- Once you setup ATT… then you can easily use functions like
InitHealth(100.f)
.
- For learning purpose, create a actor to change Attributes instead of Gameplay Effect.
- Creating mesh and sphere component.
- Setting up OnOverlap, EndOverlap event functions and delecates.
- In OnOverlap, we can search Actor who is IAbilitySystemInterface and GetAbilitySystemComponent
- Note that GetAttributeSet need Parameter of The type of attribute set to look for
- const_cast is used for modify AttributeSet, but this is not recommended. It will be fixed in the future.
発見
ATTRIBUTE_ACCESSORSのマクロについて。
/**
* This defines a set of helper functions for accessing and initializing attributes, to avoid having to manually write these functions.
* It would creates the following functions, for attribute Health
*
* static FGameplayAttribute UMyHealthSet::GetHealthAttribute();
* FORCEINLINE float UMyHealthSet::GetHealth() const;
* FORCEINLINE void UMyHealthSet::SetHealth(float NewVal);
* FORCEINLINE void UMyHealthSet::InitHealth(float NewVal);
*
* To use this in your game you can define something like this, and then add game-specific functions as necessary:
*
* #define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
* GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
* GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
* GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
* GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
*
* ATTRIBUTE_ACCESSORS(UMyHealthSet, Health)
*/
Delecate について。
これは要するに、関数のアドレスを渡して実行させていると考えて良さそうだ。
->OnComponentBeginOverlap.AddDynamic(this, &AAuraEffectActor::OnOverlap); Sphere
このコードがあるが、大元のEffectActorがTickしてないが、SphereはTickしている。EAがTickする必要はないが、TickしているSphereがEAを知らずにEAの関数を実行することができる。
if (Sphere->IsOverlap)
{
();
OnOverlap}
にしない理由はEAがTickしないから。
以上が適当に考えた理由。もっと詳しくはもう少し調べていかなければならない。わかりやすかったリンクが これ
次に、Delegateの関数の引数の種類については、OnComponentBeginOverlap
のDefに書いてある。
( FComponentBeginOverlapSignature, UPrimitiveComponent, OnComponentBeginOverlap, UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex, bool, bFromSweep, const FHitResult &, SweepResult); DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SixParams
これの UPrimitiveComponent*, OverlappedComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex, bool, bFromSweep, const FHitResult &, SweepResult
を参考にして、
void AAuraEffectActor::OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) UPrimitiveComponent
を定義したわけだ。
問題点
- Delecateについての勉強
- C++のマクロの文法についての勉強