add beehave

This commit is contained in:
2025-01-28 13:53:59 +08:00
parent d6b69c14ac
commit 144a01556d
112 changed files with 6075 additions and 205 deletions
+12
View File
@@ -0,0 +1,12 @@
extends BeehaveAction
func tick(actor: Node, blackboard: Blackboard) -> bool:
var bot = actor as Node # Your bot node
var best_slot = bot.find_best_arrangement_slot()
if best_slot != -1:
bot.arrange_playerboard_item(best_slot)
bot.action_points -= 2
return true
return false
+65
View File
@@ -0,0 +1,65 @@
@tool
extends BeehaveTree
func _ready():
# Only create tree in game, not in editor
if Engine.is_editor_hint():
return
# Create the root selector
var root_selector = BeehaveSelector.new()
root_selector.name = "RootSelector"
add_child(root_selector)
# Add the main sequences
var arrange_sequence = create_arrange_sequence()
var grab_sequence = create_grab_sequence()
var put_sequence = create_put_sequence()
var move_sequence = create_move_sequence()
root_selector.add_child(arrange_sequence)
root_selector.add_child(grab_sequence)
root_selector.add_child(put_sequence)
root_selector.add_child(move_sequence)
func create_arrange_sequence() -> BeehaveSequence:
var sequence = BeehaveSequence.new()
sequence.name = "ArrangeSequence"
# Conditions
var has_enough_ap = BeehaveCondition.new()
has_enough_ap.set_script(load("res://scripts/conditions/has_enough_ap.gd"))
var needs_arrangement = BeehaveCondition.new()
needs_arrangement.set_script(load("res://scripts/conditions/needs_arrangement.gd"))
# Action
var arrange_action = BeehaveAction.new()
arrange_action.set_script(load("res://scripts/actions/arrange_action.gd"))
sequence.add_child(has_enough_ap)
sequence.add_child(needs_arrangement)
sequence.add_child(arrange_action)
return sequence
func create_grab_sequence() -> BeehaveSequence:
var sequence = BeehaveSequence.new()
sequence.name = "GrabSequence"
# Conditions
var has_ap = BeehaveCondition.new()
has_ap.set_script(load("res://scripts/conditions/has_ap.gd"))
var can_grab = BeehaveCondition.new()
can_grab.set_script(load("res://scripts/conditions/can_grab.gd"))
# Action
var grab_action = BeehaveAction.new()
grab_action.set_script(load("res://scripts/actions/grab_action.gd"))
sequence.add_child(has_ap)
sequence.add_child(can_grab)
sequence.add_child(grab_action)
return sequence
+5
View File
@@ -0,0 +1,5 @@
extends BeehaveCondition
func tick(actor: Node, blackboard: Blackboard) -> bool:
var bot = actor as Node # Your bot node
return bot.action_points >= 2