feat: Add PlayerActionManager for handling player actions and highlights, and SpecialTilesManager for managing special tile effects and powerups.
This commit is contained in:
@@ -85,8 +85,9 @@ func highlight_cells_if_authorized(cells_to_highlight: Array, item_id: int = -1)
|
||||
|
||||
for cell in cells_to_highlight:
|
||||
highlighted_cells.append(cell)
|
||||
# Use Layer 2 for overlay highlights (prevents overwriting walls on Layer 0)
|
||||
enhanced_gridmap.set_cell_item(
|
||||
Vector3i(cell.x, 0, cell.y),
|
||||
Vector3i(cell.x, 2, cell.y),
|
||||
highlight_item
|
||||
)
|
||||
|
||||
@@ -182,10 +183,25 @@ func clear_highlights():
|
||||
# Store the current action state before clearing
|
||||
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
|
||||
|
||||
|
||||
var hover_id = enhanced_gridmap.hover_item
|
||||
|
||||
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])
|
||||
# Check Layer 2 (Overlay Highlight)
|
||||
var l2_pos = Vector3i(cell.x, 2, cell.y)
|
||||
var l2_item = enhanced_gridmap.get_cell_item(l2_pos)
|
||||
# Only clear if it looks like a highlight (e.g. ID 1)
|
||||
# or generally just clear layer 2 if we assume we own it for highlights?
|
||||
# Safest is to check against hover_id or typical highlight IDs.
|
||||
if l2_item != -1:
|
||||
enhanced_gridmap.set_cell_item(l2_pos, -1)
|
||||
|
||||
# Check Layer 0 (Floor Highlight)
|
||||
var l0_pos = Vector3i(cell.x, 0, cell.y)
|
||||
var l0_item = enhanced_gridmap.get_cell_item(l0_pos)
|
||||
if l0_item == hover_id:
|
||||
enhanced_gridmap.set_cell_item(l0_pos, enhanced_gridmap.normal_items[0])
|
||||
|
||||
highlighted_cells.clear()
|
||||
|
||||
|
||||
@@ -312,8 +312,12 @@ func _execute_area_freeze(center_pos: Vector2i = Vector2i.ZERO):
|
||||
var pos = center_pos + Vector2i(x, y)
|
||||
if enhanced_gridmap.is_position_valid(pos):
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
# Use Item 12 (Blue Freeze Tile) on Layer 0 (Floor)
|
||||
if main: main.rpc("sync_grid_item", pos.x, 0, pos.y, 12)
|
||||
if main:
|
||||
# CHECK: Don't overwrite Wall Block (Item 4)
|
||||
var current_item = enhanced_gridmap.get_cell_item(Vector3i(pos.x, 0, pos.y))
|
||||
if current_item != 4: # 4 is Wall Block
|
||||
# Use Item 12 (Blue Freeze Tile) on Layer 0 (Floor)
|
||||
main.rpc("sync_grid_item", pos.x, 0, pos.y, 12)
|
||||
|
||||
# Cleanup visual timer (managed locally by author)
|
||||
get_tree().create_timer(FREEZE_SLOW_DURATION).timeout.connect(func():
|
||||
@@ -322,8 +326,13 @@ func _execute_area_freeze(center_pos: Vector2i = Vector2i.ZERO):
|
||||
var pos = center_pos + Vector2i(x, y)
|
||||
if enhanced_gridmap.is_position_valid(pos):
|
||||
var main = player.get_tree().get_root().get_node_or_null("Main")
|
||||
# Restore to Item 0 (Standard Floor)
|
||||
if main: main.rpc("sync_grid_item", pos.x, 0, pos.y, 0)
|
||||
if main:
|
||||
# CHECK: Only restore if it is STILL Ice (Item 12)
|
||||
# This prevents removing a Wall that was placed AFTER the freeze started
|
||||
var current_check = enhanced_gridmap.get_cell_item(Vector3i(pos.x, 0, pos.y))
|
||||
if current_check == 12:
|
||||
# Restore to Item 0 (Standard Floor)
|
||||
main.rpc("sync_grid_item", pos.x, 0, pos.y, 0)
|
||||
)
|
||||
|
||||
func toggle_wall_orientation():
|
||||
|
||||
Reference in New Issue
Block a user