attempt to make stop n go gamemode

This commit is contained in:
2026-02-19 03:42:59 +08:00
parent 4ce917db0f
commit a7a8106b7e
11 changed files with 516 additions and 28 deletions
+8 -6
View File
@@ -165,7 +165,7 @@ func add_powerup_from_item(item_id: int):
emit_signal("powerup_unlocked", effect, powerup_levels[effect])
print("Player %s leveled up %s to Lvl %d" % [player.name, SpecialEffect.keys()[effect], powerup_levels[effect]])
if player.is_multiplayer_authority():
if player.is_multiplayer_authority() and multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
rpc("sync_inventory_add", effect, powerup_levels[effect])
@rpc("any_peer", "call_local", "reliable")
@@ -254,7 +254,7 @@ func activate_effect(effect: int, target_player: Node3D = null):
_execute_invisible_mode(player)
# Play generic cast animation or sound?
if player.is_multiplayer_authority():
if player.is_multiplayer_authority() and multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
player.rpc("trigger_screen_shake", "light")
# Sync cooldown to others not strictly needed unless UI shows it?
# Probably local UI only.
@@ -308,7 +308,8 @@ func _execute_area_freeze(center_pos: Vector2i = Vector2i.ZERO):
# If inside square radius
if dx <= radius and dy <= radius:
p.rpc("apply_slow_effect", FREEZE_SLOW_DURATION)
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
p.rpc("apply_slow_effect", FREEZE_SLOW_DURATION)
NotificationManager.send_message(p, "Caught in Freeze Zone!", NotificationManager.MessageType.WARNING)
if p != player: # Don't score for freezing self (unless desired?) - Assuming enemies
hit_count += 1
@@ -336,7 +337,8 @@ func _execute_area_freeze(center_pos: Vector2i = Vector2i.ZERO):
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)
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
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():
@@ -404,7 +406,7 @@ func _execute_block_floor(target_pos: Vector2i):
if player.is_multiplayer_authority():
var main = player.get_tree().get_root().get_node_or_null("Main")
if main:
if main and multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
main.rpc("sync_grid_item", block_pos.x, block_pos.y, block_pos.z, 4)
# Record for restoration
@@ -462,7 +464,7 @@ func spawn_powerups_around(center: Vector2i, force_powerups: bool = true):
if player.is_multiplayer_authority():
var main = player.get_tree().get_root().get_node_or_null("Main")
if main:
if main and multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
main.rpc("sync_grid_item", cell.x, cell.y, cell.z, item_id)