feat: Implement player input and movement managers for grid-based interaction and movement.
This commit is contained in:
+41
-2
@@ -1951,7 +1951,40 @@ func sync_throw_tekton(target_pos: Vector2i):
|
|||||||
|
|
||||||
print("[Player %s] Threw Tekton to %s (Dist: %s)" % [name, target_pos, target_pos.distance_to(tekton.current_position)])
|
print("[Player %s] Threw Tekton to %s (Dist: %s)" % [name, target_pos, target_pos.distance_to(tekton.current_position)])
|
||||||
|
|
||||||
|
# is_attack_mode is already declared at top of file (or inherited?)
|
||||||
|
# Keeping is_knock_mode here for now or moving it up would be better, but let's just fix the error first.
|
||||||
|
var is_knock_mode: bool = false # Yellow mode for knocking Tekton
|
||||||
|
|
||||||
|
func enter_attack_mode():
|
||||||
|
if not is_multiplayer_authority(): return
|
||||||
|
|
||||||
|
is_attack_mode = true
|
||||||
|
is_knock_mode = false # Mutually exclusive
|
||||||
|
NotificationManager.send_message(self, "Attack Mode ACTIVATED (Red)", NotificationManager.MessageType.POWERUP)
|
||||||
|
update_active_player_indicator()
|
||||||
|
|
||||||
|
func enter_knock_mode():
|
||||||
|
if not is_multiplayer_authority(): return
|
||||||
|
|
||||||
|
is_knock_mode = true
|
||||||
|
is_attack_mode = false # Mutually exclusive
|
||||||
|
NotificationManager.send_message(self, "Knock Mode ACTIVATED (Yellow)", NotificationManager.MessageType.POWERUP)
|
||||||
|
update_active_player_indicator()
|
||||||
|
|
||||||
|
func update_active_player_indicator():
|
||||||
|
var color = Color.WHITE
|
||||||
|
|
||||||
|
if is_attack_mode:
|
||||||
|
color = Color.RED
|
||||||
|
elif is_knock_mode:
|
||||||
|
color = Color.YELLOW
|
||||||
|
|
||||||
|
# Apply visual tint to character model across network
|
||||||
|
rpc("sync_modulate", color)
|
||||||
|
|
||||||
func knock_tekton():
|
func knock_tekton():
|
||||||
|
# ... legacy or helper function ...
|
||||||
|
pass
|
||||||
if not is_multiplayer_authority() or is_frozen:
|
if not is_multiplayer_authority() or is_frozen:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1968,12 +2001,18 @@ func knock_tekton():
|
|||||||
if is_multiplayer_authority():
|
if is_multiplayer_authority():
|
||||||
rpc("sync_knock_tekton", tekton.get_path())
|
rpc("sync_knock_tekton", tekton.get_path())
|
||||||
|
|
||||||
|
# Reset Knock Mode after successful hit
|
||||||
|
is_knock_mode = false
|
||||||
|
NotificationManager.send_message(self, "Knock Successful!", NotificationManager.MessageType.POWERUP)
|
||||||
|
update_active_player_indicator()
|
||||||
|
|
||||||
@rpc("any_peer", "call_local", "reliable")
|
@rpc("any_peer", "call_local", "reliable")
|
||||||
func sync_knock_tekton(tekton_path: NodePath):
|
func sync_knock_tekton(tekton_path: NodePath):
|
||||||
var tekton = get_node_or_null(tekton_path)
|
var tekton = get_node_or_null(tekton_path)
|
||||||
if tekton:
|
if tekton:
|
||||||
# Intensity 2.0 for knock (drops 200% tiles)
|
# Intensity 2.0 for knock (drops 200% tiles) + Shrink/Recover
|
||||||
tekton.on_hit(self , 2.0)
|
# Use on_thrown_landing to trigger shrink animation and floor freeze
|
||||||
|
tekton.on_thrown_landing(self, 2.0)
|
||||||
print("[Player %s] Knocked Tekton %s" % [name, tekton.name])
|
print("[Player %s] Knocked Tekton %s" % [name, tekton.name])
|
||||||
|
|
||||||
# Visual feedback (Juice)
|
# Visual feedback (Juice)
|
||||||
|
|||||||
@@ -102,7 +102,15 @@ func handle_unhandled_input(event):
|
|||||||
KEY_Q:
|
KEY_Q:
|
||||||
if player.powerup_manager:
|
if player.powerup_manager:
|
||||||
# Attack Mode (formerly Special)
|
# Attack Mode (formerly Special)
|
||||||
|
# Now we want "Straight to Attack Mode" style
|
||||||
|
|
||||||
player.powerup_manager.use_special_effect()
|
player.powerup_manager.use_special_effect()
|
||||||
|
|
||||||
|
# Force visual update / mutual exclusivity manually if powerup manager doesn't do it yet
|
||||||
|
if player.is_attack_mode and player.has_method("enter_attack_mode"):
|
||||||
|
# Re-triggering enter_attack_mode might be redundant but safely ensures visuals/Knock=False
|
||||||
|
player.enter_attack_mode()
|
||||||
|
|
||||||
KEY_E:
|
KEY_E:
|
||||||
if player.powerup_manager:
|
if player.powerup_manager:
|
||||||
# Spawn Boost
|
# Spawn Boost
|
||||||
@@ -117,7 +125,10 @@ func handle_unhandled_input(event):
|
|||||||
else:
|
else:
|
||||||
player.grab_tekton()
|
player.grab_tekton()
|
||||||
KEY_B:
|
KEY_B:
|
||||||
player.knock_tekton()
|
if player.has_method("enter_knock_mode"):
|
||||||
|
player.enter_knock_mode()
|
||||||
|
else:
|
||||||
|
player.knock_tekton()
|
||||||
|
|
||||||
# Handle spawn point selection if not yet selected
|
# Handle spawn point selection if not yet selected
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,18 @@ func simple_move_to(grid_position: Vector2i) -> bool:
|
|||||||
if not try_push(grid_position, push_dir):
|
if not try_push(grid_position, push_dir):
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
# Check for Tekton interaction (Knock Mode)
|
||||||
|
# If moving into a Tekton's space while in Knock Mode, trigger knock
|
||||||
|
if player.get("is_knock_mode"):
|
||||||
|
# Find Tekton at grid_position
|
||||||
|
var tektons = player.get_tree().get_nodes_in_group("Tektons")
|
||||||
|
for t in tektons:
|
||||||
|
if t.current_position == grid_position and not t.is_carried:
|
||||||
|
# Trigger Knock
|
||||||
|
player.knock_tekton()
|
||||||
|
return false # Don't move into the tile, just knock
|
||||||
|
|
||||||
|
|
||||||
rotate_towards_target(grid_position)
|
rotate_towards_target(grid_position)
|
||||||
|
|
||||||
if player.is_multiplayer_authority() and player.has_method("sync_walk_animation"):
|
if player.is_multiplayer_authority() and player.has_method("sync_walk_animation"):
|
||||||
|
|||||||
+6
-4
@@ -148,9 +148,11 @@ func _flash_damage():
|
|||||||
var is_recovering: bool = false # True when shrunk/waiting
|
var is_recovering: bool = false # True when shrunk/waiting
|
||||||
|
|
||||||
@rpc("any_peer", "call_local", "reliable")
|
@rpc("any_peer", "call_local", "reliable")
|
||||||
func on_thrown_landing(attacker: Node = null):
|
func on_thrown_landing(attacker: Node = null, intensity: float = 1.0):
|
||||||
"""Called when Tekton lands after being thrown."""
|
"""Called when Tekton lands after being thrown or knocked."""
|
||||||
print("[Tekton] Landed! Shrinking and waiting...")
|
print("[Tekton] Landed/Knocked! Shrinking and waiting... (Intensity: %.1f)" % intensity)
|
||||||
|
|
||||||
|
_flash_damage() # Add visual flash too? Why not.
|
||||||
|
|
||||||
is_recovering = true
|
is_recovering = true
|
||||||
|
|
||||||
@@ -194,7 +196,7 @@ func on_thrown_landing(attacker: Node = null):
|
|||||||
|
|
||||||
# Spawn tiles (as requested "tekton will spawn a tiles around that floor also")
|
# Spawn tiles (as requested "tekton will spawn a tiles around that floor also")
|
||||||
if is_multiplayer_authority():
|
if is_multiplayer_authority():
|
||||||
spawn_tiles_around(8) # Standard amount
|
spawn_tiles_around(int(8 * intensity))
|
||||||
|
|
||||||
# Floor Freeze (Visual/Instant - Run on all clients locally)
|
# Floor Freeze (Visual/Instant - Run on all clients locally)
|
||||||
temporarily_change_floor(current_position, 1, 6, 3.0)
|
temporarily_change_floor(current_position, 1, 6, 3.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user