feat: Introduce PlayerMovementManager to centralize grid-based player and bot movement, including multiplayer synchronization and push interactions.

This commit is contained in:
Yogi Wiguna
2026-03-05 15:32:45 +08:00
parent fb6d9df5db
commit aa26e9f2a4
3 changed files with 93 additions and 13 deletions
+20 -9
View File
@@ -168,20 +168,31 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
# === NEW LOGIC: Only allow push if in ATTACK MODE ===
if not player.get("is_attack_mode"):
# Standard bumping effect or nothing?
print("[Move] Push blocked: Not in attack mode (%s trying to push)" % player.name)
# Standard bumping effect (Visual only)
print("[Move] Push blocked: Not in attack mode (%s trying to push %s)" % [player.name, other_player.name])
if _can_rpc():
player.rpc("sync_bump", target_pos, true) # Soft bump
elif player.has_method("sync_bump"):
player.sync_bump(target_pos, true)
return false
# === SUPER PUSH (Attack Mode) ===
print("Player %s SUPER PUSHING %s!" % [player.name, other_player.name])
# SAFE ZONE PROTECTION
# Columns 6, 7, 8 and 14, 15, 16 are Safe Zones
var safe_columns = [6, 7, 8, 14, 15, 16]
if target_pos.x in safe_columns:
print(" - Attack BLOCKED by Safe Zone!")
NotificationManager.send_message(player, "Cannot Attack in Safe Zone!", NotificationManager.MessageType.WARNING)
return false
# Visual Feedback: Attack Bump
if _can_rpc():
player.rpc("sync_bump", target_pos, false) # Attack bump
elif player.has_method("sync_bump"):
player.sync_bump(target_pos, false)
# SAFE ZONE PROTECTION (Only in Stop n Go)
if LobbyManager.is_game_mode(GameMode.Mode.STOP_N_GO):
# Columns 6, 7, 8 and 14, 15, 16 are Safe Zones
var safe_columns = [6, 7, 8, 14, 15, 16]
if target_pos.x in safe_columns:
print(" - Attack BLOCKED by Safe Zone!")
NotificationManager.send_message(player, "Cannot Attack in Safe Zone!", NotificationManager.MessageType.WARNING)
return false
# 1. 3-Floor Knockback towards Starting Line (X=0)
var push_direction = Vector2i(-1, 0) # Backwards