update
This commit is contained in:
+6
-6
@@ -114,16 +114,16 @@ func set_action_state(new_state):
|
|||||||
return
|
return
|
||||||
|
|
||||||
current_action_state = new_state
|
current_action_state = new_state
|
||||||
if not local_player_character.is_bot:
|
if local_player_character.is_bot == false:
|
||||||
local_player_character.clear_highlights()
|
local_player_character.clear_highlights()
|
||||||
local_player_character.clear_playerboard_highlights()
|
local_player_character.clear_playerboard_highlights()
|
||||||
|
|
||||||
match new_state:
|
match new_state:
|
||||||
ActionState.MOVING:
|
ActionState.MOVING:
|
||||||
if not local_player_character.is_bot:
|
if local_player_character.is_bot == false:
|
||||||
local_player_character.highlight_movement_range()
|
local_player_character.highlight_movement_range()
|
||||||
ActionState.GRABBING:
|
ActionState.GRABBING:
|
||||||
if not local_player_character.is_bot:
|
if local_player_character.is_bot == false:
|
||||||
local_player_character.highlight_adjacent_cells()
|
local_player_character.highlight_adjacent_cells()
|
||||||
if local_player_character.has_item_at_current_position():
|
if local_player_character.has_item_at_current_position():
|
||||||
local_player_character.highlighted_cells.append(local_player_character.current_position)
|
local_player_character.highlighted_cells.append(local_player_character.current_position)
|
||||||
@@ -132,14 +132,14 @@ func set_action_state(new_state):
|
|||||||
local_player_character.enhanced_gridmap.hover_item
|
local_player_character.enhanced_gridmap.hover_item
|
||||||
)
|
)
|
||||||
ActionState.PUTTING:
|
ActionState.PUTTING:
|
||||||
if not local_player_character.is_bot:
|
if local_player_character.is_bot == false:
|
||||||
local_player_character.highlight_occupied_playerboard_slots()
|
local_player_character.highlight_occupied_playerboard_slots()
|
||||||
ActionState.RANDOMIZING:
|
ActionState.RANDOMIZING:
|
||||||
if not local_player_character.is_bot:
|
if local_player_character.is_bot == false:
|
||||||
local_player_character.highlight_random_valid_cells()
|
local_player_character.highlight_random_valid_cells()
|
||||||
ActionState.ARRANGING:
|
ActionState.ARRANGING:
|
||||||
show_arrangement_ui()
|
show_arrangement_ui()
|
||||||
if not local_player_character.is_bot:
|
if local_player_character.is_bot == false:
|
||||||
local_player_character.highlight_occupied_playerboard_slots()
|
local_player_character.highlight_occupied_playerboard_slots()
|
||||||
|
|
||||||
func update_button_states():
|
func update_button_states():
|
||||||
|
|||||||
+20
-20
@@ -58,7 +58,7 @@ func _ready():
|
|||||||
var behavior_tree = $BehaviorTree
|
var behavior_tree = $BehaviorTree
|
||||||
|
|
||||||
# Early setup for bots
|
# Early setup for bots
|
||||||
if is_bot or is_in_group("Bots"):
|
if is_bot == true or is_in_group("Bots"):
|
||||||
# Set Input process to false for bots immediately
|
# Set Input process to false for bots immediately
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
set_process_unhandled_input(false)
|
set_process_unhandled_input(false)
|
||||||
@@ -119,7 +119,7 @@ func _physics_process(_delta):
|
|||||||
rpc("remote_set_position", global_position)
|
rpc("remote_set_position", global_position)
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if is_bot or is_in_group("Bots"):
|
if is_bot == true or is_in_group("Bots"):
|
||||||
set_process_unhandled_input(false)
|
set_process_unhandled_input(false)
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
return
|
return
|
||||||
@@ -133,7 +133,7 @@ func _unhandled_input(event):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
if is_bot or is_in_group("Bots"):
|
if is_bot == true or is_in_group("Bots"):
|
||||||
set_process_unhandled_input(false)
|
set_process_unhandled_input(false)
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
return
|
return
|
||||||
@@ -166,7 +166,7 @@ func _on_slot_gui_input(event, slot_index, slot_ui) -> int:
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
func handle_grid_click(grid_position: Vector2i):
|
func handle_grid_click(grid_position: Vector2i):
|
||||||
if is_bot or is_in_group("Bots"):
|
if is_bot == true or is_in_group("Bots"):
|
||||||
return
|
return
|
||||||
var main = get_tree().get_root().get_node_or_null("Main")
|
var main = get_tree().get_root().get_node_or_null("Main")
|
||||||
if not main:
|
if not main:
|
||||||
@@ -287,7 +287,7 @@ func move_player_to_clicked_position(grid_position: Vector2i):
|
|||||||
path.pop_front()
|
path.pop_front()
|
||||||
rpc("start_movement_along_path", path)
|
rpc("start_movement_along_path", path)
|
||||||
action_points -= 1
|
action_points -= 1
|
||||||
if not is_bot:
|
if not is_bot == true:
|
||||||
clear_highlights()
|
clear_highlights()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -307,7 +307,7 @@ func start_movement_along_path(path: Array, clear_visual: bool = true):
|
|||||||
current_position = Vector2i(path[-1].x, path[-1].y)
|
current_position = Vector2i(path[-1].x, path[-1].y)
|
||||||
is_player_moving = false
|
is_player_moving = false
|
||||||
|
|
||||||
if clear_visual:
|
if clear_visual == true:
|
||||||
enhanced_gridmap.clear_path_visualization()
|
enhanced_gridmap.clear_path_visualization()
|
||||||
|
|
||||||
has_moved_this_turn = path.size() <= movement_range
|
has_moved_this_turn = path.size() <= movement_range
|
||||||
@@ -406,7 +406,7 @@ func grab_item(grid_position: Vector2i = current_position) -> bool:
|
|||||||
if item == -1:
|
if item == -1:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if is_in_group("Bots") or is_bot:
|
if is_in_group("Bots") or is_bot == true:
|
||||||
var empty_slot = playerboard.find(-1)
|
var empty_slot = playerboard.find(-1)
|
||||||
if empty_slot == -1:
|
if empty_slot == -1:
|
||||||
return false
|
return false
|
||||||
@@ -465,7 +465,7 @@ func put_item(grid_position: Vector2i = current_position) -> bool:
|
|||||||
|
|
||||||
has_performed_action = true
|
has_performed_action = true
|
||||||
consume_action_points(1)
|
consume_action_points(1)
|
||||||
if not is_bot:
|
if not is_bot == true:
|
||||||
clear_highlights()
|
clear_highlights()
|
||||||
clear_playerboard_highlights()
|
clear_playerboard_highlights()
|
||||||
selected_playerboard_slot = -1
|
selected_playerboard_slot = -1
|
||||||
@@ -481,7 +481,7 @@ func handle_put_action():
|
|||||||
if not main or action_points < 1:
|
if not main or action_points < 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not is_bot:
|
if not is_bot == true:
|
||||||
clear_highlights()
|
clear_highlights()
|
||||||
clear_playerboard_highlights()
|
clear_playerboard_highlights()
|
||||||
|
|
||||||
@@ -516,7 +516,7 @@ func handle_playerboard_slot_selected(slot_index: int):
|
|||||||
|
|
||||||
has_performed_action = true
|
has_performed_action = true
|
||||||
consume_action_points(1)
|
consume_action_points(1)
|
||||||
if not is_bot:
|
if not is_bot == true:
|
||||||
clear_highlights()
|
clear_highlights()
|
||||||
clear_playerboard_highlights()
|
clear_playerboard_highlights()
|
||||||
selected_gridmap_position = Vector2i(-1, -1)
|
selected_gridmap_position = Vector2i(-1, -1)
|
||||||
@@ -532,7 +532,7 @@ func handle_put_slot_selected(slot_index: int):
|
|||||||
if slot_index in highlighted_cells and playerboard[slot_index] in goals:
|
if slot_index in highlighted_cells and playerboard[slot_index] in goals:
|
||||||
selected_playerboard_slot = slot_index
|
selected_playerboard_slot = slot_index
|
||||||
clear_highlights()
|
clear_highlights()
|
||||||
if not is_bot:
|
if not is_bot == true:
|
||||||
highlight_empty_adjacent_cells()
|
highlight_empty_adjacent_cells()
|
||||||
|
|
||||||
|
|
||||||
@@ -570,7 +570,7 @@ func arrange_playerboard_item(slot_index: int):
|
|||||||
slot.gui_input.connect(_on_slot_clicked.bind(i))
|
slot.gui_input.connect(_on_slot_clicked.bind(i))
|
||||||
|
|
||||||
func _on_slot_clicked(event: InputEvent, slot_index: int):
|
func _on_slot_clicked(event: InputEvent, slot_index: int):
|
||||||
if not event is InputEventMouseButton or is_bot or not event.pressed or event.button_index != MOUSE_BUTTON_LEFT:
|
if not event is InputEventMouseButton or is_bot == true or not event.pressed or event.button_index != MOUSE_BUTTON_LEFT:
|
||||||
return
|
return
|
||||||
|
|
||||||
var main = get_tree().get_root().get_node_or_null("Main")
|
var main = get_tree().get_root().get_node_or_null("Main")
|
||||||
@@ -638,7 +638,7 @@ func playerboard_is_full() -> bool:
|
|||||||
return playerboard.find(-1) == -1
|
return playerboard.find(-1) == -1
|
||||||
|
|
||||||
func highlight_movement_range():
|
func highlight_movement_range():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
|
|
||||||
for x in range(enhanced_gridmap.columns):
|
for x in range(enhanced_gridmap.columns):
|
||||||
@@ -651,7 +651,7 @@ func highlight_movement_range():
|
|||||||
enhanced_gridmap.set_cell_item(Vector3i(x, 0, z), enhanced_gridmap.hover_item)
|
enhanced_gridmap.set_cell_item(Vector3i(x, 0, z), enhanced_gridmap.hover_item)
|
||||||
|
|
||||||
func highlight_adjacent_cells():
|
func highlight_adjacent_cells():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
|
|
||||||
var current_cell = Vector3i(current_position.x, 1, current_position.y)
|
var current_cell = Vector3i(current_position.x, 1, current_position.y)
|
||||||
@@ -669,7 +669,7 @@ func highlight_adjacent_cells():
|
|||||||
|
|
||||||
|
|
||||||
func highlight_empty_adjacent_cells():
|
func highlight_empty_adjacent_cells():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Clear previous highlights
|
# Clear previous highlights
|
||||||
@@ -694,7 +694,7 @@ func highlight_empty_adjacent_cells():
|
|||||||
enhanced_gridmap.hover_item)
|
enhanced_gridmap.hover_item)
|
||||||
|
|
||||||
func highlight_random_valid_cells():
|
func highlight_random_valid_cells():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
|
|
||||||
var valid_cells = []
|
var valid_cells = []
|
||||||
@@ -715,7 +715,7 @@ func highlight_random_valid_cells():
|
|||||||
valid_cells.remove_at(index)
|
valid_cells.remove_at(index)
|
||||||
|
|
||||||
func highlight_occupied_playerboard_slots():
|
func highlight_occupied_playerboard_slots():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
|
|
||||||
var main = get_tree().get_root().get_node_or_null("Main")
|
var main = get_tree().get_root().get_node_or_null("Main")
|
||||||
@@ -740,7 +740,7 @@ func highlight_occupied_playerboard_slots():
|
|||||||
main.update_playerboard_ui()
|
main.update_playerboard_ui()
|
||||||
|
|
||||||
func clear_highlights():
|
func clear_highlights():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
if not enhanced_gridmap:
|
if not enhanced_gridmap:
|
||||||
return
|
return
|
||||||
@@ -759,7 +759,7 @@ func clear_highlights():
|
|||||||
child.hide()
|
child.hide()
|
||||||
|
|
||||||
func clear_playerboard_highlights():
|
func clear_playerboard_highlights():
|
||||||
if is_bot or is_in_group("Bots") or not is_multiplayer_authority():
|
if is_bot == true or is_in_group("Bots") or not is_multiplayer_authority():
|
||||||
return
|
return
|
||||||
var main = get_tree().get_root().get_node_or_null("Main")
|
var main = get_tree().get_root().get_node_or_null("Main")
|
||||||
if main and main.playerboard_ui:
|
if main and main.playerboard_ui:
|
||||||
@@ -904,7 +904,7 @@ func consume_action_points(points: int):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Don't consume points for bots in non-turn-based mode
|
# Don't consume points for bots in non-turn-based mode
|
||||||
if is_bot and not main.turn_based_mode:
|
if is_bot == true and not main.turn_based_mode:
|
||||||
_after_action_completed()
|
_after_action_completed()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ func tick(actor: Node, blackboard: Blackboard) -> int:
|
|||||||
if actor.action_points <= 0:
|
if actor.action_points <= 0:
|
||||||
return FAILURE
|
return FAILURE
|
||||||
|
|
||||||
if not actor.is_bot and not actor.is_in_group("Bots"):
|
if not actor.is_bot == true and not actor.is_in_group("Bots"):
|
||||||
return FAILURE
|
return FAILURE
|
||||||
|
|
||||||
# Execute movement
|
# Execute movement
|
||||||
if actor.is_within_movement_range(target_pos):
|
if actor.is_within_movement_range(target_pos):
|
||||||
if actor.is_bot:
|
if actor.is_bot == true:
|
||||||
var path = actor.enhanced_gridmap.find_path(
|
var path = actor.enhanced_gridmap.find_path(
|
||||||
Vector2(actor.current_position),
|
Vector2(actor.current_position),
|
||||||
Vector2(target_pos),
|
Vector2(target_pos),
|
||||||
|
|||||||
@@ -1,27 +1,19 @@
|
|||||||
@tool
|
@tool
|
||||||
extends Blackboard
|
extends Blackboard
|
||||||
|
|
||||||
# Default values when initializing blackboard
|
|
||||||
var default_data = {
|
var default_data = {
|
||||||
"move_target": null, # Vector2i for movement target
|
"move_target": null,
|
||||||
"can_arrange": false, # Whether bot can arrange items
|
"current_action": "",
|
||||||
"can_grab": false, # Whether bot can grab items
|
"action_points": 3, # Adjust this value based on your game design
|
||||||
"can_put": false, # Whether bot can put items
|
"last_position": null,
|
||||||
"should_move": false, # Whether bot should move
|
"path": [],
|
||||||
"action_points": 0, # Current action points
|
"is_moving": false
|
||||||
"current_action": "", # Current action being performed
|
|
||||||
"item_to_grab": null, # Item to grab
|
|
||||||
"grab_position": null, # Position to grab from
|
|
||||||
"put_position": null, # Position to put item
|
|
||||||
"arrange_from": -1, # Slot to arrange from
|
|
||||||
"arrange_to": -1 # Slot to arrange to
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
if Engine.is_editor_hint():
|
if Engine.is_editor_hint():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Initialize with default values
|
|
||||||
for key in default_data:
|
for key in default_data:
|
||||||
if not has_value(key):
|
if not has_value(key):
|
||||||
set_value(key, default_data[key])
|
set_value(key, default_data[key])
|
||||||
|
|||||||
Reference in New Issue
Block a user