Skip to content

Fix: Check child count before applying interrupt#121

Merged
bitbrain merged 4 commits into
bitbrain:godot-4.xfrom
Werninator:fix_interrupt_error
Feb 13, 2023
Merged

Fix: Check child count before applying interrupt#121
bitbrain merged 4 commits into
bitbrain:godot-4.xfrom
Werninator:fix_interrupt_error

Conversation

@Werninator

Copy link
Copy Markdown

Description

Currently, an out of bounds error will happen when:

  • there's no child node inside the BeehaveTree
  • BeehaveTree.enabled = false

So it doesn't throw an error, when:
- there's no child node inside the BeehaveTree
- the BeehaveTree is disabled
@bitbrain

Copy link
Copy Markdown
Owner

Could you also add a test here? https://github.com/bitbrain/beehave/blob/godot-4.x/test/beehave_tree_test.gd

@bitbrain bitbrain added the 🟡 changes requested Changes have been requested from the contributor. label Feb 11, 2023
Patrick Werner and others added 3 commits February 11, 2023 16:59
* EmptyTree
  A tree, that is activated and has no children
* OnlyOneActionTree
  A tree with only one action in it
* DeactivatedTree
  A tree that is deactivated
@bitbrain bitbrain added 🐛 bug Something isn't working and removed 🟡 changes requested Changes have been requested from the contributor. labels Feb 13, 2023
@bitbrain
bitbrain merged commit 21da42d into bitbrain:godot-4.x Feb 13, 2023
@Werninator
Werninator deleted the fix_interrupt_error branch February 13, 2023 12:04
lostptr pushed a commit to lostptr/beehave that referenced this pull request Feb 13, 2023
* Fix: Check child count before applying interrupt

So it doesn't throw an error, when:
- there's no child node inside the BeehaveTree
- the BeehaveTree is disabled

* Add duck typing check for interrupt method in child

* 🧪 Add Trees to UnitTestScene to cause errors if fix is not applied

* EmptyTree
  A tree, that is activated and has no children
* OnlyOneActionTree
  A tree with only one action in it
* DeactivatedTree
  A tree that is deactivated

---------

Co-authored-by: miguel <miguel-gonzalez@gmx.de>
bitbrain added a commit that referenced this pull request Feb 15, 2023
…118

* Added `enter()` and `exit()` methods for beehave nodes

- Added `enter()` and `exit()` methods in BeehaveNode.
- Adjusted some composites to use those methods now
- Since it's the parent's responsability to call those methods,
all tests needed to be adjusted so that a `BeehaveTree` is
added as the root.
- Some tests needed adjustments because now decorators **will**
throw errors if they have no children.
- A new test was added to validade the enter and exit methods.
  - A new test action was added to make those tests possible.

* Changed `enter` and `exit` to `before_run` and `after_run`

- A short explanation of those methods was also added in the README.

* Fix: Check child count before applying interrupt (#121)

* Fix: Check child count before applying interrupt

So it doesn't throw an error, when:
- there's no child node inside the BeehaveTree
- the BeehaveTree is disabled

* Add duck typing check for interrupt method in child

* 🧪 Add Trees to UnitTestScene to cause errors if fix is not applied

* EmptyTree
  A tree, that is activated and has no children
* OnlyOneActionTree
  A tree with only one action in it
* DeactivatedTree
  A tree that is deactivated

---------

Co-authored-by: miguel <miguel-gonzalez@gmx.de>

* 🐛 do only unregister monitor when present (#128)

* Update addons/beehave/nodes/beehave_tree.gd

---------

Co-authored-by: miguel <miguel-gonzalez@gmx.de>
Co-authored-by: Patrick Werner <paddi@tastenklopfer.io>
bitbrain added a commit that referenced this pull request Feb 15, 2023
…118

* Added `enter()` and `exit()` methods for beehave nodes

- Added `enter()` and `exit()` methods in BeehaveNode.
- Adjusted some composites to use those methods now
- Since it's the parent's responsability to call those methods,
all tests needed to be adjusted so that a `BeehaveTree` is
added as the root.
- Some tests needed adjustments because now decorators **will**
throw errors if they have no children.
- A new test was added to validade the enter and exit methods.
  - A new test action was added to make those tests possible.

* Changed `enter` and `exit` to `before_run` and `after_run`

- A short explanation of those methods was also added in the README.

* Fix: Check child count before applying interrupt (#121)

* Fix: Check child count before applying interrupt

So it doesn't throw an error, when:
- there's no child node inside the BeehaveTree
- the BeehaveTree is disabled

* Add duck typing check for interrupt method in child

* 🧪 Add Trees to UnitTestScene to cause errors if fix is not applied

* EmptyTree
  A tree, that is activated and has no children
* OnlyOneActionTree
  A tree with only one action in it
* DeactivatedTree
  A tree that is deactivated

---------

Co-authored-by: miguel <miguel-gonzalez@gmx.de>

* 🐛 do only unregister monitor when present (#128)

* Update addons/beehave/nodes/beehave_tree.gd

---------

Co-authored-by: miguel <miguel-gonzalez@gmx.de>
Co-authored-by: Patrick Werner <paddi@tastenklopfer.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants