EvolvingBehavior  0.2.0
 
Loading...
Searching...
No Matches

Keeps a mapping of IDs to template BehaviorTree nodes. More...

#include <NodeMapper.h>

Inheritance diagram for UNodeMapper:
UService

Public Member Functions

void Register (const UBTTaskNode *node)
 
void Register (const UBTCompositeNode *node)
 
void Register (const UBTService *node)
 
void Register (const UBTDecorator *node)
 
bool TryGetMapping (const UBTNode *node, FNodeMapID &result) const
 Tries to retrieve a mapped ID for the give node. More...
 
bool TryGetTemplate (FNodeMapID mapping, UBTNode *&result) const
 Tries to retrieve the template node for a given Map ID. More...
 
FNodeMapID GetOrAddMapping (const UBTCompositeNode *node)
 Retrieve a mapped ID for the given node, adding it if it did not exist. More...
 
FNodeMapID GetOrAddMapping (const UBTTaskNode *node)
 Retrieve a mapped ID for the given node, adding it if it did not exist. More...
 
FNodeMapID GetOrAddMapping (const UBTService *node)
 Retrieve a mapped ID for the given node, adding it if it did not exist. More...
 
FNodeMapID GetOrAddMapping (const UBTDecorator *node)
 Retrieve a mapped ID for the given node, adding it if it did not exist. More...
 
FNodeMapID GetRandomCompositeID (URandomGen *randomGen)
 
FNodeMapID GetRandomTaskID (URandomGen *randomGen)
 
FNodeMapID GetRandomServiceID (URandomGen *randomGen)
 
FNodeMapID GetRandomDecoratorID (URandomGen *randomGen)
 
- Public Member Functions inherited from UService
virtual void Init (UServiceInjector *injector)
 

Protected Member Functions

void Reset (UBTNode *node)
 
void AddMapping (UBTNode *node, FNodeMapID nodeID)
 Add the given node as a Template, creating a new mapping. More...
 

Additional Inherited Members

- Protected Attributes inherited from UService
UServiceInjectorserviceInjector
 

Detailed Description

Keeps a mapping of IDs to template BehaviorTree nodes.

Author
npc
Date
12/01/17

The NodeMapper stores a map of FNodeMapID to UBTNode. Each Node should be thought of as the template for creating new nodes with the same variables and type.

When you map a node, its ID must be unique. Currently, IDs are the node name. Therefore, you should always name your nodes uniquely.

When you retrieve nodes from the NodeMapper, it returns the template directly. You should then copy the template, not modify it.

Member Function Documentation

◆ AddMapping()

void UNodeMapper::AddMapping ( UBTNode *  node,
FNodeMapID  nodeID 
)
protected

Add the given node as a Template, creating a new mapping.

Parameters
nodeThe node to add.

The node ID must be unique. At the moment, the ID is just the Node Name.

◆ GetOrAddMapping() [1/4]

FNodeMapID UNodeMapper::GetOrAddMapping ( const UBTCompositeNode *  node)

Retrieve a mapped ID for the given node, adding it if it did not exist.

Parameters
nodeThe node to map.
Returns
The ID for this node (new or unchanged).

◆ GetOrAddMapping() [2/4]

FNodeMapID UNodeMapper::GetOrAddMapping ( const UBTDecorator *  node)

Retrieve a mapped ID for the given node, adding it if it did not exist.

Parameters
nodeThe node to map.
Returns
The ID for this node (new or unchanged).

◆ GetOrAddMapping() [3/4]

FNodeMapID UNodeMapper::GetOrAddMapping ( const UBTService *  node)

Retrieve a mapped ID for the given node, adding it if it did not exist.

Parameters
nodeThe node to map.
Returns
The ID for this node (new or unchanged).

◆ GetOrAddMapping() [4/4]

FNodeMapID UNodeMapper::GetOrAddMapping ( const UBTTaskNode *  node)

Retrieve a mapped ID for the given node, adding it if it did not exist.

Parameters
nodeThe node to map.
Returns
The ID for this node (new or unchanged).

◆ TryGetMapping()

bool UNodeMapper::TryGetMapping ( const UBTNode *  node,
FNodeMapID result 
) const

Tries to retrieve a mapped ID for the give node.

Parameters
nodeThe template node to retrieve.
resultThe mapped ID, if found.
Returns
True if the mapping was found, false otherwise.

◆ TryGetTemplate()

bool UNodeMapper::TryGetTemplate ( FNodeMapID  mapping,
UBTNode *&  result 
) const

Tries to retrieve the template node for a given Map ID.

Parameters
mappingThe Mapped ID to retrieve.
resultThe resulting template node, if found.
Returns
True if the node was found, false otherwise

You should not modify the resulting template node - you should copy it.


The documentation for this class was generated from the following files:
  • Source/EvolvingBehavior/Public/NodeMapper.h
  • Source/EvolvingBehavior/Private/NodeMapper.cpp