From 46f6552a8eafd88cc8d7864e55656a28b7cc99e2 Mon Sep 17 00:00:00 2001 From: pojol Date: Fri, 7 Jul 2023 20:17:04 +0800 Subject: [PATCH] fix : wait node, the issue of getting stuck in loop node --- bot/behavior/action_wait.go | 4 +++- bot/behavior/node.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/behavior/action_wait.go b/bot/behavior/action_wait.go index a2985aa..73ec73d 100644 --- a/bot/behavior/action_wait.go +++ b/bot/behavior/action_wait.go @@ -45,7 +45,8 @@ func (a *WaitAction) onNext(t *Tick) { if currTime >= a.endtime { a.endtime = 0 - if a.base.ChildrenNum() > 0 { + if a.base.ChildrenNum() > 0 && !a.base.GetFreeze() { + a.base.SetFreeze(true) t.blackboard.Append([]INod{a.base.Children()[0]}) } else { a.base.parent.onNext(t) @@ -59,6 +60,7 @@ func (a *WaitAction) onNext(t *Tick) { func (a *WaitAction) onReset() { a.endtime = 0 + a.base.SetFreeze(false) for _, child := range a.base.Children() { child.onReset() diff --git a/bot/behavior/node.go b/bot/behavior/node.go index 3761a58..fd615cd 100644 --- a/bot/behavior/node.go +++ b/bot/behavior/node.go @@ -73,6 +73,7 @@ func (a *Node) GetFreeze() bool { return a.freeze } +// SetFreeze 使节点无效(已经执行过的节点) func (a *Node) SetFreeze(f bool) { a.freeze = f }