feat: Introduce PlayerActionManager for action point and grid highlighting, SpecialTilesManager for special tile effects, and a tile_freeze mesh resource.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
[gd_resource type="BoxMesh" format=3 uid="uid://b5cc3prem52r6"]
|
[gd_resource type="BoxMesh" format=3 uid="uid://b5cc3prem52r6"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e3p1j"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e3p1j"]
|
||||||
transparency = 1
|
|
||||||
albedo_color = Color(0.38039216, 1, 0.9607843, 0.5)
|
albedo_color = Color(0.38039216, 1, 0.9607843, 0.5)
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ extends Node
|
|||||||
|
|
||||||
var player: Node3D
|
var player: Node3D
|
||||||
var enhanced_gridmap: Node
|
var enhanced_gridmap: Node
|
||||||
var highlighted_cells = []
|
var highlighted_cells = [] # List of positions
|
||||||
|
# highlight_restore_items no longer needed for Layer 2
|
||||||
|
|
||||||
func initialize(p_player: Node3D, p_gridmap: Node):
|
func initialize(p_player: Node3D, p_gridmap: Node):
|
||||||
player = p_player
|
player = p_player
|
||||||
@@ -76,7 +77,7 @@ func highlight_cells_if_authorized(cells_to_highlight: Array, item_id: int = -1)
|
|||||||
|
|
||||||
for cell in cells_to_highlight:
|
for cell in cells_to_highlight:
|
||||||
highlighted_cells.append(cell)
|
highlighted_cells.append(cell)
|
||||||
# Use Layer 2 for overlay highlights
|
# Use Layer 2 for overlay highlights (prevents overwriting Execution on Layer 0)
|
||||||
enhanced_gridmap.set_cell_item(
|
enhanced_gridmap.set_cell_item(
|
||||||
Vector3i(cell.x, 2, cell.y),
|
Vector3i(cell.x, 2, cell.y),
|
||||||
highlight_item
|
highlight_item
|
||||||
@@ -96,6 +97,7 @@ func highlight_empty_adjacent_cells():
|
|||||||
var current_cell = Vector3i(player.current_position.x, 1, player.current_position.y)
|
var current_cell = Vector3i(player.current_position.x, 1, player.current_position.y)
|
||||||
if enhanced_gridmap.get_cell_item(current_cell) == -1:
|
if enhanced_gridmap.get_cell_item(current_cell) == -1:
|
||||||
highlighted_cells.append(player.current_position)
|
highlighted_cells.append(player.current_position)
|
||||||
|
# Set on Layer 2 (Overlay)
|
||||||
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 2, player.current_position.y),
|
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 2, player.current_position.y),
|
||||||
enhanced_gridmap.hover_item)
|
enhanced_gridmap.hover_item)
|
||||||
print("Highlighted current position: ", player.current_position)
|
print("Highlighted current position: ", player.current_position)
|
||||||
@@ -108,6 +110,7 @@ func highlight_empty_adjacent_cells():
|
|||||||
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
|
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
|
||||||
if enhanced_gridmap.get_cell_item(cell) == -1: # Check if cell is empty
|
if enhanced_gridmap.get_cell_item(cell) == -1: # Check if cell is empty
|
||||||
highlighted_cells.append(cell_pos)
|
highlighted_cells.append(cell_pos)
|
||||||
|
# Set on Layer 2 (Overlay)
|
||||||
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 2, cell_pos.y),
|
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 2, cell_pos.y),
|
||||||
enhanced_gridmap.hover_item)
|
enhanced_gridmap.hover_item)
|
||||||
print("Highlighted adjacent cell: ", cell_pos)
|
print("Highlighted adjacent cell: ", cell_pos)
|
||||||
@@ -123,6 +126,7 @@ func highlight_random_valid_cells():
|
|||||||
var current_item = enhanced_gridmap.get_cell_item(current_cell)
|
var current_item = enhanced_gridmap.get_cell_item(current_cell)
|
||||||
if current_item != -1:
|
if current_item != -1:
|
||||||
highlighted_cells.append(player.current_position)
|
highlighted_cells.append(player.current_position)
|
||||||
|
# Set on Layer 2 (Overlay)
|
||||||
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 2, player.current_position.y),
|
enhanced_gridmap.set_cell_item(Vector3i(player.current_position.x, 2, player.current_position.y),
|
||||||
enhanced_gridmap.hover_item)
|
enhanced_gridmap.hover_item)
|
||||||
|
|
||||||
@@ -134,6 +138,7 @@ func highlight_random_valid_cells():
|
|||||||
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
|
var cell = Vector3i(cell_pos.x, 1, cell_pos.y)
|
||||||
if enhanced_gridmap.get_cell_item(cell) != -1: # Only highlight cells with items
|
if enhanced_gridmap.get_cell_item(cell) != -1: # Only highlight cells with items
|
||||||
highlighted_cells.append(cell_pos)
|
highlighted_cells.append(cell_pos)
|
||||||
|
# Set on Layer 2 (Overlay)
|
||||||
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 2, cell_pos.y),
|
enhanced_gridmap.set_cell_item(Vector3i(cell_pos.x, 2, cell_pos.y),
|
||||||
enhanced_gridmap.hover_item)
|
enhanced_gridmap.hover_item)
|
||||||
|
|
||||||
|
|||||||
@@ -400,34 +400,41 @@ func _execute_area_freeze(target_pos: Vector2i = Vector2i(-9999, -9999)):
|
|||||||
else:
|
else:
|
||||||
NotificationManager.send_message(player, "Hit %d Players!" % hit_count, NotificationManager.MessageType.GOAL)
|
NotificationManager.send_message(player, "Hit %d Players!" % hit_count, NotificationManager.MessageType.GOAL)
|
||||||
|
|
||||||
# Visual Feedback (Layer 2 - Overlay Level)
|
# Visual Feedback (Layer 0 - Ground Level, matching Wall logic)
|
||||||
if player.is_multiplayer_authority():
|
if player.is_multiplayer_authority():
|
||||||
var main_node = get_node_or_null("/root/Main")
|
var main_node = get_node_or_null("/root/Main")
|
||||||
if main_node and main_node.has_method("sync_grid_items_batch"):
|
if main_node and main_node.has_method("sync_grid_items_batch"):
|
||||||
var batch_data = []
|
var batch_data = []
|
||||||
|
var restoration_data = [] # Stores {pos, item} to restore later
|
||||||
|
|
||||||
for rx in range(-radius, radius + 1):
|
for rx in range(-radius, radius + 1):
|
||||||
for rz in range(-radius, radius + 1):
|
for rz in range(-radius, radius + 1):
|
||||||
var cell_x = center_pos.x + rx
|
var cx = center_pos.x + rx
|
||||||
var cell_z = center_pos.y + rz
|
var cz = center_pos.y + rz
|
||||||
# Put back on Layer 2 (Overlay) as requested
|
var pos = Vector3i(cx, 0, cz)
|
||||||
batch_data.append({"x": cell_x, "y": 2, "z": cell_z, "item": 5})
|
|
||||||
|
# Get original ground item to restore later
|
||||||
|
var original_ground = enhanced_gridmap.get_cell_item(pos)
|
||||||
|
|
||||||
|
# Ignore if it is an immutable tile (Safe Zone 2, Wall 4, etc)
|
||||||
|
if original_ground in [1, 2, 3, 4, 15, 16]: continue
|
||||||
|
|
||||||
|
restoration_data.append({"pos": pos, "item": original_ground})
|
||||||
|
batch_data.append({"x": cx, "y": 0, "z": cz, "item": 5})
|
||||||
|
|
||||||
if not batch_data.is_empty():
|
if not batch_data.is_empty():
|
||||||
main_node.rpc("sync_grid_items_batch", batch_data)
|
main_node.rpc("sync_grid_items_batch", batch_data)
|
||||||
|
|
||||||
# Removal timer
|
# Removal timer with accurate restoration
|
||||||
get_tree().create_timer(FREEZE_SLOW_DURATION).timeout.connect(func():
|
get_tree().create_timer(FREEZE_SLOW_DURATION).timeout.connect(func():
|
||||||
var cl_node = get_node_or_null("/root/Main")
|
var cl_node = get_node_or_null("/root/Main")
|
||||||
if not cl_node: return
|
if not cl_node: return
|
||||||
var clear_batch = []
|
var clear_batch = []
|
||||||
for rx in range(-radius, radius + 1):
|
for entry in restoration_data:
|
||||||
for rz in range(-radius, radius + 1):
|
var p = entry.pos
|
||||||
var cx = center_pos.x + rx
|
# Only restore if it is STILL our Freeze tile
|
||||||
var cz = center_pos.y + rz
|
if enhanced_gridmap.get_cell_item(p) == 5:
|
||||||
# Check if it is STILL Freeze Overlay on Layer 2
|
clear_batch.append({"x": p.x, "y": 0, "z": p.z, "item": entry.item})
|
||||||
if enhanced_gridmap.get_cell_item(Vector3i(cx, 2, cz)) == 5:
|
|
||||||
# Remove Item (back to -1)
|
|
||||||
clear_batch.append({"x": cx, "y": 2, "z": cz, "item": -1})
|
|
||||||
if not clear_batch.is_empty():
|
if not clear_batch.is_empty():
|
||||||
cl_node.rpc("sync_grid_items_batch", clear_batch)
|
cl_node.rpc("sync_grid_items_batch", clear_batch)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user