replace with multiplayer-coop files
This commit is contained in:
28
src/scripts/stairs.gd
Normal file
28
src/scripts/stairs.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
extends Area2D
|
||||
|
||||
# Stairs that trigger level completion when player enters
|
||||
|
||||
func _ready():
|
||||
# Connect body entered signal
|
||||
body_entered.connect(_on_body_entered)
|
||||
|
||||
# Set collision layer/mask to detect players
|
||||
collision_layer = 0
|
||||
collision_mask = 1 # Detect players (layer 1)
|
||||
|
||||
func _on_body_entered(body: Node2D):
|
||||
print("Stairs: Body entered: ", body, " is_player: ", body.is_in_group("player") if body else false, " is_dead: ", body.is_dead if body and "is_dead" in body else false)
|
||||
if body and body.is_in_group("player") and not body.is_dead:
|
||||
print("Stairs: Player entered stairs! Player: ", body.name)
|
||||
# Only trigger on server/authority
|
||||
if multiplayer.is_server() or not multiplayer.has_multiplayer_peer():
|
||||
print("Stairs: Server detected, calling game_world")
|
||||
var game_world = get_tree().get_first_node_in_group("game_world")
|
||||
if game_world:
|
||||
print("Stairs: Game world found, calling _on_player_reached_stairs")
|
||||
game_world._on_player_reached_stairs(body)
|
||||
else:
|
||||
print("Stairs: ERROR - Game world not found!")
|
||||
else:
|
||||
print("Stairs: Not server, ignoring")
|
||||
|
||||
Reference in New Issue
Block a user