void UBTDecorator_TimeLimit::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) { OwnerComp.RequestExecution(this); // make sure that next tick won't happen before execution request is processed SetNextTickTime(NodeMemory, 1000000.0f); }
void UBTDecorator_BlueprintBase::OnBlackboardChange(const UBlackboardComponent& Blackboard, FBlackboard::FKey ChangedKeyID) { UBehaviorTreeComponent* BehaviorComp = (UBehaviorTreeComponent*)Blackboard.GetBrainComponent(); if (BehaviorComp && GetShouldAbort(*BehaviorComp)) { BehaviorComp->RequestExecution(this); } }
void UBTDecorator_CompareBBEntries::OnBlackboardChange(const UBlackboardComponent& Blackboard, FBlackboard::FKey ChangedKeyID) { UBehaviorTreeComponent* BehaviorComp = static_cast<UBehaviorTreeComponent*>(Blackboard.GetBrainComponent()); if (BehaviorComp && (BlackboardKeyA.GetSelectedKeyID() == ChangedKeyID || BlackboardKeyB.GetSelectedKeyID() == ChangedKeyID)) { BehaviorComp->RequestExecution(this); } }
void UBTDecorator_KeepInCone::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) { TNodeInstanceMemory* DecoratorMemory = reinterpret_cast<TNodeInstanceMemory*>(NodeMemory); FVector CurrentDir(1.0f, 0, 0); if (CalculateCurrentDirection(OwnerComp, CurrentDir)) { const float Angle = DecoratorMemory->InitialDirection.CosineAngle2D(CurrentDir); if (Angle < ConeHalfAngleDot || (IsInversed() && Angle > ConeHalfAngleDot)) { OwnerComp.RequestExecution(this); } } }
void UBTComposite_SimpleParallel::NotifyChildExecution(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, int32 ChildIdx, EBTNodeResult::Type& NodeResult) const { FBTParallelMemory* MyMemory = (FBTParallelMemory*)NodeMemory; if (ChildIdx == EBTParallelChild::MainTask) { MyMemory->MainTaskResult = NodeResult; if (NodeResult == EBTNodeResult::InProgress) { EBTTaskStatus::Type Status = OwnerComp.GetTaskStatus(Children[EBTParallelChild::MainTask].ChildTask); if (Status == EBTTaskStatus::Active) { // can't register if task is currently being aborted (latent abort returns in progress) MyMemory->bMainTaskIsActive = true; MyMemory->bForceBackgroundTree = false; OwnerComp.RegisterParallelTask(Children[EBTParallelChild::MainTask].ChildTask); RequestDelayedExecution(OwnerComp, EBTNodeResult::Succeeded); } } else if (MyMemory->bMainTaskIsActive) { MyMemory->bMainTaskIsActive = false; const int32 MyInstanceIdx = OwnerComp.FindInstanceContainingNode(this); OwnerComp.UnregisterParallelTask(Children[EBTParallelChild::MainTask].ChildTask, MyInstanceIdx); if (NodeResult != EBTNodeResult::Aborted && !MyMemory->bRepeatMainTask) { // check if subtree should be aborted when task finished with success/failed result if (FinishMode == EBTParallelMode::AbortBackground) { OwnerComp.RequestExecution((UBTCompositeNode*)this, MyInstanceIdx, Children[EBTParallelChild::MainTask].ChildTask, EBTParallelChild::MainTask, NodeResult); } } } else if (NodeResult == EBTNodeResult::Succeeded && FinishMode == EBTParallelMode::WaitForBackground) { // special case: if main task finished instantly, but composite is supposed to wait for background tree, // request single run of background tree anyway MyMemory->bForceBackgroundTree = true; RequestDelayedExecution(OwnerComp, EBTNodeResult::Succeeded); } } }
void UBTDecorator_TagCooldown::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) { check(bActivatesCooldown); FBTTagCooldownDecoratorMemory* DecoratorMemory = (FBTTagCooldownDecoratorMemory*)NodeMemory; if (!DecoratorMemory->bRequestedRestart) { if (HasCooldownFinished(OwnerComp)) { DecoratorMemory->bRequestedRestart = true; OwnerComp.RequestExecution(this); } } }
void UBTDecorator_BlueprintBase::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) { if (AIOwner != nullptr && ReceiveTickImplementations & FBTNodeBPImplementationHelper::AISpecific) { ReceiveTickAI(AIOwner, AIOwner->GetPawn(), DeltaSeconds); } else if (ReceiveTickImplementations & FBTNodeBPImplementationHelper::Generic) { ReceiveTick(ActorOwner, DeltaSeconds); } // possible this got ticked due to the decorator being configured as an observer if (GetNeedsTickForConditionChecking() && GetShouldAbort(OwnerComp)) { OwnerComp.RequestExecution(this); } }
void UBTDecorator_TimeLimit::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds) { OwnerComp.RequestExecution(this); }