19 lines
617 B
GDScript
19 lines
617 B
GDScript
class_name ArrangeCondition extends ConditionLeaf
|
|
|
|
func tick(actor: Node, blackboard: Blackboard) -> int:
|
|
# Check we have enough action points
|
|
if actor.action_points < 2:
|
|
return FAILURE
|
|
|
|
# Check for items that can be arranged
|
|
for i in range(actor.playerboard.size()):
|
|
if actor.playerboard[i] != -1:
|
|
var neighbors = actor.get_adjacent_playerboard_slots(i)
|
|
for adj_slot in neighbors:
|
|
if actor.playerboard[adj_slot] == -1 and actor.playerboard[i] in actor.goals:
|
|
blackboard.set_value("source_slot", i)
|
|
blackboard.set_value("target_slot", adj_slot)
|
|
return SUCCESS
|
|
|
|
return FAILURE
|