delete files in nickes

This commit is contained in:
2026-01-11 03:34:14 +01:00
parent b692b4f39d
commit 9b55af2e67
46 changed files with 2237 additions and 654 deletions

View File

@@ -17,6 +17,7 @@ var is_local_player: bool = false
var can_send_rpcs: bool = false # Flag to prevent RPCs until player is fully initialized
var all_clients_ready: bool = false # Server only: true when all clients have notified they're ready
var all_clients_ready_time: float = 0.0 # Server only: time when all_clients_ready was set to true
var teleported_this_frame: bool = false # Flag to prevent position sync from overriding teleportation
# Input device (for local multiplayer)
var input_device: int = -1 # -1 for keyboard, 0+ for gamepad index
@@ -37,6 +38,7 @@ var push_direction_locked: int = Direction.DOWN # Locked facing direction when p
var initial_grab_position = Vector2.ZERO # Position of grabbed object when first grabbed
var initial_player_position = Vector2.ZERO # Position of player when first grabbed
var object_blocked_by_wall = false # True if pushed object is blocked by a wall
var was_dragging_last_frame = false # Track if we were dragging last frame to detect start/stop
# Being held state
var being_held_by: Node = null
@@ -720,6 +722,9 @@ func _update_z_physics(delta):
shadow.modulate.a = 0.5
func _physics_process(delta):
# Reset teleport flag at start of frame
teleported_this_frame = false
# Update animations
_update_animation(delta)
@@ -963,6 +968,27 @@ func _handle_input():
if current_animation != "THROW" and current_animation != "DAMAGE" and current_animation != "SWORD":
_set_animation("IDLE")
# Handle drag sound for interactable objects
var is_dragging_now = false
if held_object and is_pushing and not is_lifting:
# Player is pushing (not lifting) - check if moving
if input_vector.length() > 0.1 and not object_blocked_by_wall:
# Player is moving while pushing - this is dragging
is_dragging_now = true
# Continuously play drag sound while dragging (method checks if already playing)
if held_object.has_method("play_drag_sound"):
held_object.play_drag_sound()
# Stop drag sound when stopping or not dragging
if not is_dragging_now and was_dragging_last_frame:
# Stopped dragging - stop drag sound
if held_object and held_object.has_method("stop_drag_sound"):
held_object.stop_drag_sound()
# Update drag state for next frame
was_dragging_last_frame = is_dragging_now
# Reduce speed by half when pushing/pulling
var current_speed = move_speed * (0.5 if is_pushing else 1.0)
velocity = input_vector * current_speed
@@ -1263,6 +1289,7 @@ func _lift_object():
_sync_grab.rpc(held_object.get_path(), true, push_axis)
print("Lifted: ", held_object.name)
$SfxLift.play()
func _start_pushing():
if not held_object:
@@ -1321,6 +1348,11 @@ func _stop_pushing():
is_pushing = false
push_axis = Vector2.ZERO
# Stop drag sound when releasing object
if held_object and held_object.has_method("stop_drag_sound"):
held_object.stop_drag_sound()
was_dragging_last_frame = false # Reset drag state
# Store reference and CURRENT position - don't change it!
var released_obj = held_object
var released_obj_position = released_obj.global_position # Store exact position
@@ -1443,6 +1475,7 @@ func _throw_object():
# Play throw animation
_set_animation("THROW")
$SfxThrow.play()
# Sync throw over network
if multiplayer.has_multiplayer_peer() and is_multiplayer_authority() and can_send_rpcs and is_inside_tree():
@@ -1887,6 +1920,19 @@ func _sync_place_down(obj_path: NodePath, place_pos: Vector2):
if obj.has_method("set_being_held"):
obj.set_being_held(false)
@rpc("any_peer", "reliable")
func _sync_teleport_position(new_pos: Vector2):
# Sync teleport position from server to clients
# Server calls this to teleport any player (even if client has authority over their own player)
# Only update if we're not on the server (server already set position directly)
if not multiplayer.is_server():
global_position = new_pos
# Reset velocity to prevent player from moving back to old position
velocity = Vector2.ZERO
# Set flag to prevent position sync from overriding teleportation this frame
teleported_this_frame = true
print(name, " teleported to ", new_pos, " (synced from server, is_authority: ", is_multiplayer_authority(), ")")
@rpc("any_peer", "unreliable")
func _sync_held_object_pos(obj_path: NodePath, pos: Vector2):
# Sync held object position to other clients
@@ -2410,6 +2456,7 @@ func _show_damage_number(amount: float, from_position: Vector2):
get_tree().current_scene.add_child(damage_label)
damage_label.global_position = global_position + Vector2(0, -16)
@rpc("any_peer", "reliable")
func _sync_damage(_amount: float, attacker_position: Vector2):
# This RPC only syncs visual effects, not damage application
# (damage is already applied via rpc_take_damage)