Skip to content

Commit

Permalink
fix : wait node, the issue of getting stuck in loop node
Browse files Browse the repository at this point in the history
  • Loading branch information
pojol committed Jul 7, 2023
1 parent 7f84cde commit 46f6552
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bot/behavior/action_wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions bot/behavior/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (a *Node) GetFreeze() bool {
return a.freeze
}

// SetFreeze 使节点无效(已经执行过的节点)
func (a *Node) SetFreeze(f bool) {
a.freeze = f
}
Expand Down

0 comments on commit 46f6552

Please sign in to comment.