From 6a7854e239eaff8b3ff38f3a114e112a7e7743e1 Mon Sep 17 00:00:00 2001 From: Jovan Gerodetti Date: Sun, 12 Apr 2026 17:51:19 +0200 Subject: [PATCH] Split gdextension into two --- .github/workflows/build.yml | 61 +++++++---- native/Cargo.lock | 21 ++++ native/Cargo.toml | 16 +-- native/editor/Cargo.toml | 27 +++++ native/{src/editor => editor/src}/ao_baker.rs | 45 ++++---- .../editor => editor/src}/ao_baker.rs.uid | 0 .../editor => editor/src}/building_imports.rs | 64 ++++++----- .../src}/building_imports.rs.uid | 0 native/{src/editor => editor/src}/gltf.rs | 26 +++-- native/{src/editor => editor/src}/gltf.rs.uid | 0 native/{src/editor.rs => editor/src/lib.rs} | 25 ++++- .../editor.rs.uid => editor/src/lib.rs.uid} | 0 native/{src/editor => editor/src}/ui.rs | 0 native/{src/editor => editor/src}/ui.rs.uid | 0 .../src}/ui/progress_dialog.rs | 0 .../src}/ui/progress_dialog.rs.uid | 0 native/{ => editor}/src/util.rs | 101 +----------------- native/editor/src/util.rs.uid | 1 + native/game/Cargo.toml | 27 +++++ native/{ => game}/src/ext.rs | 0 native/{ => game}/src/ext.rs.uid | 0 native/{ => game}/src/ext/node_3d.rs | 0 native/{ => game}/src/ext/node_3d.rs.uid | 0 native/{ => game}/src/lib.rs | 4 +- native/{ => game}/src/lib.rs.uid | 0 native/{ => game}/src/objects.rs | 0 native/{ => game}/src/objects.rs.uid | 0 .../src/objects/scene_object_registry.rs | 0 .../src/objects/scene_object_registry.rs.uid | 0 native/{ => game}/src/project_settings.rs | 0 native/{ => game}/src/project_settings.rs.uid | 0 native/{ => game}/src/resources.rs | 0 native/{ => game}/src/resources.rs.uid | 0 .../{ => game}/src/resources/input_device.rs | 0 .../src/resources/input_device.rs.uid | 0 native/{ => game}/src/resources/items.rs | 0 native/{ => game}/src/resources/items.rs.uid | 0 .../src/resources/items/helicopter_upgrade.rs | 0 .../resources/items/helicopter_upgrade.rs.uid | 0 .../src/resources/water_decal_tracker.rs | 0 .../src/resources/water_decal_tracker.rs.uid | 0 .../src/resources/world_constants.rs | 0 .../src/resources/world_constants.rs.uid | 0 native/{ => game}/src/road_navigation.rs | 24 ++--- native/{ => game}/src/road_navigation.rs.uid | 0 native/{ => game}/src/scripts/effects.rs | 0 native/{ => game}/src/scripts/effects.rs.uid | 0 .../src/scripts/effects/water_decal.rs | 0 .../src/scripts/effects/water_decal.rs.uid | 0 native/{ => game}/src/scripts/mod.rs | 0 native/{ => game}/src/scripts/mod.rs.uid | 0 native/{ => game}/src/scripts/objects.rs | 0 native/{ => game}/src/scripts/objects.rs.uid | 0 .../{ => game}/src/scripts/objects/agents.rs | 0 .../src/scripts/objects/agents.rs.uid | 0 .../src/scripts/objects/agents/car.rs | 0 .../src/scripts/objects/agents/car.rs.uid | 0 .../src/scripts/objects/building.rs | 0 .../src/scripts/objects/building.rs.uid | 0 .../src/scripts/objects/building/fire.rs | 0 .../src/scripts/objects/building/fire.rs.uid | 0 .../{ => game}/src/scripts/objects/camera.rs | 0 .../src/scripts/objects/camera.rs.uid | 0 .../src/scripts/objects/canon_upgrade.rs | 0 .../src/scripts/objects/canon_upgrade.rs.uid | 0 .../src/scripts/objects/debugger_3_d.rs | 0 .../src/scripts/objects/debugger_3_d.rs.uid | 0 .../src/scripts/objects/water_jet.rs | 10 +- .../src/scripts/objects/water_jet.rs.uid | 0 .../src/scripts/particles/dust_particles.rs | 0 .../scripts/particles/dust_particles.rs.uid | 0 .../{ => game}/src/scripts/particles/mod.rs | 0 .../src/scripts/particles/mod.rs.uid | 0 .../src/scripts/spawner/car_spawner.rs | 0 .../src/scripts/spawner/car_spawner.rs.uid | 0 .../src/scripts/spawner/fire_spawner.rs | 0 .../src/scripts/spawner/fire_spawner.rs.uid | 0 native/{ => game}/src/scripts/spawner/mod.rs | 0 .../{ => game}/src/scripts/spawner/mod.rs.uid | 0 native/{ => game}/src/scripts/ui.rs | 0 native/{ => game}/src/scripts/ui.rs.uid | 0 .../{ => game}/src/scripts/ui/title_menu.rs | 0 .../src/scripts/ui/title_menu.rs.uid | 0 native/{ => game}/src/scripts/world.rs | 0 native/{ => game}/src/scripts/world.rs.uid | 0 .../{ => game}/src/scripts/world/buildings.rs | 0 .../src/scripts/world/buildings.rs.uid | 0 .../{ => game}/src/scripts/world/gi_probes.rs | 0 .../src/scripts/world/gi_probes.rs.uid | 0 .../src/scripts/world/solar_setup.rs | 11 +- .../src/scripts/world/solar_setup.rs.uid | 0 native/{ => game}/src/terrain_builder.rs | 0 native/{ => game}/src/terrain_builder.rs.uid | 0 native/{ => game}/src/terrain_builder/lerp.rs | 0 .../src/terrain_builder/lerp.rs.uid | 0 .../{ => game}/src/terrain_builder/point.rs | 0 .../src/terrain_builder/point.rs.uid | 0 .../src/terrain_builder/terrain_rotation.rs | 0 .../terrain_builder/terrain_rotation.rs.uid | 0 .../src/terrain_builder/tile_surface.rs | 0 .../src/terrain_builder/tile_surface.rs.uid | 0 native/game/src/util.rs | 90 ++++++++++++++++ native/{ => game}/src/util.rs.uid | 0 native/{ => game}/src/util/async_support.rs | 0 .../{ => game}/src/util/async_support.rs.uid | 0 native/{ => game}/src/util/logger.rs | 0 native/{ => game}/src/util/logger.rs.uid | 0 native/{ => game}/src/util/numbers.rs | 0 native/{ => game}/src/util/numbers.rs.uid | 0 native/{ => game}/src/world.rs | 0 native/{ => game}/src/world.rs.uid | 0 .../src/world/city_coords_feature.rs | 0 .../src/world/city_coords_feature.rs.uid | 0 native/{ => game}/src/world/city_data.rs | 0 native/{ => game}/src/world/city_data.rs.uid | 0 .../src/world/city_data/terrain_slope.rs | 0 .../src/world/city_data/terrain_slope.rs.uid | 0 resources/Debug/debugger_3d.tscn | 2 +- .../Buildings/condominiums_medium_2.tscn | 2 +- .../Buildings/home_middle_class_3.tscn | 2 +- .../Buildings/office_building_medium_4.tscn | 2 +- resources/Objects/Helis/Helicopter.tscn | 2 +- resources/Objects/Helis/Upgrades/canon.tscn | 6 +- resources/Objects/Spawner/CarSpawner.tscn | 2 +- resources/Objects/Spawner/fire_spawner.tscn | 2 +- .../Objects/Vehicles/car_station_wagon.tscn | 2 +- resources/main.tscn | 20 ++-- resources/title_screen.tscn | 2 +- src/editor.gdextension | 10 ++ src/editor.gdextension.uid | 1 + src/native.gdextension | 2 +- 131 files changed, 363 insertions(+), 247 deletions(-) create mode 100644 native/editor/Cargo.toml rename native/{src/editor => editor/src}/ao_baker.rs (84%) rename native/{src/editor => editor/src}/ao_baker.rs.uid (100%) rename native/{src/editor => editor/src}/building_imports.rs (79%) rename native/{src/editor => editor/src}/building_imports.rs.uid (100%) rename native/{src/editor => editor/src}/gltf.rs (92%) rename native/{src/editor => editor/src}/gltf.rs.uid (100%) rename native/{src/editor.rs => editor/src/lib.rs} (94%) rename native/{src/editor.rs.uid => editor/src/lib.rs.uid} (100%) rename native/{src/editor => editor/src}/ui.rs (100%) rename native/{src/editor => editor/src}/ui.rs.uid (100%) rename native/{src/editor => editor/src}/ui/progress_dialog.rs (100%) rename native/{src/editor => editor/src}/ui/progress_dialog.rs.uid (100%) rename native/{ => editor}/src/util.rs (56%) create mode 100644 native/editor/src/util.rs.uid create mode 100644 native/game/Cargo.toml rename native/{ => game}/src/ext.rs (100%) rename native/{ => game}/src/ext.rs.uid (100%) rename native/{ => game}/src/ext/node_3d.rs (100%) rename native/{ => game}/src/ext/node_3d.rs.uid (100%) rename native/{ => game}/src/lib.rs (94%) rename native/{ => game}/src/lib.rs.uid (100%) rename native/{ => game}/src/objects.rs (100%) rename native/{ => game}/src/objects.rs.uid (100%) rename native/{ => game}/src/objects/scene_object_registry.rs (100%) rename native/{ => game}/src/objects/scene_object_registry.rs.uid (100%) rename native/{ => game}/src/project_settings.rs (100%) rename native/{ => game}/src/project_settings.rs.uid (100%) rename native/{ => game}/src/resources.rs (100%) rename native/{ => game}/src/resources.rs.uid (100%) rename native/{ => game}/src/resources/input_device.rs (100%) rename native/{ => game}/src/resources/input_device.rs.uid (100%) rename native/{ => game}/src/resources/items.rs (100%) rename native/{ => game}/src/resources/items.rs.uid (100%) rename native/{ => game}/src/resources/items/helicopter_upgrade.rs (100%) rename native/{ => game}/src/resources/items/helicopter_upgrade.rs.uid (100%) rename native/{ => game}/src/resources/water_decal_tracker.rs (100%) rename native/{ => game}/src/resources/water_decal_tracker.rs.uid (100%) rename native/{ => game}/src/resources/world_constants.rs (100%) rename native/{ => game}/src/resources/world_constants.rs.uid (100%) rename native/{ => game}/src/road_navigation.rs (96%) rename native/{ => game}/src/road_navigation.rs.uid (100%) rename native/{ => game}/src/scripts/effects.rs (100%) rename native/{ => game}/src/scripts/effects.rs.uid (100%) rename native/{ => game}/src/scripts/effects/water_decal.rs (100%) rename native/{ => game}/src/scripts/effects/water_decal.rs.uid (100%) rename native/{ => game}/src/scripts/mod.rs (100%) rename native/{ => game}/src/scripts/mod.rs.uid (100%) rename native/{ => game}/src/scripts/objects.rs (100%) rename native/{ => game}/src/scripts/objects.rs.uid (100%) rename native/{ => game}/src/scripts/objects/agents.rs (100%) rename native/{ => game}/src/scripts/objects/agents.rs.uid (100%) rename native/{ => game}/src/scripts/objects/agents/car.rs (100%) rename native/{ => game}/src/scripts/objects/agents/car.rs.uid (100%) rename native/{ => game}/src/scripts/objects/building.rs (100%) rename native/{ => game}/src/scripts/objects/building.rs.uid (100%) rename native/{ => game}/src/scripts/objects/building/fire.rs (100%) rename native/{ => game}/src/scripts/objects/building/fire.rs.uid (100%) rename native/{ => game}/src/scripts/objects/camera.rs (100%) rename native/{ => game}/src/scripts/objects/camera.rs.uid (100%) rename native/{ => game}/src/scripts/objects/canon_upgrade.rs (100%) rename native/{ => game}/src/scripts/objects/canon_upgrade.rs.uid (100%) rename native/{ => game}/src/scripts/objects/debugger_3_d.rs (100%) rename native/{ => game}/src/scripts/objects/debugger_3_d.rs.uid (100%) rename native/{ => game}/src/scripts/objects/water_jet.rs (98%) rename native/{ => game}/src/scripts/objects/water_jet.rs.uid (100%) rename native/{ => game}/src/scripts/particles/dust_particles.rs (100%) rename native/{ => game}/src/scripts/particles/dust_particles.rs.uid (100%) rename native/{ => game}/src/scripts/particles/mod.rs (100%) rename native/{ => game}/src/scripts/particles/mod.rs.uid (100%) rename native/{ => game}/src/scripts/spawner/car_spawner.rs (100%) rename native/{ => game}/src/scripts/spawner/car_spawner.rs.uid (100%) rename native/{ => game}/src/scripts/spawner/fire_spawner.rs (100%) rename native/{ => game}/src/scripts/spawner/fire_spawner.rs.uid (100%) rename native/{ => game}/src/scripts/spawner/mod.rs (100%) rename native/{ => game}/src/scripts/spawner/mod.rs.uid (100%) rename native/{ => game}/src/scripts/ui.rs (100%) rename native/{ => game}/src/scripts/ui.rs.uid (100%) rename native/{ => game}/src/scripts/ui/title_menu.rs (100%) rename native/{ => game}/src/scripts/ui/title_menu.rs.uid (100%) rename native/{ => game}/src/scripts/world.rs (100%) rename native/{ => game}/src/scripts/world.rs.uid (100%) rename native/{ => game}/src/scripts/world/buildings.rs (100%) rename native/{ => game}/src/scripts/world/buildings.rs.uid (100%) rename native/{ => game}/src/scripts/world/gi_probes.rs (100%) rename native/{ => game}/src/scripts/world/gi_probes.rs.uid (100%) rename native/{ => game}/src/scripts/world/solar_setup.rs (96%) rename native/{ => game}/src/scripts/world/solar_setup.rs.uid (100%) rename native/{ => game}/src/terrain_builder.rs (100%) rename native/{ => game}/src/terrain_builder.rs.uid (100%) rename native/{ => game}/src/terrain_builder/lerp.rs (100%) rename native/{ => game}/src/terrain_builder/lerp.rs.uid (100%) rename native/{ => game}/src/terrain_builder/point.rs (100%) rename native/{ => game}/src/terrain_builder/point.rs.uid (100%) rename native/{ => game}/src/terrain_builder/terrain_rotation.rs (100%) rename native/{ => game}/src/terrain_builder/terrain_rotation.rs.uid (100%) rename native/{ => game}/src/terrain_builder/tile_surface.rs (100%) rename native/{ => game}/src/terrain_builder/tile_surface.rs.uid (100%) create mode 100644 native/game/src/util.rs rename native/{ => game}/src/util.rs.uid (100%) rename native/{ => game}/src/util/async_support.rs (100%) rename native/{ => game}/src/util/async_support.rs.uid (100%) rename native/{ => game}/src/util/logger.rs (100%) rename native/{ => game}/src/util/logger.rs.uid (100%) rename native/{ => game}/src/util/numbers.rs (100%) rename native/{ => game}/src/util/numbers.rs.uid (100%) rename native/{ => game}/src/world.rs (100%) rename native/{ => game}/src/world.rs.uid (100%) rename native/{ => game}/src/world/city_coords_feature.rs (100%) rename native/{ => game}/src/world/city_coords_feature.rs.uid (100%) rename native/{ => game}/src/world/city_data.rs (100%) rename native/{ => game}/src/world/city_data.rs.uid (100%) rename native/{ => game}/src/world/city_data/terrain_slope.rs (100%) rename native/{ => game}/src/world/city_data/terrain_slope.rs.uid (100%) create mode 100644 src/editor.gdextension create mode 100644 src/editor.gdextension.uid diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c9fe9723..56c7e59c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,15 +33,18 @@ jobs: vendor: unknown env: -gnu lib: libnative.so + editor_lib: libeditor.so - platform: windows os: windows-2025 vendor: pc env: '-msvc' lib: native.dll + editor_lib: editor.dll - platform: darwin os: macos-14 vendor: apple lib: libnative.dylib + editor_lib: libeditor.dylib exclude: - platform: linux arch: aarch64 @@ -78,12 +81,20 @@ jobs: run: | cd native/ ${{ env.CARGO_BUILD }} ${{ env.TARGET_TRIPLET}} --release - - name: Debug Artifacts + + - name: Debug libnative Artifact uses: actions/upload-artifact@v4 + if: ${{ !inputs.release }} with: name: libnative-${{ matrix.platform }}-${{ matrix.arch }}-debug path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.lib }} - - name: Release Artifacts + - name: Debug libeditor Artifact + uses: actions/upload-artifact@v4 + with: + name: libeditor-${{ matrix.platform }}-${{ matrix.arch }}-debug + path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.editor_lib }} + + - name: Release libnative Artifacts uses: actions/upload-artifact@v4 if: inputs.release with: @@ -104,6 +115,7 @@ jobs: aarch64: true extension: '.dmg' lib: libnative.dylib + editor_lib: "libeditor.dylib" template_dir: '$HOME/Library/Application\ Support/Godot/export_templates' godot_artefact: 'macOS.universal' - profile: 'Windows' @@ -115,6 +127,7 @@ jobs: aarch64: true extension: '.exe' lib: native.dll + editor_lib: "libeditor.so" template_dir: '$HOME/.local/share/godot/export_templates' godot_artefact: 'linux.x86_64' - profile: 'Linux' @@ -123,6 +136,7 @@ jobs: vendor: 'unknown' os: ubuntu-24.04 lib: libnative.so + editor_lib: "libeditor.so" template_dir: '$HOME/.local/share/godot/export_templates' godot_artefact: 'linux.x86_64' x86_64: true @@ -162,38 +176,42 @@ jobs: cd ${{ matrix.template_dir }}/${{ matrix.version }}.stable curl -LO https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_export_templates.tpz unzip -j Godot_v${{ matrix.version }}-stable_export_templates.tpz - - name: download host libs - if: ${{ matrix.platform != 'linux' && startsWith(matrix.os, 'ubuntu') }} - uses: actions/download-artifact@v5 + - name: download editor lib + uses: actions/download-artifact@v8 with: - name: libnative-linux-x86_64-debug - path: native/target/x86_64-unknown-linux-gnu/debug/ - + name: libeditor-${{ startsWith(matrix.os, 'ubuntu') && 'linux' || matrix.platform }}-${{ startsWith(matrix.os, 'ubuntu') && 'x86_64' || 'aarch64' }}-debug + path: native/target/${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-unknown-linux-gnu' || 'aarch64-apple-darwin' }}/debug/ + merge-multiple: true + - name: download x86_64 debug libs - if: matrix.x86_64 - uses: actions/download-artifact@v5 + if: ${{ matrix.x86_64 && !inputs.release }} + uses: actions/download-artifact@v8 with: name: libnative-${{ matrix.platform }}-x86_64-debug path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/ + merge-multiple: true - name: download x86_64 release libs - if: ${{ matrix.x86_64 && inputs.release }} - uses: actions/download-artifact@v5 + if: ${{ matrix.x86_64 && inputs.release }} + uses: actions/download-artifact@v8 with: name: libnative-${{ matrix.platform }}-x86_64-release path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/ + merge-multiple: true - name: download aarch64 debug libs - if: matrix.aarch64 - uses: actions/download-artifact@v5 + if: ${{ matrix.aarch64 && !inputs.release }} + uses: actions/download-artifact@v8 with: name: libnative-${{ matrix.platform }}-aarch64-debug path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/ + merge-multiple: true - name: download aarch64 release libs if: ${{ matrix.aarch64 && inputs.release }} - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v8 with: name: libnative-${{ matrix.platform }}-aarch64-release path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/ + merge-multiple: true - name: create universal libnative if: matrix.platform == 'darwin' @@ -210,8 +228,10 @@ jobs: let aarch64_debug = $"($aarch64_path)/debug/${{ matrix.lib }}" let aarch64_release = $"($aarch64_path)/release/${{ matrix.lib }}" - mkdir $"native/target/universal-($platform_dir)/debug/" - lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}" + if not $release { + mkdir $"native/target/universal-($platform_dir)/debug/" + lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}" + } if $release { mkdir $"native/target/universal-($platform_dir)/release/" @@ -234,10 +254,7 @@ jobs: let profile = if $release { "release" } else { "debug" } rm -r $"native/target/x86_64-($platform_dir)/($profile)/" - - if $release { - rm -r $"native/target/aarch64-($platform_dir)/($profile)/" - } + rm -r $"native/target/aarch64-($platform_dir)/($profile)/" - name: export-debug shell: nu {0} @@ -272,4 +289,4 @@ jobs: - uses: actions/upload-artifact@v4 with: name: SimChopper_${{ matrix.profile }}_${{ steps.describe.outputs.ref }} - path: ${{ env.EXPORT_DIR }} \ No newline at end of file + path: ${{ env.EXPORT_DIR }} diff --git a/native/Cargo.lock b/native/Cargo.lock index dd1f1308..de4b2817 100644 --- a/native/Cargo.lock +++ b/native/Cargo.lock @@ -161,6 +161,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "editor" +version = "0.5.0" +dependencies = [ + "anyhow", + "backtrace", + "derive-debug", + "godot", + "godot-rust-script", + "itertools", + "kanal", + "lerp", + "num", + "num_enum", + "pomsky-macro", + "rand 0.9.2", + "rayon", + "regex", + "thiserror", +] + [[package]] name = "either" version = "1.12.0" diff --git a/native/Cargo.toml b/native/Cargo.toml index 8a6dcdc7..3f31e76b 100644 --- a/native/Cargo.toml +++ b/native/Cargo.toml @@ -1,12 +1,12 @@ -[package] -name = "native" -version = "0.5.0" -edition = "2021" +[workspace] +members = ["game", "editor"] +resolver = "3" -[lib] -crate-type = ["cdylib"] +[workspace.package] +edition = "2024" +version = "0.5.0" -[dependencies] +[workspace.dependencies] godot = { version = "0.5.0", features = ["experimental-threads", "api-4-5", "register-docs"] } godot-rust-script = { git = "https://github.com/titannano/godot-rust-script", rev = "ca89cf182f6b9e051b66e1e52e23489e25f9077c" } lerp = "0.4.0" @@ -23,6 +23,6 @@ pomsky-macro = "0.11.0" regex = "1.10.5" kanal = { version = "0.1.1", features = ["async"] } -[lints.clippy] +[workspace.lints.clippy] pedantic = "deny" used_underscore_items = { level = "allow", priority = 1 } diff --git a/native/editor/Cargo.toml b/native/editor/Cargo.toml new file mode 100644 index 00000000..634cb04b --- /dev/null +++ b/native/editor/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "editor" +version.workspace = true +edition.workspace = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +godot.workspace = true +godot-rust-script.workspace = true +lerp.workspace = true +backtrace.workspace = true +num.workspace = true +rayon.workspace = true +itertools.workspace = true +num_enum.workspace = true +derive-debug.workspace = true +thiserror.workspace = true +anyhow.workspace = true +rand.workspace = true +pomsky-macro.workspace = true +regex.workspace = true +kanal.workspace = true + +[lints] +workspace = true diff --git a/native/src/editor/ao_baker.rs b/native/editor/src/ao_baker.rs similarity index 84% rename from native/src/editor/ao_baker.rs rename to native/editor/src/ao_baker.rs index 95ff738f..9a1122dc 100644 --- a/native/src/editor/ao_baker.rs +++ b/native/editor/src/ao_baker.rs @@ -10,16 +10,21 @@ use std::{ process::{Command, Stdio}, }; -use godot::builtin::{GString, PackedStringArray, VariantType}; -use godot::classes::{EditorInterface, ProjectSettings, RefCounted, SceneTree}; use godot::obj::{Base, Gd, Singleton}; -use godot::prelude::{godot_api, GodotClass}; +use godot::prelude::{GodotClass, godot_api}; use godot::register::info::PropertyHint; use godot::task; +use godot::{ + builtin::{GString, PackedStringArray, VariantType}, + global::godot_error, +}; +use godot::{ + classes::{EditorInterface, ProjectSettings, RefCounted, SceneTree}, + global::godot_print, +}; -use crate::editor::new_non_zero; -use crate::editor::ui::{ForgroundProcess, ProgressDialog}; -use crate::util::logger; +use crate::new_non_zero; +use crate::ui::{ForgroundProcess, ProgressDialog}; #[derive(GodotClass)] #[class(base = RefCounted, no_init)] @@ -85,7 +90,7 @@ impl AoBaker { editor_settings.get_setting("filesystem/import/blender/blender_path"); if blender_path_variant.is_nil() { - logger::error!("Unable to get blender path!"); + godot_error!("Unable to get blender path!"); return; } @@ -114,18 +119,14 @@ impl AoBaker { std::fs::read_dir(system_path.to_string()) .inspect_err(|err| { - logger::error!( - "unable to read directory: {}.\nError: {}", - system_path, - err - ); + godot_error!("Unable to read directory: {}.\nError: {}", system_path, err); }) .ok() }) .flatten() .filter_map(|entry| { entry - .inspect_err(|err| logger::error!("Failed to enumerate directory entry: {err}")) + .inspect_err(|err| godot_error!("Failed to enumerate directory entry: {err}")) .ok() }) .filter(|entry| { @@ -168,14 +169,14 @@ impl AoBaker { .stdout(Stdio::piped()) .stdin(Stdio::null()); - logger::debug!("invoking blender: {:?}", blender_command); + godot_print!("invoking blender: {:?}", blender_command); let blender = blender_command.spawn(); let mut blender = match blender { Ok(child) => child, Err(err) => { - logger::error!("Failed to spawn blender process: {}", err); + godot_error!("Failed to spawn blender process: {}", err); return; } }; @@ -191,14 +192,14 @@ impl AoBaker { // We are not done yet. Ok(None) => (), - // we are done and it was a success + // We are done and it was a success Ok(Some(status)) if status.success() => { break; } - // we are done but blender failed. + // We are done but blender failed. Ok(Some(status)) => { - logger::error!( + godot_error!( "Blender exited with status {}", status.code().unwrap_or_default() ); @@ -207,7 +208,7 @@ impl AoBaker { // getting the status didn't work Err(err) => { - logger::error!("Failed to check blender exit status: {err}"); + godot_error!("Failed to check blender exit status: {err}"); break; } } @@ -216,7 +217,7 @@ impl AoBaker { let line_error = stdreader.read_line(&mut read_buffer); if let Err(err) = line_error { - logger::error!("failed to read from blender stdout: {err}"); + godot_error!("failed to read from blender stdout: {err}"); continue; } @@ -224,14 +225,14 @@ impl AoBaker { let label = read_buffer.split('|').nth(1).unwrap_or_default(); dialog.bind_mut().push_task_step(label); - logger::info!("Blender: {read_buffer}"); + godot_print!("Blender: {read_buffer}"); } if read_buffer.starts_with("File|") { let label = read_buffer.split('|').nth(1).unwrap_or_default(); dialog.bind_mut().push_task(label); - logger::info!("Blender: {read_buffer}"); + godot_print!("Blender: {read_buffer}"); } let _: () = next_frame.to_future().await; diff --git a/native/src/editor/ao_baker.rs.uid b/native/editor/src/ao_baker.rs.uid similarity index 100% rename from native/src/editor/ao_baker.rs.uid rename to native/editor/src/ao_baker.rs.uid diff --git a/native/src/editor/building_imports.rs b/native/editor/src/building_imports.rs similarity index 79% rename from native/src/editor/building_imports.rs rename to native/editor/src/building_imports.rs index 0d5681ea..ceadb1fd 100644 --- a/native/src/editor/building_imports.rs +++ b/native/editor/src/building_imports.rs @@ -9,18 +9,16 @@ use std::collections::VecDeque; use godot::builtin::{GString, VarDictionary, Vector2i}; use godot::classes::{ - editor_file_dialog, ConfigFile, DirAccess, EditorFileDialog, EditorInterface, FileAccess, - MeshInstance3D, Object, PackedScene, ResourceLoader, + ConfigFile, DirAccess, EditorFileDialog, EditorInterface, FileAccess, MeshInstance3D, Object, + PackedScene, ResourceLoader, editor_file_dialog, }; -use godot::global::Error; +use godot::global::{Error, godot_error, godot_print, godot_warn}; use godot::meta::ToGodot; -use godot::obj::{Base, Gd, GodotClass, NewAlloc, NewGd, Singleton as _, WithBaseField}; -use godot::register::{godot_api, GodotClass}; +use godot::obj::{Base, Gd, GodotClass, NewAlloc, NewGd, Singleton as _}; +use godot::register::{GodotClass, godot_api}; use pomsky_macro::pomsky; use regex::Regex; -use crate::{class_callable, util::logger}; - #[derive(GodotClass)] #[class(base = Object, init, tool)] pub(crate) struct SetupBuildingImports { @@ -38,7 +36,7 @@ impl SetupBuildingImports { #[func] pub fn start(&mut self) { let Some(editor) = self.editor.as_ref() else { - logger::error!("Editor is unavailable!"); + godot_error!("Editor is unavailable!"); return; }; @@ -49,18 +47,18 @@ impl SetupBuildingImports { dialog.set_access(editor_file_dialog::Access::RESOURCES); dialog.set_hide_on_ok(true); - dialog.connect( - "file_selected", - &class_callable!(self, Self::on_file_selected), - ); + dialog + .signals() + .file_selected() + .connect_other(self, Self::on_file_selected); - dialog.connect( - "dir_selected", - &class_callable!(self, Self::on_dir_selected), - ); + dialog + .signals() + .dir_selected() + .connect_other(self, Self::on_dir_selected); let Some(ui) = editor.get_base_control() else { - logger::error!("Editor UI is missing!"); + godot_error!("Editor UI is missing!"); return; }; @@ -74,14 +72,14 @@ impl SetupBuildingImports { #[func] fn on_file_selected(&mut self, file_path: GString) { let Some(editor) = self.editor.as_ref() else { - logger::error!("Editor is not available!"); + godot_error!("Editor is not available!"); return; }; let import_config_name = format!("{file_path}.import"); if !FileAccess::file_exists(&import_config_name) { - logger::warn!("Resource has never been imported by the editor!"); + godot_warn!("Resource has never been imported by the editor!"); return; } @@ -96,12 +94,12 @@ impl SetupBuildingImports { #[expect(clippy::needless_pass_by_value)] fn on_dir_selected(&mut self, root_dir: GString) { let Some(editor) = self.editor.as_ref() else { - logger::error!("Editor is not available!"); + godot_error!("Editor is not available!"); return; }; if root_dir.is_empty() { - logger::error!("Directory path is empty!"); + godot_error!("Directory path is empty!"); return; } @@ -110,9 +108,9 @@ impl SetupBuildingImports { let pattern = Regex::new(pomsky! { "." ("gltf" | "glb")$ }).expect("unable to fail"); while let Some(dir_path) = dir_queue.pop_front() { - logger::info!("Traversing dir \"{}\"...", dir_path); + godot_print!("Traversing dir \"{}\"...", dir_path); let Some(dir) = DirAccess::open(&dir_path) else { - logger::error!("Directory not accessible: {}", root_dir); + godot_error!("Directory not accessible: {}", root_dir); return; }; @@ -138,10 +136,10 @@ impl SetupBuildingImports { for path in &file_queue { let import_config_name = format!("{path}.import"); - logger::info!("Processing import config \"{}\"...", import_config_name); + godot_print!("Processing import config \"{}\"...", import_config_name); if !FileAccess::file_exists(&import_config_name) { - logger::warn!("Resource has never been imported by the editor!"); + godot_print!("Resource has never been imported by the editor!"); return; } @@ -160,7 +158,7 @@ impl SetupBuildingImports { let error = file.load(config_file_name); if error != Error::OK { - logger::error!( + godot_error!( "Failed to read config file {:?}: {}", error, config_file_name @@ -174,7 +172,7 @@ impl SetupBuildingImports { .done() .try_to() .inspect_err(|err| { - logger::error!("Failed to read subresources as dictionary: {}", err); + godot_error!("Failed to read subresources as dictionary: {}", err); }) .unwrap_or_default(); @@ -183,7 +181,7 @@ impl SetupBuildingImports { .map(|value| value.try_to()) .transpose() .inspect_err(|err| { - logger::error!("Failed to read nodes as dictionary: {}", err); + godot_error!("Failed to read nodes as dictionary: {}", err); }) .ok() .flatten() @@ -195,17 +193,17 @@ impl SetupBuildingImports { .done(); let Some(scene) = scene else { - logger::error!("Failed to load resource!"); + godot_error!("Failed to load resource!"); return; }; let Ok(scene): Result, _> = scene.try_cast() else { - logger::error!("Loaded resouce is not of type PackedScene!"); + godot_error!("Loaded resouce is not of type PackedScene!"); return; }; let Some(scene_state) = scene.get_state() else { - logger::error!("Failed to read scene state!"); + godot_error!("Failed to read scene state!"); return; }; @@ -220,7 +218,7 @@ impl SetupBuildingImports { .map(|value| value.try_to()) .transpose() .inspect_err(|err| { - logger::error!("Failed to read node config as dictionary: {}", err); + godot_error!("Failed to read node config as dictionary: {}", err); }) .ok() .flatten() @@ -244,7 +242,7 @@ impl SetupBuildingImports { let error = file.save(config_file_name); if error != Error::OK { - logger::error!( + godot_error!( "Failed to write import config file {:?}: {}", error, config_file_name diff --git a/native/src/editor/building_imports.rs.uid b/native/editor/src/building_imports.rs.uid similarity index 100% rename from native/src/editor/building_imports.rs.uid rename to native/editor/src/building_imports.rs.uid diff --git a/native/src/editor/gltf.rs b/native/editor/src/gltf.rs similarity index 92% rename from native/src/editor/gltf.rs rename to native/editor/src/gltf.rs index f27d3d61..b6356625 100644 --- a/native/src/editor/gltf.rs +++ b/native/editor/src/gltf.rs @@ -13,16 +13,14 @@ use godot::builtin::{ use godot::classes::decal::DecalTexture; use godot::classes::mesh::ArrayType; use godot::classes::{ - base_material_3d, ArrayOccluder3D, BaseMaterial3D, CollisionShape3D, ConcavePolygonShape3D, - Decal, GltfNode, GltfState, IGltfDocumentExtension, Node, Node3D, OccluderInstance3D, + ArrayOccluder3D, BaseMaterial3D, CollisionShape3D, ConcavePolygonShape3D, Decal, GltfNode, + GltfState, IGltfDocumentExtension, Node, Node3D, OccluderInstance3D, base_material_3d, }; -use godot::global; +use godot::global::{self, godot_error, godot_print, godot_warn}; use godot::obj::{EngineEnum, Gd, NewAlloc, NewGd}; -use godot::prelude::{godot_api, GodotClass}; +use godot::prelude::{GodotClass, godot_api}; use itertools::Itertools; -use crate::util::logger; - #[derive(GodotClass)] #[class(base = GltfDocumentExtension, tool, init)] pub struct GltfImporter; @@ -80,19 +78,19 @@ impl IGltfDocumentExtension for GltfImporter { _parent: Option>, ) -> Option> { let Some(mut state) = state else { - logger::error!("generate_scene_node called with null GltfState!"); + godot_error!("generate_scene_node called with null GltfState!"); return None; }; let Some(mut gltf_node) = gltf_node else { - logger::error!("generate_scene_node called with null GltfNode!"); + godot_error!("generate_scene_node called with null GltfNode!"); return None; }; match use_gd_node(&mut gltf_node, &mut state) { Ok(node) => node, Err(err) => { - logger::error!("Failed to generate GD Node: {:?}", err); + godot_error!("Failed to generate GD Node: {:?}", err); None } } @@ -103,12 +101,12 @@ fn fix_ao_uv2(state: &mut Gd) -> Result<(), global::Error> { let materials = state.get_materials(); if materials.is_empty() { - logger::info!("GLTF model does not contain materials!"); + godot_print!("GLTF model does not contain materials!"); return Ok(()); } let Some(raw_materials) = state.get_json().get("materials") else { - logger::error!( + godot_error!( "GLTF model does not contain a materials array, but materials have been imported!" ); @@ -122,7 +120,7 @@ fn fix_ao_uv2(state: &mut Gd) -> Result<(), global::Error> { .iter_shared() .find(|mat| { let Some(name) = mat.to::().get("name") else { - logger::debug!("raw material doesn't have a name!"); + godot_print!("raw material doesn't have a name!"); return false; }; @@ -131,7 +129,7 @@ fn fix_ao_uv2(state: &mut Gd) -> Result<(), global::Error> { .map(|mat| mat.to::()); let Some(raw_material) = raw_material else { - logger::error!("Unable to locate raw material in GLTF model!"); + godot_error!("Unable to locate raw material in GLTF model!"); return; }; @@ -153,7 +151,7 @@ fn fix_ao_uv2(state: &mut Gd) -> Result<(), global::Error> { fn fix_emissive_materials(state: &mut Gd) { state.get_materials().iter_shared().for_each(|material| { let Ok(mut base_material) = material.try_cast::() else { - logger::warn!("GLTF material is not being imported as BaseMaterial3D"); + godot_warn!("GLTF material is not being imported as BaseMaterial3D"); return; }; diff --git a/native/src/editor/gltf.rs.uid b/native/editor/src/gltf.rs.uid similarity index 100% rename from native/src/editor/gltf.rs.uid rename to native/editor/src/gltf.rs.uid diff --git a/native/src/editor.rs b/native/editor/src/lib.rs similarity index 94% rename from native/src/editor.rs rename to native/editor/src/lib.rs index 3ff46c72..23846dcc 100644 --- a/native/src/editor.rs +++ b/native/editor/src/lib.rs @@ -8,7 +8,8 @@ mod ao_baker; mod building_imports; mod gltf; -pub mod ui; +mod ui; +mod util; use std::num::NonZero; use std::ops::DerefMut; @@ -22,16 +23,21 @@ use godot::classes::{ ProjectSettings, }; use godot::global::{self, godot_error, godot_print}; +use godot::init::{ExtensionLibrary, gdextension}; use godot::meta::{AsArg, FromGodot}; use godot::obj::{Base, Gd, NewGd, OnReady, Singleton as _, WithBaseField}; use godot::register::info::PropertyHint; -use godot::register::{godot_api, GodotClass}; +use godot::register::{GodotClass, godot_api}; use building_imports::SetupBuildingImports; -use crate::engine_callable; use crate::util::variant_type_default_value; +struct GDExtensionEntry; + +#[gdextension] +unsafe impl ExtensionLibrary for GDExtensionEntry {} + #[derive(GodotClass)] #[class(tool, base=EditorPlugin, internal)] struct EditorExtension { @@ -270,3 +276,16 @@ impl EngineSettings for Gd { self.deref_mut().add_property_info(property_info); } } + +#[macro_export] +macro_rules! engine_callable { + ($instance:expr, $host:ident::$fn:ident) => {{ + fn __typecheck>(instance: &Gd) -> &Gd { + instance + } + + let _fn_ptr = $host::$fn; + + __typecheck($instance).callable(stringify!($fn)) + }}; +} diff --git a/native/src/editor.rs.uid b/native/editor/src/lib.rs.uid similarity index 100% rename from native/src/editor.rs.uid rename to native/editor/src/lib.rs.uid diff --git a/native/src/editor/ui.rs b/native/editor/src/ui.rs similarity index 100% rename from native/src/editor/ui.rs rename to native/editor/src/ui.rs diff --git a/native/src/editor/ui.rs.uid b/native/editor/src/ui.rs.uid similarity index 100% rename from native/src/editor/ui.rs.uid rename to native/editor/src/ui.rs.uid diff --git a/native/src/editor/ui/progress_dialog.rs b/native/editor/src/ui/progress_dialog.rs similarity index 100% rename from native/src/editor/ui/progress_dialog.rs rename to native/editor/src/ui/progress_dialog.rs diff --git a/native/src/editor/ui/progress_dialog.rs.uid b/native/editor/src/ui/progress_dialog.rs.uid similarity index 100% rename from native/src/editor/ui/progress_dialog.rs.uid rename to native/editor/src/ui/progress_dialog.rs.uid diff --git a/native/src/util.rs b/native/editor/src/util.rs similarity index 56% rename from native/src/util.rs rename to native/editor/src/util.rs index 76ebc512..1dc3aee2 100644 --- a/native/src/util.rs +++ b/native/editor/src/util.rs @@ -1,45 +1,13 @@ -/* - * Copyright (c) SimChopper; Jovan Gerodetti and contributors. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -pub mod async_support; -pub mod logger; -mod numbers; - -#[cfg(debug_assertions)] use godot::builtin::{ - Aabb, Callable, Color, NodePath, PackedByteArray, PackedColorArray, PackedFloat32Array, + Aabb, Basis, Callable, Color, NodePath, PackedByteArray, PackedColorArray, PackedFloat32Array, PackedFloat64Array, PackedInt32Array, PackedInt64Array, PackedStringArray, PackedVector2Array, PackedVector3Array, PackedVector4Array, Plane, Projection, Quaternion, Rect2, Rect2i, Rid, Signal, StringName, Transform2D, Transform3D, VarArray, VarDictionary, Variant, VariantType, - Vector2, Vector2i, Vector3i, Vector4, Vector4i, + Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i, }; -use godot::builtin::{Basis, Vector3}; -#[cfg(debug_assertions)] use godot::classes::Object; -use godot::classes::{SceneTree, SceneTreeTimer}; -use godot::obj::Gd; -#[cfg(debug_assertions)] -use godot::obj::NewAlloc; - -pub use numbers::*; - -/// Create a new in game one-shot timer in seconds. -#[inline] -pub fn timer(tree: &mut Gd, delay: f64) -> Gd { - tree.create_timer_ex(delay) - .process_always(false) - .ignore_time_scale(false) - .process_in_physics(true) - .done() - .unwrap() -} +use godot::obj::NewAlloc as _; -#[cfg(debug_assertions)] -#[inline] pub fn variant_type_default_value(ty: VariantType) -> Variant { const MAX: i32 = VariantType::MAX.ord; @@ -91,66 +59,3 @@ pub fn variant_type_default_value(ty: VariantType) -> Variant { } } } - -pub(crate) mod vector3 { - use godot::builtin::Vector3; - - #[expect(unused)] - pub const XY_PLANE: Vector3 = Vector3 { - x: 1.0, - y: 1.0, - z: 0.0, - }; - - pub const XZ_PLANE: Vector3 = Vector3 { - x: 1.0, - y: 0.0, - z: 1.0, - }; - - #[expect(unused)] - pub const YZ_PLANE: Vector3 = Vector3 { - x: 0.0, - y: 1.0, - z: 1.0, - }; -} - -#[inline] -pub(crate) fn basis_from_normal(normal: Vector3) -> Basis { - Basis::from_cols( - normal.cross(Basis::IDENTITY.col_c()), - normal, - Basis::IDENTITY.col_a().cross(normal), - ) -} - -#[macro_export] -macro_rules! debug_3d { - ($debugger: expr => $($variable: tt),+) => { - #[cfg(debug_assertions)] - if let Some(ref mut debugger) = $debugger { - use $crate::scripts::objects::debugger_3_d::IDebugger3D; - - $( - $crate::debug_3d!(inner debugger, $variable); - )+ - } - }; - - (inner $debugger: ident, (float $variable: ident)) => { - $debugger.debug_data().set(stringify!($variable), ($variable * 100.0).round() / 100.0); - }; - - (inner $debugger: ident, (as_deg $variable: ident)) => { - $debugger.debug_data().set(stringify!($variable), $variable.to_degrees()); - }; - - (inner $debugger: ident, (ref $variable: ident)) => { - $debugger.debug_data().set(stringify!($variable), &$variable); - }; - - (inner $debugger: ident, $variable: ident) => { - $debugger.debug_data().set(stringify!($variable), $variable); - }; -} diff --git a/native/editor/src/util.rs.uid b/native/editor/src/util.rs.uid new file mode 100644 index 00000000..308340c1 --- /dev/null +++ b/native/editor/src/util.rs.uid @@ -0,0 +1 @@ +uid://dqxj6rqo4m0xg diff --git a/native/game/Cargo.toml b/native/game/Cargo.toml new file mode 100644 index 00000000..14ec21bb --- /dev/null +++ b/native/game/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "native" +version.workspace = true +edition.workspace = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +godot.workspace = true +godot-rust-script.workspace = true +lerp.workspace = true +backtrace.workspace = true +num.workspace = true +rayon.workspace = true +itertools.workspace = true +num_enum.workspace = true +derive-debug.workspace = true +thiserror.workspace = true +anyhow.workspace = true +rand.workspace = true +pomsky-macro.workspace = true +regex.workspace = true +kanal.workspace = true + +[lints] +workspace = true diff --git a/native/src/ext.rs b/native/game/src/ext.rs similarity index 100% rename from native/src/ext.rs rename to native/game/src/ext.rs diff --git a/native/src/ext.rs.uid b/native/game/src/ext.rs.uid similarity index 100% rename from native/src/ext.rs.uid rename to native/game/src/ext.rs.uid diff --git a/native/src/ext/node_3d.rs b/native/game/src/ext/node_3d.rs similarity index 100% rename from native/src/ext/node_3d.rs rename to native/game/src/ext/node_3d.rs diff --git a/native/src/ext/node_3d.rs.uid b/native/game/src/ext/node_3d.rs.uid similarity index 100% rename from native/src/ext/node_3d.rs.uid rename to native/game/src/ext/node_3d.rs.uid diff --git a/native/src/lib.rs b/native/game/src/lib.rs similarity index 94% rename from native/src/lib.rs rename to native/game/src/lib.rs index af4f6dea..b057a641 100644 --- a/native/src/lib.rs +++ b/native/game/src/lib.rs @@ -5,8 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#[cfg(debug_assertions)] -mod editor; mod ext; mod objects; mod project_settings; @@ -18,7 +16,7 @@ mod util; mod world; use godot::init::InitStage; -use godot::prelude::{gdextension, ExtensionLibrary}; +use godot::prelude::{ExtensionLibrary, gdextension}; struct NativeLib; diff --git a/native/src/lib.rs.uid b/native/game/src/lib.rs.uid similarity index 100% rename from native/src/lib.rs.uid rename to native/game/src/lib.rs.uid diff --git a/native/src/objects.rs b/native/game/src/objects.rs similarity index 100% rename from native/src/objects.rs rename to native/game/src/objects.rs diff --git a/native/src/objects.rs.uid b/native/game/src/objects.rs.uid similarity index 100% rename from native/src/objects.rs.uid rename to native/game/src/objects.rs.uid diff --git a/native/src/objects/scene_object_registry.rs b/native/game/src/objects/scene_object_registry.rs similarity index 100% rename from native/src/objects/scene_object_registry.rs rename to native/game/src/objects/scene_object_registry.rs diff --git a/native/src/objects/scene_object_registry.rs.uid b/native/game/src/objects/scene_object_registry.rs.uid similarity index 100% rename from native/src/objects/scene_object_registry.rs.uid rename to native/game/src/objects/scene_object_registry.rs.uid diff --git a/native/src/project_settings.rs b/native/game/src/project_settings.rs similarity index 100% rename from native/src/project_settings.rs rename to native/game/src/project_settings.rs diff --git a/native/src/project_settings.rs.uid b/native/game/src/project_settings.rs.uid similarity index 100% rename from native/src/project_settings.rs.uid rename to native/game/src/project_settings.rs.uid diff --git a/native/src/resources.rs b/native/game/src/resources.rs similarity index 100% rename from native/src/resources.rs rename to native/game/src/resources.rs diff --git a/native/src/resources.rs.uid b/native/game/src/resources.rs.uid similarity index 100% rename from native/src/resources.rs.uid rename to native/game/src/resources.rs.uid diff --git a/native/src/resources/input_device.rs b/native/game/src/resources/input_device.rs similarity index 100% rename from native/src/resources/input_device.rs rename to native/game/src/resources/input_device.rs diff --git a/native/src/resources/input_device.rs.uid b/native/game/src/resources/input_device.rs.uid similarity index 100% rename from native/src/resources/input_device.rs.uid rename to native/game/src/resources/input_device.rs.uid diff --git a/native/src/resources/items.rs b/native/game/src/resources/items.rs similarity index 100% rename from native/src/resources/items.rs rename to native/game/src/resources/items.rs diff --git a/native/src/resources/items.rs.uid b/native/game/src/resources/items.rs.uid similarity index 100% rename from native/src/resources/items.rs.uid rename to native/game/src/resources/items.rs.uid diff --git a/native/src/resources/items/helicopter_upgrade.rs b/native/game/src/resources/items/helicopter_upgrade.rs similarity index 100% rename from native/src/resources/items/helicopter_upgrade.rs rename to native/game/src/resources/items/helicopter_upgrade.rs diff --git a/native/src/resources/items/helicopter_upgrade.rs.uid b/native/game/src/resources/items/helicopter_upgrade.rs.uid similarity index 100% rename from native/src/resources/items/helicopter_upgrade.rs.uid rename to native/game/src/resources/items/helicopter_upgrade.rs.uid diff --git a/native/src/resources/water_decal_tracker.rs b/native/game/src/resources/water_decal_tracker.rs similarity index 100% rename from native/src/resources/water_decal_tracker.rs rename to native/game/src/resources/water_decal_tracker.rs diff --git a/native/src/resources/water_decal_tracker.rs.uid b/native/game/src/resources/water_decal_tracker.rs.uid similarity index 100% rename from native/src/resources/water_decal_tracker.rs.uid rename to native/game/src/resources/water_decal_tracker.rs.uid diff --git a/native/src/resources/world_constants.rs b/native/game/src/resources/world_constants.rs similarity index 100% rename from native/src/resources/world_constants.rs rename to native/game/src/resources/world_constants.rs diff --git a/native/src/resources/world_constants.rs.uid b/native/game/src/resources/world_constants.rs.uid similarity index 100% rename from native/src/resources/world_constants.rs.uid rename to native/game/src/resources/world_constants.rs.uid diff --git a/native/src/road_navigation.rs b/native/game/src/road_navigation.rs similarity index 96% rename from native/src/road_navigation.rs rename to native/game/src/road_navigation.rs index 256763f7..7b16ea89 100644 --- a/native/src/road_navigation.rs +++ b/native/game/src/road_navigation.rs @@ -10,16 +10,16 @@ use std::cmp::Ordering; use std::collections::BTreeMap; use std::sync::OnceLock; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use godot::builtin::math::ApproxEq; use godot::builtin::{Transform3D, VarDictionary, Vector3}; use godot::classes::Node3D; use godot::global::snappedf; use godot::obj::{Gd, OnEditor}; -use godot::prelude::{godot_api, GodotClass}; +use godot::prelude::{GodotClass, godot_api}; use num::ToPrimitive; -use rand::distr::Uniform; use rand::Rng; +use rand::distr::Uniform; use crate::world::city_coords_feature::CityCoordsFeature; use crate::world::city_data::TryFromDictionary; @@ -64,7 +64,7 @@ enum Direction { } impl Direction { - // Direction degrees in radiants. + // Direction degrees in radians. const FORWARD: f64 = 0.0; const BACK: f64 = 180.0f64.to_radians(); const BACK_NEGATIVE: f64 = -180.0f64.to_radians(); @@ -229,7 +229,7 @@ impl RoadNavigation { let neighbors = cache.get_or_init(|| { let (x, y) = tile_coords; - let neighbors = [ + [ y.checked_sub(1).map(|y| (x, y)), x.checked_sub(1).map(|x| (x, y)), Some((x + 1, y)), @@ -239,9 +239,7 @@ impl RoadNavigation { .flatten() .filter_map(|tile_coords| self.network.get(&tile_coords)) .map(|node| node.building.tile_coords) - .collect(); - - neighbors + .collect() }); Some(neighbors) @@ -256,7 +254,7 @@ impl RoadNavigation { (x, y) }; - // fas track, pick node at global transform + // fast track, pick node at global transform if let Some(node) = self.try_node(own_coords) { return Some(node); } @@ -372,7 +370,7 @@ impl RoadNavigation { let current_location = current.get_global_transform(Vector3::ZERO).origin; let target_location = target.get_global_transform(Vector3::ZERO).origin; - // current and target might be the same if we arrived at the target node. + // Current and target might be the same if we arrived at the target node. if current_location .distance_squared_to(target_location) .approx_eq(&0.0) @@ -400,7 +398,7 @@ impl RoadNavigation { let angle_actor_orientation = dir.angle_to(actor_orientation); let angle = dir.angle_to(dir_target); - // multiplying the angle between the target and the neighbor with the + // Multiplying the angle between the target and the neighbor with the // angle between the current actor orientation and the required actor // orientation, adds bias towards a neighbor that is in the direction // of the actors current orientation. @@ -432,7 +430,7 @@ impl RoadNavigation { } } -/// Configuration resource to setup road navigation for vehicles. +/// Configuration resource to set up road navigation for vehicles. #[derive(GodotClass)] #[class(base = Resource, init)] pub struct RoadNavigationConfig { @@ -450,7 +448,7 @@ impl RoadNavigationConfig { } pub(crate) fn road_navigation_mut(&mut self) -> &mut RoadNavigation { - // make sure instance is initialized. + // Make sure instance is initialized. self.road_navigation(); self.instance.get_mut().expect("we just initialized") diff --git a/native/src/road_navigation.rs.uid b/native/game/src/road_navigation.rs.uid similarity index 100% rename from native/src/road_navigation.rs.uid rename to native/game/src/road_navigation.rs.uid diff --git a/native/src/scripts/effects.rs b/native/game/src/scripts/effects.rs similarity index 100% rename from native/src/scripts/effects.rs rename to native/game/src/scripts/effects.rs diff --git a/native/src/scripts/effects.rs.uid b/native/game/src/scripts/effects.rs.uid similarity index 100% rename from native/src/scripts/effects.rs.uid rename to native/game/src/scripts/effects.rs.uid diff --git a/native/src/scripts/effects/water_decal.rs b/native/game/src/scripts/effects/water_decal.rs similarity index 100% rename from native/src/scripts/effects/water_decal.rs rename to native/game/src/scripts/effects/water_decal.rs diff --git a/native/src/scripts/effects/water_decal.rs.uid b/native/game/src/scripts/effects/water_decal.rs.uid similarity index 100% rename from native/src/scripts/effects/water_decal.rs.uid rename to native/game/src/scripts/effects/water_decal.rs.uid diff --git a/native/src/scripts/mod.rs b/native/game/src/scripts/mod.rs similarity index 100% rename from native/src/scripts/mod.rs rename to native/game/src/scripts/mod.rs diff --git a/native/src/scripts/mod.rs.uid b/native/game/src/scripts/mod.rs.uid similarity index 100% rename from native/src/scripts/mod.rs.uid rename to native/game/src/scripts/mod.rs.uid diff --git a/native/src/scripts/objects.rs b/native/game/src/scripts/objects.rs similarity index 100% rename from native/src/scripts/objects.rs rename to native/game/src/scripts/objects.rs diff --git a/native/src/scripts/objects.rs.uid b/native/game/src/scripts/objects.rs.uid similarity index 100% rename from native/src/scripts/objects.rs.uid rename to native/game/src/scripts/objects.rs.uid diff --git a/native/src/scripts/objects/agents.rs b/native/game/src/scripts/objects/agents.rs similarity index 100% rename from native/src/scripts/objects/agents.rs rename to native/game/src/scripts/objects/agents.rs diff --git a/native/src/scripts/objects/agents.rs.uid b/native/game/src/scripts/objects/agents.rs.uid similarity index 100% rename from native/src/scripts/objects/agents.rs.uid rename to native/game/src/scripts/objects/agents.rs.uid diff --git a/native/src/scripts/objects/agents/car.rs b/native/game/src/scripts/objects/agents/car.rs similarity index 100% rename from native/src/scripts/objects/agents/car.rs rename to native/game/src/scripts/objects/agents/car.rs diff --git a/native/src/scripts/objects/agents/car.rs.uid b/native/game/src/scripts/objects/agents/car.rs.uid similarity index 100% rename from native/src/scripts/objects/agents/car.rs.uid rename to native/game/src/scripts/objects/agents/car.rs.uid diff --git a/native/src/scripts/objects/building.rs b/native/game/src/scripts/objects/building.rs similarity index 100% rename from native/src/scripts/objects/building.rs rename to native/game/src/scripts/objects/building.rs diff --git a/native/src/scripts/objects/building.rs.uid b/native/game/src/scripts/objects/building.rs.uid similarity index 100% rename from native/src/scripts/objects/building.rs.uid rename to native/game/src/scripts/objects/building.rs.uid diff --git a/native/src/scripts/objects/building/fire.rs b/native/game/src/scripts/objects/building/fire.rs similarity index 100% rename from native/src/scripts/objects/building/fire.rs rename to native/game/src/scripts/objects/building/fire.rs diff --git a/native/src/scripts/objects/building/fire.rs.uid b/native/game/src/scripts/objects/building/fire.rs.uid similarity index 100% rename from native/src/scripts/objects/building/fire.rs.uid rename to native/game/src/scripts/objects/building/fire.rs.uid diff --git a/native/src/scripts/objects/camera.rs b/native/game/src/scripts/objects/camera.rs similarity index 100% rename from native/src/scripts/objects/camera.rs rename to native/game/src/scripts/objects/camera.rs diff --git a/native/src/scripts/objects/camera.rs.uid b/native/game/src/scripts/objects/camera.rs.uid similarity index 100% rename from native/src/scripts/objects/camera.rs.uid rename to native/game/src/scripts/objects/camera.rs.uid diff --git a/native/src/scripts/objects/canon_upgrade.rs b/native/game/src/scripts/objects/canon_upgrade.rs similarity index 100% rename from native/src/scripts/objects/canon_upgrade.rs rename to native/game/src/scripts/objects/canon_upgrade.rs diff --git a/native/src/scripts/objects/canon_upgrade.rs.uid b/native/game/src/scripts/objects/canon_upgrade.rs.uid similarity index 100% rename from native/src/scripts/objects/canon_upgrade.rs.uid rename to native/game/src/scripts/objects/canon_upgrade.rs.uid diff --git a/native/src/scripts/objects/debugger_3_d.rs b/native/game/src/scripts/objects/debugger_3_d.rs similarity index 100% rename from native/src/scripts/objects/debugger_3_d.rs rename to native/game/src/scripts/objects/debugger_3_d.rs diff --git a/native/src/scripts/objects/debugger_3_d.rs.uid b/native/game/src/scripts/objects/debugger_3_d.rs.uid similarity index 100% rename from native/src/scripts/objects/debugger_3_d.rs.uid rename to native/game/src/scripts/objects/debugger_3_d.rs.uid diff --git a/native/src/scripts/objects/water_jet.rs b/native/game/src/scripts/objects/water_jet.rs similarity index 98% rename from native/src/scripts/objects/water_jet.rs rename to native/game/src/scripts/objects/water_jet.rs index 5f00d5d3..a912ed08 100644 --- a/native/src/scripts/objects/water_jet.rs +++ b/native/game/src/scripts/objects/water_jet.rs @@ -7,7 +7,7 @@ use std::boxed::Box; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use godot::builtin::{Aabb, Array, Callable, StringName, Variant, Vector3}; use godot::classes::object::ConnectFlags; use godot::classes::{ @@ -16,7 +16,7 @@ use godot::classes::{ use godot::meta::ToGodot; use godot::obj::{Gd, Inherits}; use godot::prelude::{GodotClass, NodePath}; -use godot_rust_script::{godot_script_impl, GodotScript, OnEditor, RsRef}; +use godot_rust_script::{GodotScript, OnEditor, RsRef, godot_script_impl}; use crate::ext::node_3d::Node3DExt; use crate::resources::WaterDecalTracker; @@ -267,11 +267,9 @@ impl WaterJet { return false; } - let can_spawn = decals_at_point + decals_at_point .iter() - .all(|decal| decal.distance_to(point.position) > extent); - - can_spawn + .all(|decal| decal.distance_to(point.position) > extent) } fn align_decal_normal(&self, point: Intersection) -> Intersection { diff --git a/native/src/scripts/objects/water_jet.rs.uid b/native/game/src/scripts/objects/water_jet.rs.uid similarity index 100% rename from native/src/scripts/objects/water_jet.rs.uid rename to native/game/src/scripts/objects/water_jet.rs.uid diff --git a/native/src/scripts/particles/dust_particles.rs b/native/game/src/scripts/particles/dust_particles.rs similarity index 100% rename from native/src/scripts/particles/dust_particles.rs rename to native/game/src/scripts/particles/dust_particles.rs diff --git a/native/src/scripts/particles/dust_particles.rs.uid b/native/game/src/scripts/particles/dust_particles.rs.uid similarity index 100% rename from native/src/scripts/particles/dust_particles.rs.uid rename to native/game/src/scripts/particles/dust_particles.rs.uid diff --git a/native/src/scripts/particles/mod.rs b/native/game/src/scripts/particles/mod.rs similarity index 100% rename from native/src/scripts/particles/mod.rs rename to native/game/src/scripts/particles/mod.rs diff --git a/native/src/scripts/particles/mod.rs.uid b/native/game/src/scripts/particles/mod.rs.uid similarity index 100% rename from native/src/scripts/particles/mod.rs.uid rename to native/game/src/scripts/particles/mod.rs.uid diff --git a/native/src/scripts/spawner/car_spawner.rs b/native/game/src/scripts/spawner/car_spawner.rs similarity index 100% rename from native/src/scripts/spawner/car_spawner.rs rename to native/game/src/scripts/spawner/car_spawner.rs diff --git a/native/src/scripts/spawner/car_spawner.rs.uid b/native/game/src/scripts/spawner/car_spawner.rs.uid similarity index 100% rename from native/src/scripts/spawner/car_spawner.rs.uid rename to native/game/src/scripts/spawner/car_spawner.rs.uid diff --git a/native/src/scripts/spawner/fire_spawner.rs b/native/game/src/scripts/spawner/fire_spawner.rs similarity index 100% rename from native/src/scripts/spawner/fire_spawner.rs rename to native/game/src/scripts/spawner/fire_spawner.rs diff --git a/native/src/scripts/spawner/fire_spawner.rs.uid b/native/game/src/scripts/spawner/fire_spawner.rs.uid similarity index 100% rename from native/src/scripts/spawner/fire_spawner.rs.uid rename to native/game/src/scripts/spawner/fire_spawner.rs.uid diff --git a/native/src/scripts/spawner/mod.rs b/native/game/src/scripts/spawner/mod.rs similarity index 100% rename from native/src/scripts/spawner/mod.rs rename to native/game/src/scripts/spawner/mod.rs diff --git a/native/src/scripts/spawner/mod.rs.uid b/native/game/src/scripts/spawner/mod.rs.uid similarity index 100% rename from native/src/scripts/spawner/mod.rs.uid rename to native/game/src/scripts/spawner/mod.rs.uid diff --git a/native/src/scripts/ui.rs b/native/game/src/scripts/ui.rs similarity index 100% rename from native/src/scripts/ui.rs rename to native/game/src/scripts/ui.rs diff --git a/native/src/scripts/ui.rs.uid b/native/game/src/scripts/ui.rs.uid similarity index 100% rename from native/src/scripts/ui.rs.uid rename to native/game/src/scripts/ui.rs.uid diff --git a/native/src/scripts/ui/title_menu.rs b/native/game/src/scripts/ui/title_menu.rs similarity index 100% rename from native/src/scripts/ui/title_menu.rs rename to native/game/src/scripts/ui/title_menu.rs diff --git a/native/src/scripts/ui/title_menu.rs.uid b/native/game/src/scripts/ui/title_menu.rs.uid similarity index 100% rename from native/src/scripts/ui/title_menu.rs.uid rename to native/game/src/scripts/ui/title_menu.rs.uid diff --git a/native/src/scripts/world.rs b/native/game/src/scripts/world.rs similarity index 100% rename from native/src/scripts/world.rs rename to native/game/src/scripts/world.rs diff --git a/native/src/scripts/world.rs.uid b/native/game/src/scripts/world.rs.uid similarity index 100% rename from native/src/scripts/world.rs.uid rename to native/game/src/scripts/world.rs.uid diff --git a/native/src/scripts/world/buildings.rs b/native/game/src/scripts/world/buildings.rs similarity index 100% rename from native/src/scripts/world/buildings.rs rename to native/game/src/scripts/world/buildings.rs diff --git a/native/src/scripts/world/buildings.rs.uid b/native/game/src/scripts/world/buildings.rs.uid similarity index 100% rename from native/src/scripts/world/buildings.rs.uid rename to native/game/src/scripts/world/buildings.rs.uid diff --git a/native/src/scripts/world/gi_probes.rs b/native/game/src/scripts/world/gi_probes.rs similarity index 100% rename from native/src/scripts/world/gi_probes.rs rename to native/game/src/scripts/world/gi_probes.rs diff --git a/native/src/scripts/world/gi_probes.rs.uid b/native/game/src/scripts/world/gi_probes.rs.uid similarity index 100% rename from native/src/scripts/world/gi_probes.rs.uid rename to native/game/src/scripts/world/gi_probes.rs.uid diff --git a/native/src/scripts/world/solar_setup.rs b/native/game/src/scripts/world/solar_setup.rs similarity index 96% rename from native/src/scripts/world/solar_setup.rs rename to native/game/src/scripts/world/solar_setup.rs index f56c1cc7..6637fbbb 100644 --- a/native/src/scripts/world/solar_setup.rs +++ b/native/game/src/scripts/world/solar_setup.rs @@ -7,14 +7,17 @@ use std::f32; -use godot::builtin::math::FloatExt; use godot::builtin::Vector3; +use godot::builtin::math::FloatExt; +#[cfg(debug_assertions)] +use godot::classes::Performance; use godot::classes::class_macros::private::virtuals::Xrvrs::math::ApproxEq; -use godot::classes::{light_3d, DirectionalLight3D, Node3D, Performance, Time, VoxelGiData}; +use godot::classes::{DirectionalLight3D, Node3D, Time, VoxelGiData, light_3d}; use godot::obj::{Gd, Singleton as _}; -use godot_rust_script::{godot_script_impl, GodotScript, OnEditor, ScriptSignal}; +use godot_rust_script::{GodotScript, OnEditor, ScriptSignal, godot_script_impl}; use num::ToPrimitive; +#[cfg(debug_assertions)] use crate::script_callable; use crate::util::Uf32; @@ -66,7 +69,7 @@ impl SolarSetup { } #[cfg(debug_assertions)] - pub fn debug_monitors(&self) { + fn debug_monitors(&self) { let mut performance = Performance::singleton(); performance.add_custom_monitor( diff --git a/native/src/scripts/world/solar_setup.rs.uid b/native/game/src/scripts/world/solar_setup.rs.uid similarity index 100% rename from native/src/scripts/world/solar_setup.rs.uid rename to native/game/src/scripts/world/solar_setup.rs.uid diff --git a/native/src/terrain_builder.rs b/native/game/src/terrain_builder.rs similarity index 100% rename from native/src/terrain_builder.rs rename to native/game/src/terrain_builder.rs diff --git a/native/src/terrain_builder.rs.uid b/native/game/src/terrain_builder.rs.uid similarity index 100% rename from native/src/terrain_builder.rs.uid rename to native/game/src/terrain_builder.rs.uid diff --git a/native/src/terrain_builder/lerp.rs b/native/game/src/terrain_builder/lerp.rs similarity index 100% rename from native/src/terrain_builder/lerp.rs rename to native/game/src/terrain_builder/lerp.rs diff --git a/native/src/terrain_builder/lerp.rs.uid b/native/game/src/terrain_builder/lerp.rs.uid similarity index 100% rename from native/src/terrain_builder/lerp.rs.uid rename to native/game/src/terrain_builder/lerp.rs.uid diff --git a/native/src/terrain_builder/point.rs b/native/game/src/terrain_builder/point.rs similarity index 100% rename from native/src/terrain_builder/point.rs rename to native/game/src/terrain_builder/point.rs diff --git a/native/src/terrain_builder/point.rs.uid b/native/game/src/terrain_builder/point.rs.uid similarity index 100% rename from native/src/terrain_builder/point.rs.uid rename to native/game/src/terrain_builder/point.rs.uid diff --git a/native/src/terrain_builder/terrain_rotation.rs b/native/game/src/terrain_builder/terrain_rotation.rs similarity index 100% rename from native/src/terrain_builder/terrain_rotation.rs rename to native/game/src/terrain_builder/terrain_rotation.rs diff --git a/native/src/terrain_builder/terrain_rotation.rs.uid b/native/game/src/terrain_builder/terrain_rotation.rs.uid similarity index 100% rename from native/src/terrain_builder/terrain_rotation.rs.uid rename to native/game/src/terrain_builder/terrain_rotation.rs.uid diff --git a/native/src/terrain_builder/tile_surface.rs b/native/game/src/terrain_builder/tile_surface.rs similarity index 100% rename from native/src/terrain_builder/tile_surface.rs rename to native/game/src/terrain_builder/tile_surface.rs diff --git a/native/src/terrain_builder/tile_surface.rs.uid b/native/game/src/terrain_builder/tile_surface.rs.uid similarity index 100% rename from native/src/terrain_builder/tile_surface.rs.uid rename to native/game/src/terrain_builder/tile_surface.rs.uid diff --git a/native/game/src/util.rs b/native/game/src/util.rs new file mode 100644 index 00000000..a4c8d944 --- /dev/null +++ b/native/game/src/util.rs @@ -0,0 +1,90 @@ +/* + * Copyright (c) SimChopper; Jovan Gerodetti and contributors. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +pub mod async_support; +pub mod logger; +mod numbers; + +use godot::builtin::{Basis, Vector3}; +use godot::classes::{SceneTree, SceneTreeTimer}; +use godot::obj::Gd; + +pub use numbers::*; + +/// Create a new in game one-shot timer in seconds. +#[inline] +pub fn timer(tree: &mut Gd, delay: f64) -> Gd { + tree.create_timer_ex(delay) + .process_always(false) + .ignore_time_scale(false) + .process_in_physics(true) + .done() + .unwrap() +} + +pub(crate) mod vector3 { + use godot::builtin::Vector3; + + #[expect(unused)] + pub const XY_PLANE: Vector3 = Vector3 { + x: 1.0, + y: 1.0, + z: 0.0, + }; + + pub const XZ_PLANE: Vector3 = Vector3 { + x: 1.0, + y: 0.0, + z: 1.0, + }; + + #[expect(unused)] + pub const YZ_PLANE: Vector3 = Vector3 { + x: 0.0, + y: 1.0, + z: 1.0, + }; +} + +#[inline] +pub(crate) fn basis_from_normal(normal: Vector3) -> Basis { + Basis::from_cols( + normal.cross(Basis::IDENTITY.col_c()), + normal, + Basis::IDENTITY.col_a().cross(normal), + ) +} + +#[macro_export] +macro_rules! debug_3d { + ($debugger: expr => $($variable: tt),+) => { + #[cfg(debug_assertions)] + if let Some(ref mut debugger) = $debugger { + use $crate::scripts::objects::debugger_3_d::IDebugger3D; + + $( + $crate::debug_3d!(inner debugger, $variable); + )+ + } + }; + + (inner $debugger: ident, (float $variable: ident)) => { + $debugger.debug_data().set(stringify!($variable), ($variable * 100.0).round() / 100.0); + }; + + (inner $debugger: ident, (as_deg $variable: ident)) => { + $debugger.debug_data().set(stringify!($variable), $variable.to_degrees()); + }; + + (inner $debugger: ident, (ref $variable: ident)) => { + $debugger.debug_data().set(stringify!($variable), &$variable); + }; + + (inner $debugger: ident, $variable: ident) => { + $debugger.debug_data().set(stringify!($variable), $variable); + }; +} diff --git a/native/src/util.rs.uid b/native/game/src/util.rs.uid similarity index 100% rename from native/src/util.rs.uid rename to native/game/src/util.rs.uid diff --git a/native/src/util/async_support.rs b/native/game/src/util/async_support.rs similarity index 100% rename from native/src/util/async_support.rs rename to native/game/src/util/async_support.rs diff --git a/native/src/util/async_support.rs.uid b/native/game/src/util/async_support.rs.uid similarity index 100% rename from native/src/util/async_support.rs.uid rename to native/game/src/util/async_support.rs.uid diff --git a/native/src/util/logger.rs b/native/game/src/util/logger.rs similarity index 100% rename from native/src/util/logger.rs rename to native/game/src/util/logger.rs diff --git a/native/src/util/logger.rs.uid b/native/game/src/util/logger.rs.uid similarity index 100% rename from native/src/util/logger.rs.uid rename to native/game/src/util/logger.rs.uid diff --git a/native/src/util/numbers.rs b/native/game/src/util/numbers.rs similarity index 100% rename from native/src/util/numbers.rs rename to native/game/src/util/numbers.rs diff --git a/native/src/util/numbers.rs.uid b/native/game/src/util/numbers.rs.uid similarity index 100% rename from native/src/util/numbers.rs.uid rename to native/game/src/util/numbers.rs.uid diff --git a/native/src/world.rs b/native/game/src/world.rs similarity index 100% rename from native/src/world.rs rename to native/game/src/world.rs diff --git a/native/src/world.rs.uid b/native/game/src/world.rs.uid similarity index 100% rename from native/src/world.rs.uid rename to native/game/src/world.rs.uid diff --git a/native/src/world/city_coords_feature.rs b/native/game/src/world/city_coords_feature.rs similarity index 100% rename from native/src/world/city_coords_feature.rs rename to native/game/src/world/city_coords_feature.rs diff --git a/native/src/world/city_coords_feature.rs.uid b/native/game/src/world/city_coords_feature.rs.uid similarity index 100% rename from native/src/world/city_coords_feature.rs.uid rename to native/game/src/world/city_coords_feature.rs.uid diff --git a/native/src/world/city_data.rs b/native/game/src/world/city_data.rs similarity index 100% rename from native/src/world/city_data.rs rename to native/game/src/world/city_data.rs diff --git a/native/src/world/city_data.rs.uid b/native/game/src/world/city_data.rs.uid similarity index 100% rename from native/src/world/city_data.rs.uid rename to native/game/src/world/city_data.rs.uid diff --git a/native/src/world/city_data/terrain_slope.rs b/native/game/src/world/city_data/terrain_slope.rs similarity index 100% rename from native/src/world/city_data/terrain_slope.rs rename to native/game/src/world/city_data/terrain_slope.rs diff --git a/native/src/world/city_data/terrain_slope.rs.uid b/native/game/src/world/city_data/terrain_slope.rs.uid similarity index 100% rename from native/src/world/city_data/terrain_slope.rs.uid rename to native/game/src/world/city_data/terrain_slope.rs.uid diff --git a/resources/Debug/debugger_3d.tscn b/resources/Debug/debugger_3d.tscn index d34cd8e7..13d5698d 100644 --- a/resources/Debug/debugger_3d.tscn +++ b/resources/Debug/debugger_3d.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://byr7jias4d8hc"] -[ext_resource type="Script" uid="uid://b1dsfsam1klye" path="res://native/src/scripts/objects/debugger_3_d.rs" id="1_fagxb"] +[ext_resource type="Script" uid="uid://b1dsfsam1klye" path="res://native/game/src/scripts/objects/debugger_3_d.rs" id="1_fagxb"] [ext_resource type="PackedScene" uid="uid://c36tta374cm54" path="res://resources/HUD/debug/debug_3d.tscn" id="2_bq2lw"] [sub_resource type="ViewportTexture" id="ViewportTexture_0mey1"] diff --git a/resources/Objects/Buildings/condominiums_medium_2.tscn b/resources/Objects/Buildings/condominiums_medium_2.tscn index c7b78745..b5f6cf2d 100644 --- a/resources/Objects/Buildings/condominiums_medium_2.tscn +++ b/resources/Objects/Buildings/condominiums_medium_2.tscn @@ -1,7 +1,7 @@ [gd_scene format=3 uid="uid://c8umigs5eeyn3"] [ext_resource type="PackedScene" uid="uid://bmfjmd3guekcu" path="res://resources/Meshes/Buildings/Condominiums/medium_2.gltf" id="1"] -[ext_resource type="Script" uid="uid://c50j0d6f8phpx" path="res://native/src/scripts/objects/building.rs" id="2_gr7u5"] +[ext_resource type="Script" uid="uid://c50j0d6f8phpx" path="res://native/game/src/scripts/objects/building.rs" id="2_gr7u5"] [ext_resource type="Texture2D" uid="uid://drioin3jjvc4m" path="res://resources/Particles/fire/emitters/condominiums_medium_2.res" id="3_5pv00"] [ext_resource type="Texture2D" uid="uid://hg48d3hbeio4" path="res://resources/Particles/fire/emitters/condominiums_medium_2_normals.res" id="4_m0oy2"] diff --git a/resources/Objects/Buildings/home_middle_class_3.tscn b/resources/Objects/Buildings/home_middle_class_3.tscn index 27889cb6..d0acd4ff 100644 --- a/resources/Objects/Buildings/home_middle_class_3.tscn +++ b/resources/Objects/Buildings/home_middle_class_3.tscn @@ -1,7 +1,7 @@ [gd_scene format=3 uid="uid://5lcllve4d4s5"] [ext_resource type="PackedScene" uid="uid://h1n7d1h23vcn" path="res://resources/Meshes/Buildings/Home/middle_class_3.gltf" id="1"] -[ext_resource type="Script" uid="uid://c50j0d6f8phpx" path="res://native/src/scripts/objects/building.rs" id="2_dq8cm"] +[ext_resource type="Script" uid="uid://c50j0d6f8phpx" path="res://native/game/src/scripts/objects/building.rs" id="2_dq8cm"] [ext_resource type="Texture2D" uid="uid://bmihrxkgvh4nm" path="res://resources/Particles/fire/emitters/home_middle_class_3.res" id="3_c8e1x"] [ext_resource type="Texture2D" uid="uid://b8p7nili11nkk" path="res://resources/Particles/fire/emitters/home_middle_class_3_normals.res" id="4_huvg1"] diff --git a/resources/Objects/Buildings/office_building_medium_4.tscn b/resources/Objects/Buildings/office_building_medium_4.tscn index 10b684c6..ed21a5eb 100644 --- a/resources/Objects/Buildings/office_building_medium_4.tscn +++ b/resources/Objects/Buildings/office_building_medium_4.tscn @@ -1,7 +1,7 @@ [gd_scene format=3 uid="uid://b0uxnw5wje6y4"] [ext_resource type="PackedScene" uid="uid://dpq3c588herdb" path="res://resources/Meshes/Buildings/Offices/medium_4.gltf" id="1"] -[ext_resource type="Script" uid="uid://c50j0d6f8phpx" path="res://native/src/scripts/objects/building.rs" id="2_67wch"] +[ext_resource type="Script" uid="uid://c50j0d6f8phpx" path="res://native/game/src/scripts/objects/building.rs" id="2_67wch"] [ext_resource type="Texture2D" uid="uid://bkvm0hs3ou6ud" path="res://resources/Particles/fire/emitters/office_building_medium_4.res" id="3_uich8"] [ext_resource type="Texture2D" uid="uid://cqsayw0rbdfne" path="res://resources/Particles/fire/emitters/office_building_medium_4_normals.res" id="4_uich8"] diff --git a/resources/Objects/Helis/Helicopter.tscn b/resources/Objects/Helis/Helicopter.tscn index ded23a7f..f50c58a9 100644 --- a/resources/Objects/Helis/Helicopter.tscn +++ b/resources/Objects/Helis/Helicopter.tscn @@ -2,7 +2,7 @@ [ext_resource type="HelicopterUpgrade" uid="uid://c02c65wkdq1r5" path="res://resources/Items/water_canon_helicopter_upgrade.tres" id="2_0cfwx"] [ext_resource type="Material" uid="uid://cjoloelf8ku4k" path="res://resources/Materials/dust_material.tres" id="2_8yiqd"] -[ext_resource type="Script" uid="uid://btdtyemgtmocf" path="res://native/src/scripts/particles/dust_particles.rs" id="2_ocmjg"] +[ext_resource type="Script" uid="uid://btdtyemgtmocf" path="res://native/game/src/scripts/particles/dust_particles.rs" id="2_ocmjg"] [ext_resource type="Script" uid="uid://cdhopkxkcjpyl" path="res://src/Objects/Helicopters/Helicopter.gd" id="3"] [ext_resource type="Material" uid="uid://ckkpoyyglqm80" path="res://resources/Particles/Rotor/rotor_dust_particles_schweizer.tres" id="3_0kehh"] [ext_resource type="AnimationNodeStateMachine" uid="uid://xbcrg5mghpup" path="res://resources/Animations/HelicopterRotorSoundStates.tres" id="4_8iee2"] diff --git a/resources/Objects/Helis/Upgrades/canon.tscn b/resources/Objects/Helis/Upgrades/canon.tscn index 51949dfd..b0024344 100644 --- a/resources/Objects/Helis/Upgrades/canon.tscn +++ b/resources/Objects/Helis/Upgrades/canon.tscn @@ -1,14 +1,14 @@ [gd_scene format=3 uid="uid://c0pat4v54oe86"] [ext_resource type="PackedScene" uid="uid://daf3wyyha2hm" path="res://resources/Meshes/Helis/upgrades/cannon.gltf" id="1_54ycj"] -[ext_resource type="Script" uid="uid://dvqexwe8r1gw7" path="res://native/src/scripts/objects/canon_upgrade.rs" id="2_1jnub"] +[ext_resource type="Script" uid="uid://dvqexwe8r1gw7" path="res://native/game/src/scripts/objects/canon_upgrade.rs" id="2_1jnub"] [ext_resource type="Material" uid="uid://bamhf7as5ev7r" path="res://resources/Particles/water_jet/water_jet.tres" id="2_nsqv1"] [ext_resource type="Material" uid="uid://cdtr7t6dqskao" path="res://resources/Materials/water_particle_material.tres" id="3_lyjqx"] -[ext_resource type="Script" uid="uid://clfua0cr30myq" path="res://native/src/scripts/objects/water_jet.rs" id="4_3ki7x"] +[ext_resource type="Script" uid="uid://clfua0cr30myq" path="res://native/game/src/scripts/objects/water_jet.rs" id="4_3ki7x"] [ext_resource type="Texture2D" uid="uid://cgajeno6v3mbj" path="res://resources/Particles/water_jet/water_particle_alpha.png" id="4_owba1"] [ext_resource type="Texture2D" uid="uid://d17vaba581i6" path="res://resources/Particles/water_jet/water_particle_normal.png" id="5_cxogv"] [ext_resource type="WaterDecalTracker" uid="uid://bvelsm8gt2na8" path="res://resources/Config/water_decal_tracker.tres" id="6_p6un2"] -[ext_resource type="Script" uid="uid://wlx155raqrai" path="res://native/src/scripts/effects/water_decal.rs" id="9_v48py"] +[ext_resource type="Script" uid="uid://wlx155raqrai" path="res://native/game/src/scripts/effects/water_decal.rs" id="9_v48py"] [ext_resource type="AnimationLibrary" uid="uid://ccdoql0ui30qd" path="res://resources/Animations/canon_water_jet.tres" id="10_u6k6a"] [ext_resource type="AnimationNodeStateMachine" uid="uid://bhxg4j3d3uxr0" path="res://resources/Animations/canon_water_jet_animation_states.tres" id="11_sjwuo"] [ext_resource type="PackedScene" uid="uid://byr7jias4d8hc" path="res://resources/Debug/debugger_3d.tscn" id="12_xx02s"] diff --git a/resources/Objects/Spawner/CarSpawner.tscn b/resources/Objects/Spawner/CarSpawner.tscn index 1adb4973..8ed93d38 100644 --- a/resources/Objects/Spawner/CarSpawner.tscn +++ b/resources/Objects/Spawner/CarSpawner.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://blyermwgncstx"] -[ext_resource type="Script" uid="uid://bc552pej2vb8b" path="res://native/src/scripts/spawner/car_spawner.rs" id="1_c5pws"] +[ext_resource type="Script" uid="uid://bc552pej2vb8b" path="res://native/game/src/scripts/spawner/car_spawner.rs" id="1_c5pws"] [sub_resource type="CylinderMesh" id="CylinderMesh_falwk"] top_radius = 10.0 diff --git a/resources/Objects/Spawner/fire_spawner.tscn b/resources/Objects/Spawner/fire_spawner.tscn index 2d8e94d7..ad6fc5d0 100644 --- a/resources/Objects/Spawner/fire_spawner.tscn +++ b/resources/Objects/Spawner/fire_spawner.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://5jijewumod80"] -[ext_resource type="Script" uid="uid://rv7naiqpa17x" path="res://native/src/scripts/spawner/fire_spawner.rs" id="1_aar5t"] +[ext_resource type="Script" uid="uid://rv7naiqpa17x" path="res://native/game/src/scripts/spawner/fire_spawner.rs" id="1_aar5t"] [ext_resource type="Texture2D" uid="uid://c8edk8pamge2n" path="res://resources/Particles/fire/emitters/example_building.res" id="2_h5f1y"] [ext_resource type="Texture2D" uid="uid://dsau4l5yoyua" path="res://resources/Particles/fire/emitters/example_building_normals.res" id="3_cbxbr"] [ext_resource type="AnimationLibrary" uid="uid://dtoyo725l55bb" path="res://resources/Animations/fire_spawner/fire_spawner_animations.tres" id="4_rhyet"] diff --git a/resources/Objects/Vehicles/car_station_wagon.tscn b/resources/Objects/Vehicles/car_station_wagon.tscn index 73af0f2c..f4dadfee 100644 --- a/resources/Objects/Vehicles/car_station_wagon.tscn +++ b/resources/Objects/Vehicles/car_station_wagon.tscn @@ -1,7 +1,7 @@ [gd_scene format=3 uid="uid://k14yev0gxbkc"] [ext_resource type="PackedScene" uid="uid://drfx6m1pn4ap6" path="res://resources/Meshes/Vehicles/car_station_wagon.gltf" id="1_fohcy"] -[ext_resource type="Script" uid="uid://fglqwp4se6ra" path="res://native/src/scripts/objects/agents/car.rs" id="2_uxtlx"] +[ext_resource type="Script" uid="uid://fglqwp4se6ra" path="res://native/game/src/scripts/objects/agents/car.rs" id="2_uxtlx"] [ext_resource type="RoadNavigationConfig" uid="uid://dvccb8vdrejqp" path="res://resources/Config/road_navigation.tres" id="3_g0ogw"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_juekg"] diff --git a/resources/main.tscn b/resources/main.tscn index 780c7941..c8fe7a87 100644 --- a/resources/main.tscn +++ b/resources/main.tscn @@ -7,20 +7,20 @@ [ext_resource type="Script" uid="uid://ksr8mwgn8xoq" path="res://src/Objects/World/Backdrop.gd" id="6"] [ext_resource type="CameraAttributesPhysical" uid="uid://ckjhc3lehild4" path="res://resources/Environments/camera_attributes_physical.tres" id="7_yho3v"] [ext_resource type="Environment" uid="uid://bl607wqoa882d" path="res://resources/Environments/WorldEnv.tres" id="8"] -[ext_resource type="Script" uid="uid://jljpgypnojsp" path="res://native/src/scripts/objects/camera.rs" id="8_qw8ew"] +[ext_resource type="Script" uid="uid://jljpgypnojsp" path="res://native/game/src/scripts/objects/camera.rs" id="8_qw8ew"] [ext_resource type="VoxelGIData" uid="uid://cu5hs3tfbj2xd" path="res://resources/Config/voxel_gi_params.tres" id="9_nkrdn"] [ext_resource type="Script" uid="uid://bblluinwmhapb" path="res://src/Objects/Camera/CameraInterpolation.gd" id="10"] [ext_resource type="Script" uid="uid://dbmgsvtd552t6" path="res://src/Objects/Terrain/Terrain.gd" id="11"] [ext_resource type="Material" uid="uid://d3jryprnnxb6x" path="res://resources/Materials/terrain_material.tres" id="12"] -[ext_resource type="Script" uid="uid://c0a6eytloytey" path="res://native/src/scripts/world/solar_setup.rs" id="12_88vys"] +[ext_resource type="Script" uid="uid://c0a6eytloytey" path="res://native/game/src/scripts/world/solar_setup.rs" id="12_88vys"] [ext_resource type="InputDevice" uid="uid://bky2vkjjwnd0p" path="res://resources/Config/primary_input_device.tres" id="12_hd7nr"] [ext_resource type="Material" uid="uid://bmp5rvu5slnnt" path="res://resources/Materials/ocean_material.tres" id="13"] [ext_resource type="Script" uid="uid://d15feraixcdwm" path="res://src/Objects/World/Networks.gd" id="14"] [ext_resource type="WorldConstants" uid="uid://dbxp5cngs1a5g" path="res://resources/Config/world_constants.tres" id="15"] -[ext_resource type="Script" uid="uid://bn2ww2ekrihcg" path="res://native/src/scripts/world/buildings.rs" id="15_23gpq"] +[ext_resource type="Script" uid="uid://bn2ww2ekrihcg" path="res://native/game/src/scripts/world/buildings.rs" id="15_23gpq"] [ext_resource type="PackedScene" uid="uid://cmv7rt4gqew38" path="res://resources/Objects/Helis/schweizer_300.tscn" id="16_e6k8r"] [ext_resource type="RoadNavigationConfig" uid="uid://dvccb8vdrejqp" path="res://resources/Config/road_navigation.tres" id="16_eq860"] -[ext_resource type="Script" uid="uid://djjvfkec3e3ph" path="res://native/src/scripts/world/gi_probes.rs" id="19_e3ctf"] +[ext_resource type="Script" uid="uid://djjvfkec3e3ph" path="res://native/game/src/scripts/world/gi_probes.rs" id="19_e3ctf"] [ext_resource type="AnimationLibrary" uid="uid://bc7h3e5qkdula" path="res://resources/Animations/title_screen_ui.tres" id="21_hlc2k"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nkrdn"] @@ -97,7 +97,7 @@ gi_probes = NodePath("GiProbes") environment = ExtResource("8") camera_attributes = ExtResource("7_yho3v") -[node name="SolarSetup" type="Node3D" parent="SubViewportContainer/SubViewport/World/Environment" unique_id=850312298 node_paths=PackedStringArray("sun", "moon")] +[node name="SolarSetup" type="Node3D" parent="SubViewportContainer/SubViewport/World/Environment" unique_id=1882445554 node_paths=PackedStringArray("sun", "moon")] transform = Transform3D(1, 0, 0, 0, 0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0) rotation_order = 0 script = ExtResource("12_88vys") @@ -105,6 +105,7 @@ sun = NodePath("Sun") moon = NodePath("Moon") day_length = 10 voxel_gi_data = ExtResource("9_nkrdn") +metadata/_custom_type_script = "uid://c0a6eytloytey" [node name="Sun" type="DirectionalLight3D" parent="SubViewportContainer/SubViewport/World/Environment/SolarSetup" unique_id=898696932] transform = Transform3D(1, -3.48787e-16, 3.48787e-16, -3.48787e-16, -1, 8.74228e-08, 3.48787e-16, -8.74228e-08, -1, 2.08165e-12, -5.50338e-09, 0.1) @@ -132,13 +133,15 @@ directional_shadow_blend_splits = true directional_shadow_fade_start = 0.6 directional_shadow_max_distance = 200.0 -[node name="Camera" type="Camera3D" parent="SubViewportContainer/SubViewport/World" unique_id=2064854527 node_paths=PackedStringArray("solar_setup")] +[node name="Camera" type="Camera3D" parent="SubViewportContainer/SubViewport/World" unique_id=2011441420 node_paths=PackedStringArray("solar_setup", "focus_target")] transform = Transform3D(1, 0, 0, 0, 0.8910063, 0.45399037, 0, -0.45399037, 0.8910063, -45.4393, 4.499999, 25.9155) attributes = ExtResource("7_yho3v") doppler_tracking = 2 current = true script = ExtResource("8_qw8ew") solar_setup = NodePath("../Environment/SolarSetup") +focus_target = NodePath("../Schweizer_300") +metadata/_custom_type_script = "uid://jljpgypnojsp" [node name="Schweizer_300" parent="SubViewportContainer/SubViewport/World" unique_id=1998635440 node_paths=PackedStringArray("child_camera", "child_main_camera", "child_debug_camera") groups=["player"] instance=ExtResource("16_e6k8r")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -45.4393, -9.81614e-07, 17.9155) @@ -175,14 +178,15 @@ road_navigation = ExtResource("16_eq860") [node name="Road" type="Node3D" parent="SubViewportContainer/SubViewport/World/Networks" unique_id=392084148 groups=["road-network"]] -[node name="Buildings" type="Node" parent="SubViewportContainer/SubViewport/World" unique_id=730073247] +[node name="Buildings" type="Node" parent="SubViewportContainer/SubViewport/World" unique_id=127425830] script = ExtResource("15_23gpq") world_constants = ExtResource("15") +metadata/_custom_type_script = "uid://bn2ww2ekrihcg" [node name="Backdrop" type="Node" parent="SubViewportContainer/SubViewport/World" unique_id=1333752962] script = ExtResource("6") -[node name="GiProbes" type="Node3D" parent="SubViewportContainer/SubViewport/World" unique_id=67311610] +[node name="GiProbes" type="Node3D" parent="SubViewportContainer/SubViewport/World" unique_id=468319335] script = ExtResource("19_e3ctf") world_constants = ExtResource("15") camera_attributes = ExtResource("7_yho3v") diff --git a/resources/title_screen.tscn b/resources/title_screen.tscn index e741272e..b657fb19 100644 --- a/resources/title_screen.tscn +++ b/resources/title_screen.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://b0l6ccv01wtnb"] -[ext_resource type="Script" uid="uid://cshfde6s4ex66" path="res://native/src/scripts/ui/title_menu.rs" id="1_4ijke"] +[ext_resource type="Script" uid="uid://cshfde6s4ex66" path="res://native/game/src/scripts/ui/title_menu.rs" id="1_4ijke"] [ext_resource type="PackedScene" uid="uid://csuvlu656dwm4" path="res://resources/Objects/Buildings/hangar_2.tscn" id="1_lejt8"] [ext_resource type="Environment" uid="uid://x8xcxt7ri4pi" path="res://resources/Environments/title_screen_env.tres" id="2_scex8"] [ext_resource type="CameraAttributesPhysical" uid="uid://dxi45jwp3asnw" path="res://resources/Environments/title_screen_camera_attributes.tres" id="3_gbrg3"] diff --git a/src/editor.gdextension b/src/editor.gdextension new file mode 100644 index 00000000..357132bc --- /dev/null +++ b/src/editor.gdextension @@ -0,0 +1,10 @@ +[configuration] +entry_symbol = "gdext_rust_init" +compatibility_minimum = 4.5 +reloadable = true + +[libraries] +macos.editor.arm64="res://native/target/aarch64-apple-darwin/debug/libeditor.dylib" +macos.editor.x86_64="res://native/target/x86_64-apple-darwin/debug/libeditor.dylib" +windows.editor.x86_64="res://native/target/x86_64-pc-windows-msvc/debug/editor.dll" +linux.editor.x86_64="res://native/target/x86_64-unknown-linux-gnu/debug/libeditor.so" diff --git a/src/editor.gdextension.uid b/src/editor.gdextension.uid new file mode 100644 index 00000000..696fc996 --- /dev/null +++ b/src/editor.gdextension.uid @@ -0,0 +1 @@ +uid://yvx5kgctecmt diff --git a/src/native.gdextension b/src/native.gdextension index 6f211030..5341fd06 100644 --- a/src/native.gdextension +++ b/src/native.gdextension @@ -4,7 +4,7 @@ compatibility_minimum = 4.5 reloadable = true [build] -source = "res://native/" +source = "res://native/game/" [libraries] macos.debug.arm64="res://native/target/aarch64-apple-darwin/debug/libnative.dylib"