Skip to content

Commit

Permalink
Reorganization refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
QueenOfSquiggles committed Dec 31, 2023
1 parent 0272624 commit 490e165
Show file tree
Hide file tree
Showing 31 changed files with 102 additions and 40 deletions.
8 changes: 2 additions & 6 deletions src/editor_utils.rs → src/editor/editor_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use godot::engine::{EditorCommandPalette, EditorPlugin, IEditorPlugin, PopupMenu};
use godot::prelude::*;

use crate::game_globals::CoreGlobals;
use crate::serialization::SquigglesSerialized;

pub fn register_editor_elements() {}

pub fn unregister_editor_elements() {}
use crate::scene::game_globals::CoreGlobals;
use crate::scene::serialization::SquigglesSerialized;

#[derive(GodotClass)]
#[class(tool, editor_plugin, init, base=EditorPlugin)]
Expand Down
1 change: 1 addition & 0 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod editor_plugin;
28 changes: 6 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,23 @@
use godot::prelude::*;

// module specifications
pub mod camera;
pub mod editor_plugin;
pub mod editor_utils;
pub mod error_handling;
pub mod game_globals;
pub mod game_settings;
pub mod godot_replacements;
pub mod input;
pub mod interaction;
pub mod serialization;
pub mod signals;
pub mod state_machine;
pub mod utility_nodes;
pub mod vfx_stack;
pub mod editor;
pub mod scene;

// extension loading
struct SquigglesCore;

#[gdextension]
unsafe impl ExtensionLibrary for SquigglesCore {
fn on_level_init(level: InitLevel) {
match level {
InitLevel::Scene => editor_plugin::register_engine_elements(),
InitLevel::Editor => editor_utils::register_editor_elements(),
_ => (),
if level == InitLevel::Scene {
scene::editor_plugin::register_engine_elements();
}
}

fn on_level_deinit(level: InitLevel) {
match level {
InitLevel::Scene => editor_plugin::unregister_engine_elements(),
InitLevel::Editor => editor_utils::unregister_editor_elements(),
_ => (),
if level == InitLevel::Scene {
scene::editor_plugin::unregister_engine_elements();
}
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion src/editor_plugin.rs → src/scene/editor_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use godot::{engine::*, prelude::*};
use once_cell::sync::Lazy;

use crate::game_globals::CoreGlobals;
use crate::scene::game_globals::CoreGlobals;

pub static SINGLETON_CORE_GLOBALS: Lazy<StringName> = Lazy::new(|| StringName::from("CoreGlobals"));

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/game_globals.rs → src/scene/game_globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use godot::{
};

use crate::{
camera::{CameraBrain3D, CAMERA_BRAIN_GROUP},
editor_plugin::SINGLETON_CORE_GLOBALS,
game_settings::SquigglesCoreConfig,
serialization::SquigglesSerialized,
scene::camera::{CameraBrain3D, CAMERA_BRAIN_GROUP},
scene::editor_plugin::SINGLETON_CORE_GLOBALS,
scene::game_settings::SquigglesCoreConfig,
scene::serialization::SquigglesSerialized,
};

const PROJECT_SETTINGS_NAMESPACE: &str = "addons/squiggles_core/";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::serialization::{SaveDataBuilder, SquigglesSerialized};
use crate::scene::serialization::{SaveDataBuilder, SquigglesSerialized};
use godot::prelude::*;

#[derive(GodotClass)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use godot::{
use num_derive::FromPrimitive;
use num_traits::{FromPrimitive, ToPrimitive};

use crate::serialization::{SaveDataBuilder, SquigglesSerialized};
use crate::scene::serialization::{SaveDataBuilder, SquigglesSerialized};

#[derive(FromPrimitive)]
enum MappingsStyle {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use godot::{
prelude::*,
};

use crate::serialization::{SaveDataBuilder, SquigglesSerialized};
use crate::scene::serialization::{SaveDataBuilder, SquigglesSerialized};

#[derive(GodotClass)]
#[class(tool, base=Resource)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use godot::prelude::*;

use crate::{serialization::SquigglesSerialized, vfx_stack::vfx_stack_resource::VFXStack};
use crate::scene::{serialization::SquigglesSerialized, vfx_stack::vfx_stack_resource::VFXStack};

use self::{
audio::GameAudioSettings, controls::GameControlsSettings, gameplay::GameGameplaySettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use godot::{
prelude::*,
};

use crate::game_globals::CoreGlobals;
use crate::scene::game_globals::CoreGlobals;

#[derive(GodotClass)]
#[class(init, base=WorldEnvironment)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/scene/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub mod camera;
pub mod editor_plugin;
pub mod error_handling;
pub mod game_globals;
pub mod game_settings;
pub mod godot_replacements;
pub mod input;
pub mod interaction;
pub mod procedural_meshes;
pub mod serialization;
pub mod signals;
pub mod state_machine;
pub mod utility_nodes;
pub mod vfx_stack;
1 change: 1 addition & 0 deletions src/scene/procedural_meshes/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod spline_mesh;
66 changes: 66 additions & 0 deletions src/scene/procedural_meshes/spline_mesh.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// use godot::{
// engine::{ArrayMesh, IMeshInstance3D, Mesh, MeshDataTool, MeshInstance3D, Path3D},
// prelude::*,
// };

// #[derive(GodotClass)]
// #[class(init, base=MeshInstance3D)]
// pub struct SplineMesh {
// #[export]
// spline: Option<Gd<Path3D>>,
// #[export]
// target_mesh: Option<Gd<Mesh>>,
// #[base]
// base: Base<MeshInstance3D>,
// }

// #[godot_api]
// impl IMeshInstance3D for SplineMesh {}

// #[godot_api]
// impl SplineMesh {
// #[func]
// pub fn generate_mesh(&mut self) {
// self.ensure_array_mesh();
// let Some(generic_mesh) = self.base.get_mesh() else {
// return;
// };
// let array_mesh_cast: Result<Gd<ArrayMesh>, _> = generic_mesh.try_cast();
// let Ok(mut array_mesh) = array_mesh_cast else {
// return;
// };
// let Some(spline) = self.spline.clone() else {
// return;
// };
// let Some(spline) = spline.get_curve() else {
// return;
// };
// let Some(target) = self.target_mesh.clone() else {
// return;
// };
// array_mesh.clear_surfaces();

// let interval = spline.get_bake_interval();
// let length = spline.get_baked_length();
// let points = spline.get_baked_points();
// let tilts = spline.get_baked_tilts();
// let ups = spline.get_baked_up_vectors();
// let data = MeshDataTool::new();
// for (index, value) in points.as_slice().iter().enumerate() {
// let tilt = tilts.as_slice()[index];
// let up = ups.as_slice()[index];
// }
// }

// fn ensure_array_mesh(&mut self) {
// if self.base.get_mesh().is_none() {
// self.base.set_mesh(ArrayMesh::new().upcast());
// return;
// }
// let arr_cast: Result<Gd<ArrayMesh>, _> = self.base.get_mesh().unwrap().try_cast();
// let Ok(_) = arr_cast else {
// self.base.set_mesh(ArrayMesh::new().upcast());
// return;
// };
// }
// }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use godot::{
prelude::*,
};

use crate::game_globals::CoreGlobals;
use crate::scene::game_globals::CoreGlobals;

use super::vfx_stack_resource::VFXStack;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use godot::{engine::ShaderMaterial, prelude::*};

use crate::signals::emit;
use crate::scene::signals::emit;

#[derive(GodotClass)]
#[class(init, base=Resource)]
Expand Down

0 comments on commit 490e165

Please sign in to comment.