Skip to content

Commit

Permalink
Merge pull request #70 from dfego/get-configuration-warnings-missing-…
Browse files Browse the repository at this point in the history
…return-annotation

fix: Static Typing for _get_configuration_warnings
  • Loading branch information
ThePat02 authored Jan 4, 2024
2 parents e7fd3a5 + 13542b9 commit 2364d8d
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 29 deletions.
6 changes: 3 additions & 3 deletions addons/behaviour_toolkit/behaviour_tree/bt_leaf.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@icon("res://addons/behaviour_toolkit/icons/BTLeaf.svg")
class_name BTLeaf extends BTBehaviour
## A leaf is where the actual logic that controlls the actor or other nodes
## is implemented.
## is implemented.
##
## It is the base class for all leaves and can be extended to implement
## custom behaviours.[br]
Expand All @@ -16,13 +16,13 @@ func tick(_delta: float, _actor: Node, _blackboard: Blackboard) -> BTStatus:

func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

var parent = get_parent()
var children = get_children()

if not parent is BTBehaviour and not parent is BTRoot:
warnings.append("BTLeaf node must be a child of BTBehaviour or BTRoot node.")

if children.size() > 0:
warnings.append("BTLeaf node must not have any children.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class_name BTLeafIntegration extends BTLeaf
update_configuration_warnings()


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func _get_machine() -> FiniteStateMachine:
return get_child(0)


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []
var children = get_children()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func tick(delta: float, actor: Node, blackboard: Blackboard):
return BTStatus.SUCCESS


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func tick(delta: float, actor: Node, _blackboard: Blackboard):
return BTStatus.SUCCESS


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func tick(_delta: float, _actor: Node, _blackboard: Blackboard) -> BTStatus:
return return_status


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func tick(_delta: float, _actor: Node, _blackboard: Blackboard) -> BTStatus:
return BTStatus.SUCCESS


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func _init_tween(actor: Node, blackboard: Blackboard):
tween.tween_property(actor, tween_property, tween_value, duration)


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
4 changes: 2 additions & 2 deletions addons/behaviour_toolkit/finite_state_machine/fsm_state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func _on_exit(_actor: Node, _blackboard: Blackboard) -> void:
pass


func _get_configuration_warnings():
var warnings = []
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

var parent: Node = get_parent()
if not parent is FiniteStateMachine:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ func _get_behaviour_tree() -> BTRoot:

if get_child_count() == 0:
return null

for child in get_children():
if child is BTRoot:
return child

return null

func _get_configuration_warnings():

func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand All @@ -73,11 +74,13 @@ func _get_configuration_warnings():
has_root = true
elif not child is FSMTransition:
warnings.append("FSMStateIntegratedBT can only have BTRoot and FSMTransition children.")

if not has_root:
warnings.append("FSMStateIntegratedBT must have a BTRoot child node.")

if fire_event_on_status and event == "":
warnings.append("FSMStateIntegratedBT has fire_event_on_status enabled, but no event is set.")
warnings.append(
"FSMStateIntegratedBT has fire_event_on_status enabled, but no event is set."
)

return warnings
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class_name FSMStateIntegrationReturn extends FSMState
## [enum BTStatus.FAILURE] depending on the state's return_status property,
## which stops execution of FSM attached to [BTIntegratedFSM].


enum BTStatus {
SUCCESS,
FAILURE,
Expand All @@ -31,7 +30,7 @@ func _on_exit(_actor: Node, _blackboard: Blackboard) -> void:
pass


func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
10 changes: 5 additions & 5 deletions addons/behaviour_toolkit/finite_state_machine/fsm_transition.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func is_valid(_actor: Node, _blackboard: Blackboard) -> bool:
func is_valid_event(current_event: String) -> bool:
if current_event == "":
return false

return current_event == event


Expand All @@ -53,16 +53,16 @@ func get_next_state() -> FSMState:
return next_state


func _get_configuration_warnings():
var warnings = []
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

var parent: Node = get_parent()
if not parent is FSMState:
warnings.append("FSMTransition should be a child of FSMState.")

if not next_state:
warnings.append("FSMTransition has no next state.")

if use_event and event == "":
warnings.append("FSMTransition has no event set.")

Expand Down
2 changes: 1 addition & 1 deletion script_templates/BTComposite/new_composite.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func tick(_delta: float, _actor: Node, _blackboard: Blackboard) -> BTStatus:

# Add custom configuration warnings
# Note: Can be deleted if you don't want to define your own warnings.
func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
2 changes: 1 addition & 1 deletion script_templates/BTDecorator/new_decorator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func tick(_delta: float, _actor: Node, _blackboard: Blackboard) -> BTStatus:

# Add custom configuration warnings
# Note: Can be deleted if you don't want to define your own warnings.
func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
2 changes: 1 addition & 1 deletion script_templates/BTLeaf/new_leaf.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func tick(_delta: float, _actor: Node, _blackboard: Blackboard) -> BTStatus:

# Add custom configuration warnings
# Note: Can be deleted if you don't want to define your own warnings.
func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
2 changes: 1 addition & 1 deletion script_templates/FSMState/new_state.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func _on_exit(_actor: Node, _blackboard: Blackboard) -> void:

# Add custom configuration warnings
# Note: Can be deleted if you don't want to define your own warnings.
func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down
3 changes: 2 additions & 1 deletion script_templates/FSMTransition/new_transition.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@tool
extends FSMTransition


# Executed when the transition is taken.
func _on_transition(_delta: float, _actor: Node, _blackboard: Blackboard) -> void:
pass
Expand All @@ -13,7 +14,7 @@ func is_valid(_actor: Node, _blackboard: Blackboard) -> bool:

# Add custom configuration warnings
# Note: Can be deleted if you don't want to define your own warnings.
func _get_configuration_warnings():
func _get_configuration_warnings() -> PackedStringArray:
var warnings: Array = []

warnings.append_array(super._get_configuration_warnings())
Expand Down

0 comments on commit 2364d8d

Please sign in to comment.