This commit is contained in:
2025-01-31 17:45:35 +08:00
parent cf389135c0
commit ef8d06b6cc
7 changed files with 253 additions and 26 deletions
+15
View File
@@ -1,6 +1,21 @@
extends ActionLeaf
func is_goals_achieved(actor) -> bool:
for i in range(3):
for j in range(3):
var board_idx = (i + 1) * 5 + (j + 1)
var goal_idx = i * 3 + j
if actor.goals[goal_idx] != -1 and actor.goals[goal_idx] != actor.playerboard[board_idx]:
return false
elif actor.goals[goal_idx] == -1 and actor.playerboard[board_idx] != -1:
return false
return true
func tick(actor: Node, blackboard: Blackboard) -> int:
# Don't move if goals are achieved
if is_goals_achieved(actor):
return FAILURE
# Get target from blackboard
var target_pos = blackboard.get_value("move_target")
if not target_pos: