Convert FreeSpaceControl to EntityComponent

This commit is contained in:
Michael Huebner 2025-03-11 13:39:55 +01:00
parent 75d98aad6b
commit d78574f54a
5 changed files with 33 additions and 14 deletions

View file

@ -1,4 +1,7 @@
use anyhow::Result;
use context::prelude::cgmath::*;
use ecs::{ComponentDebug, EntityComponent, World};
use std::time::Duration;
pub struct FreeSpaceControlSettings {
@ -156,3 +159,25 @@ impl FreeSpaceControl {
)
}
}
impl EntityComponent for FreeSpaceControl {
fn enable(&mut self, _world: &mut World) -> Result<()> {
Ok(())
}
fn disable(&mut self, _world: &mut World) -> Result<()> {
self.last_update = None;
Ok(())
}
fn name(&self) -> &str {
Self::debug_name()
}
}
impl ComponentDebug for FreeSpaceControl {
fn debug_name() -> &'static str {
"FreeSpaceControl"
}
}

View file

@ -1,13 +1,10 @@
pub mod animation;
pub mod draw;
pub mod particle_system;
pub mod bounding_box;
pub mod audio;
pub mod bounding_box;
pub mod draw;
pub mod free_space_control;
pub mod location;
pub mod particle_system;
// angle of current object
pub fn angle(v1: crate::prelude::cgmath::Vector2<f32>) -> crate::prelude::cgmath::Rad<f32> {

View file

@ -1,10 +1,9 @@
pub use super::components::{animation::Animation, audio::Audio, draw::Draw};
pub use super::components::{
audio::{ON_DISABLE_SOUND, ON_ENABLE_SOUND},
animation::Animation,
audio::{Audio, ON_DISABLE_SOUND, ON_ENABLE_SOUND},
bounding_box::BoundingBox,
draw::Draw,
free_space_control::*,
location::Location,
particle_system::*,
};
// pub use super::query::SceneQuery;

View file

@ -1,6 +1,5 @@
pub mod camera;
pub mod free_camera_control;
pub mod free_space_control;
pub mod light;
pub mod prelude;
pub mod top_down_camera_control;

View file

@ -1,6 +1,5 @@
pub use super::camera::*;
pub use super::free_camera_control::*;
pub use super::free_space_control::*;
pub use super::light::*;
pub use super::top_down_camera_control::*;
pub use super::validcommandbuffer::*;