diff --git a/game/VehicleSelect.tscn b/game/VehicleSelect.tscn index d9aa17b..97cfabe 100644 --- a/game/VehicleSelect.tscn +++ b/game/VehicleSelect.tscn @@ -205,6 +205,7 @@ __meta__ = { } [connection signal="pressed" from="HUD/ReturnButton" to="." method="return_to_main"] +[connection signal="item_selected" from="HUD/SideContainer/ColorOption" to="." method="set_paint"] [connection signal="pressed" from="HUD/SideContainer/DriveButton" to="." method="confirm_vehicle"] [connection signal="pressed" from="HUD/Selector/BackButton" to="." method="move_selection" binds= [ -1 ]] [connection signal="pressed" from="HUD/Selector/NextButton" to="." method="move_selection" binds= [ 1 ]] diff --git a/scripts/game/Driving.gd b/scripts/game/Driving.gd index 86e98d3..acc38d2 100644 --- a/scripts/game/Driving.gd +++ b/scripts/game/Driving.gd @@ -30,7 +30,7 @@ signal return_to_main() # -- Functions -- # - Sets up the driven vehicle - -func setup_driving(vehicle_path: String) -> void: +func setup_driving(vehicle_path: String, paint: int) -> void: if vehicle_path == null or vehicle_path == "": push_error("Driving: Can't initialize without an path to a vehicle!") # Load the selected vehicle @@ -38,6 +38,7 @@ func setup_driving(vehicle_path: String) -> void: driven_vehicle = vehicle_scene.instance() add_child(driven_vehicle) # Setup nodes + driven_vehicle.VehiclePaint = paint driven_vehicle.global_transform = spawnpoint.global_transform gimbalcam.set_vehicle(driven_vehicle) outermirror.set_displayed_vehicle(driven_vehicle) diff --git a/scripts/game/Main.gd b/scripts/game/Main.gd index 653837f..40dda75 100644 --- a/scripts/game/Main.gd +++ b/scripts/game/Main.gd @@ -65,10 +65,11 @@ func select_a_vehicle() -> void: func drive_selected_vehicle() -> void: # Get selected vehicle var selected_vehicle : String = state_vehicle_select.chosen_vehicle() + var paint : int = state_vehicle_select.chosen_paint() # Change states set_active_state(GameState.DRIVE) # Setup new scene - state_driving.setup_driving(selected_vehicle) + state_driving.setup_driving(selected_vehicle, paint) # - State change to TitleScreen - func return_to_main() -> void: diff --git a/scripts/game/VehicleSelect.gd b/scripts/game/VehicleSelect.gd index a4a9987..0ec08d4 100644 --- a/scripts/game/VehicleSelect.gd +++ b/scripts/game/VehicleSelect.gd @@ -112,6 +112,12 @@ func _transforms_close(a : Transform, b : Transform, threshold : float) -> bool: and (a.origin - b.origin).length() < threshold ) -# - Returns selected vehicle file - +# - Returns selected settings - func chosen_vehicle() -> String: return vehicle_pool[selected_vehicle].filename +func chosen_paint() -> int: + return color_option.selected + +# - Sets the paint of the vehicle - +func set_paint(index : int): + vehicle_pool[selected_vehicle].VehiclePaint = index