update
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
extends ConditionLeaf
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
if actor.playerboard_is_full():
|
||||
return FAILURE
|
||||
|
||||
# Check current position
|
||||
var current_cell = Vector3i(actor.current_position.x, 1, actor.current_position.y)
|
||||
var item = actor.enhanced_gridmap.get_cell_item(current_cell)
|
||||
if item in actor.goals:
|
||||
blackboard.set_value("grab_position", actor.current_position)
|
||||
return SUCCESS
|
||||
|
||||
# Check adjacent cells
|
||||
var neighbors = actor.enhanced_gridmap.get_neighbors(actor.current_position, 0)
|
||||
for neighbor in neighbors:
|
||||
if not neighbor.is_walkable:
|
||||
continue
|
||||
var cell = Vector3i(neighbor.position.x, 1, neighbor.position.y)
|
||||
item = actor.enhanced_gridmap.get_cell_item(cell)
|
||||
if item in actor.goals:
|
||||
blackboard.set_value("grab_position", neighbor.position)
|
||||
return SUCCESS
|
||||
|
||||
return FAILURE
|
||||
Reference in New Issue
Block a user