update
This commit is contained in:
@@ -1,5 +1,24 @@
|
||||
extends ActionLeaf
|
||||
|
||||
func is_goals_achieved(actor) -> bool:
|
||||
# Check only central 3x3 area of playerboard against goals
|
||||
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
|
||||
|
||||
# Also check outside the goal area
|
||||
if i == 0 or i == 4 or j == 0 or j == 4:
|
||||
if actor.playerboard[i * 5 + j] != -1:
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
var put_position = blackboard.get_value("put_position")
|
||||
var put_slot = blackboard.get_value("put_slot")
|
||||
@@ -16,7 +35,7 @@ func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
if actor.enhanced_gridmap.get_cell_item(cell) != -1:
|
||||
return FAILURE
|
||||
|
||||
# Put the item
|
||||
# Execute put
|
||||
var item = actor.playerboard[put_slot]
|
||||
if actor.is_multiplayer_authority():
|
||||
actor.rpc("sync_grid_item", cell.x, cell.y, cell.z, item)
|
||||
|
||||
Reference in New Issue
Block a user