diff --git a/Cargo.toml b/Cargo.toml index fda16e8..bd9262b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ members = [ "map", "rpg_components", "entity_manager", - "character_window", + "character_window", "ecs", ] [workspace.dependencies] diff --git a/ConfigHandler/Cargo.toml b/ConfigHandler/Cargo.toml index 480802c..615204f 100644 --- a/ConfigHandler/Cargo.toml +++ b/ConfigHandler/Cargo.toml @@ -2,7 +2,7 @@ name = "config_handler" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/Networking/Cargo.toml b/Networking/Cargo.toml index 09d1647..102f7b1 100644 --- a/Networking/Cargo.toml +++ b/Networking/Cargo.toml @@ -2,7 +2,7 @@ name = "networking" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -19,5 +19,5 @@ trust-dns-resolver = { workspace = true, optional = true } [features] local_ip = ["if-addrs"] -public_ip = ["public-ip", "async-std"] +public_ip = ["async-std", "public-ip"] resolve_dns = ["trust-dns-resolver"] diff --git a/asset/Cargo.toml b/asset/Cargo.toml index 555a35e..af37e0f 100644 --- a/asset/Cargo.toml +++ b/asset/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "asset" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/character_window/Cargo.toml b/character_window/Cargo.toml index 5062943..4a6a623 100644 --- a/character_window/Cargo.toml +++ b/character_window/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "character_window" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow = { workspace = true } @@ -10,4 +10,4 @@ destructure_traitobject = { workspace = true } downcast-rs = { workspace = true } engine = { path = "../engine" } -rpg_components = { path = "../rpg_components" } \ No newline at end of file +rpg_components = { path = "../rpg_components" } diff --git a/context/Cargo.toml b/context/Cargo.toml index 5581c8e..d71433f 100644 --- a/context/Cargo.toml +++ b/context/Cargo.toml @@ -2,7 +2,7 @@ name = "context" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [dependencies] utilities = { workspace = true } diff --git a/controllable_thread/Cargo.toml b/controllable_thread/Cargo.toml index bd1323d..a67b599 100644 --- a/controllable_thread/Cargo.toml +++ b/controllable_thread/Cargo.toml @@ -2,7 +2,7 @@ name = "controllable_thread" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/ecs/Cargo.toml b/ecs/Cargo.toml new file mode 100644 index 0000000..0c75686 --- /dev/null +++ b/ecs/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "ecs" +version = "0.1.0" +authors = ["hodasemi "] +edition = "2024" + +[dependencies] +anyhow.workspace = true +destructure_traitobject.workspace = true +indexmap.workspace = true +serde = { workspace = true, features = ["derive"] } +paste.workspace = true +ron.workspace = true + +scene_update_macros = { path = "../scene_update_macros" } + +[features] +timings = [] diff --git a/engine/src/scene/content/entity.rs b/ecs/src/entity.rs similarity index 63% rename from engine/src/scene/content/entity.rs rename to ecs/src/entity.rs index b2d6dec..0356a3b 100644 --- a/engine/src/scene/content/entity.rs +++ b/ecs/src/entity.rs @@ -1,24 +1,14 @@ -use crate::prelude::*; - use core::fmt; use std::any::TypeId; -use std::cmp::Ordering; use std::{num::ParseIntError, str::FromStr}; use anyhow::Result; +use serde::{Deserialize, Serialize}; + +use crate::{ComponentDebug, ComponentNotFoundError, EntityComponent, MultiMut, TypeMap}; pub const COMPONENT_SEPARATOR: char = 'ยง'; -// Used for serialisation over network -#[derive(Serialize, Deserialize)] -pub struct EntityCreateInfo { - gltf_file: Option, - network_id: Option, - ignore_transactions: bool, -} - -impl ComponentCreateInfo<'_> for EntityCreateInfo {} - #[derive(Default)] pub struct ActivationState { activated: bool, @@ -34,7 +24,7 @@ impl ActivationState { } } -pub struct EntityObject { +pub struct EntityObject { #[cfg(debug_assertions)] pub debug_name: Option, @@ -48,16 +38,16 @@ pub struct EntityObject { pub entity_id: u32, // component map - pub(crate) components: TypeMap, + pub(crate) components: TypeMap, #[cfg(debug_assertions)] component_names: Vec, } -unsafe impl Send for EntityObject {} -unsafe impl Sync for EntityObject {} +unsafe impl Send for EntityObject {} +unsafe impl Sync for EntityObject {} -impl EntityObject { +impl EntityObject { pub(crate) fn new(id: u32) -> Self { Self { #[cfg(debug_assertions)] @@ -80,11 +70,11 @@ impl EntityObject { self.gltf_file.as_ref() } - pub fn multi_mut(&mut self) -> MultiMut<'_> { + pub fn multi_mut(&mut self) -> MultiMut<'_, S> { self.components.multi_mut() } - pub fn insert_component( + pub fn insert_component + ComponentDebug>( &mut self, component: T, ) -> Option { @@ -108,8 +98,11 @@ impl EntityObject { pub(crate) fn insert_component_by_id( &mut self, type_id: TypeId, - component: Box, - ) -> Option> { + component: Box>, + ) -> Option>> + where + S: 'static, + { assert!( !self.activation_state.is_active(), "inserting components while the entity is activated is not allowed" @@ -127,7 +120,7 @@ impl EntityObject { self.components.insert_type(type_id, component) } - pub fn remove_component(&mut self) -> Option { + pub fn remove_component>(&mut self) -> Option { assert!( !self.activation_state.is_active(), "removing components while the entity is activated is not allowed" @@ -152,7 +145,10 @@ impl EntityObject { pub(crate) fn remove_component_by_id( &mut self, type_id: TypeId, - ) -> Option> { + ) -> Option>> + where + S: 'static, + { assert!( !self.activation_state.is_active(), "removing components while the entity is activated is not allowed" @@ -179,19 +175,19 @@ impl EntityObject { &self.component_names } - pub fn get_component( + pub fn get_component + ComponentDebug>( &self, ) -> std::result::Result<&T, ComponentNotFoundError> { self.components.get() } - pub fn get_component_mut( + pub fn get_component_mut + ComponentDebug>( &mut self, ) -> std::result::Result<&mut T, ComponentNotFoundError> { self.components.get_mut() } - pub fn contains_component(&self) -> bool { + pub fn contains_component>(&self) -> bool { self.components.contains::() } @@ -203,7 +199,7 @@ impl EntityObject { Entity { id: self.entity_id } } - pub fn clone_without_components(&self, engine: &Engine) -> EntityObject { + pub(crate) fn clone_without_components(&self, id: u32) -> EntityObject { EntityObject { #[cfg(debug_assertions)] debug_name: self.debug_name.clone(), @@ -213,17 +209,17 @@ impl EntityObject { activation_state: Default::default(), - entity_id: engine.assets().get_entity_id(), + entity_id: id, // component map - components: TypeMap::new(), + components: TypeMap::default(), #[cfg(debug_assertions)] component_names: Vec::new(), } } - pub fn clone_component_from( + pub fn clone_component_from + ComponentDebug + Clone>( &mut self, other: &Self, ) -> Result<()> { @@ -240,8 +236,8 @@ pub struct Entity { pub(crate) id: u32, } -impl PartialEq for Entity { - fn eq(&self, entity: &EntityObject) -> bool { +impl PartialEq> for Entity { + fn eq(&self, entity: &EntityObject) -> bool { self.id == entity.entity_id } } @@ -265,77 +261,3 @@ impl FromStr for Entity { Ok(Self { id: s.parse()? }) } } - -#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)] -pub struct NetworkID { - pub(crate) id: u32, -} - -impl NetworkID { - pub fn display_vector(v: &Vec) -> String { - // add starting bracket - let mut s = String::from("["); - - for id in v { - s += &format!("{},", id.id); - } - - // remove last comma - s.pop(); - - // add closing bracket - s += "]"; - - s - } - - pub fn from_opt(me: Option) -> String { - match me { - Some(nid) => format!("Some({})", nid), - None => "None".to_string(), - } - } - - pub fn try_opt(s: &str) -> Result> { - Ok(if s == "None" { - None - } else { - if !s.starts_with("Some") { - panic!("unexpected string when parsing Option: {}", s); - } - - let tmp = s - .trim_start_matches("Some") - .trim_start_matches('(') - .trim_end_matches(')'); - - Some(tmp.parse()?) - }) - } -} - -impl fmt::Display for NetworkID { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.id) - } -} - -impl FromStr for NetworkID { - type Err = ParseIntError; - - fn from_str(s: &str) -> std::result::Result { - Ok(Self { id: s.parse()? }) - } -} - -impl Ord for NetworkID { - fn cmp(&self, other: &Self) -> Ordering { - self.id.cmp(&other.id) - } -} - -impl PartialOrd for NetworkID { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} diff --git a/engine/src/scene/content/events.rs b/ecs/src/events.rs similarity index 80% rename from engine/src/scene/content/events.rs rename to ecs/src/events.rs index 6e5b56c..b9ec535 100644 --- a/engine/src/scene/content/events.rs +++ b/ecs/src/events.rs @@ -5,20 +5,25 @@ use std::{ ops::DerefMut, }; -use crate::prelude::SceneContents; - -#[derive(Default)] -pub struct Events { +pub struct Events { events: HashMap< TypeId, ( Vec>, - Vec, &dyn Any) -> anyhow::Result<()> + Send + Sync>>, + Vec anyhow::Result<()> + Send + Sync>>, ), >, } -impl Events { +impl Default for Events { + fn default() -> Self { + Self { + events: HashMap::new(), + } + } +} + +impl Events { pub(crate) fn clone_from_register(&self) -> Self { Self { events: self @@ -54,13 +59,13 @@ impl Events { pub fn add_reader(&mut self, f: F) where - F: Fn(&mut SceneContents<'_>, &T) -> anyhow::Result<()> + Send + Sync + 'static, + F: Fn(&mut C, &T) -> anyhow::Result<()> + Send + Sync + 'static, { match self.events.get_mut(&TypeId::of::()) { - Some((_, listener)) => listener.push(Box::new(move |scene, payload| { + Some((_, listener)) => listener.push(Box::new(move |c, payload| { let typed_payload: &T = payload.downcast_ref().unwrap(); - f(scene, typed_payload) + f(c, typed_payload) })), None => panic!("register event type first!"), } @@ -73,11 +78,11 @@ impl Events { } } - pub(crate) fn fire_events(&mut self, scene: &mut SceneContents<'_>) -> anyhow::Result<()> { + pub(crate) fn fire_events(&mut self, c: &mut C) -> anyhow::Result<()> { for (payloads, listeners) in self.events.values_mut() { for payload in payloads.iter_mut() { for listener in listeners.iter_mut() { - (listener)(scene, payload.deref_mut())?; + (listener)(c, payload.deref_mut())?; } } diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs new file mode 100644 index 0000000..3011d6c --- /dev/null +++ b/ecs/src/lib.rs @@ -0,0 +1,17 @@ +mod entity; +mod events; +mod resources; +mod type_map; +mod unsafe_component_store; +mod updates; +mod world; + +pub use crate::entity::{Entity, EntityObject}; +pub use crate::events::Events; +pub use crate::resources::{ResourceMultiMut, Resources}; +pub use crate::type_map::{ + ComponentCreateInfo, ComponentDebug, ComponentNotFoundError, EntityComponent, MultiMut, TypeMap, +}; +pub use crate::unsafe_component_store::UnsafeComponentStore; +pub use crate::updates::*; +pub use crate::world::World; diff --git a/engine/src/scene/content/resources.rs b/ecs/src/resources.rs similarity index 100% rename from engine/src/scene/content/resources.rs rename to ecs/src/resources.rs diff --git a/engine/src/scene/content/type_map.rs b/ecs/src/type_map.rs similarity index 76% rename from engine/src/scene/content/type_map.rs rename to ecs/src/type_map.rs index 734121f..4d0d962 100644 --- a/engine/src/scene/content/type_map.rs +++ b/ecs/src/type_map.rs @@ -2,8 +2,8 @@ use std::mem::transmute; use std::{ any::{Any, TypeId}, collections::{ - hash_map::{Iter, IterMut}, HashMap, + hash_map::{Iter, IterMut}, }, fmt::Display, }; @@ -12,14 +12,12 @@ use anyhow::Result; use destructure_traitobject; use serde::{Deserialize, Serialize}; -use crate::prelude::*; - -pub trait EntityComponent: Any + Send + Sync { - fn enable(&mut self, _scene: &mut Scene) -> Result<()> { +pub trait EntityComponent: Any + Send + Sync { + fn enable(&mut self, _scene: &mut S) -> Result<()> { Ok(()) } - fn disable(&mut self, _scene: &mut Scene) -> Result<()> { + fn disable(&mut self, _scene: &mut S) -> Result<()> { Ok(()) } @@ -47,19 +45,20 @@ pub trait ComponentCreateInfo<'de>: Serialize + Deserialize<'de> { } } -#[derive(Default)] -pub struct TypeMap { - map: HashMap>, +pub struct TypeMap { + map: HashMap>>, } -impl TypeMap { - pub fn new() -> Self { - TypeMap { +impl Default for TypeMap { + fn default() -> Self { + Self { map: HashMap::new(), } } +} - pub fn insert(&mut self, value: T) -> Option { +impl TypeMap { + pub fn insert + ComponentDebug>(&mut self, value: T) -> Option { self.map .insert(TypeId::of::(), Box::new(value)) .map(|any| *Self::downcast_unchecked(any)) @@ -68,21 +67,21 @@ impl TypeMap { pub fn insert_type( &mut self, type_id: TypeId, - component: Box, - ) -> Option> { + component: Box>, + ) -> Option>> { self.map.insert(type_id, component) } - pub fn remove(&mut self) -> Option { + pub fn remove>(&mut self) -> Option { self.remove_by_type_id(&TypeId::of::()) .map(|any| *Self::downcast_unchecked(any)) } - pub fn remove_by_type_id(&mut self, type_id: &TypeId) -> Option> { + pub fn remove_by_type_id(&mut self, type_id: &TypeId) -> Option>> { self.map.remove(type_id) } - pub fn get( + pub fn get + ComponentDebug>( &self, ) -> std::result::Result<&T, ComponentNotFoundError> { self.map @@ -94,13 +93,13 @@ impl TypeMap { pub fn get_by_type_id( &self, type_id: &TypeId, - ) -> std::result::Result<&Box, ComponentNotFoundError> { + ) -> std::result::Result<&Box>, ComponentNotFoundError> { self.map .get(type_id) .ok_or_else(|| ComponentNotFoundError::type_id(*type_id)) } - pub fn get_mut( + pub fn get_mut + ComponentDebug>( &mut self, ) -> std::result::Result<&mut T, ComponentNotFoundError> { self.map @@ -112,13 +111,13 @@ impl TypeMap { pub fn get_mut_by_type_id( &mut self, type_id: &TypeId, - ) -> std::result::Result<&mut Box, ComponentNotFoundError> { + ) -> std::result::Result<&mut Box>, ComponentNotFoundError> { self.map .get_mut(type_id) .ok_or_else(|| ComponentNotFoundError::type_id(*type_id)) } - pub fn contains(&self) -> bool { + pub fn contains>(&self) -> bool { self.contains_type_id(&TypeId::of::()) } @@ -126,24 +125,24 @@ impl TypeMap { self.map.contains_key(type_id) } - pub fn multi_mut(&mut self) -> MultiMut<'_> { + pub fn multi_mut(&mut self) -> MultiMut<'_, S> { MultiMut::new(&mut self.map) } - pub fn iter(&self) -> Iter<'_, TypeId, Box> { + pub fn iter(&self) -> Iter<'_, TypeId, Box>> { self.map.iter() } - pub fn iter_mut(&mut self) -> IterMut<'_, TypeId, Box> { + pub fn iter_mut(&mut self) -> IterMut<'_, TypeId, Box>> { self.map.iter_mut() } - fn downcast_unchecked(boxed: Box) -> Box { + fn downcast_unchecked>(boxed: Box>) -> Box { unsafe { Box::from_raw(Box::into_raw(boxed) as *mut T) } } - pub(crate) fn downcast_ref_unchecked( - boxed_ref: &Box, + pub fn downcast_ref_unchecked>( + boxed_ref: &Box>, ) -> &T { unsafe { let ptr_to_ptr: *const *const T = @@ -153,8 +152,8 @@ impl TypeMap { } } - pub(crate) fn downcast_mut_unchecked( - boxed_ref: &mut Box, + pub fn downcast_mut_unchecked>( + boxed_ref: &mut Box>, ) -> &mut T { unsafe { let ptr_to_ptr: *mut *mut T = @@ -166,13 +165,13 @@ impl TypeMap { } /// Allows mutable access to multiple components at once -pub struct MultiMut<'a> { - map: &'a mut HashMap>, - buffer: Vec<*mut Box>, +pub struct MultiMut<'a, S> { + map: &'a mut HashMap>>, + buffer: Vec<*mut Box>>, } -impl<'a> MultiMut<'a> { - fn new(map: &'a mut HashMap>) -> Self { +impl<'a, S> MultiMut<'a, S> { + fn new(map: &'a mut HashMap>>) -> Self { MultiMut { map, buffer: Vec::new(), @@ -180,7 +179,7 @@ impl<'a> MultiMut<'a> { } /// Returns requested type on success - pub fn get( + pub fn get + ComponentDebug>( &mut self, ) -> std::result::Result<&'a mut T, ComponentNotFoundError> { self.get_by_type_id(&TypeId::of::()) @@ -192,7 +191,7 @@ impl<'a> MultiMut<'a> { pub fn get_by_type_id( &mut self, type_id: &TypeId, - ) -> std::result::Result<&'a mut Box, ComponentNotFoundError> { + ) -> std::result::Result<&'a mut Box>, ComponentNotFoundError> { match self.map.get_mut(type_id) { Some(v) => { let ptr = v as *mut _; @@ -206,7 +205,7 @@ impl<'a> MultiMut<'a> { } } - let t: Option<&'a mut Box> = unsafe { transmute(ptr) }; + let t: Option<&'a mut Box>> = unsafe { transmute(ptr) }; t.ok_or_else(|| ComponentNotFoundError::type_id(*type_id)) } @@ -262,7 +261,7 @@ struct Test { z: u32, } -impl EntityComponent for Test { +impl EntityComponent for Test { fn name(&self) -> &str { "Test" } @@ -282,7 +281,7 @@ impl PartialEq for Test { #[test] fn verify_multi_mut() { - let mut map = TypeMap::new(); + let mut map = TypeMap::<()>::default(); map.insert(Test::default()); @@ -300,7 +299,7 @@ fn verify_multi_mut() { #[test] fn verify_insert() { - let mut map = TypeMap::new(); + let mut map = TypeMap::<()>::default(); let reference = Test { x: 5, y: 20, z: 30 }; @@ -312,7 +311,7 @@ fn verify_insert() { #[test] fn verify_get() { - let mut map = TypeMap::new(); + let mut map = TypeMap::<()>::default(); let reference = Test { x: 5, y: 20, z: 30 }; @@ -323,7 +322,7 @@ fn verify_get() { #[test] fn verify_get_mut() { - let mut map = TypeMap::new(); + let mut map = TypeMap::<()>::default(); let reference = Test { x: 5, y: 20, z: 30 }; diff --git a/engine/src/scene/content/unsafe_component_store.rs b/ecs/src/unsafe_component_store.rs similarity index 97% rename from engine/src/scene/content/unsafe_component_store.rs rename to ecs/src/unsafe_component_store.rs index 73423aa..cdf17af 100644 --- a/engine/src/scene/content/unsafe_component_store.rs +++ b/ecs/src/unsafe_component_store.rs @@ -27,7 +27,7 @@ impl UnsafeComponentStore { "Called UnsafeComponentStore while being empty" ); - self.ptr.as_mut().unwrap() + unsafe { self.ptr.as_mut().unwrap() } } pub fn is_init(&self) -> bool { diff --git a/engine/src/scene/content/updates.rs b/ecs/src/updates.rs similarity index 65% rename from engine/src/scene/content/updates.rs rename to ecs/src/updates.rs index 0beb796..b614a42 100644 --- a/engine/src/scene/content/updates.rs +++ b/ecs/src/updates.rs @@ -1,7 +1,6 @@ #![allow(clippy::type_complexity)] use std::any::TypeId; -use std::collections::HashMap; use std::marker::PhantomData; #[cfg(feature = "timings")] @@ -13,19 +12,19 @@ use indexmap::IndexMap; #[cfg(feature = "timings")] use super::super::timings::Timings; -use crate::prelude::*; +use crate::*; use scene_update_macros::implement_pair_update; macro_rules! impl_singleton_update { ( $name: ident, $([$var: ident]$(,)?)+ ) => { - impl Archetype { + impl Archetype { paste::item! { pub fn [](f: F, filter: Filter) -> Self where - F: Fn(&mut SceneContents<'_>, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, - Filter: CheckFilter + 'static, + F: Fn(&mut C, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, + Filter: CheckFilter + 'static, $( - $var: EntityComponent + ComponentDebug, + $var: EntityComponent + ComponentDebug, )+ { $( @@ -69,13 +68,13 @@ macro_rules! impl_singleton_update { } } - impl AddUpdates2<( $( $var, )+ ), Func, Filter> for Updates + impl AddUpdates2 for Updates where $( - $var: EntityComponent + ComponentDebug, + $var: EntityComponent + ComponentDebug, )+ - Func: Fn(& mut SceneContents<'_>, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, - Filter: CheckFilter + 'static + Func: Fn(& mut C, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, + Filter: CheckFilter + 'static { fn add_update( &mut self, @@ -83,7 +82,7 @@ macro_rules! impl_singleton_update { priority: u32, func: Func, filter: Filter, - entities: &IndexMap + entities: &IndexMap> ) -> Result<()> { paste::item! { self.add(name, priority, Update::Single(Archetype::[](func, filter)), entities) @@ -91,13 +90,14 @@ macro_rules! impl_singleton_update { } } - impl AddUpdates<( $( $var, )+ ), Func, Filter> for Scene + impl AddUpdates<( $( $var, )+ ), Func, Filter> for World where $( - $var: EntityComponent + ComponentDebug, + $var: EntityComponent + ComponentDebug, )+ - Func: Fn(& mut SceneContents<'_>, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, - Filter: CheckFilter + 'static + Func: Fn(& mut C, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, + Filter: CheckFilter + 'static, + C: Send + Sync { fn add_update( &mut self, @@ -110,25 +110,25 @@ macro_rules! impl_singleton_update { } } - impl Scene { - paste::item! { - pub fn [](&mut self, name: impl ToString, f: F, filter: Filter) -> Result<()> - where - F: Fn(&mut SceneContents<'_>, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, - Filter: CheckFilter + 'static, - $( - $var: EntityComponent + ComponentDebug, - )+ - { - let mut archetype = Archetype::[](f, filter); - archetype.setup(&self.entities)?; + // impl Scene { + // paste::item! { + // pub fn [](&mut self, name: impl ToString, f: F, filter: Filter) -> Result<()> + // where + // F: Fn(&mut SceneContents<'_>, Entity, $(&mut $var,)+) -> Result<()> + Send + Sync + Clone + 'static, + // Filter: CheckFilter + 'static, + // $( + // $var: EntityComponent + ComponentDebug, + // )+ + // { + // let mut archetype = Archetype::[](f, filter); + // archetype.setup(&self.entities)?; - self.archetypes.insert(name.to_string(), archetype); + // self.archetypes.insert(name.to_string(), archetype); - Ok(()) - } - } - } + // Ok(()) + // } + // } + // } }; } @@ -139,19 +139,19 @@ macro_rules! impl_pair_update { $rhs_id: expr, ( $([$rhs_little: ident: $rhs_big: ident]$(,)?)+ ) ) => { - impl ArchetypePair { + impl ArchetypePair { paste::item! { pub fn [] (f: F, left_filter: LeftFilter, right_filter: RightFilter) -> Self where - F: Fn(&mut SceneContents<'_>, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, - LeftFilter: CheckFilter + 'static, - RightFilter: CheckFilter + 'static, + F: Fn(&mut C, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, + LeftFilter: CheckFilter + 'static, + RightFilter: CheckFilter + 'static, $( - $rhs_big: EntityComponent + ComponentDebug, + $rhs_big: EntityComponent + ComponentDebug, )+ $( - $lhs_big: EntityComponent + ComponentDebug, + $lhs_big: EntityComponent + ComponentDebug, )+ { $( @@ -220,17 +220,17 @@ macro_rules! impl_pair_update { } } - impl AddUpdates2<( ($( $lhs_big, )+), ($($rhs_big,)+) ), Func, (LhsFilter, RhsFilter)> for Updates + impl AddUpdates2 for Updates where $( - $rhs_big: EntityComponent + ComponentDebug, + $rhs_big: EntityComponent + ComponentDebug, )+ $( - $lhs_big: EntityComponent + ComponentDebug, + $lhs_big: EntityComponent + ComponentDebug, )+ - Func: Fn(& mut SceneContents<'_>, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, - LhsFilter: CheckFilter + 'static, - RhsFilter: CheckFilter + 'static + Func: Fn(& mut C, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, + LhsFilter: CheckFilter + 'static, + RhsFilter: CheckFilter + 'static { fn add_update( &mut self, @@ -238,7 +238,7 @@ macro_rules! impl_pair_update { priority: u32, func: Func, filter: (LhsFilter, RhsFilter), - entities: &IndexMap + entities: &IndexMap> ) -> Result<()> { paste::item! { self.add(name, priority, Update::Pair(ArchetypePair::[](func, filter.0, filter.1)), entities)?; @@ -248,17 +248,18 @@ macro_rules! impl_pair_update { } } - impl AddUpdates<( ($( $lhs_big, )+), ($($rhs_big,)+) ), Func, (LhsFilter, RhsFilter)> for Scene + impl AddUpdates<( ($( $lhs_big, )+), ($($rhs_big,)+) ), Func, (LhsFilter, RhsFilter)> for World where $( - $rhs_big: EntityComponent + ComponentDebug, + $rhs_big: EntityComponent + ComponentDebug, )+ $( - $lhs_big: EntityComponent + ComponentDebug, + $lhs_big: EntityComponent + ComponentDebug, )+ - Func: Fn(& mut SceneContents<'_>, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, - LhsFilter: CheckFilter + 'static, - RhsFilter: CheckFilter + 'static + Func: Fn(& mut C, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, + LhsFilter: CheckFilter + 'static, + RhsFilter: CheckFilter + 'static, + C: Send + Sync { fn add_update( &mut self, @@ -271,47 +272,56 @@ macro_rules! impl_pair_update { } } - impl AddUpdates<( ($( $lhs_big, )+), ($($rhs_big,)+) ), Func, Filter> for Scene - where - $( - $rhs_big: EntityComponent + ComponentDebug, - )+ - $( - $lhs_big: EntityComponent + ComponentDebug, - )+ - Func: Fn(& mut SceneContents<'_>, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, - Filter: CheckFilter + 'static, - { - fn add_update( - &mut self, - name: &str, - priority: u32, - func: Func, - filter: Filter, - ) -> Result<()> { - paste::item! { - self.updates.add_update(name, priority, func, (filter.clone(), filter), &self.entities)?; - } + // impl AddUpdates<( ($( $lhs_big, )+), ($($rhs_big,)+) ), Func, Filter> for Scene + // where + // $( + // $rhs_big: EntityComponent + ComponentDebug, + // )+ + // $( + // $lhs_big: EntityComponent + ComponentDebug, + // )+ + // Func: Fn(& mut SceneContents<'_>, (Entity, $(&mut $lhs_big,)+), (Entity, $(&mut $rhs_big,)+)) -> Result<()> + Send + Sync + Clone + 'static, + // Filter: CheckFilter + 'static, + // { + // fn add_update( + // &mut self, + // name: &str, + // priority: u32, + // func: Func, + // filter: Filter, + // ) -> Result<()> { + // paste::item! { + // self.updates.add_update(name, priority, func, (filter.clone(), filter), &self.entities)?; + // } - Ok(()) - } - } + // Ok(()) + // } + // } }; } macro_rules! impl_update_filter { ( $name: ident, $([$big: ident, $little: ident]$(,)?)+ ) => { paste::item! { - pub struct [<$name Filter>]<$($big: EntityComponent,)+> + pub struct [<$name Filter>],)+> + where + C: Send + Sync { + c: std::marker::PhantomData, + $( $little: std::marker::PhantomData<$big>, )+ } - impl<$($big: EntityComponent,)+> Default for [<$name Filter>]<$($big,)+> { + impl,)+> Default for [<$name Filter>] + where + C: Send + Sync + { fn default() -> Self { Self { + c: std::marker::PhantomData, + $( $little: std::marker::PhantomData, )+ @@ -319,8 +329,11 @@ macro_rules! impl_update_filter { } } - impl<$($big: EntityComponent,)+> CheckFilter for [<$name Filter>]<$($big,)+> { - fn check(&self, entity: &EntityObject) -> bool { + impl,)+> CheckFilter for [<$name Filter>] + where + C: Send + Sync + { + fn check(&self, entity: &EntityObject) -> bool { $( if entity.contains_component::<$big>() { return false; @@ -330,7 +343,7 @@ macro_rules! impl_update_filter { true } - fn verify_dedup(&self) { + fn verify_dedup>(&self) { $( if TypeId::of::() == TypeId::of::<$big>() { panic!("Type is used as input and filter at the same time"); @@ -339,9 +352,14 @@ macro_rules! impl_update_filter { } } - impl<$($big: EntityComponent,)+> Clone for [<$name Filter>]<$($big,)+> { + impl,)+> Clone for [<$name Filter>] + where + C: Send + Sync + { fn clone(&self) -> Self { Self { + c: self.c.clone(), + $( $little: self.$little.clone(), )+ @@ -352,39 +370,41 @@ macro_rules! impl_update_filter { }; } -pub struct Query +pub struct Query where - F: CheckFilter, + F: CheckFilter, { pub components: T, + d: PhantomData, + c: PhantomData, } pub trait AddUpdates { fn add_update(&mut self, name: &str, priority: u32, func: Func, filter: Filter) -> Result<()>; } -trait AddUpdates2 { +trait AddUpdates2 { fn add_update( &mut self, name: &str, priority: u32, func: Func, filter: Filter, - entities: &IndexMap, + entities: &IndexMap>, ) -> Result<()>; } -pub trait CheckFilter: Send + Sync + Default + Clone { - fn check(&self, entity: &EntityObject) -> bool; - fn verify_dedup(&self); +pub trait CheckFilter: Send + Sync + Default + Clone { + fn check(&self, entity: &EntityObject) -> bool; + fn verify_dedup>(&self); } #[derive(Default, Clone)] pub struct EmptyFilter; -impl CheckFilter for EmptyFilter { - fn check(&self, _entity: &EntityObject) -> bool { +impl CheckFilter for EmptyFilter { + fn check(&self, _entity: &EntityObject) -> bool { true } @@ -410,23 +430,19 @@ impl ArchetypeInfo { } } -pub struct Archetype { - check_entity: Box bool + Send + Sync>, +pub struct Archetype { + check_entity: Box) -> bool + Send + Sync>, create_callback: Box< - dyn Fn( - &EntityObject, - ) - -> Result) -> Result<()> + Send + Sync>> + dyn Fn(&EntityObject) -> Result Result<()> + Send + Sync>> + Send + Sync, >, - entities: - IndexMap) -> Result<()> + Send + Sync>>, + entities: IndexMap Result<()> + Send + Sync>>, } -impl Archetype { - pub fn add_entity(&mut self, entity_object: &EntityObject) -> Result<()> { +impl Archetype { + pub fn add_entity(&mut self, entity_object: &EntityObject) -> Result<()> { if (self.check_entity)(entity_object) { let cb = (self.create_callback)(entity_object)?; @@ -440,7 +456,7 @@ impl Archetype { self.entities.swap_remove(&entity); } - pub fn execute(&self, scene_contents: &mut SceneContents<'_>) -> Result<()> { + pub fn execute(&self, scene_contents: &mut C) -> Result<()> { for (entity, callback) in self.entities.iter() { callback(*entity, scene_contents)?; } @@ -448,7 +464,7 @@ impl Archetype { Ok(()) } - pub fn setup(&mut self, entities: &IndexMap) -> Result<()> { + pub fn setup(&mut self, entities: &IndexMap>) -> Result<()> { for (entity, entity_object) in entities.iter() { if (self.check_entity)(entity_object) { let cb = (self.create_callback)(entity_object)?; @@ -462,37 +478,34 @@ impl Archetype { pub(crate) fn entities( &self, - ) -> &IndexMap) -> Result<()> + Send + Sync>> - { + ) -> &IndexMap Result<()> + Send + Sync>> { &self.entities } } -pub struct ArchetypePair { - check_left_entity: Box bool + Send + Sync>, - check_right_entity: Box bool + Send + Sync>, +pub struct ArchetypePair { + check_left_entity: Box) -> bool + Send + Sync>, + check_right_entity: Box) -> bool + Send + Sync>, create_callback: Box< dyn Fn( - &EntityObject, - &EntityObject, - ) -> Result< - Box) -> Result<()> + Send + Sync>, - > + Send + &EntityObject, + &EntityObject, + ) + -> Result Result<()> + Send + Sync>> + + Send + Sync, >, - entities: IndexMap< - (Entity, Entity), - Box) -> Result<()> + Send + Sync>, - >, + entities: + IndexMap<(Entity, Entity), Box Result<()> + Send + Sync>>, } -impl ArchetypePair { +impl ArchetypePair { pub(crate) fn add_entity( &mut self, - entity_object: &EntityObject, - entities: &IndexMap, + entity_object: &EntityObject, + entities: &IndexMap>, ) -> Result<()> { for (other_entity, other_entity_object) in entities.iter() { if entity_object.as_entity() == *other_entity { @@ -533,7 +546,7 @@ impl ArchetypePair { } } - pub(crate) fn execute(&self, scene_contents: &mut SceneContents<'_>) -> Result<()> { + pub(crate) fn execute(&self, scene_contents: &mut C) -> Result<()> { for ((left_entity, right_entity), callback) in self.entities.iter() { callback(*left_entity, *right_entity, scene_contents)?; } @@ -541,7 +554,7 @@ impl ArchetypePair { Ok(()) } - pub(crate) fn setup(&mut self, entities: &IndexMap) -> Result<()> { + pub(crate) fn setup(&mut self, entities: &IndexMap>) -> Result<()> { for (lhs_entity, lhs_entity_object) in entities.iter() { for (rhs_entity, rhs_entity_object) in entities.iter() { if lhs_entity != rhs_entity @@ -559,33 +572,43 @@ impl ArchetypePair { } } -pub enum Update { - Single(Archetype), - Pair(ArchetypePair), +pub enum Update { + Single(Archetype), + Pair(ArchetypePair), } -impl From for Update { - fn from(archetype: Archetype) -> Self { +impl From> for Update { + fn from(archetype: Archetype) -> Self { Self::Single(archetype) } } -impl From for Update { - fn from(pair: ArchetypePair) -> Self { +impl From> for Update { + fn from(pair: ArchetypePair) -> Self { Self::Pair(pair) } } -#[derive(Default)] -pub struct Updates { +pub struct Updates { #[cfg(feature = "timings")] timings: Timings, - updates: Vec<(String, u32, Update)>, + updates: Vec<(String, u32, Update)>, } -impl Updates { - pub(crate) fn update(&mut self, scene_contents: &mut SceneContents<'_>) -> Result<()> { +impl Default for Updates { + fn default() -> Self { + Self { + #[cfg(feature = "timings")] + timings: Timings::default, + + updates: Vec::new(), + } + } +} + +impl Updates { + pub(crate) fn update(&mut self, scene_contents: &mut C) -> Result<()> { #[cfg(feature = "timings")] if let Some(timings) = self.timings.check_timing(scene_contents.now(), None) { if !timings.is_empty() { @@ -622,8 +645,8 @@ impl Updates { pub(crate) fn add_entity( &mut self, - entity_object: &EntityObject, - entities: &IndexMap, + entity_object: &EntityObject, + entities: &IndexMap>, ) -> Result<()> { for (_, _, update) in self.updates.iter_mut() { match update { @@ -663,8 +686,8 @@ impl Updates { &mut self, name: &str, priority: u32, - mut update: Update, - entities: &IndexMap, + mut update: Update, + entities: &IndexMap>, ) -> Result<()> { match &mut update { Update::Single(archetype) => archetype.setup(entities)?, @@ -682,46 +705,46 @@ impl Updates { } } -#[derive(Default)] -pub struct Archetypes { - archetypes: HashMap, -} +// #[derive(Default)] +// pub struct Archetypes { +// archetypes: HashMap, +// } -impl Archetypes { - pub(crate) fn add_entity(&mut self, entity_object: &EntityObject) -> Result<()> { - for archetype in self.archetypes.values_mut() { - archetype.add_entity(entity_object)?; - } +// impl Archetypes { +// pub(crate) fn add_entity(&mut self, entity_object: &EntityObject) -> Result<()> { +// for archetype in self.archetypes.values_mut() { +// archetype.add_entity(entity_object)?; +// } - Ok(()) - } +// Ok(()) +// } - pub(crate) fn remove_entity(&mut self, entity: Entity) { - for archetype in self.archetypes.values_mut() { - archetype.remove_entity(entity); - } - } +// pub(crate) fn remove_entity(&mut self, entity: Entity) { +// for archetype in self.archetypes.values_mut() { +// archetype.remove_entity(entity); +// } +// } - pub(crate) fn clear(&mut self) { - self.archetypes.clear(); - } +// pub(crate) fn clear(&mut self) { +// self.archetypes.clear(); +// } - pub(crate) fn insert(&mut self, name: String, archetype: Archetype) { - assert!(self.archetypes.insert(name, archetype).is_none()); - } +// pub(crate) fn insert(&mut self, name: String, archetype: Archetype) { +// assert!(self.archetypes.insert(name, archetype).is_none()); +// } - pub(crate) fn get(&self, name: &String) -> Option<&Archetype> { - self.archetypes.get(name) - } +// pub(crate) fn get(&self, name: &String) -> Option<&Archetype> { +// self.archetypes.get(name) +// } - pub(crate) fn execute( - &self, - name: &String, - scene_contents: &mut SceneContents<'_>, - ) -> Result<()> { - self.archetypes[name].execute(scene_contents) - } -} +// pub(crate) fn execute( +// &self, +// name: &String, +// scene_contents: &mut SceneContents<'_>, +// ) -> Result<()> { +// self.archetypes[name].execute(scene_contents) +// } +// } #[rustfmt::skip] impl_singleton_update!(single, [R]); diff --git a/ecs/src/world.rs b/ecs/src/world.rs new file mode 100644 index 0000000..ffbc971 --- /dev/null +++ b/ecs/src/world.rs @@ -0,0 +1,21 @@ +use indexmap::IndexMap; + +use crate::*; + +pub struct World { + pub(crate) updates: Updates, + pub(crate) events: Events, + pub(crate) resources: Resources, + pub(crate) entities: IndexMap>, +} + +impl Default for World { + fn default() -> Self { + Self { + updates: Updates::default(), + events: Events::default(), + resources: Resources::default(), + entities: IndexMap::default(), + } + } +} diff --git a/engine/Cargo.toml b/engine/Cargo.toml index a9cd312..485eb2d 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -2,7 +2,7 @@ name = "engine" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [dependencies] # needed @@ -24,8 +24,7 @@ lua-wrapper = { path = "../lua-wrapper" } scene_update_macros = { path = "../scene_update_macros" } asset = { path = "../asset" } loading_screen = { path = "../loading-screen" } -context = { path = "../context", features = ["sound", "bundle_sdl2"] } +context = { path = "../context", features = ["bundle_sdl2", "sound"] } [features] timings = [] - diff --git a/engine/src/engine/engineobject.rs b/engine/src/engine/engineobject.rs index aa6f764..e715312 100644 --- a/engine/src/engine/engineobject.rs +++ b/engine/src/engine/engineobject.rs @@ -7,7 +7,7 @@ use std::any::Any; use std::collections::HashMap; use std::sync::{Arc, RwLock}; -use super::engine_object_data::{EngineObjectAccess, EngineObjectDataHandle}; +// use super::engine_object_data::{EngineObjectAccess, EngineObjectDataHandle}; #[derive(Debug)] pub enum EngineEvent { @@ -29,68 +29,71 @@ pub enum EngineEvent { FileDrop(String), } -pub trait EngineObjectHelper: Any { - type Payload: Send + Sync; +// pub trait EngineObjectHelper: Any { +// type Payload: Send + Sync; - fn access(&self) -> EngineObjectAccess<'_, Self::Payload>; - fn payload(&self) -> EngineObjectDataHandle; - fn ui(&self) -> &States; - fn ui_mut(&mut self) -> &mut States; +// fn access(&self) -> EngineObjectAccess<'_, Self::Payload>; +// fn payload(&self) -> EngineObjectDataHandle; +// fn ui(&self) -> &States; +// fn ui_mut(&mut self) -> &mut States; - fn access_callback_mut(&self, f: F) -> impl FnMut() -> Result<()> + Send + Sync + 'static - where - F: FnMut(EngineObjectAccess<'_, Self::Payload>) -> Result<()> + Send + Sync + 'static, - { - self.payload().access_callback_mut(f) - } +// fn access_callback_mut<'a, F>( +// &'a self, +// f: F, +// ) -> impl FnMut() -> Result<()> + Send + Sync + 'static +// where +// F: FnMut(EngineObjectAccess<'a, Self::Payload>) -> Result<()> + Send + Sync + 'static, +// { +// self.payload().access_callback_mut(f) +// } - fn access_callback(&self, f: F) -> impl Fn() -> Result<()> + Send + Sync + 'static - where - F: Fn(EngineObjectAccess<'_, Self::Payload>) -> Result<()> + Send + Sync + 'static, - { - self.payload().access_callback(f) - } +// fn access_callback(&self, f: F) -> impl Fn() -> Result<()> + Send + Sync + 'static +// where +// F: Fn(EngineObjectAccess<'_, Self::Payload>) -> Result<()> + Send + Sync + 'static, +// { +// self.payload().access_callback(f) +// } - fn handle_callback_mut(&self, mut f: F) -> impl FnMut() -> Result<()> + Send + Sync + 'static - where - F: FnMut( - EngineObjectDataHandle, - EngineObjectAccess<'_, Self::Payload>, - ) -> Result<()> - + Send - + Sync - + 'static, - { - let handle = self.payload(); +// fn handle_callback_mut(&self, mut f: F) -> impl FnMut() -> Result<()> + Send + Sync + 'static +// where +// F: FnMut( +// EngineObjectDataHandle, +// EngineObjectAccess<'_, Self::Payload>, +// ) -> Result<()> +// + Send +// + Sync +// + 'static, +// { +// let handle = self.payload(); - move || { - let data = handle.as_data(); - let access = data.access(); +// move || { +// let data = handle.as_data(); +// let access = data.access(); - f(handle.copy(), access) - } - } +// f(handle.copy(), access) +// } +// } - fn handle_callback(&self, f: F) -> impl Fn() -> Result<()> + Send + Sync + 'static - where - F: Fn( - EngineObjectDataHandle, - EngineObjectAccess<'_, Self::Payload>, - ) -> Result<()> - + Send - + Sync - + 'static, - { - let handle = self.payload(); +// fn handle_callback(&self, f: F) -> impl Fn() -> Result<()> + Send + Sync + 'static +// where +// F: Fn( +// EngineObjectDataHandle, +// EngineObjectAccess<'_, Self::Payload>, +// ) -> Result<()> +// + Send +// + Sync +// + 'static, +// { +// let handle = self.payload(); - move || { - let data = handle.as_data(); - let access = data.access(); +// move || { +// let data = handle.as_data(); +// let access = data.access(); - f(handle.copy(), access) - } - } -} +// f(handle.copy(), access) +// } +// } +// } pub trait EngineObject: Any { fn name(&self) -> &str; diff --git a/engine/src/engine/mod.rs b/engine/src/engine/mod.rs index efe8f52..7658fb9 100644 --- a/engine/src/engine/mod.rs +++ b/engine/src/engine/mod.rs @@ -4,4 +4,4 @@ pub mod enginesettings; pub mod engineobject; pub mod asset_handler; -pub mod engine_object_data; +// pub mod engine_object_data; diff --git a/engine/src/prelude.rs b/engine/src/prelude.rs index 72382d0..b5b7b50 100644 --- a/engine/src/prelude.rs +++ b/engine/src/prelude.rs @@ -7,8 +7,11 @@ pub use loading_screen::*; pub use crate::scene::prelude::*; pub use crate::engine::{ - engine_object_data::*, - engineobject::{EngineObject, EngineObjectHelper}, + // engine_object_data::*, + engineobject::{ + EngineObject, + // EngineObjectHelper + }, }; pub use crate::engine::asset_handler::{AssetHandler, AssetLoader}; @@ -17,8 +20,8 @@ pub use crate::engine::{engine::*, enginesettings::*}; pub use crate::engine::engineobject::EngineEvent; pub use serde::{ - ser::{SerializeMap, SerializeSeq, SerializeStruct}, Deserialize, Deserializer, Serialize, Serializer, + ser::{SerializeMap, SerializeSeq, SerializeStruct}, }; pub use ron; diff --git a/engine/src/scene/content/mod.rs b/engine/src/scene/content/mod.rs index 2835e34..e343be4 100644 --- a/engine/src/scene/content/mod.rs +++ b/engine/src/scene/content/mod.rs @@ -1,12 +1,5 @@ pub mod components; -pub mod entity; pub mod map; -pub mod unsafe_component_store; -pub mod updates; - -pub mod events; pub mod prelude; -pub mod query; -mod resources; -pub mod type_map; +mod query; diff --git a/engine/src/scene/content/prelude.rs b/engine/src/scene/content/prelude.rs index 89c3e41..2a838ad 100644 --- a/engine/src/scene/content/prelude.rs +++ b/engine/src/scene/content/prelude.rs @@ -1,7 +1,5 @@ pub use super::map::Map; -pub use super::entity::{Entity, EntityObject, NetworkID}; - pub use super::components::{animation::Animation, audio::Audio, draw::Draw}; pub use super::components::{ @@ -12,11 +10,3 @@ pub use super::components::{ }; pub use super::query::SceneQuery; -pub use super::unsafe_component_store::UnsafeComponentStore; -pub use super::updates::*; - -pub use super::type_map::{ - ComponentCreateInfo, ComponentDebug, ComponentNotFoundError, EntityComponent, MultiMut, TypeMap, -}; - -pub use super::resources::{ResourceMultiMut, Resources}; diff --git a/entity_manager/Cargo.toml b/entity_manager/Cargo.toml index f5e2259..071fbb6 100644 --- a/entity_manager/Cargo.toml +++ b/entity_manager/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "entity_manager" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow = { workspace = true } assetpath = { workspace = true } serde = { workspace = true } -engine = { path = "../engine" } \ No newline at end of file +engine = { path = "../engine" } diff --git a/gavania-core/Cargo.toml b/gavania-core/Cargo.toml index 670c9bb..bbd35df 100644 --- a/gavania-core/Cargo.toml +++ b/gavania-core/Cargo.toml @@ -3,7 +3,7 @@ name = "gavania-core" version = "0.1.0" authors = ["hodasemi "] build = "src/osbuild.rs" -edition = "2021" +edition = "2024" [dependencies] rusqlite = { workspace = true } @@ -27,4 +27,3 @@ entity_manager = { path = "../entity_manager" } [features] wayland = [] - diff --git a/gltf-loader/Cargo.toml b/gltf-loader/Cargo.toml index d87b1f2..ca43310 100644 --- a/gltf-loader/Cargo.toml +++ b/gltf-loader/Cargo.toml @@ -2,7 +2,7 @@ name = "gltf-loader" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [dependencies] gltf = { workspace = true } diff --git a/loading-screen/Cargo.toml b/loading-screen/Cargo.toml index 9eeab71..9ce2071 100644 --- a/loading-screen/Cargo.toml +++ b/loading-screen/Cargo.toml @@ -2,7 +2,7 @@ name = "loading_screen" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [dependencies] context = { path = "../context" } diff --git a/lua-wrapper/Cargo.toml b/lua-wrapper/Cargo.toml index 43327b6..aec5944 100644 --- a/lua-wrapper/Cargo.toml +++ b/lua-wrapper/Cargo.toml @@ -2,7 +2,7 @@ name = "lua-wrapper" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [dependencies] mlua = { workspace = true } diff --git a/map/Cargo.toml b/map/Cargo.toml index d2dde58..17a3d51 100644 --- a/map/Cargo.toml +++ b/map/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "map" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow = { workspace = true } @@ -9,4 +9,4 @@ rusqlite = { workspace = true } assetpath = { workspace = true } destructure_traitobject = { workspace = true } -engine = { path = "../engine" } \ No newline at end of file +engine = { path = "../engine" } diff --git a/math/Cargo.toml b/math/Cargo.toml index 67cb991..c1ecca9 100644 --- a/math/Cargo.toml +++ b/math/Cargo.toml @@ -2,7 +2,7 @@ name = "math" version = "0.1.0" authors = ["shnie "] -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/presentation/Cargo.toml b/presentation/Cargo.toml index 584fad6..06b6ea8 100644 --- a/presentation/Cargo.toml +++ b/presentation/Cargo.toml @@ -2,7 +2,7 @@ name = "presentation" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [dependencies] vulkan-rs = { workspace = true } diff --git a/promise/Cargo.toml b/promise/Cargo.toml index c33d6aa..abc4b55 100644 --- a/promise/Cargo.toml +++ b/promise/Cargo.toml @@ -2,7 +2,7 @@ name = "promise" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/ring_buffer/Cargo.toml b/ring_buffer/Cargo.toml index 62e282c..499be3b 100644 --- a/ring_buffer/Cargo.toml +++ b/ring_buffer/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ring_buffer" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/rpg_components/Cargo.toml b/rpg_components/Cargo.toml index 52f22b9..ba9e075 100644 --- a/rpg_components/Cargo.toml +++ b/rpg_components/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rpg_components" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] anyhow = { workspace = true } diff --git a/scene_update_macros/Cargo.toml b/scene_update_macros/Cargo.toml index 0bc4e3e..c6f9228 100644 --- a/scene_update_macros/Cargo.toml +++ b/scene_update_macros/Cargo.toml @@ -2,7 +2,7 @@ name = "scene_update_macros" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/transaction_derive/Cargo.toml b/transaction_derive/Cargo.toml index f03c5a3..6177fb8 100644 --- a/transaction_derive/Cargo.toml +++ b/transaction_derive/Cargo.toml @@ -2,7 +2,7 @@ name = "transaction_derive" version = "0.1.0" authors = ["hodasemi "] -edition = "2021" +edition = "2024" [lib] proc-macro = true