update
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
extends ActionLeaf
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
var source_slot = blackboard.get_value("source_slot")
|
||||
var target_slot = blackboard.get_value("target_slot")
|
||||
|
||||
if source_slot == -1 or target_slot == -1:
|
||||
return FAILURE
|
||||
|
||||
# Verify conditions are still valid
|
||||
if actor.action_points < 2 or actor.playerboard[source_slot] == -1:
|
||||
return FAILURE
|
||||
|
||||
if actor.playerboard[target_slot] != -1:
|
||||
return FAILURE
|
||||
|
||||
# Do the arrangement
|
||||
if actor.is_multiplayer_authority():
|
||||
var item = actor.playerboard[source_slot]
|
||||
actor.playerboard[target_slot] = item
|
||||
actor.playerboard[source_slot] = -1
|
||||
actor.rpc("sync_playerboard", actor.playerboard)
|
||||
actor.has_performed_action = true
|
||||
actor.action_points -= 2
|
||||
|
||||
return SUCCESS
|
||||
@@ -0,0 +1,27 @@
|
||||
extends ActionLeaf
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
var grab_position = blackboard.get_value("grab_position")
|
||||
if not grab_position:
|
||||
return FAILURE
|
||||
|
||||
# Find empty slot in playerboard
|
||||
var empty_slot = actor.playerboard.find(-1)
|
||||
if empty_slot == -1:
|
||||
return FAILURE
|
||||
|
||||
# Get item at position
|
||||
var cell = Vector3i(grab_position.x, 1, grab_position.y)
|
||||
var item = actor.enhanced_gridmap.get_cell_item(cell)
|
||||
if item == -1 or actor.action_points <= 0:
|
||||
return FAILURE
|
||||
|
||||
# Grab the item
|
||||
if actor.is_multiplayer_authority():
|
||||
actor.playerboard[empty_slot] = item
|
||||
actor.rpc("sync_grid_item", cell.x, cell.y, cell.z, -1)
|
||||
actor.rpc("sync_playerboard", actor.playerboard)
|
||||
actor.has_performed_action = true
|
||||
actor.action_points -= 1
|
||||
|
||||
return SUCCESS
|
||||
@@ -0,0 +1,44 @@
|
||||
extends ActionLeaf
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
var target_pos = blackboard.get_value("move_target")
|
||||
if not target_pos:
|
||||
return FAILURE
|
||||
|
||||
if actor.action_points <= 0:
|
||||
return FAILURE
|
||||
|
||||
# Verify target is still valid
|
||||
if not actor.is_within_movement_range(target_pos):
|
||||
return FAILURE
|
||||
|
||||
if actor.is_position_occupied(target_pos):
|
||||
return FAILURE
|
||||
|
||||
var cell_item = actor.enhanced_gridmap.get_cell_item(Vector3i(target_pos.x, 0, target_pos.y))
|
||||
if cell_item == -1 or cell_item in actor.enhanced_gridmap.non_walkable_items:
|
||||
return FAILURE
|
||||
|
||||
# Move to position
|
||||
actor.rotate_towards_target(target_pos)
|
||||
var path = actor.enhanced_gridmap.find_path(Vector2(actor.current_position), Vector2(target_pos))
|
||||
|
||||
if path.size() <= 1:
|
||||
return FAILURE
|
||||
|
||||
# Verify path is clear
|
||||
var valid_path = true
|
||||
for point in path.slice(1):
|
||||
if actor.is_position_occupied(Vector2i(point.x, point.y)):
|
||||
valid_path = false
|
||||
break
|
||||
|
||||
if valid_path:
|
||||
if actor.is_multiplayer_authority():
|
||||
path.pop_front()
|
||||
actor.rpc("start_movement_along_path", path)
|
||||
actor.action_points -= 1
|
||||
actor.clear_highlights()
|
||||
return SUCCESS
|
||||
|
||||
return FAILURE
|
||||
@@ -0,0 +1,28 @@
|
||||
extends ActionLeaf
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
var put_position = blackboard.get_value("put_position")
|
||||
var put_slot = blackboard.get_value("put_slot")
|
||||
|
||||
if not put_position or put_slot == -1:
|
||||
return FAILURE
|
||||
|
||||
# Check if we still have the item and AP
|
||||
if actor.action_points <= 0 or actor.playerboard[put_slot] == -1:
|
||||
return FAILURE
|
||||
|
||||
# Check if target position is still empty
|
||||
var cell = Vector3i(put_position.x, 1, put_position.y)
|
||||
if actor.enhanced_gridmap.get_cell_item(cell) != -1:
|
||||
return FAILURE
|
||||
|
||||
# Put the item
|
||||
var item = actor.playerboard[put_slot]
|
||||
if actor.is_multiplayer_authority():
|
||||
actor.rpc("sync_grid_item", cell.x, cell.y, cell.z, item)
|
||||
actor.playerboard[put_slot] = -1
|
||||
actor.rpc("sync_playerboard", actor.playerboard)
|
||||
actor.has_performed_action = true
|
||||
actor.action_points -= 1
|
||||
|
||||
return SUCCESS
|
||||
@@ -0,0 +1,11 @@
|
||||
class_name GrabAction extends ActionLeaf
|
||||
|
||||
func tick(actor: Node, blackboard: Blackboard) -> int:
|
||||
var grab_position = blackboard.get_value("grab_position")
|
||||
if not grab_position:
|
||||
return FAILURE
|
||||
|
||||
if actor.grab_item(grab_position):
|
||||
return SUCCESS
|
||||
|
||||
return FAILURE
|
||||
Reference in New Issue
Block a user