From c14879ae2b682d1d3512790d9fd4d2d69c112b6b Mon Sep 17 00:00:00 2001 From: Olof Pettersson Date: Thu, 2 Oct 2025 17:22:15 +0200 Subject: [PATCH] Cleanup --- .../module_builder_editor_plugin.gd | 8 ++--- scenes/ship/components/accelerometer.tscn | 1 - scenes/ship/spaceship.gd | 30 ------------------- scenes/ship/spaceship.tscn | 2 +- scenes/ship/systems/thruster_controller.gd | 22 -------------- scripts/orbital_body_2d.gd | 10 +------ 6 files changed, 6 insertions(+), 67 deletions(-) diff --git a/addons/module_builder_plugin/module_builder_editor_plugin.gd b/addons/module_builder_plugin/module_builder_editor_plugin.gd index 62f188d..841f426 100644 --- a/addons/module_builder_plugin/module_builder_editor_plugin.gd +++ b/addons/module_builder_plugin/module_builder_editor_plugin.gd @@ -247,12 +247,12 @@ func _place_piece_from_preview(): undo_redo.add_do_method(piece_to_place, "set_owner", target_module) # DO method: recalculates physics. - undo_redo.add_do_method(target_module, "_recalculate_physics_properties") + undo_redo.add_do_method(target_module, "_recalculate_collision_shape") # UNDO method: removes the piece from the scene parent. undo_redo.add_undo_method(target_module.structural_container, "remove_child", piece_to_place) # UNDO method: recalculates physics. - undo_redo.add_undo_method(target_module, "_recalculate_physics_properties") + undo_redo.add_undo_method(target_module, "_recalculate_collision_shape") undo_redo.commit_action() @@ -319,10 +319,10 @@ func _remove_piece_with_undo_redo(piece: StructuralPiece): undo_redo.add_undo_method(builder_scene_root, "add_child", module) else: undo_redo.add_do_method(parent, "remove_child", piece) - undo_redo.add_do_method(module, "_recalculate_physics_properties") + undo_redo.add_do_method(module, "_recalculate_collision_shape") undo_redo.add_undo_method(parent, "add_child", piece) - undo_redo.add_undo_method(module, "_recalculate_physics_properties") + undo_redo.add_undo_method(module, "_recalculate_collision_shape") undo_redo.commit_action() diff --git a/scenes/ship/components/accelerometer.tscn b/scenes/ship/components/accelerometer.tscn index 36c4043..8ce7a37 100644 --- a/scenes/ship/components/accelerometer.tscn +++ b/scenes/ship/components/accelerometer.tscn @@ -12,7 +12,6 @@ inertia = 0.0 script = ExtResource("1_8lsml") spring_stiffness = 0.1 spring_damping = 0.1 -base_mass = null inertia = 0.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/scenes/ship/spaceship.gd b/scenes/ship/spaceship.gd index bcefd0d..928b007 100644 --- a/scenes/ship/spaceship.gd +++ b/scenes/ship/spaceship.gd @@ -25,31 +25,12 @@ func _ready() -> void: super() GameManager.register_ship(self) - #linear_damp = 0 - #angular_damp_mode = RigidBody2D.DAMP_MODE_REPLACE - #angular_damp = 0 - - # Connect to signals from our subsystems - #fuel_system.fuel_mass_changed.connect(_on_fuel_mass_changed) - #life_support.hull_breach_detected.connect(_on_hull_breach) - - # Set the initial mass of the RigidBody - #update_total_mass() - # Give the navigation computer a reference to this ship if navigation_computer: navigation_computer.ship = self camera.make_current() -func _process(delta: float): - # The queue_redraw() call tells Godot that this object needs to be redrawn - # on the next frame, which then calls the _draw() function. - queue_redraw() - -#func _draw() -> void: - #draw_circle(Vector2.ZERO, 5.0, Color.CORAL) - # This function will now handle all non-UI input for the player-controlled ship. func _unhandled_input(event: InputEvent) -> void: # --- Map Toggling --- @@ -73,9 +54,6 @@ func _unhandled_input(event: InputEvent) -> void: Engine.time_scale = 1.0 # --- Public API for Ship Management --- -func get_total_mass() -> float: - return self.mass - # Call this to take damage. Damage can have a position for breach effects. func take_damage(amount: float, damage_position: Vector2): hull_integrity -= amount @@ -92,7 +70,6 @@ func destroy_ship(): queue_free() # --- Signal Handlers --- - #func _on_fuel_mass_changed(): # Update the ship's total mass when fuel is consumed or added #update_total_mass() @@ -101,14 +78,7 @@ func _on_hull_breach(breach_position: Vector2, force_vector: Vector2): # A hull breach applies a continuous force at a specific point # For simplicity, we can apply it as a central force and torque here var force = force_vector * 100 # Scale the force - #apply_central_force(force) # Calculate torque: Torque = r x F (cross product of position vector and force) var position_relative_to_center = breach_position - self.global_position var torque = position_relative_to_center.cross(force) - #apply_torque(torque) - -#func update_total_mass(): - #var total_mass = dry_mass + fuel_system.get_total_fuel_mass() - #self.inertia = total_mass / 1000 - #self.mass = total_mass / 1000 diff --git a/scenes/ship/spaceship.tscn b/scenes/ship/spaceship.tscn index fff03b0..a64b1b1 100644 --- a/scenes/ship/spaceship.tscn +++ b/scenes/ship/spaceship.tscn @@ -12,7 +12,7 @@ [node name="Spaceship" type="Node2D"] script = ExtResource("1_ae4p7") base_mass = 2000.0 -inertia = 10000.0 +inertia = 500.0 metadata/_custom_type_script = "uid://0isnsk356que" [node name="Module" parent="." instance=ExtResource("2_y58gg")] diff --git a/scenes/ship/systems/thruster_controller.gd b/scenes/ship/systems/thruster_controller.gd index 70f7526..69d2b4d 100644 --- a/scenes/ship/systems/thruster_controller.gd +++ b/scenes/ship/systems/thruster_controller.gd @@ -73,28 +73,6 @@ func _physics_process(_delta: float) -> void: _perform_manual_hold() #if ship: print("AUTOPILOT: Holding attitude.") - queue_redraw() - -# --- DEPRICATED DEBUG FUNC --- -#func _draw() -> void: - ## This function will draw debug info directly onto the ship - #if not is_instance_valid(ship): return - - # Draw a circle at the ship's reported center of mass - #var center_of_mass = ship.get - #draw_circle(center_of_mass, 5, Color.MAGENTA) - - # Draw lines for each thruster's force and position - #for thruster in rcs_thrusters: - #var pos = thruster.position - #var dir = thruster.thrust_direction * 25 # Scale for visibility - - # Draw a line from the center to the thruster (radius vector) - #draw_line(center_of_mass, pos, Color.WHITE, 1.0) - - # Draw an arrow at the thruster's position showing its thrust direction - #draw_line(pos, pos + dir, Color.RED, 2.0) - # --- PUBLIC API --- # The Navigation Computer calls this. diff --git a/scripts/orbital_body_2d.gd b/scripts/orbital_body_2d.gd index 3ef80ac..90d1484 100644 --- a/scripts/orbital_body_2d.gd +++ b/scripts/orbital_body_2d.gd @@ -65,15 +65,7 @@ func _update_mass_and_inertia(): if child is OrbitalBody2D: child._update_mass_and_inertia() # Recurse into children mass += child.mass - - # After calculating the mass, notify the parent if this isn't the root - #if not is_sim_root and is_instance_valid(get_parent()): - #var p = get_parent() - #while p and not (p is OrbitalBody2D): - #p = p.get_parent() - #if p is OrbitalBody2D: - #p._update_mass_and_inertia() # Trigger parent to update its mass total - + print("Node: %s, Mass: %f" % [self, mass]) func _physics_process(delta):