Minor Update
- Refactor the Player.gd - Attempt to fix joining the available room, via Room ID
This commit is contained in:
@@ -4,6 +4,7 @@ extends Node
|
||||
|
||||
var player: Node3D
|
||||
var enhanced_gridmap: Node
|
||||
var highlighted_cells = []
|
||||
|
||||
func initialize(p_player: Node3D, p_gridmap: Node):
|
||||
player = p_player
|
||||
@@ -56,7 +57,7 @@ func after_action_completed():
|
||||
if main:
|
||||
# Add this condition for bots
|
||||
if not TurnManager.turn_based_mode and (player.action_points <= 0 or player.is_bot):
|
||||
player.action_points = 20 # For bots in non-turn-based mode, this will keep refreshing
|
||||
player.action_points = 20 # For bots in non-turn-based mode, this will keep refreshing
|
||||
player.has_performed_action = false
|
||||
player.has_moved_this_turn = false
|
||||
|
||||
@@ -82,9 +83,9 @@ func highlight_cells_if_authorized(cells_to_highlight: Array):
|
||||
|
||||
clear_highlights()
|
||||
for cell in cells_to_highlight:
|
||||
player.highlighted_cells.append(cell)
|
||||
highlighted_cells.append(cell)
|
||||
enhanced_gridmap.set_cell_item(
|
||||
Vector3i(cell.x, 0, cell.y),
|
||||
Vector3i(cell.x, 0, cell.y),
|
||||
enhanced_gridmap.hover_item
|
||||
)
|
||||
|
||||
@@ -101,8 +102,8 @@ func highlight_empty_adjacent_cells():
|
||||
# Highlight current position if empty
|
||||
var current_cell = Vector3i(player.current_position.x, 1, player.current_position.y)
|
||||
if enhanced_gridmap.get_cell_item(current_cell) == -1:
|
||||
player.highlighted_cells.append(player.current_position)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 0, player.current_position.y),
|
||||
highlighted_cells.append(player.current_position)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 0, player.current_position.y),
|
||||
enhanced_gridmap.hover_item)
|
||||
print("Highlighted current position: ", player.current_position)
|
||||
|
||||
@@ -112,9 +113,9 @@ func highlight_empty_adjacent_cells():
|
||||
if neighbor.is_walkable:
|
||||
var cell_pos = neighbor.position
|
||||
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
|
||||
if enhanced_gridmap.get_cell_item(cell) == -1: # Check if cell is empty
|
||||
player.highlighted_cells.append(cell_pos)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 0, cell_pos.y),
|
||||
if enhanced_gridmap.get_cell_item(cell) == -1: # Check if cell is empty
|
||||
highlighted_cells.append(cell_pos)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 0, cell_pos.y),
|
||||
enhanced_gridmap.hover_item)
|
||||
print("Highlighted adjacent cell: ", cell_pos)
|
||||
|
||||
@@ -128,8 +129,8 @@ func highlight_random_valid_cells():
|
||||
var current_cell = Vector3i(player.current_position.x, 1, player.current_position.y)
|
||||
var current_item = enhanced_gridmap.get_cell_item(current_cell)
|
||||
if current_item != -1:
|
||||
player.highlighted_cells.append(player.current_position)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 0, player.current_position.y),
|
||||
highlighted_cells.append(player.current_position)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 0, player.current_position.y),
|
||||
enhanced_gridmap.hover_item)
|
||||
|
||||
# Then check all adjacent cells for items
|
||||
@@ -138,9 +139,9 @@ func highlight_random_valid_cells():
|
||||
if neighbor.is_walkable:
|
||||
var cell_pos = neighbor.position
|
||||
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
|
||||
if enhanced_gridmap.get_cell_item(cell) != -1: # Only highlight cells with items
|
||||
player.highlighted_cells.append(cell_pos)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 0, cell_pos.y),
|
||||
if enhanced_gridmap.get_cell_item(cell) != -1: # Only highlight cells with items
|
||||
highlighted_cells.append(cell_pos)
|
||||
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 0, cell_pos.y),
|
||||
enhanced_gridmap.hover_item)
|
||||
|
||||
func highlight_occupied_playerboard_slots():
|
||||
@@ -162,8 +163,8 @@ func highlight_occupied_playerboard_slots():
|
||||
if player.playerboard[i] in player.goals:
|
||||
var slot = main.ui_manager.playerboard_ui.get_child(i)
|
||||
if slot.get_child_count() > 0:
|
||||
slot.get_child(0).show() # Show highlight for matching items
|
||||
player.highlighted_cells.append(i) # Add to highlighted cells for tracking
|
||||
slot.get_child(0).show() # Show highlight for matching items
|
||||
highlighted_cells.append(i) # Add to highlighted cells for tracking
|
||||
|
||||
# Update the UI to reflect changes
|
||||
main.ui_manager.update_playerboard_ui()
|
||||
@@ -180,7 +181,7 @@ func highlight_valid_obstacle_cells():
|
||||
for x in range(enhanced_gridmap.columns):
|
||||
for z in range(enhanced_gridmap.rows):
|
||||
var pos = Vector2i(x, z)
|
||||
var cell = Vector3i(x, 3, z) # Check floor 3 for occupancy
|
||||
var cell = Vector3i(x, 3, z) # Check floor 3 for occupancy
|
||||
var occupied_by_player = false
|
||||
var occupied_by_obstacle = false
|
||||
|
||||
@@ -212,11 +213,11 @@ func clear_highlights():
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
var current_state = main.ui_manager.current_action_state if main else null
|
||||
|
||||
for cell in player.highlighted_cells:
|
||||
for cell in highlighted_cells:
|
||||
if cell is Vector2i:
|
||||
enhanced_gridmap.set_cell_item(Vector3i(cell.x, 0, cell.y), enhanced_gridmap.normal_items[0])
|
||||
|
||||
player.highlighted_cells.clear()
|
||||
highlighted_cells.clear()
|
||||
|
||||
if main and main.ui_manager.playerboard_ui:
|
||||
for i in range(main.ui_manager.playerboard_ui.get_child_count()):
|
||||
@@ -244,4 +245,4 @@ func clear_playerboard_highlights():
|
||||
if slot.get_child_count() > 1: slot.get_child(1).hide()
|
||||
if slot.get_child_count() > 2: slot.get_child(2).hide()
|
||||
|
||||
player.highlighted_cells.clear()
|
||||
highlighted_cells.clear()
|
||||
|
||||
Reference in New Issue
Block a user