Merge branch 'Menotdan-bt_infinite_loop'
This commit is contained in:
@@ -624,8 +624,10 @@ void BehaviorTreeLoopDecorator::PostUpdate(const BehaviorUpdateContext& context,
|
|||||||
if (result == BehaviorUpdateResult::Success)
|
if (result == BehaviorUpdateResult::Success)
|
||||||
{
|
{
|
||||||
auto state = GetState<State>(context.Memory);
|
auto state = GetState<State>(context.Memory);
|
||||||
state->Loops--;
|
if (!InfiniteLoop)
|
||||||
if (state->Loops > 0)
|
state->Loops--;
|
||||||
|
|
||||||
|
if (state->Loops > 0 || InfiniteLoop)
|
||||||
{
|
{
|
||||||
// Keep running in a loop but reset node's state (preserve self state)
|
// Keep running in a loop but reset node's state (preserve self state)
|
||||||
result = BehaviorUpdateResult::Running;
|
result = BehaviorUpdateResult::Running;
|
||||||
|
|||||||
@@ -305,12 +305,16 @@ API_CLASS(Sealed) class FLAXENGINE_API BehaviorTreeLoopDecorator : public Behavi
|
|||||||
DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(BehaviorTreeLoopDecorator, BehaviorTreeDecorator);
|
DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(BehaviorTreeLoopDecorator, BehaviorTreeDecorator);
|
||||||
API_AUTO_SERIALIZATION();
|
API_AUTO_SERIALIZATION();
|
||||||
|
|
||||||
// Amount of times to execute the node. Unused if LoopCountSelector is used.
|
// Is the loop infinite (until failed)?
|
||||||
API_FIELD(Attributes="EditorOrder(10), Limit(0)")
|
API_FIELD(Attributes = "EditorOrder(10)")
|
||||||
|
bool InfiniteLoop = false;
|
||||||
|
|
||||||
|
// Amount of times to execute the node. Unused if LoopCountSelector is used or if InfiniteLoop is used.
|
||||||
|
API_FIELD(Attributes="EditorOrder(20), Limit(0), VisibleIf(nameof(InfiniteLoop), true)")
|
||||||
int32 LoopCount = 3;
|
int32 LoopCount = 3;
|
||||||
|
|
||||||
// Amount of times to execute the node from behavior's knowledge (blackboard, goal or sensor). If set, overrides LoopCount.
|
// Amount of times to execute the node from behavior's knowledge (blackboard, goal or sensor). If set, overrides LoopCount. Unused if InfiniteLoop is used.
|
||||||
API_FIELD(Attributes="EditorOrder(20)")
|
API_FIELD(Attributes="EditorOrder(30), VisibleIf(nameof(InfiniteLoop), true)")
|
||||||
BehaviorKnowledgeSelector<int32> LoopCountSelector;
|
BehaviorKnowledgeSelector<int32> LoopCountSelector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user