feat: update vfx
This commit is contained in:
@@ -389,6 +389,14 @@ func _execute_area_freeze(target_pos: Vector2i = Vector2i(-9999, -9999)):
|
||||
|
||||
SfxManager.rpc("play_rpc", "freeze")
|
||||
|
||||
# Floor VFX: cover the whole frozen area on every peer.
|
||||
var main_vfx = get_node_or_null("/root/Main")
|
||||
if main_vfx and main_vfx.has_method("play_freeze_floor_vfx"):
|
||||
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
|
||||
main_vfx.rpc("play_freeze_floor_vfx", center_pos.x, center_pos.y, radius, FREEZE_SLOW_DURATION)
|
||||
else:
|
||||
main_vfx.play_freeze_floor_vfx(center_pos.x, center_pos.y, radius, FREEZE_SLOW_DURATION)
|
||||
|
||||
if hit_count > 0 and player.is_multiplayer_authority():
|
||||
var is_sng = LobbyManager.is_game_mode(GameMode.Mode.STOP_N_GO)
|
||||
if not is_sng:
|
||||
@@ -403,44 +411,9 @@ func _execute_area_freeze(target_pos: Vector2i = Vector2i(-9999, -9999)):
|
||||
else:
|
||||
NotificationManager.send_message(player, "Hit %d Players!" % hit_count, NotificationManager.MessageType.GOAL)
|
||||
|
||||
# Visual Feedback (Layer 0 - Ground Level, matching Wall logic)
|
||||
if player.is_multiplayer_authority():
|
||||
var main_node = get_node_or_null("/root/Main")
|
||||
if main_node and main_node.has_method("sync_grid_items_batch"):
|
||||
var batch_data = []
|
||||
var restoration_data = [] # Stores {pos, item} to restore later
|
||||
|
||||
for rx in range(-radius, radius + 1):
|
||||
for rz in range(-radius, radius + 1):
|
||||
var cx = center_pos.x + rx
|
||||
var cz = center_pos.y + rz
|
||||
var pos = Vector3i(cx, 0, cz)
|
||||
|
||||
# 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():
|
||||
main_node.rpc("sync_grid_items_batch", batch_data)
|
||||
|
||||
# Removal timer with accurate restoration
|
||||
get_tree().create_timer(FREEZE_SLOW_DURATION).timeout.connect(func():
|
||||
var cl_node = get_node_or_null("/root/Main")
|
||||
if not cl_node: return
|
||||
var clear_batch = []
|
||||
for entry in restoration_data:
|
||||
var p = entry.pos
|
||||
# Only restore if it is STILL our Freeze tile
|
||||
if enhanced_gridmap.get_cell_item(p) == 5:
|
||||
clear_batch.append({"x": p.x, "y": 0, "z": p.z, "item": entry.item})
|
||||
if not clear_batch.is_empty():
|
||||
cl_node.rpc("sync_grid_items_batch", clear_batch)
|
||||
)
|
||||
# Visual feedback is the freeze-floor VFX (play_freeze_floor_vfx above). The
|
||||
# blue layer-0 highlight tiles were removed so only the VFX shows; the slow
|
||||
# effect is driven by active_freeze_zones / layer-2 checks, not these tiles.
|
||||
|
||||
|
||||
func _execute_block_floor(target_pos: Vector2i = Vector2i(-999, -999)):
|
||||
@@ -474,31 +447,40 @@ func _execute_block_floor(target_pos: Vector2i = Vector2i(-999, -999)):
|
||||
var main = get_node_or_null("/root/Main")
|
||||
if main and main.has_method("sync_grid_items_batch"):
|
||||
var batch_data = []
|
||||
var vfx_cells := PackedVector2Array()
|
||||
for n in neighbors:
|
||||
var pos = n.position
|
||||
if _is_position_blocked_by_stand(pos): continue
|
||||
|
||||
|
||||
var block_pos = Vector3i(pos.x, 0, pos.y)
|
||||
var original_item = enhanced_gridmap.get_cell_item(block_pos)
|
||||
|
||||
|
||||
# PROTECTED FLOOR CHECK: avoid overwriting Start (1), Safe (2), Finish (3), or Wall (4)
|
||||
var is_immutable = false
|
||||
if "immutable_items" in enhanced_gridmap:
|
||||
if original_item in enhanced_gridmap.immutable_items:
|
||||
is_immutable = true
|
||||
if original_item in [1, 2, 3, 4, 15, 16] or is_immutable: continue
|
||||
|
||||
|
||||
batch_data.append({"x": block_pos.x, "y": 0, "z": block_pos.z, "item": 4})
|
||||
|
||||
vfx_cells.append(Vector2(block_pos.x, block_pos.z))
|
||||
|
||||
# Record for restoration
|
||||
blocked_tiles.append({
|
||||
"position": block_pos,
|
||||
"original_item": original_item,
|
||||
"timer": BLOCK_DURATION
|
||||
})
|
||||
|
||||
|
||||
if not batch_data.is_empty():
|
||||
main.rpc("sync_grid_items_batch", batch_data)
|
||||
|
||||
# Block VFX: one box_block per cell, animated, on every peer.
|
||||
if not vfx_cells.is_empty() and main.has_method("play_block_floor_vfx"):
|
||||
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
|
||||
main.rpc("play_block_floor_vfx", vfx_cells, BLOCK_DURATION)
|
||||
else:
|
||||
main.play_block_floor_vfx(vfx_cells, BLOCK_DURATION)
|
||||
|
||||
# Notify
|
||||
SfxManager.rpc("play_rpc", "wall")
|
||||
|
||||
Reference in New Issue
Block a user