-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basics implemented for scene serde, serialisation working for some co…
…mponents.
- Loading branch information
Showing
24 changed files
with
1,346 additions
and
879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
pub mod transform; | ||
pub mod entity_name; | ||
pub mod state; | ||
|
||
pub mod exports { | ||
pub use super::entity_name::EntityName; | ||
pub use super::transform::Transform; | ||
pub use crate::renderer::camera::Camera; | ||
pub use super::state::State; | ||
pub use crate::renderer::renderable::Renderable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use cobalt_ecs::exports::Component; | ||
|
||
|
||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] | ||
pub struct State(hashbrown::HashMap<String, StateValue>); | ||
|
||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] | ||
pub enum StateValue { | ||
Bool(bool), | ||
U8(u8), | ||
U16(u16), | ||
U32(u32), | ||
U64(u64), | ||
I8(i8), | ||
I16(i16), | ||
I32(i32), | ||
I64(i64), | ||
F32(f32), | ||
F64(f64), | ||
String(String), | ||
Array(Vec<StateValue>), | ||
Map(hashbrown::HashMap<String, StateValue>), | ||
} | ||
|
||
impl Component for State { | ||
type SerContext<'a> = (); | ||
|
||
fn serialize<'se, S>(&self, _context: Self::SerContext<'se>, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: serde::Serializer { | ||
serde::Serialize::serialize(&self, serializer) | ||
} | ||
|
||
type DeContext<'a> = (); | ||
|
||
fn deserialise<'de, D>(_context: Self::DeContext<'de>, deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: serde::Deserializer<'de> { | ||
let state: State = serde::Deserialize::deserialize(deserializer)?; | ||
Ok(state) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.