multyplayer
This commit is contained in:
+10
-5
@@ -54,6 +54,12 @@ func _on_body_entered(body: Node3D) -> void:
|
||||
if _combining or body == _item:
|
||||
return
|
||||
|
||||
# Combining is a world-state change: only the server/offline host runs it.
|
||||
# (Clients never have the base item snapped, so their zone won't monitor, but
|
||||
# guard explicitly in case of overlap during authority handoff.)
|
||||
if not NetworkManager.owns_world():
|
||||
return
|
||||
|
||||
var other := _find_combinable(body)
|
||||
if not other:
|
||||
return
|
||||
@@ -75,11 +81,9 @@ func _combine(other_body: Node3D, result: PackedScene) -> void:
|
||||
_combining = false
|
||||
return
|
||||
|
||||
# Spawn the result at the base item's location, in world space.
|
||||
# Spawn the result (networked) at the base item's location, in world space.
|
||||
var base_transform := _item.global_transform
|
||||
var result_instance: Node3D = result.instantiate()
|
||||
_item.get_tree().current_scene.add_child(result_instance)
|
||||
result_instance.global_transform = base_transform
|
||||
var result_instance := NetworkManager.spawn_item(result.resource_path, base_transform)
|
||||
|
||||
# Free the base item and consume the incoming item.
|
||||
snap_zone.drop_object()
|
||||
@@ -90,7 +94,8 @@ func _combine(other_body: Node3D, result: PackedScene) -> void:
|
||||
other_body.queue_free()
|
||||
|
||||
# Snap the result into the now-empty zone.
|
||||
snap_zone.pick_up_object(result_instance)
|
||||
if result_instance:
|
||||
snap_zone.pick_up_object(result_instance)
|
||||
|
||||
|
||||
# Find a CombinableItem among the direct children of [param node].
|
||||
|
||||
Reference in New Issue
Block a user