void UBTDecorator_BlueprintBase::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) { if (AIOwner != nullptr && ReceiveObserverActivatedImplementations & FBTNodeBPImplementationHelper::AISpecific) { ReceiveObserverActivatedAI(AIOwner, AIOwner->GetPawn()); } else if (ReceiveObserverActivatedImplementations & FBTNodeBPImplementationHelper::Generic) { ReceiveObserverActivated(ActorOwner); } if (GetNeedsTickForConditionChecking()) { // if set up as observer, and has a condition check, we want to check the condition every frame // highly inefficient, but hopefully people will use it only for prototyping. bNotifyTick = true; } UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent(); if (BlackboardComp) { for (int32 NameIndex = 0; NameIndex < ObservedKeyNames.Num(); NameIndex++) { const FBlackboard::FKey KeyID = BlackboardComp->GetKeyID(ObservedKeyNames[NameIndex]); if (KeyID != FBlackboard::InvalidKey) { BlackboardComp->RegisterObserver(KeyID, this, FOnBlackboardChange::CreateUObject(this, &UBTDecorator_BlueprintBase::OnBlackboardChange)); } } } }
void UBTDecorator_CompareBBEntries::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) { UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent(); if (BlackboardComp) { BlackboardComp->RegisterObserver(BlackboardKeyA.GetSelectedKeyID(), this, FOnBlackboardChange::CreateUObject(this, &UBTDecorator_CompareBBEntries::OnBlackboardChange)); BlackboardComp->RegisterObserver(BlackboardKeyB.GetSelectedKeyID(), this, FOnBlackboardChange::CreateUObject(this, &UBTDecorator_CompareBBEntries::OnBlackboardChange)); } }