Space Plunder
Loading...
Searching...
No Matches
UBTDecorator_RandomChance Class Reference

#include <BTDecorator_RandomChance.h>

Inheritance diagram for UBTDecorator_RandomChance:

Public Member Functions

 UBTDecorator_RandomChance ()
 

Protected Member Functions

virtual bool CalculateRawConditionValue (UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) const override
 
virtual FString GetStaticDescription () const override
 

Protected Attributes

int32 MaxChance = 1
 

Detailed Description

UBTDecorator_RandomChance is a decorator that adds randomness to the execution of its child node. It calculates a raw condition value based on a random chance and a maximum chance specified by the user.

Constructor & Destructor Documentation

◆ UBTDecorator_RandomChance()

UBTDecorator_RandomChance::UBTDecorator_RandomChance ( )
11{
12 NodeName = TEXT("Random Chance");
13}

Member Function Documentation

◆ CalculateRawConditionValue()

bool UBTDecorator_RandomChance::CalculateRawConditionValue ( UBehaviorTreeComponent & OwnerComp,
uint8 * NodeMemory ) const
overrideprotectedvirtual
16{
17 TRACE_CPUPROFILER_EVENT_SCOPE(UBTDecorator_RandomChance::CalculateRawConditionValue);
18 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Behaviors);
19 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Decorators);
20 return 0 == FMath::RandRange(0, (MaxChance - 1));
21}
int32 MaxChance
Definition BTDecorator_RandomChance.h:28
virtual bool CalculateRawConditionValue(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) const override
Definition BTDecorator_RandomChance.cpp:15

◆ GetStaticDescription()

FString UBTDecorator_RandomChance::GetStaticDescription ( ) const
overrideprotectedvirtual
24{
25 FString Description;
26 Description += FString::Printf(TEXT("\n 1 in %i Chance"), MaxChance);
27 return Description;
28}

Member Data Documentation

◆ MaxChance

int32 UBTDecorator_RandomChance::MaxChance = 1
protected

The documentation for this class was generated from the following files: