diff --git a/addons/godotsteam/win64/~libgodotsteam.windows.template_debug.x86_64.dll b/addons/godotsteam/win64/~libgodotsteam.windows.template_debug.x86_64.dll deleted file mode 100644 index c80cff6..0000000 Binary files a/addons/godotsteam/win64/~libgodotsteam.windows.template_debug.x86_64.dll and /dev/null differ diff --git a/assets/core/interactables/ship-helm/ship_helm.gd b/assets/core/interactables/ship-helm/ship_helm.gd index f287785..cfc0c3c 100644 --- a/assets/core/interactables/ship-helm/ship_helm.gd +++ b/assets/core/interactables/ship-helm/ship_helm.gd @@ -4,9 +4,14 @@ extends Interactable var parent_ship: Ship +var uuid: String = "" + func _ready(): - parent_ship = get_parent() #sets the parent ship to the ship that the helm is placed on + uuid = NetworkManager.register_node(self) + NetworkManager.property_update_received.connect(_on_property_update) + parent_ship = get_parent().get_parent() #sets the parent ship to the ship that the helm is placed on + NetworkManager.sync_property(uuid, "parent_ship", parent_ship) func interact(): @@ -17,3 +22,12 @@ func interact(): elif parent_ship.ship_is_piloted: player_reference.set_is_piloting(false) parent_ship.ship_is_piloted = false + parent_ship._sync_piloting_state() + + +func _on_property_update(uuid: String, property_name: String, value: Variant): + if NetworkManager.node_map.has(uuid): + var node = NetworkManager.node_map[uuid] + node.set(property_name, value) + else: + printerr("Received property update but node_id is wrong? Expected " + str(uuid) + " but got " + str(uuid)) diff --git a/assets/core/ships/ship_script.gd b/assets/core/ships/ship_script.gd index ed3e6bb..286ee94 100644 --- a/assets/core/ships/ship_script.gd +++ b/assets/core/ships/ship_script.gd @@ -3,6 +3,7 @@ class_name Ship extends RigidBody3D @export var player_detection_area: Area3D +@export var helm_location_marker: Marker3D var ship_helm_scene: PackedScene = load("res://assets/core/interactables/ship-helm/ship-helm.tscn") @@ -13,7 +14,7 @@ var ship_id: int = 0 var ship_is_piloted: bool = false var current_level -var _ignore_next_call := false +var uuid: String = "" @export_range(0.01, 1.0, 0.01) var base_turn_speed: float = 0.35 @export var max_turn_speed: float = 0.5 @@ -24,6 +25,11 @@ var _ignore_next_call := false func _ready(): + uuid = NetworkManager.register_node(self) + NetworkManager.property_update_received.connect(_on_property_update) + + if !NetworkManager.is_host: return + #connect signals player_detection_area.body_entered.connect(_on_area_3d_body_entered) player_detection_area.body_exited.connect(_on_area_3d_body_exited) @@ -34,7 +40,8 @@ func _ready(): GameConsole.log_debug("Ship ID: " + str(ship_id)) -func _physics_process(delta): +func _physics_process(_delta): + if !NetworkManager.is_host: return if ship_is_piloted: var turn_speed = base_turn_speed / max(mass, 1) var lift_speed = base_lift_speed / max(mass, 1) @@ -56,8 +63,8 @@ func _physics_process(delta): target_velocity = -transform.basis.z * top_speed elif Input.is_action_pressed("move_backwards"): target_velocity = transform.basis.z * top_speed - var acceleration = (target_velocity - linear_velocity) * acceleration - apply_central_force(acceleration * mass) + var current_acceleration = (target_velocity - linear_velocity) * acceleration + apply_central_force(current_acceleration * mass) if linear_velocity.length() > top_speed: linear_velocity = linear_velocity.normalized() * top_speed @@ -66,9 +73,15 @@ func _physics_process(delta): # Self level slowly global_rotation.x = lerpf(global_rotation.x, 0, 0.1) global_rotation.z = lerpf(global_rotation.z, 0, 0.1) + + # Networking + NetworkManager.sync_property(uuid, "global_position", global_position) + NetworkManager.sync_property(uuid, "global_rotation", global_rotation) + NetworkManager.sync_property(uuid, "piloting_player", piloting_player) func _on_area_3d_body_entered(body: Node3D) -> void: + if !NetworkManager.is_host: return if body is Player and body.get_parent() != self: body.ship_entered(self) piloting_player = body @@ -77,6 +90,7 @@ func _on_area_3d_body_entered(body: Node3D) -> void: func _on_area_3d_body_exited(body: Node3D) -> void: + if !NetworkManager.is_host: return if body is Player and body.get_parent() != get_node("/root/DevLevel/"): body.ship_exited() ship_is_piloted = false @@ -86,6 +100,19 @@ func _on_area_3d_body_exited(body: Node3D) -> void: func _add_ship_helm(_ship_helm_scene: PackedScene): + if !NetworkManager.is_host: return var ship_helm = _ship_helm_scene.instantiate() - add_child(ship_helm) - ship_helm = get_node("ShipHelm") + helm_location_marker.add_child(ship_helm) + ship_helm = helm_location_marker.get_node("ShipHelm") + + +func _on_property_update(uuid: String, property_name: String, value: Variant): + if NetworkManager.node_map.has(uuid): + var node = NetworkManager.node_map[uuid] + node.set(property_name, value) + else: + printerr("Received property update but node_id is wrong? Expected " + str(uuid) + " but got " + str(uuid)) + + +func _sync_piloting_state(): + NetworkManager.sync_property(uuid, "ship_is_piloted", ship_is_piloted) diff --git a/assets/core/ships/shuttle-class/shuttle-class.tscn b/assets/core/ships/shuttle-class/shuttle-class.tscn index d8f355c..138be02 100644 --- a/assets/core/ships/shuttle-class/shuttle-class.tscn +++ b/assets/core/ships/shuttle-class/shuttle-class.tscn @@ -16,13 +16,14 @@ size = Vector3(5, 0.15, 20) [sub_resource type="BoxShape3D" id="BoxShape3D_7o08p"] size = Vector3(4.99609, 3.11252, 20.0022) -[node name="ShuttleClass" type="RigidBody3D" node_paths=PackedStringArray("player_detection_area")] +[node name="ShuttleClass" type="RigidBody3D" node_paths=PackedStringArray("player_detection_area", "helm_location_marker")] collision_layer = 8 collision_mask = 200 mass = 700.0 gravity_scale = 0.0 script = ExtResource("1_ghft7") player_detection_area = NodePath("PlayerDetectionArea") +helm_location_marker = NodePath("HelmLocationMarker") [node name="ShipToShipCol" type="CollisionShape3D" parent="."] shape = SubResource("BoxShape3D_6gbwt") @@ -44,3 +45,6 @@ shape = SubResource("BoxShape3D_6gbwt") [node name="PlayerDetectionAreaCol" type="CollisionShape3D" parent="PlayerDetectionArea"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.47652, 0) shape = SubResource("BoxShape3D_7o08p") + +[node name="HelmLocationMarker" type="Marker3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0) diff --git a/godot-jolt/windows/~godot-jolt_windows-x64_editor.dll b/godot-jolt/windows/~godot-jolt_windows-x64_editor.dll deleted file mode 100644 index c05d288..0000000 Binary files a/godot-jolt/windows/~godot-jolt_windows-x64_editor.dll and /dev/null differ